Skip to content

[FlyDSL] [Perf] Add DeepSeek-V4.1-Flash TP4 A8W4 MoE rows for 512-8192 tokens with the XCD-remap stage 1 on gfx950 (E385, top-7) - #8650

Open
amd-pedghazi wants to merge 20 commits into
ROCm:mainfrom
amd-pedghazi:amd/dsv41-e385-xcd-rows-512-8192
Open

amd-pedghazi wants to merge 20 commits into
ROCm:mainfrom
amd-pedghazi:amd/dsv41-e385-xcd-rows-512-8192

Conversation

@amd-pedghazi

@amd-pedghazi amd-pedghazi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two CSV files in aiter/configs/model_configs/ with five gfx950 rows for the DeepSeek-V4.1-Flash TP4 A8W4 MoE shape (model_dim 5120, inter_dim 640, 385 experts, top-7) at 512, 1024, 2048, 4096 and 8192 tokens. Every row pairs an XCD-remap stage 1 (_xcd1 or _xcd4) with the v2-layout reduce stage 2. Stacked on #7918 at b2fc31b5f; review only the commits 97a8b27ca6 (the rows) and 585020b694 (file names only).

Related open PRs for this key:

Motivation

On main this key has no rows below 16384 tokens, so fused_moe takes its heuristic kernels there. DeepSeek-V4.1-Flash DSpark verify steps send 257-2048 tokens per MoE call at high concurrency, and prefill batches of 2-8 short prompts land in the 4096 and 8192 buckets.

Changes

  • New aiter/configs/model_configs/dsv41_e385_verify_xcd_tuned_fmoe.csv (3 rows) and dsv41_e385_prefill_tuned_fmoe.csv (2 rows), picked up by the model_configs/ scan. The tested build has the same rows, byte for byte, under other file names.
  • No code change. The us1 / us2 / us columns of the verify rows come from the earlier plain-stage-1 rows of these buckets, not from timing these kernels; the prefill rows carry 0. fused_moe does not use these columns to pick kernels.

Performance (if applicable)

Hardware Workload/configuration Before After Change
MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0 fused_moe call, real prefill routing, CUDA graph, median of 8 rounds, 2176 / 2600 / 3072 / 4074 tokens (4096 bucket) heuristic (no row, as on main): 608.9 / 548.9 / 630.6 / 709.0 us 4096 row: 421.7 / 384.4 / 436.5 / 493.9 us -30.7 % / -30.0 % / -30.8 % / -30.3 %
same same, 5120 / 6144 / 7000 / 8192 tokens (8192 bucket) heuristic: 905.5 / 1011.1 / 1080.9 / 1151.5 us 8192 row: 641.6 / 704.2 / 755.6 / 825.9 us -29.1 % / -30.4 % / -30.1 % / -28.3 %
same fused_moe call, CUDA graph, median, 384 / 512 / 1024 / 2048 tokens (512-2048 buckets), real prefill routing (1) heuristic: 229.0 / 272.8 / 297.9 / 349.9 us verify rows: 206.6 / 249.6 / 228.5 / 275.4 us -9.8 % / -8.5 % / -23.3 % / -21.3 %
same fused_moe call, CUDA graph, median, real verify routing, v2-layout stage 2 with the plain stage 1 vs with the XCD-remap stage 1 of these rows (1), 288 / 384 / 768 / 1000 / 1536 / 2048 tokens 141.5 / 172.5 / 272.2 / 303.3 / 416.6 / 456.4 us 133.1 / 164.5 / 249.0 / 270.2 / 395.1 / 422.8 us -5.9 % / -4.6 % / -8.5 % / -10.9 % / -5.2 % / -7.4 %
4 x MI355X SGLang serving, DeepSeek-V4.1-Flash TP4, random 1k/1k, c256; order rows, no rows, no rows, rows, same GPUs without the prefill rows with the prefill rows mean TTFT -2.7 %, throughput +0.4 %
4 x MI355X same, random 8k/1k, DSpark, c256; 4 order-balanced pairs (2) plain-stage-1 rows (FP8 mixed stage 2) at 512-2048 the verify rows + the one-launch MoE of amd-pedghazi#8 throughput +1.30 % (se 0.13 %)
4 x MI355X SGLang serving, DeepSeek-V4.1-Flash TP4, DSpark, random dataset, 8 points (table below); order rows, no rows, no rows, rows no rows at 512-8192 (heuristic, as on main) all five rows of this PR output throughput +3.8 % / +4.1 % (geometric mean, two orders), median TPOT -3.9 % / -3.3 %

