Skip to content

[Triton/Gluon] Support a bf16 recurrent state in the fused GDN decode kernel - #6884

Merged
eky-amd merged 2 commits into
ROCm:mainfrom
eky-amd:gdn-fused-decode-bf16-state
Nov 3, 2026
Merged

eky-amd merged 2 commits into
ROCm:mainfrom
eky-amd:gdn-fused-decode-bf16-state

Conversation

@eky-amd

@eky-amd eky-amd commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Let fused_gdn_decode_qkvz take 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_state may 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.
  • A bf16 state always runs the ratio-generic kernel (_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) is 16 // 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 accepts torch.bfloat16 for ssm_state; other dtypes are still rejected.
  • bench_fused_gdn_decode_qkvz.py gains --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:

Hardware Workload/configuration Before (fp32 state) After (bf16 state) Change
MI355X (gfx950) 16 key heads, ratio 3, head dim 128, flat layout, batch 1 14.84 14.02 −5.5%
MI355X (gfx950) same, batch 8 17.10 14.38 −15.9%
MI355X (gfx950) same, batch 16 24.96 16.31 −34.7%
MI355X (gfx950) same, batch 64 69.81 46.52 −33.4%
MI355X (gfx950) same, batch 128 151.96 87.02 −42.7%
MI355X (gfx950) same, batch 256 291.24 188.05 −35.4%

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

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

The kernel lives under _gluon_kernels/gfx950/ and is gfx950-only; MI250X/MI300X do not run it. Tested on MI355X.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The wrapper docstring lists the accepted ssm_state dtypes; no guide documents this kernel.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. An fp32 state takes the same kernels as before.

PR Self-Review

Reviewed revision

903df76bf52a

Behavior and intent

A bf16 ssm_state was rejected by fused_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.py on MI355X: 91 / 91 pass, 38 of them bf16-state cases (branch 4927e8a0e9 on main 78f416704f).
  • 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.
  • Unverified: the test run predates the PR's current base; it has not been repeated on the rebased head.

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_loc padding) are parametrized over state_dtype fp32 / 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:
    • New --state-dtype fp32|bf16 (default fp32) selects the dtype of the recurrent state pool; bf16 runs the ratio-generic kernel.
    • bytes_moved accounts 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.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6884 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@eky-amd
eky-amd force-pushed the gdn-fused-decode-bf16-state branch from dad317c to 4927e8a Compare October 23, 2026 17:56
@eky-amd
eky-amd marked this pull request as ready for review October 23, 2026 17:56
@eky-amd
eky-amd requested a review from a team October 23, 2026 17:56
@github-actions github-actions Bot changed the title [Gluon] Support a bf16 recurrent state in the fused GDN decode kernel [Triton/Gluon] Support a bf16 recurrent state in the fused GDN decode kernel Oct 23, 2026
@azaidy
azaidy requested a review from vgokhale October 23, 2026 19:13
@Boss2002n
Boss2002n requested a balanced review from Copilot October 24, 2026 01:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@eky-amd
eky-amd force-pushed the gdn-fused-decode-bf16-state branch 2 times, most recently from bc26b88 to 210e571 Compare October 29, 2026 16:09
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 6bf6aebedec7 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — PR-specific question has no substantive answer

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@eky-amd
eky-amd force-pushed the gdn-fused-decode-bf16-state branch from d46c545 to 903df76 Compare November 2, 2026 18:00
@eky-amd
eky-amd merged commit 720b36c into ROCm:main Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants