Skip to content

[AMD][Qwen3.8] Route GDN decode, MTP verify and prefill front end through aiter FlyDSL kernels on gfx942 - #111

Merged
apinge merged 7 commits into
apinge:qwen4_v0.5.21from
yicyang:qwen38-gdn-flydsl-pr
Nov 20, 2026
Merged

apinge merged 7 commits into
apinge:qwen4_v0.5.21from
yicyang:qwen38-gdn-flydsl-pr

Conversation

@yicyang

@yicyang yicyang commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

On gfx942, Qwen3.8-Flash-Next GDN (linear attention) decode, MTP target verify and prefill now run on aiter FlyDSL kernels (apinge/aiter#11).

How to enable

On by default in evaluation/launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh. For other launches, use the existing flags (no new env vars):

--linear-attn-decode-backend aiter    # FlyDSL fused decode
--linear-attn-prefill-backend aiter   # FlyDSL prefill front end + aiter chunked prefill
--linear-attn-verify-backend aiter    # FlyDSL fused MTP target verify (chain, topk 1)
--mamba-ssm-dtype float32             # FlyDSL kernels need the fp32 SSM state
  • Requires gfx942 (MI300X / MI308X / MI325X). Other GPUs, a bf16 SSM state, tree verify (topk > 1), ReplaySSM, and layers or batches the kernels do not cover keep the original Triton path.
  • In the launch script, LINEAR_ATTN_PREFILL_BACKEND=triton turns the prefill part off.
  • Check the server log for GDN kernel dispatcher: decode=FlyDSLGDNKernel, ..., verify=FlyDSLGDNKernel and GDN: using aiter FlyDSL decode / target verify / prefill front end ....

Design

  • Decode and verify keep the Triton kernel interface: a new FlyDSLGDNKernel sits behind GDNKernelDispatcher and reuses the existing fused proj/conv protocol (the model hands (projected_qkvz, projected_ba) to the backend, which returns (core_attn_out, z)).

Decode

Per layer, TP2, bs 8, from a serving torch profile:

stage before this PR
b/a .contiguous() torch elementwise x2, 10.8 us FlyDSL fused_qkvzba_conv1d_gated_delta_rule_decode_flydsl, 1 kernel, 15.9 us
cat(q, k, v) torch CatArrayBatchedCopy, 6.2 us fused
causal conv update Triton _causal_conv1d_update_kernel, 5.8 us fused
gating + l2norm + recurrence Triton fused_recurrent_gated_delta_rule_packed_decode_kernel, 26.2 us fused
z copy torch elementwise, 5.4 us fused (the kernel writes a contiguous z)
gated RMSNorm Triton _layer_norm_fwd_1pass_kernel, 5.5 us unchanged, 5.5 us
total 60 us, 7 kernels 21.4 us, 2 kernels (-64%)

Decode step: GDN kernels go from 2.17 to 0.77 ms, and step time from 15.35 to 13.81 ms (-10%).

decode fusion

MTP target verify

Per layer, TP2, bs 8, 4 draft tokens, from a serving torch profile (EAGLE 3/1/4):

stage before this PR
b/a/z copies + cat(q, k, v) torch, 4 kernels, 20.1 us FlyDSL fused_qkvzba_conv1d_gated_delta_rule_verify_flydsl, 1 kernel, 28.6 us
causal conv update + intermediate conv windows Triton _causal_conv1d_update_kernel, 5.4 us fused
gating + l2norm + 4-step recurrence + intermediate states Triton fused_sigmoid_gating_delta_rule_update_kernel, 34.1 us fused
total 59.6 us, 6 kernels 28.6 us, 1 kernel (-52%)

verify fusion

MTP cycle (draft + verify): GDN verify kernels go from 2.15 to 1.03 ms, and cycle time from 23.67 to 22.39 ms (-5.4%). The recurrence steps run at the write bandwidth (each step writes a 64 KB fp32 state per head); accept length is unchanged.

Prefill

Per prefill step (36 layers), TP2, 8 x 12000-token requests:

stage before this PR
cat(q, k, v) torch CatArrayBatchedCopy, 12.4 ms FlyDSL flydsl_gdn_prefill_front, 1 kernel, 13.6 ms
causal conv1d + SiLU Triton _causal_conv1d_fwd_kernel, 22.8 ms fused
q/k/v split Triton fused_qkv_split_gdn_prefill_kernel, 5.0 ms fused
q, k l2norm Triton l2norm_fwd_kernel x2, 3.8 ms fused
chunk output o aiter Triton chunk_fwd_kernel_o_opt_vk (BK=32, BV=64), 25.6 ms same kernel, gfx942 config BK=64 / BV=128, 17.1 ms
z copy + gated RMSNorm torch elementwise + Triton norm, ~4 + 7.9 ms norm reads strided z, no copy, 7.9 ms
b/a copies + gating torch elementwise + Triton fused_gdn_gating_kernel gating reads strided b/a, no copies, 1.2 ms
prepare, chunk state h aiter FlyDSL, 16.6 + 31.5 ms unchanged
GDN total 142.3 ms 99.7 ms (-30%)

Prefill step: 836 to 787 ms (-5.9%).

prefill fusion

E2E

Setup:

  • MI308X, launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh (SP + SDMA, MTP off), 12000 in / 350 out.
  • Base branch and this PR were run interleaved: 2 rounds (TP2) and 3 rounds (TP4).
TP2 c8 TP2 c12 TP4 c8 TP4 c12
QPS, before / after 0.758 / 0.819 0.856 / 0.921 0.974 / 1.038 1.125 / 1.203
QPS +8.0% +7.6% +6.6% +6.9%
TTFT / TPOT -3.7% / -9.4% -4.8% / -8.4% -6.7% / -5.9% -5.3% / -7.0%

With MTP on (the launch script as is: MTP=1, EAGLE 3/1/4), TP2, interleaved runs (base 2, Triton-verify 4, this PR 4):

c8 c12
QPS: base / PR with Triton verify / PR 1.135 / 1.177 / 1.195 1.195 / 1.248 / 1.258
QPS vs base +5.3% +5.2%
TPOT vs base -5.4% -5.6%
FlyDSL verify alone (vs Triton verify): QPS / TPOT +1.5% / -1.9% +0.8% / -1.6%

A second, later set on the same node (slower overall, base 3 / others 2 runs) gives the same picture: QPS +5.8% / +5.4% vs base, verify alone +2.1% / +1.5%. Accept length is unchanged (3.46 base, 3.49 Triton verify, 3.50 PR).

Accuracy:

  • gsm8k (1319 questions, TP2), with the launch script:
    • MTP on: 0.9772 before, 0.9772 after (accept length 3.11 / 3.12); earlier set 0.978 / 0.978 (0.979 with Triton verify);
    • MTP off: base 0.9779 / 0.9802 / 0.9825, this PR 0.9795 / 0.9787 / 0.9764 / 0.9772, within the run-to-run spread (one run's standard error is about 0.004).
  • Test test/registered/attention/test_gdn_flydsl_gfx942.py, vs the Triton chain (decode, verify, prefill front end): conv caches and intermediate conv windows are bit-exact, SSM and intermediate states are within 1e-5. Inputs the kernels cannot read (e.g. fp16) fall back to Triton bit-exactly.

Trace (Before)

Prefill

image

Decode

image

MTP verify

image

Trace (After)

Prefill

image

Decode

image

MTP verify

image

…lyDSL kernels on gfx942

Decode: new FlyDSLGDNKernel keeps TritonGDNKernel's interface
(packed_decode is a drop-in) and also serves the existing fused decode
projection/Conv1D protocol: Qwen3_5GatedDeltaNet hands in
(projected_qkvz, projected_ba) and gets (core_attn_out, z) back from one
aiter fused_qkvzba_conv1d_gated_delta_rule_decode_flydsl launch, which
replaces the b/a copies, q/k/v cat, causal_conv1d_update, packed recurrence
and z copy. GDNKernelDispatcher wraps the Triton decode kernel with it on
gfx942 when aiter provides the kernels.
Prefill: flydsl_gdn_prefill_front replaces cat + causal_conv1d_fwd + qkv
split + 2x l2norm; the gated norm reads z as a strided view (no copy).
Both are taken only when the layer/cache contract matches (K=V=128, bf16
conv, fp32 SSM state, no replayssm/MIS/state tracking); otherwise the
Triton path runs unchanged.
packed_decode now falls back to Triton unless activations are bf16, A_log is
fp32, dt_bias is bf16/fp32, the scale is 128^-0.5 and HV is a multiple of H.
The per-layer gate also requires num_q_heads == num_k_heads. Adds an fp16
packed_decode case that must match Triton exactly.
- qwen3_5: the FlyDSL prefill path joins the existing projection dispatch and
  reuses the common norm/out_proj tail with the strided-z option instead of
  duplicating it; the forward-mode checks move into its gate.
- gdn_backend: one per-layer gate (supports_flydsl) instead of a gate plus an
  alias; drop prefill checks implied by the aiter prefill metadata.
- gdn_flydsl: drop an attribute only read from the verify kernel.
…gate

Address review on sgl-project#111:
- decode and prefill share log_flydsl_path (lru_cache) instead of a kernel
  flag plus a module global.
- the prefill front-end gate says which conditions come from the aiter
  chunked prefill and which from forward_extend; drop the extend-kernel
  isinstance check, implied by the aiter prefill metadata.
…kend aiter

FlyDSL decode was switched on implicitly under the triton decode backend,
with no way to turn it off. Make it explicit, like the prefill side:
- --linear-attn-decode-backend accepts aiter and selects the FlyDSL decode
  kernel (Triton fallback when unavailable); triton is plain Triton again.
- the prefill front end follows --linear-attn-prefill-backend aiter only, no
  longer tied to the decode backend.
- evaluation launch script: --linear-attn-decode-backend aiter.
- test: the decode backend flag selects the kernel.
…kend aiter

Chain verify (topk 1) hands the in_proj outputs to the aiter FlyDSL verify kernel
on gfx942; tree verify, ReplaySSM and other GPUs stay on Triton. The Qwen3.8 launch
script selects it.
@yicyang yicyang changed the title [AMD][Qwen3.8] Route GDN decode and prefill front end through aiter FlyDSL kernels on gfx942 [AMD][Qwen3.8] Route GDN decode, MTP verify and prefill front end through aiter FlyDSL kernels on gfx942 Nov 20, 2026
@yicyang
yicyang marked this pull request as ready for review November 20, 2026 04:03
@yicyang
yicyang requested a review from apinge November 20, 2026 04:05
@yicyang

yicyang commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

PR #111 routes Qwen3.8 GDN decode, MTP verify and the prefill front end through aiter FlyDSL kernels on gfx942. Both runs use the same Qwen4 MI308X CI workflow (qwen4-ci.yml) and the same 6 cases.

Case GSM8K TTFT ms (Δ) TPOT ms (Δ)
Qwen3.8-Flash-TP2-Base 98.50% → 98.50% 584.098 → 552.433 (−5.4%) 7.269 → 6.752 (−7.1%)
Qwen3.8-Flash-TP2-MTP 98.00% → 98.00% 613.101 → 582.103 (−5.1%) 3.956 → 3.530 (−10.8%)
Qwen3.5-35B-TP4-Base 97.50% → 98.00% 167.011 → 163.105 (−2.3%) 4.095 → 4.159 (+1.6%)
Qwen3.5-35B-TP1-DFlash 97.00% → 97.50% 308.407 → 298.045 (−3.4%) 2.907 → 2.885 (−0.8%)
Qwen3.5-397B-TP8-Base 99.50% → 99.00% 372.692 → 329.173 (−11.7%) 6.933 → 6.067 (−12.5%)
Qwen3.5-397B-TP8-DFlash 98.50% → 99.00% 408.651 → 360.135 (−11.9%) 3.492 → 3.002 (−14.0%)
Case Output tok/s (Δ) QPS (Δ) Accept length (Δ)
Qwen3.8-Flash-TP2-Base 112.112 → 120.281 (+7.3%) 0.320 → 0.344 (+7.5%) —
Qwen3.8-Flash-TP2-MTP 175.471 → 192.857 (+9.9%) 0.501 → 0.551 (+10.0%) 3.490 → 3.481 (−0.3%)
Qwen3.5-35B-TP4-Base 226.123 → 223.289 (−1.3%) 0.452 → 0.447 (−1.1%) —
Qwen3.5-35B-TP1-DFlash 284.118 → 287.589 (+1.2%) 0.568 → 0.575 (+1.2%) 5.889 → 5.929 (+0.7%)
Qwen3.5-397B-TP8-Base 130.443 → 148.915 (+14.2%) 0.261 → 0.298 (+14.2%) —
Qwen3.5-397B-TP8-DFlash 232.308 → 268.936 (+15.8%) 0.465 → 0.538 (+15.7%) 7.917 → 7.952 (+0.4%)

Takeaways

  • Qwen3.8 (the target of this PR):
    • TPOT drops 7.1% for Base and 10.8% for MTP. Output throughput rises 7.3% for Base and 9.9% for MTP.
    • TTFT drops about 5% in both cases.
    • MTP accept length is unchanged (3.490 → 3.481), so the MTP verify path produces the same drafts it did before.
  • Qwen3.5-35B: all changes are between −3.4% and +1.6%, which is within run-to-run variation.
  • Qwen3.5-397B:
    • The PR does not change this model's code path, but the table shows +14–16% throughput.
    • The cause is a slow baseline run. In the [Qwen3.8] Cherry pick sp&sdma #104 CI comment, TP8-Base ran at 145.0 tok/s with a TPOT of 6.225 ms, and TP8-DFlash ran at 262.5 tok/s. In this baseline run, TP8-Base ran at 130.4 tok/s with a TPOT of 6.933 ms.
    • This PR's numbers (148.9 and 268.9 tok/s) are within about 3% of the earlier ones. The 397B gain should not be credited to this PR.
  • Accuracy: GSM8K changes are ±0.5 pp, within run-to-run variation. All cases stay above the minimum threshold.

@apinge
apinge merged commit b2ff410 into apinge:qwen4_v0.5.21 Nov 20, 2026
8 of 9 checks passed
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.

3 participants