Skip to content

[FlyDSL] [MoE] [Perf] DeepSeek-V4.1-Flash TP4 A8W4: stage 1 -> stage 2 in one launch for verify steps up to 512 tokens, opt-in exact stage-1 FP8 rule (gfx950) - #8658

Open
amd-pedghazi wants to merge 29 commits into
ROCm:mainfrom
amd-pedghazi:amd/dsv41-fused-moe-s12

Conversation

@amd-pedghazi

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

Copy link
Copy Markdown
Contributor

Summary

For DeepSeek-V4.1-Flash TP4 on gfx950 (A8W4: MXFP8 activations x MXFP4 weights; model_dim 5120, inter_dim 640, 385 experts, top-7), fused_moe can run MoE stage 1 and stage 2 as one kernel launch for calls of up to 512 tokens (DSpark verify steps), and the stage-1 FP8 epilogue can quantize with the exact rule of the two-kernel path. Both are opt-in through environment variables; with them unset nothing changes.

Stacked on #7917 and #7918 (merge commits 8806e9a55 and 004ced2dd on top of main ecb8d3f81). Review only two commits: b056787b1f (the change) and da06fd8cdb (AITER names for the module, env vars and log tag; no behaviour change). The last two commits merge main into the branch. ac2c4fa154 merged main 3fd42598c (which has moev2 phases 0-2); its only conflict was the _flydsl_v2_stage2_wrapper signature in aiter/fused_moe.py (both inter_dim_pad from #7917 and scatter_intermediate from main are kept). The head bd85bd0320 merges main 9c9fb96e0 without conflicts and does not change this PR's two kernel files.

