Skip to content

[ASM] Add gfx950 Qwen3.8-Flash-Next fused MXFP4 prefill producers - #8044

Open
vstakhov-amd wants to merge 4 commits into
mainfrom
flashnext-asm-prefill
Open

vstakhov-amd wants to merge 4 commits into
mainfrom
flashnext-asm-prefill

Conversation

@vstakhov-amd

@vstakhov-amd vstakhov-amd commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

[ASM] Add gfx950 Qwen3.8-Flash-Next fused MXFP4 prefill producers (TP1 and TP2)

What

Two fused assembly MoE producers for Qwen3.8-Flash-Next prefill on gfx950 (model 2560, 513 experts with the fused shared expert, top-k 11, SiLU, MXFP4 activations and weights):

  • ..._fp32gate_i384_route.co — intermediate 384 (TP2: 320 + 64 padding)
  • ..._fp32gate_i640_route.co — intermediate 640 (TP1)

Both use the existing post-reduction mode (flat=3): standard fmoe launcher, Opus sort with 256-row tiles, token-major BF16 partials and the FlyDSL reduction. No Python, C++, FlyDSL or Triton changes: two code objects, two manifest rows and config rows in qwen3_8_flash_fp4_tuned_fmoe.csv.

Config rows, the same for intermediate 384 and 640:

  • 16384: replaces the tuned FlyDSL row.
  • 32768: new row. Main has no tuned row there and runs the heuristic FlyDSL default.

