Repository navigation
[Triton/Gluon] Support a bf16 recurrent state in the fused GDN decode kernel - #6884
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
dad317c to
4927e8a
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The changed bf16 memory layout and dispatch path need human review backed by independent gfx950 correctness and latency validation.
No open issues 🎉
What changed in this PR
This PR adds bf16 recurrent-state support to AITER’s fused GDN decode operation on gfx950. It halves state storage and read/write bytes while keeping the recurrent update in fp32.
Changes:
- Accept bf16 states and route them through the ratio-generic kernel with dtype-aware memory accesses.
- Extend correctness tests across state dtypes, layouts, strided pools, and padding.
- Add benchmark state-dtype selection and adjust bandwidth accounting.
| File | Description |
|---|---|
op_tests/triton_tests/gated_delta_net/test_fused_gdn_decode_qkvz.py |
Parameterizes existing coverage for fp32 and bf16 states. |
op_tests/op_benchmarks/triton/bench_fused_gdn_decode_qkvz.py |
Adds --state-dtype and dtype-aware byte counts. |
aiter/ops/triton/gated_delta_net/fused_gdn_decode_qkvz.py |
Updates validation, dispatch, and state access sizing. |
aiter/ops/triton/_gluon_kernels/gfx950/gated_delta_net/fused_gdn_decode_qkvz_ratio.py |
Converts loaded states to fp32 and stores updates in the state dtype. |
Review effort: Balanced
bc26b88 to
210e571
Compare
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
210e571 to
d46c545
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Ethan Ky <[email protected]>
d46c545 to
903df76
Compare
Summary
Let
fused_gdn_decode_qkvztake a bf16 recurrent state. The update still runs in fp32 and is stored in the state's dtype; an fp32 state behaves as before.Motivation
fused_gdn_decode_qkvz(#5520, #6488) accepts only an fp32 recurrent state. The state read and write is the largest memory traffic of a GDN decode step, and vLLM already offers a bf16 state (--mamba-ssm-cache-dtype bfloat16). With a bf16 state the fused kernel moves half the state bytes.Companion vLLM PR: vllm-project/vllm#61428 (fused GDN decode integration, which allows a bf16 state on ROCm).
Changes
ssm_statemay be fp32 or bf16. The kernel loads the state tile, converts it to fp32, applies the gated delta-rule update in fp32, and stores the result in the state's dtype._decode_group_ratio). The generated ratio-2 pair kernels are unchanged and keep serving the fp32 interleaved case.KS(elements per lane per state-tile row) is16 // ssm_state.element_size(): 4 for fp32, 8 for bf16, so each lane still issues one contiguous 16 B access.fused_gdn_decode_qkvz_supported()also acceptstorch.bfloat16forssm_state; other dtypes are still rejected.bench_fused_gdn_decode_qkvz.pygains--state-dtype fp32|bf16, and its byte count uses the state's element size.Performance (if applicable)
bench_fused_gdn_decode_qkvz.py --num-k-heads 16 --ratio 3 --layout flat, µs per call, fp32 state → bf16 state:Batches 2 and 4: 15.07 → 14.16 µs (−6.0 %) and 15.26 → 14.08 µs (−7.7 %); batch 32: 40.91 → 26.58 µs (−35.0 %).
Testing
The kernel lives under
_gluon_kernels/gfx950/and is gfx950-only; MI250X/MI300X do not run it. Tested on MI355X.Documentation
The wrapper docstring lists the accepted
ssm_statedtypes; no guide documents this kernel.Dependencies
Breaking Changes
None. An fp32 state takes the same kernels as before.
PR Self-Review
Reviewed revision
903df76bf52aBehavior and intent
A bf16
ssm_statewas rejected byfused_gdn_decode_qkvz_supported(), so a bf16-state server fell back to the unfused path. It is now accepted and runs the ratio-generic kernel with fp32 math and a bf16 store. fp32 behavior is unchanged.Validation and unverified scope
python3 -m pytest op_tests/triton_tests/gated_delta_net/test_fused_gdn_decode_qkvz.pyon MI355X: 91 / 91 pass, 38 of them bf16-state cases (branch4927e8a0e9on main78f416704f).python3 op_tests/op_benchmarks/triton/bench_fused_gdn_decode_qkvz.py --state-dtype bf16 --num-k-heads 16 --ratio 3 --layout flat(and--state-dtype fp32): table above.PR-specific question
None
Changed op tests
op_tests/triton_tests/gated_delta_net/test_fused_gdn_decode_qkvz.py: the existing correctness tests (batch ladder, ratios, flat layout, slot-strided pools,query_start_locpadding) are parametrized overstate_dtypefp32 / bf16, with a bf16 reference that rounds the stored state. Not redundant: the bf16 path is a different kernel dispatch and a different store dtype, which none of the fp32 cases reach.op_tests/op_benchmarks/triton/bench_fused_gdn_decode_qkvz.py:--state-dtype fp32|bf16(default fp32) selects the dtype of the recurrent state pool; bf16 runs the ratio-generic kernel.bytes_movedaccounts for the state's element size instead of assuming fp32 (4 bytes), so the "TB/s" and "% peak" columns stay correct for a bf16 state, where the state read + write is half the bytes.