sdpa fp8 sm107: fused LDTM row-max + row-sum-in-MMA - #580
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds compile-time exclusive TMEM allocation and updates the SM107 FP8 prefill kernel to accumulate softmax denominators in Sigma columns. It also adds fused row-max handling, shared FP8 ones data, Sigma rescaling, and empty-KV handling. ChangesSM107 FP8 SDPA prefill
Estimated code review effort: 4 (Complex) | ~45 minutes Mergeability Score: ⚪ Minimal · up to The PR is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant SM107Kernel
participant tmem_alloc
participant nvvm_tcgen05_alloc
participant Softmax
SM107Kernel->>tmem_alloc: request exclusive TMEM
tmem_alloc->>nvvm_tcgen05_alloc: allocate exclusive storage
SM107Kernel->>Softmax: accumulate Sigma during BMM2
Softmax->>SM107Kernel: load fused row maxima
SM107Kernel->>Softmax: rescale O and Sigma
Softmax-->>SM107Kernel: read final Sigma denominator
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
9ec2a0f to
420e43f
Compare
Two Rubin levers, baked into the SM107 sibling (the Blackwell kernel is untouched; the only shared-file change is a guarded is_exclusive parameter on tile_dsl.tmem_alloc that <=512-column callers never trace): 1. Fused LDTM row-max: the unmasked softmax path loads S_acc and reduces the row max in ONE tcgen05.ld.red.f32.max per 64-column chunk (tmem_load_max_reduction_x64, the mechanism the MXFP8 kernel uses on cc10.3) instead of a manual load + software reduction; masked iters keep the software path (the fused max reduces before a mask could apply). 2. Row-sum in MMA: an N=16 ones-BMM (P x ones) accumulates the softmax denominator into 16 Sigma TMEM columns right after each sub-tile's O, where the correction warp's per-iter alpha-rescale keeps it online-softmax-consistent for free (rescale span widens 128 -> 144); the softmax warps stop reading P back through the register file to sum it, and the correction epilogue reads Sigma (one ld x1) instead of the stats sum word. B rides a constant 8-row x 128 B K-major all-ones tile written once at init (any N-split of all-ones is all-ones, so the cga2 halves are symmetric for free). Sigma now sums the fp8-QUANTIZED P, exactly matching O's numerator; empty-kv tiles guard the stale Sigma read via max == -inf (LSE = -inf convention kept). TMEM grows to the full 576-col sm107 EXCLUSIVE grant (dealloc must return the grant - a smaller dealloc leaks columns as cudaErrorTensorMemoryLeak). Same-session A/B on w2u1g (cc10.7, B8 H16 D128 e4m3->bf16 dense, vs the sibling at NVIDIA#579): 16k nomask 4.017 -> 3.471 ms (-13.6%), 16k causal 2.387 -> 2.070 (-13.3%), 65k nomask 60.780 -> 51.842 (-14.7%, 5430 TFLOPS eff), 65k causal 31.777 -> 27.013 (-15.0%). Board suite 34/34; SM100 box 34/34 (Blackwell untouched). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
420e43f to
31b7fed
Compare
|
@cudnn-ci-bot run frost |
|
🚀 Running mirror pipeline Branch: cudnn-gh/pr-580-31b7fed |
Summary
Two performance levers baked into the SM107 sibling kernel (Blackwell untouched; the only shared-file change is a guarded
is_exclusiveparameter ontile_dsl.tmem_allocthat ≤512-column callers never trace):tcgen05.ld.red.f32.maxper 64-col chunk (the MXFP8 kernel's cc10.3 mechanism); masked iters keep the software reduction.cudaErrorTensorMemoryLeak).Perf (same-session A/B vs #579, w2u1g cc10.7, B8 H16 D128 e4m3→bf16 dense)
Validation
SM107 board 34/34 (full fp8 e2e: all masks / sink / stats / both fp8 dtypes / all output dtypes vs the fp32 dequant reference — the amax_s/LSE checks cover the Σ path); SM100 box 34/34.
Stacked on #579 (contains its commit; rebases clean once it merges). The f16x2-MUFU softmax lever is deliberately excluded — it ships separately with its own numerics evidence.
🤖 Generated with Claude Code
Summary by CodeRabbit
Update (review hardening): the all-ones B tile and its init loop are now parametrized on
CTA_MMA(_ONES_ROWS = 16 // CTA_MMA). At today's cga2 this is binary-identical (8 rows); it future-proofs a cga1 config, where the fixed 8-row tile would have had the descriptor walk 1 KiB past the tile into neighboring SMEM — functionally masked only because the epilogue consumes Σ column 0 alone, which is not an invariant worth leaning on. Re-gated: board 34/34, SM100 quick pass.