The producers therefore serve 8193+ tokens. The 8192 rows stay on FlyDSL (for intermediate 384, the row added in #8123): they serve 4097–8192 tokens, where the producer is 3% ahead at 8192 but 8–22% behind at 4097–6000.

Performance

MI355X, one GPU, arms interleaved in one lease, 3 rounds, AITER_USE_FLYDSL_MOE_SORTING=1, main at d6d60ef. Whole fused_moe call, µs per layer.

Captured vLLM routing (12-layer chain, layers 24–35, 50 samples per round):

Shape Tokens main this PR Change
inter 384 (TP2) 16384 902 812 −10.1%
inter 384 (TP2) 32768 2368 1460 −38.4%
inter 640 (TP1) 16384 1094 1015 −7.2%
inter 640 (TP1) 32768 2948 1799 −39.0%

Against a tuned FlyDSL 32768 row for inter 640 (2002 µs) the producer is −10.2%.

Uniform synthetic routing (test_moe_q256_prefill.py):

Shape Tokens main this PR Change
inter 384 8193 568 524 −7.8%
inter 384 12000 645 628 −2.6%
inter 384 16384 891 843 −5.4%
inter 384 32768 2539 1437 −43.4%
inter 640 8193 698 690 −1.1%
inter 640 12000 785 808 +2.9%
inter 640 16384 1099 1063 −3.3%
inter 640 32768 3211 1719 −46.5%

The inter 640 / 16384 row is 2.9% behind tuned FlyDSL at 12000 tokens on uniform routing and ahead at both ends of its range and on captured routing.

Accuracy

  • NRMS vs the FP32 reference with FP4-requantized intermediate: 0.23% on captured chains, 0.28% in the synthetic harness, the same as the tuned FlyDSL rows (heuristic FlyDSL path at 32768 tokens: 3.3–3.8%).
  • Repeat runs bitwise equal.
  • Harness passes at 8193, 12000, 16384, 32768 and 131072 tokens for both shapes.

Dispatch checks

  • Default dispatch selects the new code objects for the rows above.
  • Unchanged: inter 384 and inter 640 at 8192 tokens (tuned FlyDSL rows).

Install two fused assembly producers for Qwen3.8-Flash-Next MoE prefill
(model 2560, 513 experts with the fused shared expert, top-k 11, SiLU,
MXFP4 activations and weights): one for intermediate 384 (TP2: 320 plus
64 padding) and one for intermediate 640 (TP1). Both use the existing
post-reduction mode (flat=3): standard fmoe launcher, Opus sort with
256-row tiles, token-major BF16 partials and the FlyDSL reduction.

Select them in the Flash MXFP4 config:
- intermediate 384: 8192, 16384 and 32768 token rows (4097+ tokens),
  which had no tuned rows and ran the heuristic FlyDSL default;
- intermediate 640: the 16384 row (replacing FlyDSL) and a new 32768
  row (8193+ tokens). The 8192 row stays on FlyDSL.
@vstakhov-amd vstakhov-amd self-assigned this Nov 17, 2026
Replace both code objects with faster builds that produce bitwise
identical output:
- tiles with at most 32 valid rows take a direct path that loads their
  activations straight into registers instead of staging them;
- workgroups visit tiles in a cost-balanced order instead of the fixed
  one (for intermediate 384 these two apply up to 8192 tokens only);
- per-load prefetch guards are dropped and the activation is applied in
  place; intermediate 640 now also keeps the down accumulators in
  VGPRs, as 384 already did.

Refresh the timings of the five config rows. Manifest rows and the
selected token rows are unchanged.
@vstakhov-amd
vstakhov-amd marked this pull request as ready for review November 18, 2026 14:22
@vstakhov-amd
vstakhov-amd requested a review from a team November 18, 2026 14:23
@github-actions github-actions Bot changed the title Add gfx950 Qwen3.8-Flash-Next fused MXFP4 prefill producers [ASM] Add gfx950 Qwen3.8-Flash-Next fused MXFP4 prefill producers Nov 18, 2026
@github-actions github-actions Bot added the ASM label Nov 18, 2026
@aiter-bot

aiter-bot commented Nov 18, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 60e1a3734952 · 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. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  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 — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • 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.

Resolve the conflict with #8123, which added tuned FlyDSL rows for
intermediate 384 at 1024..16384 tokens to the Flash MXFP4 config:
- keep the FlyDSL 8192 row. It serves 4097..8192 tokens, where the
  producer is 3% faster at 8192 but 8-22% slower at 4097..6000;
- the producer replaces the FlyDSL 16384 row and keeps its new 32768
  row, so intermediate 384 uses it from 8193 tokens, as intermediate
  640 already does.

The intermediate 640 rows, both code objects and the manifest rows are
unchanged.

@mjkvaak-amd mjkvaak-amd 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.

Thanks for the PR!

Just FYI, this work #8044 and #8867 (#8123 follow-up) both fill the same gap as this PR using FlyDSL.

Qwen3.8-Flash-Next, MI355X. Kernel: one fused_moe call, vLLM's padding and env. E2E: TP2, MTP-3, --max-num-batched-tokens 32768, 2 passes with GPU pairs swapped, output tok/s vs main.

main (#8123) #8044 #8123 + #8867
inter 384 (TP2), 32768 tokens 2476 µs 1433 µs 1524 µs
inter 640 (TP1), 32768 tokens 3172 µs 1754 µs 1882 µs
inter 256 (TP4), 32768 tokens 2017 µs no row 1206 µs
inter 384, 16384 tokens 824 µs 846 µs 824 µs
E2E 60k/128k — +6.4% +5.1%
E2E 8k/1k — +1.8% +1.5%

Your #8044 is the faster at 32k and at 16k it's on par with #8123 (main), so I recommend landing yours instead of #8867 after fixing the small requests I left. I'm taking down #8867.

_ZN5aiter49fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x32E,fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x32.co,0,0,0,2,0,16,32,1,0,0,0
_ZN5aiter50fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x160E,fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x160.co,0,0,0,1,0,16,160,1,0,0,0
_ZN5aiter50fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x320E,fmoe_bf16_pertokenMXfp4_g1u1_flat_novs_silu_16x320.co,0,0,0,1,0,16,320,1,0,0,0
fmoe_bf16_pertokenMXfp4_g1u1_silu_prefill_1tg_4w_256mx1_128nx1_ps_fp32gate_i640_route,fmoe_bf16_pertokenMXfp4_g1u1_silu_prefill_1tg_4w_256mx1_128nx1_ps_fp32gate_i640_route.co,0,0,0,1,1,256,640,3,0,0,0

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.

This file conflicts with main. #7611 added a 14th column, dim_align, to every row. After the rebase, both new rows need it. kernel_fits and the AITER_CHECK in asm_fmoe.cu require model_dim % dim_align == 0. For Flash-Next (model_dim 2560), the value has to be 512, as for the existing ..._fp32gate_route producer: 1024, which kernels without the 512-column tail drain declare, would reject every call at these keys. Since your harness already runs these at 2560, 512 should be correct.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants