← Back to Pull requests

EnzymeHLOOpt: bound the provenance walk behind DUSDUSSubsuming; fix its dangling insert #3131

Closed
unknown closed this pull request without merging on Sep 07, 2026 21:16 UTC
View on GitHub
unknown unknown commented on Sep 06, 2026 22:10 UTC
Author

computeTensorValueProvenanceImpl follows a chain of slices, updates and pads back to its sources with a Presburger relation that grows with the chain, and DUSDUSSubsuming recomputes it from scratch for every update it visits: cubic in the chain. mfem's TMOP metric kernels write a scratch buffer a few hundred times. One such kernel (270 updates, 14k lines) spends 132 s in this pattern and 3 s in everything else (passses without bit 512), and the eight fem/tmop/metrics/3xx.cpp translation units carry the whole cost of running enzyme-hlo-opt on raised kernels at compile time (#3129): 464 s of a 533 s compile, per the pass timing.

The walk now stops after 128 steps and treats what is left as an opaque source. That only loses precision: both provenances the pattern compares are computed against the same sources, so an opaque prefix makes the comparison conservative, never wrong. The kernel takes 3 s; the 45-kernel translation unit's optimizer time goes from 411 s to 78 s.

The slice case also inserted into the provenance map with arguments that were references into that map (try_emplace(value, it->second.sources, it->second.provenanceRelation)); the insertion can rehash, after which they dangle and the copy reads freed memory. Nine of the 45 kernels segfault on that, in PresburgerRelation's copy constructor. Copy first.

Test: a three-update chain read back through overlapping slices, checked line for line. The reduced shapes that exercise the pattern fold before the walk gets deep, and the kernels that hit the cost and the crash are 8-14k lines each (fem/tmop/metrics/315.cpp, kernels 43 and 44 of its pre-optimizer dump; I can attach them if useful). Lit passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

Diff: 228 lines (+171 / -57) across 2 files Reviewer: ftynse Review duration: 1386m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 228 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.325
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3131"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 37.0% (MEDIUM) · Higher = larger blast radius
37.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.6% · Safe to merge
14.6%