This is the upstream form of code we tested in a DeepSeek-V4.1-Flash build (fork draft amd-pedghazi#8; MI355X, ROCm 7.2.4, FlyDSL 0.4.0). The upstream form is not GPU-tested yet: main needs FlyDSL 0.5.3 and our test build has FlyDSL 0.4.0. It is compile-checked on CPU only (see "Validation and unverified scope"). The GPU runs it needs are listed below.

The only similar upstream PR, #8381 (closed, draft), is written for another shape (H5120 / I2304, top-6 / top-3, EP8) with its own kernels. This PR instead traces AITER's own stage-1 body and AITER's stage-2 tile (mixed stage 2, or the v2-layout tile through compile_gemm2_a4w4_port(_composition=...)) into one kernel, so it keeps the tuned tiles and the fused output can be compared bit for bit with the two-launch path.

Motivation

At 257-512 tokens, the stage-1 and stage-2 launches of a verify-step MoE call each leave the GPU partly idle at their start and end. One launch removes one launch gap and lets stage-2 tiles start while later stage-1 tiles still run.

Changes

  • New aiter/ops/flydsl/kernels/moe_fused_s12.py:
    • one 1-D grid: stage-1 tiles first, in AITER's order, then the stage-2 tiles in the stage-2 kernel's own order;
    • a stage-1 tile writes its FP8 rows and sorted e8m0 scales write-through (sc1), waits for its stores, and adds 1 to its sort block's ready counter;
    • a stage-2 tile waits until its block's counter reaches the number of stage-1 N tiles; the last stage-2 tile of a block resets the counters for the next call;
    • no co-residency assumption, no grid barrier, no fences: a stage-2 tile waits only on lower workgroup ids;
    • AITER_MOE_FUSED_S12=1 installs it for the process: it holds the stage-1 launch of a fused_moe call and launches it with the stage-2 launch of the same call. AITER_MOE_FUSED_S12_MAX_ROWS (default 512) caps the token count, AITER_MOE_FUSED_S12_OCC (default 3) sets the LDS size for 3 workgroups per CU. The reduction kernel after stage 2 is unchanged.
  • mixed_moe_gemm_2stage_common.py:
    • trace-time hooks that are empty unless the fused kernel traces a body: block ids and grid size, write-through stores, one SharedAllocator per kernel, a call after each stage-1 tile and around each stage-2 tile. The stage-1 grid formula moves into _grid1 so the fused kernel can reuse it. With the switches off, the standalone kernels build the same ISA as before (checked, see below);
    • fp8_exact for the stage-1 FP8 epilogue (AITER_MOE_S1_FP8_EXACT=1): values rounded to bf16, amax floored at 1e-10, e8m0 = ceil_pow2(amax / 448), as fused_dynamic_mxfp8_quant_moe_sort does. Without it the FP8 epilogue keeps AITER's own rule, and the MoE output error goes from 0.0268 to 0.0305 (relative L2, measured on the image form);
    • the exact rule applies to stage-1 builds with xcd_swizzle 0 and to the <tile_m>/<waves_per_eu>/<xcd_swizzle> keys listed in AITER_MOE_S1_FP8_EXACT_KEYS. We serve 32/2/1,32/3/4,64/3/1: the stage 1 of the 512, 1024 and 2048 verify rows of [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. Exact builds get _fp8qx in the kernel name instead of _fp8q.

What differs from the tested code (amd-pedghazi#8, 23d4f8169b)

  • FlyDSL 0.5.3 API of main: the epilogue hunks use fx operators (bitcast, select, fx.generic_store) instead of arith / llvm.StoreOp. The write-through store is fx.generic_store(..., memory_order=Monotonic, syncscope="agent"), the same LLVM store as before.
  • Main's stage-1 XCD remap ([FlyDSL] MoE stage 1: XCD remap over the valid rows only #7918) reads the launch grid (gpu.grid_dim); inside the fused 1-D grid that is wrong, so the stage-1 body reads it through a _grid_dim hook, and the fused kernel passes the stage-1 grid.
  • Main's get_g2 cache key has g2_scatter_lds_pairs; the fused file's key list follows it. Main also adds fp4 route-out rows to the reduce stage 2; those are not fused (they did not exist in the tested code).
  • AITER_MOE_FUSED_S12_MAX_ROWS default 512 instead of 1024: 512 is the value our test build sets and the only one measured.
  • black formatting (the tested form failed black --check), comments without local file paths, and dict literals instead of dict(key=...) calls (ruff C408). The module, env var and log tag names are AITER names (moe_fused_s12.py, AITER_MOE_FUSED_S12, AITER_MOE_FUSED_S12_MAX_ROWS, AITER_MOE_FUSED_S12_OCC, AITER_MOE_S1_FP8_EXACT, AITER_MOE_S1_FP8_EXACT_KEYS, [moe_fused_s12]); the tested code uses earlier names.

Dependencies on open PRs

Performance (if applicable)

Measured on the image form (amd-pedghazi#8, FlyDSL 0.4.0), not on this branch.

Hardware Workload/configuration Before After Change
MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0 fused_moe call, 512-token row (stage 1 t32x128x256_w2_gui_xcd1, v2-layout reduce stage 2), real verify routing, CUDA graph, median of 10 rounds, 288 / 320 / 384 / 480 tokens two launches: 136.4 / 172.2 / 164.4 / 261.1 us one launch: 128.5 / 165.7 / 157.9 / 252.8 us -5.8 % / -3.8 % / -3.9 % / -3.2 %
4 x MI355X SGLang serving, DeepSeek-V4.1-Flash TP4, DSpark, random 8k/1k, c256; 4 order-balanced pairs, same GPUs without this change, plain-stage-1 rows (FP8 mixed stage 2) at 512 / 1024 / 2048 tokens this change + the XCD-remap verify rows of #8650 throughput +1.30 % (se 0.13 %)

The serving row measures this change together with the rows of #8650. The fused launch alone, switched on against off in the same image form (8 random-dataset points in the order on, off, on, off, then two rechecks of 4096/1024 at 64 requests), is neutral within noise: throughput geometric mean -0.1 % to +0.05 % over three on/off pairs, GSM8K 97.11 % on, 96.88 % off; details in the comments. The 8-point A/B on this branch is still pending (see below).

Testing

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

gfx950 only (MI355X), so MI250X and MI300X do not apply. No op test is added yet; the GPU checks of the image form ran with our own scripts. Unticked until the GPU runs on this branch are done:

  • On main + this branch + [FlyDSL] [Bugfix] MoE stage 1: wait for the A LDS-DMA before the half-step barrier #8550, FlyDSL 0.5.3, one MI355X (about 1 h once an image with FlyDSL 0.5.3 is available): fused output bitwise equal to the two-launch path at 288-2048 tokens (eager and CUDA-graph replays, new routings per replay, counters back to 0, 0 wait timeouts); 8 eager reruns + 8 graph replays of the same input with 0 differing calls; op timing fused vs two launches at 288 / 320 / 384 / 480 / 512 tokens.
  • 8-point serving A/B of AITER_MOE_FUSED_S12=0 vs =1 (all other settings equal): random 1k/1k, 8k/1k and 60k/600 with DSpark, GSM8K per arm, order on, off, off, on, proof line [moe_fused_s12] installed only in the on arm.

Documentation

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

N/A (small opt-in change): the switches are off by default and documented in the module docstring and the builder docstring.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Uses FlyDSL 0.5.3 as pinned on main. Open PRs it needs: see "Dependencies on open PRs" above.

Breaking Changes

None. With AITER_MOE_FUSED_S12 and AITER_MOE_S1_FP8_EXACT unset, nothing changes.

PR Self-Review

Reviewed revision

bd85bd03200e44cc6a08c17ee20fc22c6e4c6628

Behavior and intent

With AITER_MOE_FUSED_S12=1, a fused_moe call of up to AITER_MOE_FUSED_S12_MAX_ROWS tokens whose row has an FP8-epilogue stage 1 and a reduce v2-layout stage 2 (or an _fp8 stage 1 and a mixed stage 2) runs both stages in one launch. Other calls, and calls during a CUDA-graph capture before the workspace exists, run as before. With AITER_MOE_S1_FP8_EXACT=1, the selected stage-1 builds quantize exactly like the two-kernel path.

Validation and unverified scope

On this branch (CPU only, FlyDSL 0.5.3 wheel, COMPILE_ONLY=1, FLYDSL_GPU_ARCH=gfx950):

  • With the switches off, the 8 standalone kernels of the verify rows (stage 1 of the 512 / 1024 / 2048 rows with both output layouts, and the two mixed stage-2 tiles) build the same final ISA as the same stack without this PR's two commits, both merged with main 3fd42598c (byte-equal .s files).
  • With the exact rule, the three stage-1 builds compile (_fp8qx, same VGPR count as the default rule, 24-48 more instructions).
  • Both fused kernels (fused, fused_v2) compile for the three buckets with occupancy 3; the ISA has sc1 stores, 5 atomics and the poll loop. LDS and VGPRs match the image form: 40976 B for the 32-row tiles, 49408 B and 194 VGPRs for the 64-row tile.
  • black --check and ruff check (0.16.0) pass on both files.

These checks ran on ac2c4fa154. The merge bd85bd0320 does not change moe_fused_s12.py or mixed_moe_gemm_2stage_common.py, so they were not rerun.

Tested only on the tested form (23d4f8169b, MI355X, ROCm 7.2.4, FlyDSL 0.4.0): bitwise equal to the two-launch path at 288-2048 tokens, 0 differing reruns with the LDS-DMA wait, GSM8K 0.9723 vs 0.9730 in serving (paired difference within noise).

Not verified: anything on GPU for this branch, other shapes, other GPUs.

PR-specific question

Are the AITER_MOE_FUSED_S12* and AITER_MOE_S1_FP8_EXACT* env var names acceptable? The tested build used other names for the same switches.

Changed op tests

None.

eppaneamd and others added 26 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]>
The v2 layout GEMM2 ran every K tile up to the padded inter_dim, and
fused_moe never told it about intermediate_pad. With the padding passed
down (D_INTER_VALID), K tiles past the unpadded width are not run; in the
last partial tile, lanes whose 32-wide K block is padding load A as zero
and use unit scales, so their products are exactly zero whatever the
padding holds.

Since stage 2 no longer reads the padding, stage 1 can skip the padding
tile when it feeds a v2 layout stage 2 (stage2_skips_inter_pad, set only
by fused_moe next to the stage-2 padding).

The a8w4 test data helper takes inter_pad and activation so the e2e test
can choose its padding.

DSv4.1 TP4 a8w4 fused_moe (inter 576 padded to 640, real routing, MI355X):
-7.5% at 256-1024 tokens, -5% at 3000-4096, -4.5% at 16384; flat at 1-16.
Reduce rows are bit-exact against intermediate_pad=0.

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]>
# Conflicts:
#	op_tests/flydsl_tests/test_flydsl_moe.py
…erify steps, opt-in exact stage-1 FP8 rule

A new FlyDSL module traces AITER's stage-1 body and the mixed or v2-layout stage-2 tile into one kernel with
per-sort-block ready counters, behind an opt-in env switch with row-limit and occupancy settings. The stage-1 builder
gets trace-time hooks and an opt-in FP8 epilogue that quantizes like the two-kernel path (switch and key list).
The next commit gives the module, the env vars and the log tag their final names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 8658 --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.

…ars AITER names

Rename the module, its env vars, log tag and trace-time hook names; no
behaviour change (the AST equals the previous commit's after the reverse
rename).

- Module: moe_fused_s12.py
- AITER_MOE_FUSED_S12=1 turns on the fused launch
- AITER_MOE_FUSED_S12_MAX_ROWS, AITER_MOE_FUSED_S12_OCC: row limit and occupancy
- AITER_MOE_S1_FP8_EXACT=1, AITER_MOE_S1_FP8_EXACT_KEYS: exact stage-1 FP8 rule
- Hooks in mixed_moe_gemm_2stage_common.py: _FUSED_S12_HOOKS, _FUSED_S12_BUILT

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@amd-pedghazi
amd-pedghazi force-pushed the amd/dsv41-fused-moe-s12 branch from a32ecfd to da06fd8 Compare November 25, 2026 09:00
@zufayu

zufayu commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Heads-up: #8255 (moev2 phases 0-2) just merged as e6d2d310, and it removes 1084 lines from
aiter/fused_moe.py, which this PR also touches. You will need a rebase.

The good news for this PR specifically: the function(s) it changes — _flydsl_stage1_wrapper, _flydsl_v2_stage2_wrapper and get_block_m — are still in
aiter/fused_moe.py
after the merge, so expect a line-offset conflict rather than having to
move code elsewhere.

What actually moved: a set of helpers now live under aiter/moev2/ and are imported back into
aiter/fused_moe.py, so every public name is unchanged. If your diff references moe_sorting,
ck_moe_stage1, asm_stage1, MOEMetadata, fused_topk or resolve_activation_dtype, those
are now re-exported from aiter.moev2.* — same names, same behavior, just a different definition site.

Nothing changes at runtime by default: AITER_MOEV2 unset means every call still takes the legacy
path. If your rebase touches MoE dispatch, python tests/moe_dispatch/snapshot.py --check will tell
you whether any dispatch decision moved.

@amd-pedghazi

Copy link
Copy Markdown
Contributor Author

Thanks @zufayu for the heads-up.

I merged current main into the branch twice (normal merge commits, no force push); the head is now bd85bd0320 on top of main 9c9fb96e0, which contains #8255. The latest merge had no conflicts.

  • My two commits change only moe_fused_s12.py and mixed_moe_gemm_2stage_common.py; the fused_moe.py hunks in this PR come from the stack under it ([FlyDSL] MoE v2 stage 2: skip the inter_dim padding #7917, [FlyDSL] MoE stage 1: XCD remap over the valid rows only #7918). The one conflict of the first merge, in _flydsl_v2_stage2_wrapper, kept both main's scatter_intermediate and [FlyDSL] MoE v2 stage 2: skip the inter_dim padding #7917's inter_dim_pad.
  • CPU checks (FlyDSL 0.5.3, compile only, gfx950): with the switch off, the 8 standalone kernels give byte-equal final ISA against the same stack without my commits; fused and fused_v2 compile for 512 / 1024 / 2048 rows; black and ruff pass. Main's commits since then do not touch these two kernel files.
  • tests/moe_dispatch/snapshot.py --check needs a ROCm toolchain; I will run it on a ROCm machine. The PR adds no dispatch rule, and the new path is off unless AITER_MOE_FUSED_S12=1.

GPU: on MI355X (TP4, DeepSeek-V4.1-Flash, DSpark, random dataset) the same kernels, switched on against off on our FlyDSL 0.4.0 build, are neutral overall (throughput geomean -0.1 to +0.1 % over three on/off pairs, GSM8K 97.1 vs 96.9). One point, 4k input / 1k output at 64 requests, is 2 to 5 % lower with the fused launch in all three pairs; I will look at it before asking for review. This branch on main with FlyDSL 0.5.3 has not run on GPU yet.

@amd-pedghazi

Copy link
Copy Markdown
Contributor Author

A follow-up on the point I flagged in my last comment (4096/1024 at 64 concurrent requests, 2 to 5 % lower with the fused launch in three pairs): it did not repeat in two rechecks, so the fused launch is neutral at these points.

Same setup as before: MI355X (gfx950), ROCm 7.2.4, FlyDSL 0.4.0, DeepSeek-V4.1-Flash, TP4, DSpark block size 5, in a container build that carries this code under earlier names; the switch selects the arm. Random dataset (--random-range-ratio 1), prefix cache off, a fresh server per run. The fused kernel's install log line appears once per rank in every on run and in no off run.

Recheck 1: order on, off, on, off; the 4096/1024 point with three seeds. Output tokens/s, mean of the two runs per arm:

in/out concurrency seed off on change
1024/1024 64 5 9220 9226 +0.1 %
4096/1024 64 108 8516 8629 +1.3 %
4096/1024 64 117 8660 8602 -0.7 %
4096/1024 64 118 8647 8722 +0.9 %
8192/1024 64 12 6576 6593 +0.3 %

Geometric mean change in throughput in the three on/off pairs: +0.4 % / +0.3 % / +0.4 % (over the three 4096/1024 seeds: +1.3 % / +0.3 % / -0.3 %). The two runs of one arm differ by up to 2 % per row.

Recheck 2: 4096/1024 at 64 requests with seed 108 (the seed of the first run), two runs per arm in both orders (on, off, off, on): on vs off -0.8 % (on first) and +3.5 % (off first); mean of the two runs per arm 8694 vs 8583 tok/s (+1.3 %), while the two runs of one arm differ by 1.8 % (on) and 2.5 % (off). 8192/1024 at 64 requests: +1.3 % / +0.5 %. (1024/1024 had one slow off run in this recheck and is left out.)

The first reading sat on two high off runs. No point shows a loss or a gain beyond the run-to-run spread. This branch on main (FlyDSL 0.5.3) has still not run on a GPU; the GPU checks listed in the description stay open.

I also updated the description to name the current head, bd85bd0320 (merge of main 9c9fb96e0, no conflict, no change to this PR's two kernel files).

@amd-pedghazi
amd-pedghazi marked this pull request as ready for review December 1, 2026 14:40
@amd-pedghazi
amd-pedghazi requested a review from a team December 1, 2026 14:40
@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 bd85bd03200e · 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. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  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 — 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.

7 participants