[ROCm] Add THD/ragged bf16 (atomic16) backward test coverage #671
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 287 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.339
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #671"
general
weight: 0.35
wangye805
Summary
On ROCm/gfx950 the CK fused-attention backward silently corrupts dQ for THD/ragged (packed / document-masked) attention on the default bf16 dq-accumulation path (
NVTE_CK_IS_V3_ATOMIC_FP32=0). Forward, dK and dV are correct.Root cause
build_bwd_fmha_argsallocates thedq_accscratch as fp32-packed(nsplits, H, total_q, d_qk)withbatch_stride_dq_acc = 0. That matches the fp32dq_convertpost-kernel, but the bf16dq_shufflepost-kernel expects a per-segment padded layout — withbatch_stride=0every ragged segment pastcu_seqlensoffset 0 is written to the offset-0 slot, so dQ is correct only for the first segment and garbage for the rest.Fix
When the v3 asm path actually runs — probed via
ck_attn_bwd_uses_v3(added in #662) — switchdq_accto AITER's per-segment bf16 layout(nsplits, B, H, pad16(s_q), 128)with matchingstride/nhead/batch/splitstrides. The v2/fallback path and non-ragged/atomic_fp32=1keep the fp32-packed layout.fused_attn_ck.cppsizes the scratch to hold either layout (the layout choice needs a GPU probe that must not run in the workspace-sizing pass).Tests
test_fused_attn.py. Previously there was no symmetric 128/128 THD backward coverage (only asymmetric 128/64) — exactly the llama3 shape.NVTE_CK_IS_V3_ATOMIC_FP32=0(atomic16 /dq_shuffle) CI run of the THD backward tests inci/jax.sh. The default fp32 path never exercised the bf16dq_accpath.Verification (MI355X / gfx950)
TE THD
padding_causalbackward vs a pure-JAX block-diagonal reference:atomic_fp32=0; per-segment all correct across[256],[100,80,76],[128,128],[64×4],[200,56], for both the v3 (dq_shuffle) and v2 paths.bwd_hd128_dq_shuffle_groupkernel (fix is on the fast path, not a fallback).atomic_fp32=1unchanged; end-to-end MaxText llama3.1-8B block-diagonal THD packing converges to eval-loss 3.3 (previously stalled ~6.1 and NaN'd).Builds on the V3 API check mechanism from #662. Supersedes #657 (which targeted an earlier base before #662).
🤖 Generated with Claude Code