Repository navigation
[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
Conversation
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.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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]>
|
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 (
I updated the description: the table is in the Performance section and the performance box is ticked. |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
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_dim5120,inter_dim640, 385 experts, top-7) at 512, 1024, 2048, 4096 and 8192 tokens. Every row pairs an XCD-remap stage 1 (_xcd1or_xcd4) with the v2-layout reduce stage 2. Stacked on #7918 atb2fc31b5f; review only the commits97a8b27ca6(the rows) and585020b694(file names only).dsv41_e385_verify_xcd_tuned_fmoe.csv, DSpark verify steps: 512t32x128x256_w2_gui_xcd1, 1024t32x128x256_w3_bnt0_gui_xcd4, 2048t64x128x256_w3_bnt0_gui_xcd1; stage 2flydsl_moe2_layout_afp8_wfp4_bf16_t{32,64}x256x128_reduce.dsv41_e385_prefill_tuned_fmoe.csv, prefill batches of 2-8 short prompts: 4096 and 8192 with the kernel pair of [Config] [Perf] Add DeepSeek-V4.1-Flash TP4 A8W4 MoE rows for 16384 / 32768 tokens with the XCD-remap stage 1 on gfx950 (E385, top-7) #8213's 16384 row (stage 1t64x128x256_w4_bnt0_gui_xcd1, stage 2..._t64x256x128_reduce_sbm64, block_m 64).Related open PRs for this key:
dsv41_fp8fp4_tuned_fmoe.csv. Its 4096 and 8192 rows have the same keys as this PR's prefill rows, with other kernels (4096: the same tiles without_xcd1; 8192: stage 1t128x128x256_bnt0_gui, stage 2..._reduce_sbm128, block_m 128). AITER's config merge raises an error when two files have a row with the same key, so only one of each pair can land. The verify rows (512-2048) do not overlap.Motivation
On main this key has no rows below 16384 tokens, so
fused_moetakes 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
aiter/configs/model_configs/dsv41_e385_verify_xcd_tuned_fmoe.csv(3 rows) anddsv41_e385_prefill_tuned_fmoe.csv(2 rows), picked up by themodel_configs/scan. The tested build has the same rows, byte for byte, under other file names.us1/us2/uscolumns 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_moedoes not use these columns to pick kernels.Performance (if applicable)
fused_moecall, real prefill routing, CUDA graph, median of 8 rounds, 2176 / 2600 / 3072 / 4074 tokens (4096 bucket)fused_moecall, CUDA graph, median, 384 / 512 / 1024 / 2048 tokens (512-2048 buckets), real prefill routing (1)fused_moecall, 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(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). AITER285579b6with #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.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 configfor 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
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
Tuned-config rows only.
Dependencies
No new third-party dependencies added
New dependencies are listed and justified below
Needs [FlyDSL] MoE stage 1: XCD remap over the valid rows only #7918 (registers the A8W4
xcd_swizzle1 stage 1 and remaps over the launch grid; stacked on [FlyDSL] [Bugfix] Fix MoE XCD swizzle on grids not divisible by 8 #7567).[FlyDSL] [Bugfix] MoE stage 1: wait for the A LDS-DMA before the half-step barrier #8550 (merged on 11-30): on main, the stage-1 kernels of the verify rows need its LDS-DMA wait for run-to-run identical output. In the tested build the same wait comes from the older [FlyDSL] [MoE] Fix a race in the async stage-1 LDS pipeline; add AITER_MOE_SKIP_INTER_PAD #6170; with that wait removed, these rows gave different output in 3 to 8 of 8 reruns at 384-1024 tokens.
[FlyDSL] Count tile2_pad in the stage-1 XCD remap grid #8512 (open) is not needed: with a v2-layout stage 2 the stage-1
tile2_padis 0 at this shape, so the remap grid equals the launch grid.Breaking Changes
None.
PR Self-Review
Reviewed revision
585020b694d2e0777921f6f9b60e111b58bd5fbfBehavior and intent
On gfx950,
fused_moefor 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
285579b6with #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.fused_moeoutput bit for bit as the same tile without the XCD remap (288-2048 tokens, verify routing); 0 NaN and 0 differences over 40 routings at 520-2048 tokens, eager and graph. The prefill rows: 0 NaN, error 0.0305 (relative L2), as [Config] [Perf] Add DeepSeek-V4.1-Flash TP4 A8W4 MoE rows for 16384 / 32768 tokens with the XCD-remap stage 1 on gfx950 (E385, top-7) #8213's 16384 row.using 2stagefor 4096 / 8192 (0no tuned FlyDSL configlines for the 4096 bucket, against 8 in the arms without the rows).cu_numother than 256.PR-specific question
N/A.
Changed op tests
None.