Rewind the allocator after the temporaries of `blas_contract!` and `planarcontract!` #628
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 276 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.336
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #628"
general
weight: 0.35
kshyatt
blas_contract!takes the permuted copies ofA,BandCfrom the allocator and frees them withtensorfree!, but never resets the allocator. For aBufferAllocator,tensorfree!does nothing, sooutside
@tensor(whose own checkpoint covers this) every contraction with symmetric tensors leaves itscopies claimed in the buffer. That includes every pullback of the
tensorcontract!rrule, which passesthe allocator on. Once the offset passes the buffer length, every later temporary becomes an ordinary
allocation, and the buffer is never empty again to be resized.
This puts an
allocator_checkpoint!/allocator_reset!pair around the temporaries, asadd_transform_kernel!and TensorOperations' ownblas_contract!already do.planarcontract!and itstwo
BraidingTensormethods had the same gap; they only leak when called directly, outside@planar.Found in QuantumKitHub/PEPSKit.jl#482, where one PEPS gradient with U(1) tensors at D = 3 left an offset of 7.2 MB in
a 143 KB buffer.
<details><summary>Reproducer</summary>
main:This PR:
</details>