(1) Measured with the exact stage-1 quantization rule of amd-pedghazi#8 for these three stage-1 tiles. The repeat of the 1536 / 2048 pair in the same process gave 422.1 -> 409.8 / 460.9 -> 441.6 us (-2.9 % / -4.2 %).
(2) The verify rows were measured in serving only together with amd-pedghazi#8. The XCD stage 1 alone on top of that arm (two pairs, random 8k/1k c256) gave +0.16 %, within noise.

Serving A/B of these rows alone (8 points)

4 x MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0, SGLang serving DeepSeek-V4.1-Flash at TP4 with DSpark (block size 5), random dataset (--random-range-ratio 1.0, warm-up and cache flush before each point). AITER 285579b6 with #7917, #7918 and #8550 ported, and the two CSV files of this PR byte for byte (not this branch). Control: the same build with header-only copies of the two CSV files, so the 512 to 8192 token buckets fall back to the heuristic, as on main. The one-launch MoE and the exact stage-1 FP8 rule of amd-pedghazi#8 were off in both arms. Order rows on, off, off, on, a fresh server per run.

in/out concurrency off tok/s (2 runs) on tok/s (2 runs) change (two orders)
1024/1024 64 9063 / 9051 9179 / 9420 +1.3 / +4.1 %
1024/1024 128 12537 / 12398 12922 / 12992 +3.1 / +4.8 %
1024/1024 256 16812 / 16828 17708 / 17892 +5.3 / +6.3 %
2048/1024 96 10596 / 10657 11110 / 10977 +4.8 / +3.0 %
4096/1024 64 8173 / 8161 8631 / 8618 +5.6 / +5.6 %
4096/1024 256 13251 / 13287 13379 / 13446 +1.0 / +1.2 %
8192/1024 64 6810 / 6707 7070 / 7012 +3.8 / +4.5 %
8192/1024 128 7961 / 8133 8404 / 8393 +5.6 / +3.2 %

Geometric mean over the 8 points: output throughput +3.8 % and +4.1 % in the two orders, median TPOT -3.9 % and -3.3 %, mean TTFT within noise (+0.3 % / -2.3 %). The two runs of one arm differ by +0.0 % (off) and +0.3 % (on) in geometric mean, and by at most 2.6 % at any point; all 8 points are faster in both orders. The control runs log no tuned FlyDSL config for the 512 / 1024 / 2048 / 4096 / 8192 token buckets of this key; the runs with the rows do not. GSM8K (1,319 questions): 97.03 % with the rows, 97.34 % without (one run each).

Testing

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

Only gfx950 is targeted, so MI250X and MI300X do not apply. Config rows only; the XCD-remap test comes with #7918. Performance: the 8-point serving A/B of these rows alone is in the Performance section; it ran on the tested build with this PR's CSV files byte for byte, not on this branch. The op-level points above are from our own scripts.

Documentation

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

Tuned-config rows only.

Dependencies

Breaking Changes

None.

PR Self-Review

Reviewed revision

585020b694d2e0777921f6f9b60e111b58bd5fbf

Behavior and intent

On gfx950, fused_moe for this shape at 257-8192 tokens takes the XCD-remap stage 1 and the v2-layout reduce stage 2 of these rows instead of the heuristic fallback. Other shapes and token counts are unchanged.

Validation and unverified scope

Tested on MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0, AITER 285579b6 with #6170, #7917, #7918, #7940, #7949 and #8550 ported to FlyDSL 0.4.0, plus amd-pedghazi#8 (these CSV files byte for byte), not on this branch.

PR-specific question

N/A.

Changed op tests

None.

