Repository navigation
[Triton/Gluon] Fused GDN decode kernel for any value/key head ratio (Qwen3.5/3.8) - #6488
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
ba5c59a to
a194014
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The support predicate rejects an intended padding mode and omits device checks for optional GPU operands.
2 open findings
What changed in this PR
Extends the gfx950 fused GDN decode operator for Qwen3.5/3.8 while retaining the existing ratio-2 kernels.
Changes:
- Adds a generic kernel for value/key head ratios 1–4 and flat packing.
- Adds strided-state support, padding metadata and preallocated output.
- Extends correctness tests and benchmark options.
| File | Description |
|---|---|
op_tests/triton_tests/gated_delta_net/test_fused_gdn_decode_qkvz.py |
Tests ratios, layouts, strided states, padding and output reuse. |
op_tests/op_benchmarks/triton/bench_fused_gdn_decode_qkvz.py |
Adds ratio and layout options; adjusts traffic estimates. |
aiter/ops/triton/gated_delta_net/fused_gdn_decode_qkvz.py |
Extends validation, arguments and kernel dispatch. |
aiter/ops/triton/_gluon_kernels/gfx950/gated_delta_net/fused_gdn_decode_qkvz_ratio.py |
Implements ratio-generic fused decode. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a194014 to
138f74b
Compare
…/3.8) Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Ethan Ky <[email protected]>
138f74b to
f723a0d
Compare
…he support check Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Ethan Ky <[email protected]>
vgokhale
left a comment
There was a problem hiding this comment.
The generic kernel can also run ratio 2, but the dispatch keeps the generated
pair kernels for it:
if ratio != 2 or flat or query_start_loc is not None:
# ratio-generic kernel
elif tokens >= _LARGE_BATCH:
# generated large-batch kernel
else:
# generated small-batch kernelSo two kernels now compute the same math. Should we keep just one?
Can you also confirm it falls back to the triton path on gfx != 950?
I can run some benchmarks to compare their performance but I'm a little hesitant to remove the generated pair kernels because they're used in SGLang, and they specialize by batch size. On the second point, I don't think there is a fused Triton version in AITER. From the vLLM side, we fall back to the unfused set of kernels if it's not gfx950. |
|
Got some comparison results between the generic kernel and the pair-specific kernels from #5520 (both running with interleaved layout, FP8, KH=4, VH=8, head dim = 128):
So for the Qwen3-Next-80B-A3B-Instruct-FP8 config, the pair-specific kernels are faster. |
…rch 441): rust_perf +1 (entries_97, output-buffer-prezero-when-kernel-writes-all-rows, DEMOTED NotBenchable-by-platform at landing) + 8 count-neutral faces on kernel hosts
rust_perf 392->393 (entries_97): the dead-pre-zero law transcribed from vLLM
@ 92b52792d #67733 ('No zero fill in either branch: the kernels write every
actual row, and padding rows only feed row-wise ops' + the NaN/poison canary
as the coverage falsifier), INVERSE polarity of vec-macro-zero-fill — one
question, ARE THE ZEROES EVER READ, disagreeing answers. THE GOAT FALSIFIER
FIRED AT LANDING: the Pareto validator priced the pair ParetoDominated
(0 faster / 3 slower / 0 tie — the fixed push-loop arm lost at every size)
and the isolated probe (identical indexing loops, only the allocation
differing) read the pure-allocation delta at 0.967/0.979 twice, inside the
tie band: the Rust class vec![0.0; n] rides alloc_zeroed, whose zero-page
path serves the zeros without a separate memset pass on this platform
posture, so the pass the rule teaches deleting is already absent where we
can validate. Per the pre-registered bar ('a Tie/Slower demotes
in-landing'): bench_spec removed (143->142 benchable / 250->251
notbenchable), the measured negative + the re-arm condition (an allocator
that memsets alloc_zeroed) recorded in-rule, the grade rewritten
NotBenchable-by-platform. The LAW stays decision content: the torch win is
real where it was measured (torch.zeros pays a real memset) and the
correctness half (uninit-read avoidance, the partial-write and
padding-row boundaries) stands.
Faces count-neutral on their OWNERS same commit (vLLM @ 78f20a5a3 #69065 +
34c653886 #61428, Apache-2.0, byte-verified at the pins; the third+fourth
stack instances of the whole-step law, never land): F1 gpu_126
whole-step-gdn-decode-window-one-launch += the CUDA-MTP 9-token +
ROCm-AITER instances; F2 gpu_152 gdn-state-snapshot += the slot-indexed
per-token store; F3 gpu_65 gqa-zero-stride += the WEIGHT-side stride-0
instance (norm.weight.expand + stride_w_group=0); F4 popcorn
alignment-gated-zero-copy-view += the contiguous-drop instance; F5 gpu_164
dependency-version += the signature-introspection variant (inspect.signature
+ 'added in ROCm/aiter#6488'); F6 gpu_09 xor-swizzle += the integer-pad
polarity face (qk_column 12-per-8 — deliberate pad buying conflict-freedom
AND mma-fragment pairing); R2-fold gpu_51 dtype-native += the state-side
polarity (widen-at-load, narrow-at-store, compute f32; the storage dtype IS
the checkpoint's own — not the lossy class); F7 gpu_78 validated-exact-shape
+= the consumer-constraint conjunct ('The kernel emits the normed output, so
out_proj cannot quantize it'). DROPS recorded: reduce_scatter butterfly
thin, zero-bias padding plumbing, capability-envelope refusal face-only
(well-owned), _encode_layer_name plumbing.
Fixtures b407_fixtures 5/5 standalone-compiled AND executed pre-entry
(debug AND -O: parity / poison-canary / anti-regime-accumulation /
padding-boundary + the tamper partial-write arm the regime condition is
load-bearing). Gates (LOCAL on amo, CARGO_TARGET_DIR=/tmp/plan407): lib
4153/0 at kernel_opt,rust_perf,rust_perf_bench,latent_retrieval; clippy -D
x2 postures clean; bare rustfmt on the touched files; pins_manifest
--write (manifest + prose agree); count web one-landing (AGENTS head,
README, .docs/11_domains/rust_perf.md, health_views perf 393 + total 1780,
the kernel-side rust_perf witness, 5 hand-typed count pins, 3
annotated-count pins 341, serde pin). Score-bench/freeze NOT owed (zero
clippy_lints delta — the Batch-401 standing convention). Plans 404/405 NOT
landed at the landing HEAD (no delta). Records: Research 441 Status ->
LANDED (the demotion disclosed), plan 406 T0-T8 ticked + lease folded,
snapshot LANDING row. LANE INTEL (T8): the 16-bit recurrent-state traffic
lever is LOSSY-GATED — never a bit-identity arm; any future
decode-state-traffic cell opens under the lossy law's per-family retention
gate (our f32 state + issue-879 quant-cert stand; the named decode blocker
stays ffn_gate_up). Teardown: .raw/vllm-gdn + /tmp/plan407 + the fixture
scratch removed at close.
Session: zed-e7e471a3@amo, 1795473279


Motivation
AITER PR #5520 added a fused Gated-DeltaNet decode op for gfx950 (packed qkvz/ba split + causal conv1d + delta-rule
recurrence + gated RMSNorm, optional FP8 epilogue), but its kernels hardcode Qwen3-Next's geometry: two value heads per key head, the interleaved per-group qkvz packing, dense state pools. Qwen3.5/3.8-27B has 48 value heads over 16 key
heads (ratio 3) and a flat
[q_all | k_all | v_all | z_all]packing, so it could not use the op and ran the decode step as three kernels (conv1d 8 µs + recurrence 79 µs + norm 4 µs per layer at 64 tokens).This PR adds a ratio-generic sibling kernel,
_decode_group_ratio, and routes it from the existing wrapper.Companion vLLM PR: vllm-project/vllm#61428
Technical Details
aiter/ops/triton/_gluon_kernels/gfx950/gated_delta_net/fused_gdn_decode_qkvz_ratio.py(new): one program per(token, key-head group) owns the group's
RATIO[V, K]fp32 state tiles in registers. Threegl.static_rangephases with per-head values carried in tuples: (1) issue every independent load — state tiles, gating scalars, output
gates, conv inputs; (2) conv through LDS, q/k L2 norms, per-head delta-rule update and
buffer_store; (3) per-headgated RMSNorm from registers. Carrying the tiles in a tuple keeps all loads ahead of the first store. Tile layout is the
ratio-2 kernels'
BlockedLayout([1, 4], [4, 16], [NW, 1])(16 lanes × 4 fp32 per row = one contiguous 16 B accessper lane). Reuses
_exp/_sigmoid/_quantization_scalefrom the ratio-2 file,softplusfrom_gluon_kernels/common/utils.pyand_silufrom_triton_kernels/common/activation.py.fused_gdn_decode_qkvz/fused_gdn_decode_qkvz_supported: new keyword arguments areqkvz_layout(
"interleaved"|"flat"),query_start_loc(rows with an empty query segment are padded CUDA-graph rows and are skipped) andout(preallocated bf16[T, VH, VD]output, saves a copy). State pools may be strided along the slot dimension and the conv window may be any strided view; the recurrent state stays dense within a slot. Dispatched atratio != 2, or with flat layout, or whenquery_start_locis provided.op_tests/op_benchmarks/triton/bench_fused_gdn_decode_qkvz.py:--ratio,--num-k-heads,--layout.Not changed: the generated ratio-2 kernels, their dispatch, and
_decode_group.Test Plan
New/extended tests (46 total pass, MI355X, Triton 3.8), correctness vs the torch reference for:
query_start_locpaddingoutPAD_SLOT_IDTest Result
Op benchmark, Qwen3.8-27B dims (KH 16 / VH 48, K = V = 128), bf16 output, 512 slots:
In vLLM serving (companion vLLM PR above), Qwen3.8-27B BF16 TP1 on one MI355X, 64 decode tokens per step:
GSM8K unchanged (0.7263 vs 0.7233 flexible).
Submission Checklist