Skip to content

[fmoe][gfx950]Flydsl mxmoe v2 - #4179

Merged
coderfeli merged 116 commits into
mainfrom
feat/dsv4-a8w4-mxmoe-v2-gemm
Aug 4, 2026
Merged

coderfeli merged 116 commits into
mainfrom
feat/dsv4-a8w4-mxmoe-v2-gemm

Conversation

@charlieguo1106

@charlieguo1106 charlieguo1106 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Technical Details

Test Plan

AITER_MOE_EXPERT_BALANCE=true python3 op_tests/test_moe_2stage.py --no-flydsl-csv -d bf16 -dim 6144,512 -q 4 -a silu -s f -e 257 -k 9 -p t --kernel -t 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768

11

AITER_FLYDSL_STAGE2_FP8=0 AITER_MOE_EXPERT_BALANCE=true python3 op_tests/test_moe_2stage.py --no-flydsl-csv -d bf16 -dim 6144,512 -q 4 -a silu -s f -e 257 -k 9 -p t --kernel -t 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768

22

Test Result

Submission Checklist

coderfeli and others added 12 commits July 6, 2026 10:10
… gemm2 port

Vendored FlyDSL #753 mxmoe-v2 gemm1/gemm2 (mxmoe_gemm_v2.py + dispatcher) and
optimized the dsv4 a8w4 (7168/512/E384/topk6) stage1 path:

- fp8-A tiny-M: enabled k_wave>1 + BN=64 (removed 3 "not ported" guards); fixed
  fp8-out BN64 store guard + accm NJ sizing; root-caused the fp8 nt B-load
  miscompile on BN64 -> force cached (also faster). M1-4 now beat flydsl-main.
- BN=128 (kw1): matches flydsl-main tile_n=128 (8 N-blocks); routed M in [512,2047].
- BM=16 stage1 for M<=1024: biggest win, occupancy-driven (168->104 VGPR, 3->4
  waves). Closes most of the mid-M gap vs flydsl-main (M1024 now ~parity).
- select_pipe_config routes dsv4 a8w4: M<=2 BN64/kw4, M4-8 BN64/kw2, BM16 for
  M<=1024, BN128 for [512,2047], else BN256/kw1.

gemm2: additive use_strip lever as patches (off by default, byte-identical),
g2port_{gemm_v2,dispatcher}.patch. v2-reduce competitive-to-faster than flydsl-main.

bench_gemm1_v2_vs_baseline.py: per-M v2-vs-flydsl-main (mixed_moe) harness.

NOTE: dsv4_fp8fp4_tuned_fmoe.csv reverted to pre-#3856 (flydsl_moe2 stage2, not
opus) for flydsl-v2-vs-flydsl-main comparison; revert this file if opus stage2 wanted.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… a8w4 to atomic

atomic_bf16_epilog's guard_padding was False on the BM32/SBM==BM/atomic path,
falling back to a plain Python `if token_id < i32_M`. Since atomic_bf16_epilog is
a helper (not @flyc.jit), that if on a dynamic value is not rewritten to a device
scf.if, so it ran unconditionally -> every padding row (~97% of rows at mid-M in
the 384-expert block-sparse floor) issued an OOB weighted atomic-fadd.

Fix: guard_padding = True (always emit the device scf.if gate; reduce was already
gated). rocprof M64: TCC_ATOMIC 7.29M->94.6K (77x), duration 932->107us (8.4x).

Post-fix v2 atomic beats reduce-TOTAL (gemm2+topk-reduce) at every M (-6..-37%),
so select_pipe_config routes dsv4 a8w4 (7168/512/E384/k6) BM32 buckets (M<=1024)
reduce->atomic; BM64 (>=2048) kept reduce (BM64 atomic not re-validated post-fix).
reduce path byte-identical; only the atomic-path IR changes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
* Reduce v2 GEMM2 LDS usage with a BF16 cshuffle path.

* perf(flydsl-moe): unlock straight-line K2 gemm2 via INTER_MAX override to cut a8w4 reduce VGPR 219->184

* perf(flydsl-moe): split gemm2 B by N-half in straight-line K2 path, halving peak B live set (VGPR 184->168)
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4179 --add-label <label>

@zufayu
zufayu requested a review from junhaha666 July 14, 2026 05:10
@charlieguo1106 charlieguo1106 self-assigned this Jul 14, 2026
@Bernard-Liu
Bernard-Liu force-pushed the feat/dsv4-a8w4-mxmoe-v2-gemm branch from 67d1433 to b343ab4 Compare July 30, 2026 06:47
Zzz9990
Zzz9990 previously approved these changes Jul 31, 2026
s1_kernels = get_flydsl_stage1_kernels(adtype, "fp4", out_dtype_str)

for blockM in blockMs:
if blockM not in (32, 64, 128):

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.

need to add blockM16 ?

"tflops",
"bw",
"flat",
"v2",

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.

If v2 generally performs better than v1, I suggest the tuner just delete v1's task. It saves some tuning time and also reduces maintenance costs.

Comment thread aiter/fused_moe.py Resolved
@zufayu
zufayu requested a review from coderfeli August 4, 2026 01:27
coderfeli
coderfeli previously approved these changes Aug 4, 2026
@coderfeli

Copy link
Copy Markdown
Collaborator

Merged. Ci passed but error commit and then cleared.

@coderfeli
coderfeli merged commit db24351 into main Aug 4, 2026
68 of 69 checks passed
@coderfeli
coderfeli deleted the feat/dsv4-a8w4-mxmoe-v2-gemm branch August 4, 2026 03:30
Jacob0226 added a commit to Jacob0226/aiter that referenced this pull request Aug 25, 2026
The previous commit shipped what `gemm_moe_tune.py --mxfp4-flydsl` picked
when re-run today. That output keeps the a4w4 stage-1 but pairs it with a
`flydsl_moe2_layout` stage-2, and on the same box that pairing is slower
than the stage-2 the overwritten rows already named: 168.50 vs 151.76 us
at token=32 (+11.0%, ranges disjoint over 15 repeats) and 232.75 vs
225.04 at token=128 (+3.4%). token=64 and 8192 are within noise.

Trusting a fresh tune here would repeat the mistake this PR is about, so
the five rows are now restored verbatim from db24351^ -- byte-identical
to what rocm/sgl-dev:v0.5.17-rocm720-mi35x-20260820 shipped and what the
serving A/B in the PR body ran.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants