[TRITONGPU] FuseNestedLoops: only trust llvm.assume that dominates the loop #11521
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 343 lines diff across 4 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.349
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11521"
general
weight: 0.35
LiRunGuo
[TRITONGPU] FuseNestedLoops: only trust
llvm.assumethat dominates the loopFixes #11519.
Problem
tritongpu-fuse-nested-loopsproves an inner loop's trip count positive bymatching an
llvm.assume(ub > lb)anywhere in the function — no dominanceor reachability query. When the assume sits on a branch the loop nest is not
reachable from (e.g. a shape-specialization branch that asserts something
about another parameter), the pass marks the inner loop as must-execute and
drops the zero-trip version split it would otherwise emit.
On a fully legal call (
m=4, n=0in the reproducer) the fused loop then runsmax(n, 1) * mtimes: the kernel returns a value the source program cannotproduce, and stores into a buffer the source program never writes (silent
memory corruption, no diagnostic).
The assumption is not being weighed and found probable: it is being read from
a program point the code under transformation cannot reach, which no
assumption-consuming analysis in LLVM or MLIR would consider valid
(
llvm::isValidAssumeForContextis dominance-gated).Fix
Thread
DominanceInfo(already held by the pass and used two functions abovein the same file) into
matchPositiveTripCountand require the matchedllvm.assumeto properly dominate the loop. Otherwise fall through to theexisting version-split path, which is what every kernel without an in-scope
assume gets today. The in-tree
_p_matmulidiom (tl.assume(loop_bound > 0)immediately before the loop) keeps the fast path — nothing is lost there.
Verification
the fix
out[:4] = [4.0, 8.0, 12.0, 16.0]and 256 spurioussinkwrites;after the fix
outstays[0.0, 0.0, 0.0, 0.0]andsinkis untouched.assume kernel contains no zero-trip test (
icmp eq i32 %4, 0absent); afterthe fix it is present, matching the assume-free control kernel.
test/TritonGPU/fuse-nested-loops.mlir: new@assume_not_dominating_loopcase asserts the zero-trip guard (
scf.if (ub == 0)) is still emitted and noarith.constant truemust-execute guard appears.Tests
/testforlittests/python/testfor end-to-end testsNew contributor declaration
rules.
pre-commit run --from-ref origin/main --to-ref HEAD(the
expand-yaml-anchorshook was skipped: it only applies to.github/workflows/integration-tests.ymland needs a network fetch ofyq).