Twist indices as a mask, and forward `backend`/`allocator` in AD rules #619
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 261 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.333
Real PR Conversation Timeline
1 comments
"Review active on #619"
general
weight: 0.35
kshyatt
Follow-up to the post-merge review comments on #599.
Changes
twist(t, inds),twist!(t, inds)andtwist!(tdst, tsrc, inds, ...)convertindsto anNTuple{numind(t), Bool}mask on entry (_twistmask), and the three-argumenttwist!has a dedicated method for a mask. Any collection of indices (tuples, vectors, ranges, anInt) is still accepted, but everything after the conversion only depends on the number of indices, so it is compiled once pernumind.- Tensors now accept a
Boolmask, just like the fusion treetwist.-
spacecheck_transform(twist, ...)andhas_shared_twisttake the mask, so the disambiguation method with theinvokecall is gone.- Out-of-range indices throw an
ArgumentErrorduring the conversion; aBoolmask of the wrong length now throws (also for fusion trees) instead of being interpreted as indices0/1.backend/allocator. The Enzyme and Mooncake rules ofpermute!,transpose!,braid!andtwist!pass the optionalbackendandallocatoron to the intermediate out-of-place call. That call now also always usescopy = true, since the intermediate is stored for theΔαpullback and should not aliasA(this was already the case for the Enzymepermute!/twist!rules).Testing
tensors/indexmanipulations,tensors/contractions,tensors/diagonal,symmetries/doubletree,other/aqua,mooncake/indexmanipulations,enzyme/{permute,transpose,braid,flip}andchainrules/linalgpass. The final version of the branch was run againsttensors/indexmanipulations,symmetries/doubletree,other/aqua,mooncake/indexmanipulations,enzyme/flipandchainrules/linalg(121810 tests); the remaining files were run on an earlier revision whose only differences are the_twistmaskrename and the mask dispatch.inds, a tensor without indices, error cases, inferability, and the absence of method ambiguities.🤖 Generated with Claude Code