eppaneamd and others added 19 commits November 6, 2026 09:08
Both FlyDSL MoE GEMM stages remap their workgroups for XCD locality with

    wgid = (lin % 8) * (n // 8) + lin // 8

which is a permutation of the n workgroups only when n is a multiple of
8. Otherwise n % 8 tiles run twice and n % 8 tiles never run: stage 1
leaves rows of its output unwritten (and split-K stage 1 adds some
partial sums twice), the atomic stage 2 adds some expert contributions
twice and drops others, and the reduce stage 2 reads slots nobody
wrote. n depends on the token count, so an `_xcd` kernel can be right
at one token count and wrong at the next.

xcd_remap_bx_by already has the remainder term. Move its remap into
xcd_remap_grid, which takes the grid size from the caller, and call it
from both MoE stages. Also correct the stage-2 comment that called
xcd_swizzle an ignored argument.

Add test_flydsl_moe_xcd_swizzle_uneven_grid: both stages with
xcd_swizzle=4 on a 2 x 18 grid, every tile holding a routed row.

The same fix was proposed in ROCm#4315, closed for inactivity.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The MoE stages put M blocks on grid y and N blocks on grid x, so they
pass grid_y as grid_m; naming the arguments makes that visible. The
docstring now states the helper's xcd_swizzle > 0 precondition, which
xcd_remap_bx_by checks before calling it.

No compiled kernel changes: the gfx950 ISA of both MoE stages, the
persistent and heterogeneous stage 2, and both GEMM callers is
byte-identical to the previous commit's.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI runs op_tests/*.py as sharded scripts, and op_tests/flydsl_tests is not in
the plan, so test_flydsl_moe_xcd_swizzle_uneven_grid never ran there. The
Focused regression tests step runs `python3 -m pytest -q tests` on pull
requests (MI35X shard 0), so the test moves, unchanged, to
tests/test_flydsl_moe_xcd_swizzle.py. It imports its data generator, tolerance
check, tile_k helper and gfx950 skip from the op test file, which keeps the
distinct_experts argument of _generate_a8w4_gui_data.

On MI355X (torch 2.13.0+rocm10.0.0, FlyDSL 0.4.2, an empty FlyDSL cache per
run): with the three kernel files of the merge-base the test fails
(xcd4_uneven_grid_stage1: output has NaN), with this commit's it passes, 0
skipped; the whole tests/ directory in CI's layout runs in 13 s.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The gfx950 skip imported from the op test uses get_gfx(), which follows
GPU_ARCHS and takes its last entry, so on an MI355X with
GPU_ARCHS='gfx950;gfx942' the regression was skipped. It now checks
get_gfx_runtime(), the running GPU, in the test body, as
op_tests/test_flydsl_pa_decode.py does.

On MI355X with GPU_ARCHS='gfx950;gfx942', get_gfx() returns gfx942 and
get_gfx_runtime() gfx950. Under the other settings tried (unset, 'gfx950',
'gfx942;gfx950') both return gfx950.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	aiter/ops/flydsl/kernels/mixed_moe_gemm_2stage_common.py
#	op_tests/flydsl_tests/test_flydsl_moe.py
The stage-1 grid is sized for the worst-case padded row count, and the
xcd_swizzle remap spread that whole grid over the 8 XCDs, so the empty
padding tail (11-25% of the tiles under real routing) landed on the last
XCDs. Remap only the rows num_valid_ids covers; rows past them keep their
ids and exit as before.

Register xcd_swizzle=1 for every stage-1 dtype, not only a16w4.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
With the stage-1 remap over valid rows, the xcd_swizzle=1 stage 1 beats the
rows ROCm#7656 picked. fused_moe on MI355X, real routing, cache flushed, against
the ROCm#7656 rows on the same build: 1536 tokens -6.3%, 3000 -6.5%, 4096
-10.0%, 8192 -2.9%, 12000 -4.2%, 16384 -0.6%.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
…_ids

Routing that leaves the worst-case stage-1 grid longer than the valid
sorted blocks, with xcd_swizzle 1 and 4; a valid tile the remap skips
leaves NaN in the output.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
FP8-A stage 2 sizes its grid from occupancy and ignores the name's persist
flag, so t32x128x128_atomic_bnt2_persist and t32x128x128_atomic_bnt2 compile
and launch the same kernel (identical compile arguments, persist_m=1). Name
the row by the kernel it runs.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
…h-grid remap

ROCm#7796 was closed without merging; ROCm#7822 handles the stage-1 padding in
the dispatch instead. Drop its padding changes and tests, but keep the
remap over the launch grid: stage 1 launches tile2_pad more N columns
than the count the remap recomputed, so with intermediate_pad (DSv4.1
TP4: 576 + 64) an xcd_swizzle stage 1 left the padded columns unwritten.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
DSv4.1 TP4 padding (576 of 640 columns, tile_k 256): stage 1 launches a
tile2_pad N block past the unpadded width. xcd_swizzle 1 and 4 must
write the same output as xcd_swizzle 0, padded columns included.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
Restore dsv41_fp8_tuned_fmoe.csv; the xcd1 stage-1 rows come with the
retune of the DSv4.1 TP4 rows.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
…map stage 1 on gfx950 (E385, top-7)

Verify buckets 512 / 1024 / 2048 and prefill buckets 4096 / 8192: XCD-remap stage 1 (ROCm#7918) with the v2-layout
reduce stage 2. Files as in the tested image.
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 8650 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

Rename the two CSVs of this PR so that their names say what they hold:
the verify buckets 512 / 1024 / 2048 (XCD-remap stage 1) and the prefill
buckets 4096 / 8192. Contents unchanged; AITER's model_configs scan still
picks them up through the *tuned_fmoe* suffix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@amd-pedghazi

Copy link
Copy Markdown
Contributor Author

Serving A/B of these rows alone, the run the description was waiting for before ticking the performance box.

Setup. 4 x MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0, SGLang serving DeepSeek-V4.1-Flash at TP4 with DSpark (block size 5), random dataset (--random-range-ratio 1.0, warm-up and cache flush before each point). AITER 285579b6 with #7917, #7918 and #8550 ported, and the two CSV files of this PR byte for byte (this branch on main needs FlyDSL 0.5.3, so it did not run as is). Control: the same build with header-only copies of the two CSV files, so the 512 to 8192 token buckets of this key fall back to the heuristic, as on main. The one-launch MoE and the exact stage-1 FP8 rule of amd-pedghazi#8 were off in both arms, so this measures the rows alone, in the form they take on main. 8 points, order rows on, off, off, on, a fresh server per run.

in/out concurrency off tok/s (2 runs) on tok/s (2 runs) change (two orders)
1024/1024 64 9063 / 9051 9179 / 9420 +1.3 / +4.1 %
1024/1024 128 12537 / 12398 12922 / 12992 +3.1 / +4.8 %
1024/1024 256 16812 / 16828 17708 / 17892 +5.3 / +6.3 %
2048/1024 96 10596 / 10657 11110 / 10977 +4.8 / +3.0 %
4096/1024 64 8173 / 8161 8631 / 8618 +5.6 / +5.6 %
4096/1024 256 13251 / 13287 13379 / 13446 +1.0 / +1.2 %
8192/1024 64 6810 / 6707 7070 / 7012 +3.8 / +4.5 %
8192/1024 128 7961 / 8133 8404 / 8393 +5.6 / +3.2 %
  • Geometric mean over the 8 points: output throughput +3.8 % and +4.1 % in the two orders, median TPOT -3.9 % and -3.3 %, mean TTFT +0.3 % and -2.3 % (within noise).
  • Noise: the two runs of one arm differ by +0.0 % (off) and +0.3 % (on) in geometric mean, and by at most 2.6 % at any point. All 8 points are faster in both orders; the smallest gain is 4096/1024 at 256 requests (+1.0 / +1.2 %).
  • Proof the rows were used: the control runs log no tuned FlyDSL config for the 512, 1024, 2048, 4096 and 8192 token buckets of this key; the runs with the rows do not.
  • Accuracy: GSM8K (1,319 questions) 97.03 % with the rows, 97.34 % without (one run each).

I updated the description: the table is in the Performance section and the performance box is ticked.

@amd-pedghazi
amd-pedghazi marked this pull request as ready for review December 1, 2026 14:43
@amd-pedghazi
amd-pedghazi requested a review from a team December 1, 2026 14:43
@github-actions github-actions Bot changed the title [Config] [Perf] Add DeepSeek-V4.1-Flash TP4 A8W4 MoE rows for 512-8192 tokens with the XCD-remap stage 1 on gfx950 (E385, top-7) [FlyDSL] [Perf] Add DeepSeek-V4.1-Flash TP4 A8W4 MoE rows for 512-8192 tokens with the XCD-remap stage 1 on gfx950 (E385, top-7) Dec 1, 2026
@github-actions github-actions Bot added the FlyDSL label Dec 1, 2026
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 585020b694d2 · 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 exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  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 — PR-specific question has no substantive answer
  • FAIL — validation answer must explicitly state what remains unverified (or say none with a reason)
  • FAIL — changed op test not explained in Changed op tests: op_tests/flydsl_tests/test_flydsl_moe.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

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

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.

6 participants