fix(rollout): pass a pre-built 4-D mask to the static graph decode forward #9004
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 224 lines diff across 2 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.324
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9004"
general
weight: 0.35
delock
Closes #9000.
Problem
With
use_graph_capture=Trueand nocontinuous_batch_size,_generate_graphgives the captured decode forward a 2-D attention mask, so Transformers builds the causal mask during capture. That fails on the supported versions:padding_mask.all()runs on the host and breaks capture with "operation not permitted when stream is capturing" (reported by @0z5a on #8197).get_query_offset, whichDeepSpeedStaticCachedoesn't have.Fix
The captured forward now gets a pre-built 4-D additive mask. The mask is refreshed before each replay, and prefill is unchanged. The fix is cherry-picked from @0z5a's commit.
_generate_graphalso raises aValueErrorforflash_attention_2, as the continuous graph path does, because it can't use a 4-D mask.#8602 includes the same mask change, but it's a much larger PR that will take a while to merge. #8852 is still needed for continuous batching without graphs on 5.x.
Test results
Run on 1 NVIDIA A40 with torch 2.14.1+cu130, using real Hugging Face models without a DeepSpeed engine.
| Transformers | New tests with this PR | Rollout and cache suites with this PR |
| --- | --- | --- | --- |
| 4.57.6 | 4 passed | 89 passed, 2 skipped |
| 5.19.0 | 4 passed | 89 passed, 2 skipped |
| 5.22.1 | 4 passed | 89 passed, 2 skipped |
Compatibility
- accelerators other than CUDA
- hybrid models
- the
flash_attention_2rejection on a real FlashAttention model