Repository navigation
[CK] [FlyDSL] Dev/ms ep32 support - #7542
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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 |
There was a problem hiding this comment.
🟡 Changes recommended
CI does not execute the new EP regressions, and GEMM replay builders omit supported FP16 and gfx1250 preshuffled-A-scale specializations, leaving cache entries uncompiled even when checks pass.
1 open issue
What changed in this PR
This PR extends AITER’s FlyDSL mixture-of-experts support for expert-parallel workloads, including A8W4 tuning and Kimi K3 configurations. It also adds ahead-of-time compilation support for tuned GEMM kernels.
Changes:
- Enables masked expert routing for supported MXMOE pipelines and updates GEMM1 payload stores.
- Adds expert-parallel tuning inputs, precision-aware candidate selection, and regression tests.
- Adds Kimi K3 tuned configurations and GEMM cache precompilation through public APIs.
| File | Description |
|---|---|
op_tests/tuning_tests/test_fast_tuning.py |
Tests activation precision, candidate pairing, and EP tuning controls. |
op_tests/test_moe_mxmoe_ep.py |
Adds EP dispatch and quantized-reference regressions. |
op_tests/test_moe_ep.py |
Adds SiTUv2 activation controls and quantized EP references. |
csrc/ck_gemm_moe_2stages_codegen/mxfp4_staged_search.py |
Validates precision compatibility between GEMM stages. |
csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py |
Adds EP routing fixtures and coupled A4W4/A8W4 tuning. |
aiter/ops/flydsl/kernels/mxfp4_gemm1.py |
Uses block-relative buffer stores for sorted payloads. |
aiter/fused_moe.py |
Enables supported MXMOE EP dispatch and forwards routing metadata. |
aiter/configs/model_configs/kimik3_a8w4_tuned_fmoe.csv |
Adds configurations for smaller local expert counts. |
aiter/aot/flydsl/gemm.py |
Adds tuned GEMM replay for precompilation and cache checking. |
Review effort: Balanced
f98e7f3 to
5173e7a
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new EP regressions do not execute in default CI and omit the required shared numerical comparison, while incorrect architecture gating and incomplete FP16 AOT replay introduce additional coverage gaps.
3 open issues
Review effort: Balanced
5173e7a to
2298f51
Compare
There was a problem hiding this comment.
🟡 Changes recommended
EP tuning can mislabel unclamped results as clamped, while the new regression tests are bypassed by CI, use unreliable build-time architecture gates, and can miss localized numerical errors.
4 open issues
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues let tests miss corrupted token rows and EP tuning ignore requested clamping, while EP64 tuning coverage and production-path regression checks remain incomplete.
9 open issues
Missing tuned EP64 coupled-pipeline rows · New Add public MXMOE selection and mask-forwarding regression tests · New Reject SwiGLU clamping with expert parallelism · New Batch-wide error metric can hide corrupted token rows · New Reject unclamped EP tasks when swiglu_limit is set Use the runtime GPU architecture for test skips and CSV records Norm-only accuracy checks can miss elementwise errors CI runs the pytest-only file without executing its tests Use buffer tensors and fx.copy for new memory operations
1 resolved since last review
Review effort: Balanced
binding7012
left a comment
There was a problem hiding this comment.
The newly added rows for topk=16 and topk=17 are identical across all columns (including us, tflops, and bw), with the exception of the topk column; they are copies rather than the result of separate tuning processes.
get_2stage_cfgs now accepts MXMOE rows under EP only with SiTUv2 and an atomic or reduce layout GEMM2, and rejects BM16 rows. BM16 sorts through the masked Opus aux sort with dispatch_policy=1, which hangs at >= 819 experts (#8014). Other activations and the scatter epilog are not validated under EP, so they stay rejected as on main. Validation: get_2stage_cfgs over every gfx950 tuned MXMOE row with is_ep=True accepts only the Kimi K3 SiTUv2 atomic/reduce rows. A BM16 EP row falls back to the default heuristics; a non-EP BM16 row is still selected. Signed-off-by: Wulley <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because coupled tuner pruning and dispatch logic can still select a GPU-hanging A4W4 BM16 configuration under expert parallelism, bypassing the runtime rejection.
No open issues 🎉
9 resolved since last review
Batch-wide error metric can hide corrupted token rows Reject SwiGLU clamping with expert parallelism Add public MXMOE selection and mask-forwarding regression tests Missing tuned EP64 coupled-pipeline rows Reject unclamped EP tasks when swiglu_limit is set Use the runtime GPU architecture for test skips and CSV records Norm-only accuracy checks can miss elementwise errors CI runs the pytest-only file without executing its tests Use buffer tensors and fx.copy for new memory operations
Review effort: Balanced
c68f886 to
f85f670
Compare
The coupled tuner (--mxfp4-flydsl) still enumerated BM16 GEMM1 candidates for A4W4 under --ep-size, and its M_est pruning kept only BM16 for rows below M_est 4. Those candidates sort through the masked Opus aux sort with dispatch_policy=1, which hangs at >= 819 experts (#8014), and the runtime rejects BM16 under EP anyway. Skip BM16 under EP for both precisions and, as for A8W4, keep every larger BM unpruned. Also fix the scatter comment: the runtime rejects the scatter epilog under EP. Validation: test_fast_tuning.py: 59 passed. The new case checks that an EP32 A4W4 row with M_est 1 gets BM32/64/128 instead of BM16 only, and that a dense A4W4 row still gets BM16. Signed-off-by: Wulley <[email protected]>
get_2stage_cfgs rejects every non-SiTUv2 MXMOE row under EP, but the coupled tuner (--mxfp4-flydsl --ep-size N) still accepted SiLU and SwiGLU rows and ran a full search whose winner inference always discards. Reject them in _unsupported_row_reason, and move the EP CPU tests to SiTUv2 rows. Validation: test_fast_tuning.py: 59 passed. The EP case now also checks that a SiLU row is rejected under EP; it fails without this change. Signed-off-by: Wulley <[email protected]>
…uner import conflict. #7542 and #8121 import clear_inherited_rocprofiler_env from mp_tuner; this branch imports gfx942_mxfp8_block_exponent from fp4_utils. Both imports are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bring in main 76c1d87. One conflict in aiter/fused_moe.py: #7542 added expert_mask and topk_ids to the keywords of _mxfp4_a4w4_stage2_fw, next to scatter_intermediate of this PR. Keep all three. The function body already forwards all three to _flydsl_v2_stage2_wrapper. Signed-off-by: Vinayak Gokhale <[email protected]>
Extend MegaMoE dispatch, reduction and return credits to four logical nodes using separate local and bounded rail windows. Support virtual 4x4 through CROSSNODE/WORLD peers, and bind separate-window SDMA to the local DevComm. Size inverse maps, counters and scratch spans from the actual topology; keep RAIL requests disjoint from the SDMA signal epoch. Include AITER PR #7542 K3 A8W4 tuning and masked EP changes. Restore the historical Stage1 BM128 M16 schedule after the M32 addition did not show an overall gain. Retain historical epilogue/quant and Stage2 M16 changes, EP32 input addressing, and version the restored Stage1 cache identity. Document physical 4x8 and virtual 4x4 launch configurations and the MORI b80cbe4 dependency patch. The M32 version plus the scratch fix completed the physical EP32 K3 numerical sweep; its TPR4096 timing anomaly remains unresolved. The restored M16 schedule has not been rerun on EP32. Validation: full base-diff Black 26.10.1, repository Ruff 0.16.0, Python/shell parsing, whitespace and CK dependency checks, and pytest 8.3.4 CPU pre-checks (117 passed). Nine single-GPU M16 cases match the historical payload and scales byte for byte. Physical EP16 M16 passed 20 K3 cases plus three targeted repeats: 368 fused and 161 independent Small-op checks, with the existing 0.05 relL2 threshold.
…ngle-kernel pipeline (#8082) * Add four-node A8W4 snapshot with K3 tuning and SDMA wiring Extend MegaMoE dispatch, reduction and return credits to four logical nodes using separate local and bounded rail windows. Support virtual 4x4 through CROSSNODE/WORLD peers, and bind separate-window SDMA to the local DevComm. Size inverse maps, counters and scratch spans from the actual topology; keep RAIL requests disjoint from the SDMA signal epoch. Include AITER PR #7542 K3 A8W4 tuning and masked EP changes. Restore the historical Stage1 BM128 M16 schedule after the M32 addition did not show an overall gain. Retain historical epilogue/quant and Stage2 M16 changes, EP32 input addressing, and version the restored Stage1 cache identity. Document physical 4x8 and virtual 4x4 launch configurations and the MORI b80cbe4 dependency patch. The M32 version plus the scratch fix completed the physical EP32 K3 numerical sweep; its TPR4096 timing anomaly remains unresolved. The restored M16 schedule has not been rerun on EP32. Validation: full base-diff Black 26.10.1, repository Ruff 0.16.0, Python/shell parsing, whitespace and CK dependency checks, and pytest 8.3.4 CPU pre-checks (117 passed). Nine single-GPU M16 cases match the historical payload and scales byte for byte. Physical EP16 M16 passed 20 K3 cases plus three targeted repeats: 368 fused and 161 independent Small-op checks, with the existing 0.05 relL2 threshold. * Optimize MegaMoE internode A8W4 pipeline for EP16 and EP32 Support BM96 GEMM1 tile groups and overlap GEMM2 activation DMA with staged weight and scale preloads. Pass the generation through the single-kernel handoff, invalidate L2 once per XCD, and limit node-reduce workers. Separate Stage1 sealing from credit returns and defer Stage2 credits until parity-slot reuse. Select the pipeline and communication geometry through scoped A8W4 tuning rows. Signed-off-by: james-huang09 <[email protected]> * Refine MegaMoE internode buffers and GEMM2 scheduling Move per-GPU GMM1 intermediates into private device storage, align local CCO allocations for pooled communicators, and support stock MORI window registration while retaining compatibility with the optional local-only API. Extend the unrolled GEMM2 pipeline to FP4, select remote fan-out by arrival, and allow GMM1-skipping CTAs to prepare the SDMA plan. Make quantization and topology explicit in tuning and respect the selected split-local setting. Key experimental modes in the compile caches, validate their parameters, and adapt the existing buffer-address probe for private storage. * Tune MegaMoE internode pipeline for EP16 and EP32 Improve dispatch/GEMM1 and GEMM2/reduce/combine scheduling with relaxed handoff, early SDMA planning and parallel/deferred credit exchange. Keep GMM1 intermediates in private device storage and use stock MORI window registration for communication buffers. Consolidate device helpers and select tile geometry, fanout, local splitting, communication paths and return chunks through the EP16 A4W4/A8W4 and EP32 A8W4 tuning table. Extend the existing internode test with real EP16/EP32 launch support, MORI V2LL reference and small-op paths, replay correctness checks, and global minimum and mean-of-rank-means over the last 20 timed replays. Signed-off-by: james-huang09 <[email protected]> * Refactor MegaMoE internode kernels and host validation Reuse existing GEMM, scale, address and synchronization helpers and remove unreachable Stage1 and Stage2 paths. Preserve the active pipeline while simplifying tile sealing, credit handling and SDMA token-ready reduction. Size receive storage from the explicit receive-route limit or the full routing bound. Select bounded rail windows and an owned local communicator above TPR 1024, including cleanup and xGMI fallback when SDMA is unavailable. Validate architecture, weight storage, routing tensors, activation options and launch devices before execution, including FlyDSL-wrapped streams. Update the existing internode test to size its CCO pool for the new capacity rules and use multiple windows for larger token capacities. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: james-huang09 <[email protected]> * Decouple MegaMoE internode A8W4 test weight preparation Prepare the A8W4 small-op gate/up W1 layout from the same quantized weights used by MegaMoE internode and reuse its A16W4 W2 layout. Keep the extra W1 tensors optional and create them only for the A8W4 small-op path, removing the test_wide_ep_moe weight helper dependency. * Use the single-kernel MegaMoE internode launch path Remove the optional two-launch host branch and its environment switch. Keep group-ready enabled and reserve independent Stage1 and Stage2 QP contexts using the existing single-kernel configuration. Drop stale timing and profiling results from comments while retaining the technical rationale, and clarify the standalone Stage2 helper docs. --------- Signed-off-by: james-huang09 <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
* [MoE] moev2 step 3.1: bf16/fp16 a16w16 path (not graduated)
Unquantized bf16/fp16 fused_moe calls (QuantType.No) can run through
aiter.moev2 when enabled with AITER_MOEV2=a16w16 (or on). The path is not
graduated: by default every call still runs the legacy code.
Behavior claim:
- Legacy dispatch is unchanged. The CPU dispatch snapshot of legacy
fused_moe is identical on gfx942, gfx942_cu80, gfx950 and gfx1201,
including the new QuantType.No feature variants, which are byte-identical
to ones generated with the upstream base's aiter package.
- When a16w16 runs a call in v2, it makes the same choices as legacy:
same kernels, parameters and inputs, same log lines and exceptions, and
the same outputs within legacy's own run-to-run noise (see Tests).
- a8w8_pt keeps its choices. It no longer takes g1u0 weights, which now
run on legacy (see Known differences).
- Both paths decline what they do not reproduce, and those calls run on
legacy: herd_topk, deterministic=True, a registered presort, a
clamping swiglu_limit (None, 0 and inf do not clamp), beta or
linear_beta, bias, global scales, padding, scatter, caller-chosen
activation dtypes, AITER_ONLINE_TUNE,
g1u0 weights, and a call whose second lookup after the sort would raise
or be declined.
What changed:
- migration/a16w16.py: path a16w16. It claims QuantType.No calls with
g1u1 bf16/fp16 3D weights on gfx942/gfx950, Silu or Gelu, separated
gate/up. Its segments are sort, quant, CK stage 1/2 and whole graph.
- migration/local.py: what the single-GPU paths share. That is the
common claims checks, the per-key cached resolve, the log-only second
lookup after the sort, run and dispatch_record. a8w8_pt now uses it.
The check phase 2 added to a8w8_pt moves here, so every local path
declines a call whose second lookup would raise or be declined, and
says so under AITER_MOE_EXPLAIN=1.
- Path.takes(problem): the dispatch keys a path runs. One segment (CK)
serves several formats, and takes keeps one path from taking another
path's keys. Dispatch, the CPU differential and the ranking checks use
it.
- CK stage 1/2 and the whole graph accept bf16 and fp16, one capability
per dtype. CK stage 1 is g1u1 only, since it always reads w1 as gate and
up (N = w1.size(1) / 2).
- Ranking:
- an a16w16 entry: the get_2stage_cfgs CK default branch;
- named boolean predicates in when(...). fmoe_1stage tests a copy of the
keys of legacy fused_moe_1stage_dict, current with upstream (it has
the gfx950 SwiGLU per_1x32 keys), and a test checks the copy;
- regions that hand their problems back to legacy (legacy="...").
The shipped table uses neither predicates nor legacy regions yet. When
the resolver declines, it says why: no entry applies, a legacy region,
or no listed structure is feasible.
- Dispatch snapshot: QuantType.No keys also get the feature variants
(FEATURE_QUANT_TYPES), and the goldens are regenerated.
- README: rows for local.py and a16w16.py (to be removed), plus the
updated descriptions of paths, ranking, resolver, CK and the tests.
- Tests:
- claims, takes and their agreement on key fields;
- g1u0 not claimed;
- the second-lookup declines, now through the shared dispatch;
- feature variants of QuantType.No keys are legacy calls;
- predicates and legacy regions;
- gpu_differential.py gains a16w16 cases and per-path synthetic rows.
Known differences and limits:
- g1u0 calls run on legacy. Legacy's CK 2-stage gives wrong output for
g1u0 (the stage-1 kernel reads w1 as gate and up), so v2 has nothing to
match. The QuantType.No keys of fused_moe_1stage_dict are all g1u0, so
legacy's default 1-stage ASM fmoe branch stays on legacy too. For
a8w8_pt this drops 544 / 751 / 544 keys on gfx942 / gfx942_cu80 /
gfx950 that phase 2 claimed, all of them the g1u0 feature variants;
it gains none.
- gfx942-only parts are checked only by the CPU differential: the
impl__flydsl_gfx942 tuned rows and the gfx942-only suites. gfx1201
bf16 rows stay on legacy.
Tests:
- CPU: tests/test_moev2_*.py and test_moe_dispatch_snapshot.py, 100
passed.
- CPU gates, on all 4 archs, 0 problems:
- differential.py: a16w16 8000 / 11,724 / 8084 and a8w8_pt 5984 /
8280 / 5984 keys on gfx942 / gfx942_cu80 / gfx950 (none on gfx1201);
- key_checks.py: 181,478 keys, 27,963 tuned rows;
- ranking_checks.py: 51,828 ranked keys, both entries reached.
- GPU differential, gfx950, 0 problems, each also with AITER_USE_NT=1
and AITER_BYPASS_TUNE_CONFIG=1:
- a16w16: 21 default and shipped-tuned cases, and 69 with a synthetic
table of bf16 CK rows;
- a8w8_pt: 15 cases, and 63 with its synthetic table.
- GPU suites, gfx950, AITER_MOEV2=off vs on (both paths):
test_moe_2stage -q 0 and -q 1 (--no-flydsl-csv), test_moe.py,
test_moe_per_tensor_a2_init, test_moe_sorting, test_moe_ep,
test_moe_local_expert_ids and test_moe_dp_share_expert. Same exit codes
and the same verdict for every check, except two swiglu_limit=7.0
checks of test_moe_2stage -q 0 (per-token and per-tensor fp8, which run
on legacy in both modes). Their verdicts also change between two runs
with AITER_MOEV2=off (1 or 2 of 2048 elements past the tolerance).
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255):
- local.py carries PR 8255's a8w8_pt code: why_not reasons, the clamps
helper, w1/w2 global scales unsupported, the live arch only, and the
preview prologue that declines before copying anything. Both paths
set why_not and supported_archs and have the ownership NOTE.
- gpu_differential.py keeps PR 8255's variant, raise and gfx942 cu80
cases; the a8w8_pt g1u0 variant is dropped (no longer claimed).
- The golden delta equals the original step's exactly. The key counts
and GPU results above are from the original base. On this base: CPU
tests 133 passed; differential a16w16 8712 / 12,773 / 8803 and
a8w8_pt 6528 / 9031 / 6528 keys on gfx942 / gfx942_cu80 / gfx950;
key_checks, ranking_checks and snapshot --check, 0 problems. The GPU
differential is rerun at the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.2: fp8 per-token and 1x128 blockscale paths (not graduated)
fp8 per-token (QuantType.per_Token) and fp8 1x128 blockscale
(QuantType.per_1x128, and per_128x128, which legacy remaps to it)
fused_moe calls can run through aiter.moev2 when enabled with
AITER_MOEV2=a8w8_ptok / a8w8_blockscale (or on). Neither path is
graduated: by default every call still runs the legacy code.
Behavior claim:
- Legacy dispatch is unchanged. The CPU dispatch snapshot of legacy
fused_moe is identical on gfx942, gfx942_cu80, gfx950 and gfx1201,
including the new per_Token and per_1x128 feature variants, which are
byte-identical to ones generated with the upstream base's aiter package.
- When either path runs a call in v2, it makes the same choices as
legacy: same kernels, parameters and inputs, same log lines and
exceptions, and the same outputs within legacy's own run-to-run noise.
The exceptions are two legacy ASM stage 1 kernel families that are not
repeatable even legacy against legacy (see Known differences).
- Calls legacy runs on 1-stage ASM are handed back to legacy: the default
1-stage regions of both formats, and 1-stage tuned rows. So is what the
shared local checks decline (herd_topk, deterministic=True, a
registered presort, a clamping swiglu_limit, beta, linear_beta, bias,
global scales, padding, scatter, caller-chosen activation dtypes,
AITER_ONLINE_TUNE, g1u0, and a call whose second lookup after the
sort would raise or be declined).
- a8w8_pt and a16w16 keep their keys and choices.
What changed:
- migration/a8w8_ptok.py: path a8w8_ptok. It claims per-token calls with
g1u1 fp8 3D weights (the arch's fp8) on gfx942/gfx950, Silu or Gelu,
separated gate/up. These resolve to CK 2-stage, ASM stage 1 + CK
stage 2, or the FlyDSL gfx942 whole graph. int8 and int4 weights stay
on legacy.
- migration/a8w8_blockscale.py: path a8w8_blockscale, the same checks for
per_1x128 / per_128x128. These resolve to CK 2-stage (with the 1x128
block_m and split-K defaults) or asm.stage1_1x128 + CK stage 2.
- segments/asm.py: asm.stage1_1x128, the ASM stage 1 that writes the
quantized intermediate and its fp32 scales into one buffer. It covers
GEMM1 and the intermediate quant, and asks for the a1 scale transposed.
The per-tensor ASM stage 1 also takes per-token fp8.
- execute/executor.py: a stage 1 that covers the intermediate quant gets
its own buffer and splits its output into the GEMM2 inputs, as legacy
does. segments/quant.py: the a1 quant can write the scale transposed.
- CK stage 1/2 accept per-token and 1x128 fp8; the whole graph accepts
per-token fp8.
- segments/defaults.py: default_block_m / default_ksplit, the legacy
default branch's 2-stage block_m and split-K per quant type.
- Ranking:
- entries fp8_per_token and fp8_blockscale. Their legacy regions are
the 1-stage branches of get_2stage_cfgs, with the thresholds as
written; everything else ranks CK 2-stage;
- predicates inter_dim_128 and blockscale_1stage_kernel (the kernel
library's fmoe_fp8_blockscale_g1u1_has_kernel, which legacy calls);
- when() tests its conditions in the order written, so the kernel
library is asked only where legacy asks it;
- FMOE_1STAGE_KEYS reads fp8 as the arch's dtypes.fp8 when looked up,
as legacy does.
- The resolver finds stage segments by the op they cover rather than by
name (MoePlan.starting). local.why_not takes a set of quant types.
overrides.xbf16 reads AITER_XBFLOAT16 where legacy reads it.
- Dispatch snapshot: per_Token and per_1x128 keys also get the feature
variants (FEATURE_QUANT_TYPES), and the goldens are regenerated.
- README: rows for a8w8_ptok.py and a8w8_blockscale.py (to be removed),
plus the updated descriptions of plan, ranking, resolver, overrides,
quant, CK, ASM, defaults, executor, the differential and the tests.
- Tests:
- claims and takes of both paths;
- the per-token 1-stage hand-back, the 1x128 block_m and split-K
defaults, a tuned ASM 1x128 row running the packed stage 1, and the
packed buffer splitting like legacy;
- when() evaluation order;
- feature variants of per_Token and per_1x128 keys are legacy calls;
- the CPU differential counts 1-stage hand-backs separately;
- gpu_differential.py gains cases for both paths (shapes with shipped
gfx950 rows among them) and, for a8w8_blockscale, synthetic rows that
swap the arch's ASM 1x128 stage 1 into its CK rows.
Known differences and limits:
- Two legacy ASM stage 1 families give different outputs for identical
inputs on gfx950, legacy against legacy, on main and on the older base
this work started from. The GPU differential reports them (they are
not excused):
- per-token fmoe_stage1_bf16_pertokenFp8_g1u1_64x128_2tg_pf3 and
_32x128_3tg_pf2 at the shipped 5120/1536 E40 top8 and E41 top10
rows: output garbage up to 1e34 in some runs;
- the 1x128 fmoe_stage1_bf16_pertokenFp8_blockscale_g1u1_* family,
which only the synthetic table runs on gfx950 (shipped ASM 1x128 rows
are gfx942 only): stage 1 output differs on every run.
- Upstream's tuned lookup now falls back to rows tuned for another
activation, except CK 2-stage and MXFP4 rows. The shipped gfx950
4096/384 E128 top8 1x128 Silu rows are 1-stage at 4 to 128 tokens, so a
Gelu call there runs 1-stage on legacy (and is handed back). The GPU
differential's Gelu case for that shape therefore moves from 32 tokens
to 2, which still runs the CK split-K default.
- gfx942-only parts are checked only by the CPU differential: the ASM
1x128 rows and the impl__flydsl_gfx942 rows.
Tests:
- CPU: tests/test_moev2_*.py and test_moe_dispatch_snapshot.py, 112
tests, 111 passed. test_outputs_match_legacy[a8w8_ptok] fails on the
per-token legacy race above.
- CPU gates, on all 4 archs, 0 problems:
- differential.py: a8w8_ptok 3657 / 6724 / 3061 and a8w8_blockscale
5523 / 7583 / 6154 keys on gfx942 / gfx942_cu80 / gfx950, with 2375 /
3357 / 4111 and 1529 / 605 / 4256 keys handed back as 1-stage;
a16w16 and a8w8_pt unchanged (none on gfx1201);
- key_checks.py: 323,445 keys, 51,639 tuned rows;
- ranking_checks.py: 104,820 ranked keys, every entry and region
reached.
- GPU differential, gfx950, shipped tables, AITER_USE_NT=1 and
--synth-table:
- a8w8_ptok: 22 cases (70 with the synthetic table); the only
problems are 2 of the per-token race cases in each mode;
- a8w8_blockscale: 20 cases, 0 problems; with the synthetic table, 64
of 136 pass and all 72 failures run the ASM 1x128 family;
- with AITER_BYPASS_TUNE_CONFIG=1, legacy runs 6 per-token and 4
blockscale cases on 1-stage ASM, and v2 hands them back; the rest
pass;
- a16w16 and a8w8_pt: 0 problems in every mode.
- GPU suites, gfx950, AITER_MOEV2=off vs on (all four paths):
test_moe_2stage -q 2, -q 3 and -q 5 (--no-flydsl-csv), test_moe_tkw1,
test_moe_blockscale, test_moe_sorting, test_moe_ep,
test_moe_local_expert_ids and test_moe_dp_share_expert. Same exit codes
and the same verdict for every check, except three that run on legacy
in both modes and also change between two AITER_MOEV2=off runs: the
per-tensor swiglu_limit=7.0 check of test_moe_2stage -q 3 and -q 5, and
the first check of test_moe_tkw1 (its 1-stage tkw1 ASM kernel, which
fails or warns on every run).
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
step 3.1):
- Both new paths set why_not and supported_archs and carry the
ownership NOTE; like a8w8_pt they claim swiglu_limit None, 0 and inf
(legacy reads them as no clamp for every format).
- differential.py keeps PR 8255's compare_launches (the 1-ulp and
legacy-spread tolerance, whole-graph launches, a second legacy run)
and adds this step's 2-stage guard, 1-stage hand-backs and output
check. gpu_differential.py keeps PR 8255's rule that a case where
legacy and v2 both raise fails unless listed in _RAISES; this step's
"both raise" pass is not taken. New GPU cases: output=, a
non-contiguous input and swiglu_limit 0 / inf for both new paths.
- The fused_moe.py note on get_2stage_cfgs points at the README's path
list instead of naming per-tensor fp8.
- Goldens regenerated. gfx950 and gfx1201 get exactly this step's
delta; on gfx942 and gfx942_cu80, 125 / 223 of the new swiglu_limit=7
per-token variant lines differ from the original step's: upstream
#8531 keeps clamped SiLU on CK where the old base chose the FlyDSL
whole graph, and PR 8255 records whole-graph plans structurally.
- The counts and GPU results above are from the original base. On this
base: CPU tests 143 passed (the GPU-only ones skip); differential
a8w8_ptok 3979 / 7355 / 3329 and a8w8_blockscale 6012 / 8265 / 6682
keys on gfx942 / gfx942_cu80 / gfx950, with 2601 / 3624 / 4486 and
1673 / 664 / 4644 handed back as 1-stage; key_checks, ranking_checks
and snapshot --check, 0 problems. The GPU differential is rerun at the
end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.3: int8 and int4-weight formats (not graduated)
No new paths. The int8 and int4-weight formats join the paths that
already own their scale layout:
- a8w8_pt takes int8 per-tensor weights;
- a8w8_ptok takes int8 per-token weights, and int4 weights packed eight to
a uint32 with fp8 activations.
No path is graduated: by default every call still runs the legacy code.
Behavior claim:
- Legacy dispatch is unchanged. The dispatch snapshot grid gains the fp8 x
uint32 per-token combination (272 keys per arch, 2992 with their feature
variants; additions only). The snapshot is identical on gfx942,
gfx942_cu80, gfx950 and gfx1201 to one generated with the upstream
base's aiter package.
- When either path runs an int8 or int4 call in v2, it makes the same
choices as legacy: same kernels, parameters and inputs, same log lines
and exceptions, and the same outputs within legacy's own run-to-run
noise. One int8 case is the exception (see Known differences).
- int8 calls with doweight_stage1 stay on legacy. No ASM int8 stage 1
kernel applies the routing weights, so legacy raises in the kernel
lookup, and still does.
- A format added to a path later stays behind AITER_MOEV2 once the path
graduates, until it passes its own gate (Path.graduated_claims).
What changed:
- CK segments accept the int8 and fp8 x int4 instances gen_instances.py
builds. asm.stage1 accepts int8 without doweight_stage1 (the get_cfg
kernel tables have no int8 kernel with it).
- Ranking: entries int8_per_token, int8_per_tensor and int4_per_token,
following the legacy default branch:
- int8 runs ASM stage 1 + CK stage 2 (int8 is not in the CK branch's
weight list), with block_m rounded up to a CK stage 2 size;
- int8 per-token keeps legacy's 1-stage branch above 32 tokens as a
legacy region;
- int4 runs CK 2-stage.
- migration/local.py: claims require w2 to have w1's dtype, and leave int8
with doweight_stage1 to legacy (in claims and in the key-level check,
so claims and takes agree).
- paths.py: Path.graduated_claims(call). When the path runs by default, it
claims only the calls this also accepts; None accepts all.
- Dispatch snapshot: the fp8 x uint32 per-token grid combination, and the
goldens are regenerated.
- README: the paths, CK, ASM and path rows describe the new formats.
- Tests:
- int8 and int4 claims, including mixed w1/w2 dtypes and int8 with
doweight_stage1;
- a8w8_pt runs only when enabled;
- int8 defaults run ASM stage 1 and int4 runs CK;
- the ASM int8 stage 1 has no doweight_stage1 kernel;
- gpu_differential.py builds int8 and int4 weights and adds their
cases.
Known differences and limits:
- Left on legacy: per-token torch.int4 weights (the a16wi4 path, a later
step) and per-tensor uint32.
- The int8 per-tensor Gelu GPU case (32 tokens, 4096/384, E128 top8) runs
the default ASM stage 1 fmoe_stage1_bf16_pertokenInt8_g1u1_32x128_3tg_pf3,
whose output differs between two legacy runs (in 2 of 3 pairs; final
outputs within 0.016). On the older base this work started from,
legacy raised in CK stage 2 for this call, so the case passed there.
The GPU differential reports it in every mode.
- The other ASM stage 1 kernels that are not repeatable legacy against
legacy (step 3.2) still show up: the per-token fp8 race cases, and,
with the synthetic table, two int8 per-tensor cases that legacy has
already been seen to get wrong in some runs.
- gfx942-only parts are checked only by the CPU differential.
Tests:
- CPU: tests/test_moev2_*.py and test_moe_dispatch_snapshot.py, 119
tests, 117 passed. test_outputs_match_legacy[a8w8_pt] and [a8w8_ptok]
fail on the legacy ASM stage 1 cases above.
- CPU gates, on all 4 archs, 0 problems:
- differential.py: a8w8_pt 7480 / 9787 / 7480 and a8w8_ptok 5817 /
8884 / 6189 keys on gfx942 / gfx942_cu80 / gfx950, with 3343 / 4325 /
4111 per-token keys handed back as 1-stage; a16w16 and
a8w8_blockscale unchanged (none on gfx1201);
- key_checks.py: 335,413 keys, 51,639 tuned rows;
- ranking_checks.py: 118,703 ranked keys, 7 entries, every region
reached.
- GPU differential, gfx950, shipped tables, AITER_USE_NT=1,
AITER_BYPASS_TUNE_CONFIG=1 and --synth-table:
- a8w8_pt: 23 cases (9 int8), 72 with the synthetic table. The only
problem is the int8 Gelu case above in each mode; with the synthetic
table, also the int8 (64, 7168, 256, E256, top8) case, whose two legacy
runs differed by 4e36;
- a8w8_ptok: 40 cases (18 int8 or int4), 88 with the synthetic table.
The only problems are 2 per-token fp8 race cases in each mode, and in
bypass mode the 6 fp8 cases legacy runs on 1-stage ASM, which v2 hands
back;
- a16w16 and a8w8_blockscale: as in step 3.2.
- GPU suites, gfx950, AITER_MOEV2=off vs on (all paths):
test_moe_2stage -q 1, -q 2 and -q 3 (--no-flydsl-csv),
test_moe_per_tensor_a2_init, test_moe_tkw1, test_moe_sorting,
test_moe_ep, test_moe_local_expert_ids and test_moe_dp_share_expert.
Same exit codes and the same verdict for every check, except checks
that run on legacy in both modes and also change between two
AITER_MOEV2=off runs: the per-token and per-tensor swiglu_limit=7.0
checks of test_moe_2stage -q 2 and -q 3, and the first check of
test_moe_tkw1 (its 1-stage tkw1 ASM kernel).
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.2):
- local.why_not gives reasons for the new declines (int8 weights with
doweight_stage1, w2 dtype differing from w1); both paths keep why_not
and supported_archs.
- route_to_v2 applies graduated_claims and still logs refusals under
AITER_MOE_EXPLAIN, now also "a format not graduated yet" when only
the graduation gate turns a call away (tested in
test_moev2_switch.py).
- gpu_differential.py case tuples: field 10 is the weight format, field
11 a dict of options; PR 8255's input variants move to
{"variant": name} (case_variant), and a test rejects the old form.
- The golden delta equals the original step's exactly. The counts and
GPU results above are from the original base, where a case that
raised the same error on legacy and v2 passed; PR 8255 fails such a
case unless listed in _RAISES. On this base: CPU tests 150 passed (the
GPU-only ones skip); differential a8w8_pt 8160 / 10,675 / 8160 and
a8w8_ptok 6323 / 9699 / 6729 keys on gfx942 / gfx942_cu80 / gfx950;
key_checks, ranking_checks and snapshot --check, 0 problems. The GPU
differential is rerun at the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.4a: feasible_plans checks segment boundaries (not graduated)
A plan is now feasible only if every buffer a segment reads matches the
one produced before it, not only if the segments cover adjacent ops. This
prepares formats whose segments share an op but not a buffer layout. No
behavior change for the registered paths.
Behavior claim:
- Legacy dispatch is unchanged: the dispatch snapshot is identical on all
4 archs, and to one generated with the upstream base's aiter package.
- v2 dispatch is unchanged: the CPU differential claims the same keys per
path on every arch as before, and the ranking checks rank the same keys.
What changed:
- Segment.reads(p) lists the buffers a segment reads. Each is matched
against the last buffer of its kind produced upstream, the call's
hidden_states first. A segment without the declaration raises, so it
cannot join a plan by accident.
- feasible_plans reports a segment that fits the op chain but no plan
because of its boundaries, with the first mismatch.
- Buf.mismatch gives the reason. quant.inter reads any unquantized
intermediate, because asm.stage1 writes bf16 for fp16 outputs too.
- README: the buf, base, resolver and test rows.
- Tests: the boundary check and the rejection reasons.
Tests:
- CPU: tests/test_moev2_*.py and test_moe_dispatch_snapshot.py, 120
tests, 118 passed. test_outputs_match_legacy[a8w8_pt] and [a8w8_ptok]
fail on the legacy ASM stage 1 cases that are not repeatable, as in
step 3.3.
- CPU gates, on all 4 archs, 0 problems, with the same counts as step
3.3: differential.py 26,820 / 37,978 / 27,907 keys claimed on gfx942 /
gfx942_cu80 / gfx950; key_checks.py 335,413 keys; ranking_checks.py
118,703 ranked keys.
- No GPU run: the change is in plan resolution only, and the CPU
differential shows the same plans for every claimed key.
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.3): the code hunks apply unchanged (Sort.reads lands in
segments/sort.py, where PR 8255 moved the sort); buf.py keeps PR 8255's
ownership NOTE. The test counts above are from the original base. On
this base: CPU tests 152 passed (the GPU-only ones skip); the CPU
differential claims the same keys per path as step 3.3 on every arch;
key_checks, ranking_checks and snapshot --check, 0 problems.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.4: mxfp4 a4w4 path (not graduated)
MXFP4 a4w4 fused_moe calls on gfx950 (per_1x32 fp4x2 activations and
weights, Silu or Gelu, separated gate/up, g1u1) can run through
aiter.moev2 with AITER_MOEV2=a4w4. The path is not graduated, so the
default is unchanged.
Behavior claim:
- Legacy dispatch is unchanged. The snapshot grid adds the per_1x32
feature variants and a4w4 Silu with doweight_stage1 on preshuffled
weights (the combination that reaches the CK-Tile split-K default).
Every existing record is kept as is; the goldens grow to 114,542 /
135,489 / 159,565 / 110,824 keys on gfx942 / gfx942_cu80 / gfx950 /
gfx1201.
- CPU differential, all 4 archs: 0 problems. gfx950 claims 9,363 a4w4
keys, hands 552 back as legacy 1-stage and 284 to a legacy 2-stage
branch (CK-Tile split-K). The other paths claim the same keys as in
step 3.4a.
- On a gfx950 GPU, gpu_differential.py --path a4w4 runs 27 cases with
the shipped table, the synthetic table, AITER_USE_NT=1 and
AITER_BYPASS_TUNE_CONFIG=1. Both sides launch the same kernels on the
same inputs with the same outputs, except (16, 6144, 512, 257, 9) and
(16, 4096, 512, 512, 10). On those two cases, two legacy runs also
differ in the sorted ids (legacy issue). The other paths give the same
results as in step 3.3.
What changed:
- The FlyDSL, MXMOE and route-reduce helpers move from fused_moe.py into
segments/flydsl.py, segments/mxmoe.py and segments/sort.py (adaptive
aux sort, fused decode sort+quant). Their text is identical to this
base's fused_moe.py. Legacy imports them back, so both sides run the
same objects. _stage2_scratch now lives in segments/flydsl.py;
aot/flydsl/moe.py and op_tests/test_moe_scatter_reduce.py patch it
there.
- segments/mxfp4.py: FlyDSL stage 1 (plain, fused fp4 quant, layout-v2
output), FlyDSL stage 2, layout-v2 stage 2 (plain and scatter over the
aux sort), MXMOE stage 1 and 2, sort.aux; CK with the fp4 instances
(and doweight_stage1, which legacy runs on CK). Boundaries aux_sorted,
v2_sorted and mxmoe_sorted; Buf.layout=None reads any layout.
- Resolver hooks:
- Segment.check_row: legacy's tuned-row discard chain, with the same
warnings.
- Segment.declines_row: a tuned CK row on preshuffled weights, which
legacy overrides with the FlyDSL heuristic.
- Segment.default_kernels: default kernel names, with legacy's tile
tiers and warning.
- Segment.stage2_kernel: the fp8 GEMM2 rename, from q_dtype_a2 or
AITER_SITUV2_A4W4_FP8_INTER.
- Segment.metadata_fields.
- This base's legacy MXFP4 changes, mirrored:
- The MXMOE discard chain rejects a row excluded for the call, inline
GEMM1 with non-BF16 input, and a sort block_m or GEMM2 tile that
differs from GEMM1's BM. It no longer rejects stage-1 bias. MXMOE
stage 1 gets native_scale_layout.
- LocalDispatch makes legacy's runtime fallbacks before the first
dispatch logs anything: the MXMOE fallback when block_size_M differs
from the configured BM (resolve again with _exclude_mxmoe; raise as
legacy does if the fallback still needs another block_m), and the
inline-sort fallback (resolve again with _disable_inline_sort). It
checks the fallback keys without logging and declines the call if
one of them declines. The inline-sort check probes a JIT module, so
it runs only after the first lookup has logged, as in legacy; a call
whose _disable_inline_sort key declines is therefore declined even
where the inline-sort row could run. The post-sort relookup drops
both flags, as legacy does.
- executor.run_mxfp4 follows the per_1x32 branches of _fused_moe_impl
and fused_moe_2stages, including:
- a contiguous hidden_states copy outside inline sort;
- num_local_tokens passed to the fused decode sort+quant;
- pre-quantization only for fp4 GEMM1 activations;
- the configured SiTU betas for MXMOE;
- topk_ids for skip_dropped_routes;
- the valid-token count for MXMOE stage 2;
- topk_weights for FlyDSL v2 stage 2 with the fp4 intermediate.
- The resolver discards a post-reduction row for a weight layout other
than separated gate/up on fully shuffled weights, with legacy's
warning, and runs the default heuristics. With a dedicated table it
declines instead.
- hooks.legacy_globals bridges legacy's _fused_decode_sort_quant_disabled
(set by test_moe_sorting_mxfp4.py) to v2, next to kernel_bench_callable.
When legacy's flag is unset it leaves the v2 hook as the caller set it.
- Ranking entry a4w4: the FlyDSL heuristic where legacy picks it, the
CK-Tile split-K default as a legacy= region, CK 2-stage otherwise.
local.key_args_supported requires Silu or Gelu.
- Differential: keys handed back to a legacy 2-stage branch are counted
separately and checked against the legacy record. The GPU differential
compares m_indices as ids, and compares sorted MX scales only at the
bytes the quant kernels write.
- README: rows for the new segment and path modules and the updated
dispatch, execute and test modules.
- Tests: the MXMOE discard chain, the block_size_M and inline-sort
fallbacks (declines decided before logging, and the order of lookups
and warnings in run), the post-reduction discard, and legacy_globals
with legacy's flag unset.
Known differences and limits:
- Left on legacy:
- 1-stage tuned rows (and FLAT, 1-stage only) until 3.6;
- CK-Tile split-K (3.5, with the a8w4 CK-Tile port);
- num_local_tokens, a1_scale and activation scales (no segment
declares them, so these calls find no plan);
- Swiglu/Situv2/Relu2, interleaved gate/up, bias, padding and scatter
(3.5).
- Legacy issue, unchanged: the MXFP4 sorts used for few tokens
(mxfp4_moe_sort and mxfp4_moe_sort_quant_fwd) do not give the same
token order on every run. The two GPU cases above fail on it with
legacy alone.
Tests:
- CPU and GPU: tests/test_moev2_*.py and test_moe_dispatch_snapshot.py,
133 tests, 131 passed. test_outputs_match_legacy[a8w8_pt] and
[a8w8_ptok] fail on the legacy cases that are not repeatable, as in
step 3.3. [a4w4] fails in some runs on the two sort cases above.
- CPU gates, 0 problems on all 4 archs: key_checks.py 524,332 keys;
ranking_checks.py 129,333 ranked keys.
- GPU suites, AITER_MOEV2=off vs on: test_moe_2stage.py (-q 0, -q 4,
--no-legacy), the MXFP4 sort, aux, dispatch and codegen tests, the
FlyDSL MoE tests, and test_moe.py, test_moe_sorting.py, test_moe_ep.py,
test_moe_local_expert_ids.py and test_moe_dp_share_expert.py.
- Results: the same exit codes and check verdicts in both modes, except
the per-token swiglu_limit=7.0 check. That check also flips between
two runs with v2 off.
- --no-legacy exits 1 in both modes: the FlyDSL AOT cache is missing on
this machine. Rerun with --csv-filter afp4_wfp4 mxmoe_g1_a4w4 to skip
the cache check: 745 checks with the same verdicts apart from the
swiglu_limit check, exit 0 in both modes. After the review fixes,
--csv-filter mxmoe_g1_a4w4 again: 203 checks, all the same.
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.4a):
- fused_moe.py is this base's file minus the moved definitions. PR 8255
had already moved moe_sorting and the adaptive aux sort helpers
(with _empty_bf16, which stays there) into segments/sort.py, so this
step adds there only the fused decode sort+quant, Sort's extras and
accumulate, and SortAux. All 40 moved definitions equal this base's
text, including three changed upstream since the original step:
_flydsl_v2_stage2_wrapper and _mxfp4_a4w4_stage2_fw (the
scatter_intermediate combine, #7771; expert_mask and topk_ids, #7542)
and _mxfp4_inline_sort_unsupported (inline sort under EP, #7542).
- This base's legacy MXFP4 expert-parallel rules (#7542), mirrored:
- a tuned inline-sort row is no longer discarded under EP;
- under EP the MXMOE discard chain rejects BM16, activations other
than SiTUv2, a GEMM2 that is not flydsl_moe2_layout_ and the scatter
epilog, and checks the generated aux shapes only without EP;
- run_mxfp4 raises under EP only for a GEMM2 that is not a layout-v2
kernel, and forwards expert_mask and topk_ids to the MXMOE stage 2
too.
- PR 8255's review changes applied to this step's code:
- a4w4 has why_not and supported_archs; the new modules carry the NOTE
banner (flydsl.py and mxmoe.py with the shared-with-legacy wording);
- LocalDispatch decides the MXFP4 fallbacks on the preview prologue,
so a call it declines reaches legacy before the prologue copies
anything; the fallback warnings read the prepared call;
- key_args_supported keeps clamps (None, 0 and inf do not clamp);
- compare_launches keeps PR 8255's tolerance (1 ulp, or twice legacy's
own spread) for floating-point tensors and its whole-graph handling;
MX scales (at the bytes the quant kernels write) and fp4 values must
be bitwise equal, and sorted fp4 buffers are masked on their raw
bytes (fp4 tensors cannot be indexed).
- Tests: the live-arch claims test runs each path on its first arch
(a4w4 is gfx950 only); under EP the BM16 inline-sort row is now
discarded by the MXMOE chain, and a BM128 MXMOE row by the SiTUv2 rule,
with legacy's warnings; the run test checks that the fallbacks are
decided on the preview and the warnings get the prepared call; CPU
tests for the sorted fp4 and MX-scale comparisons. gpu_differential
adds the generic variants for a4w4 (and noncontiguous on an inline-sort
MXMOE shape).
- The golden delta equals the original step's exactly. The counts and GPU
results above are from the original base. On this base: CPU tests
166 passed (the GPU-only ones skip); differential 0 problems on all
4 archs, gfx950 claims 10,413 a4w4 keys, hands 623 back as legacy
1-stage and 299 to CK-Tile split-K, and the other paths claim the same
keys as in step 3.4a; key_checks 524,332 keys, ranking_checks 140,392
ranked keys and snapshot --check, 0 problems. The GPU differential
(with the new variant cases and this base's EP behavior) is rerun at
the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.5: a16w4, a16wi4, a8w4, mxfp8 paths and a4w4 leftovers (not graduated)
Every per_1x32 2-stage format can run through aiter.moev2 with
AITER_MOEV2=<path>. New paths: a16w4 (bf16 x MXFP4, gfx942/gfx950),
a16wi4 (bf16 x int4 in 1x32 groups, gfx942/gfx950), a8w4 (MXFP8 x
MXFP4, gfx950) and mxfp8 (MXFP8 x MXFP8, gfx950). a4w4 gains Swiglu,
SiTUv2, bias, activation parameters, padding and the CK-Tile branches.
No path is graduated, so the default is unchanged.
Behavior claim:
- Legacy dispatch is unchanged. The snapshot grid gains bias,
interleave, pad and standard-layout variants of the per_1x32
combinations, an MXFP4-only shape and a bf16 x fp4 SiTUv2
doweight_stage1 combination. Every existing record resolves as
before; the goldens grow to 126,095 / 147,042 / 171,118 / 122,377
keys on gfx942 / gfx942_cu80 / gfx950 / gfx1201, identical to the
records this base's own code writes.
- CPU differential, all 4 archs: 0 problems. gfx950 claims a4w4=20,175,
a16w4=7,064, a16wi4=5,052, a8w4=13,211, mxfp8=5,142 keys (other paths
as in step 3.4); gfx942 a16w4=5,108, a16wi4=4,572; gfx942_cu80
a16w4=4,801, a16wi4=3,996. 0 problems on gfx950 under
AITER_FLYDSL_FORCE=0, AITER_MXMOE_FALLBACK=0,
AITER_SITUV2_A4W4_FP8_INTER=1 and AITER_OPUS_STAGE2_FP8=0; under
AITER_BYPASS_TUNE_CONFIG=1 only the known declines of 1-stage rows
legacy runs 2-stage.
- On a gfx950 GPU, gpu_differential.py with the shipped table, the
synthetic table, AITER_USE_NT=1 and AITER_BYPASS_TUNE_CONFIG=1: a4w4
49 cases, a16w4 22, a16wi4 11, a8w4 37, mxfp8 20. Both sides launch
the same kernels on the same inputs with the same outputs, and raise
the same errors, except on legacy issues that two legacy runs also
show (see Known differences) and two a4w4 SiTUv2 declines under
AITER_BYPASS_TUNE_CONFIG=1. Runs sharing a JIT directory in parallel
logged or raised differently around the mxfp8 CK build that fails;
run alone, mxfp8 matches. gfx942 not run on a GPU.
What changed:
- The CK-Tile stage functions move verbatim from fused_moe.py to
segments/ck_tile.py, the MXFP4 reroute and bias predicates to
segments/flydsl.py and _opus_stage2_fp8_enabled to segments/opus.py.
Legacy imports them back.
- executor.run_mxfp4 follows every per_1x32 branch of _fused_moe_impl
and fused_moe_2stages: bf16/fp8/int4 activation quant, bias, local
topk ids, Opus and CK-Tile arguments, route-bucket checks. Calls
legacy rejects with the a16w4 NotImplementedError are declined before
dispatch, so legacy raises.
- Segments: cktile.gemm1/gemm2 (legacy's four CK-Tile branches in
order, the swiglu_mxfp4_bf16_cktile alias row), opus.gemm1,
opus.gemm1_layout, opus.gemm2 (tuned only), asm.stage1_cktile; FlyDSL,
MXMOE and CK caps for the new formats; the untuned a16wi4 fallback and
MXMOE SiTUv2 heuristic as default kernels. The FlyDSL bias rule
follows legacy's enable_bias, which differs between heuristic and
tuned plans (Segment.row_params).
- local.claims takes per-path allowances (activations, gate modes,
bias, activation parameters, padding, quant_dtype_a, g1u0) and splits
calls by activation format; key_args_supported checks the same at
key level.
- Ranking: RANKING moves to dispatch/ranking_table.py, which states the
table rules (no overlapping entries or regions, a default for every
problem, prefer xor legacy, feasible last structure, no dead
regions). Regions can be untuned_only. New predicates for the legacy
CK-Tile and FlyDSL branches and padding.
- This base's legacy changes the original step did not cover, mirrored:
- The resolver discards, with legacy's warnings, a 1-stage SiTUv2 ASM
row on preshuffled MXFP4 weights (#6995), a 1-stage row for an
activation the ASM kernels lack, and a 1-stage SwiGLU OAI row the
call cannot run (no kernel name, not flat=1, bias, a swiglu_limit
other than 7.0, gate/up not separated GGUU). The last two apply to
plain ASM rows only, as legacy checks rows naming other kernel
families first; such 1-stage rows are declined (none ships). It
declines where legacy raises (SiTUv2 on mixed shuffles, other
gate/up layouts or runtime betas) and for a dedicated table (the
FHMoE path).
- MXMOE stage 1 sets has_bias from the call's bias1 alone.
- The prologue normalizes a SiLU swiglu_limit as _fused_moe_impl does;
run_mxfp4 hands an active SiLU limit to a CK or ASM stage 1 and
raises for CK-Tile, as fused_moe_2stages does.
- The MXMOE segments take a8w4 problems too, and the a8w4 path lists
them, for the tuned flydsl_mxmoe_g1_a8w4_* rows (kimik3, dsv4,
gptoss a8w4 tables).
- a8w4 declines interleaved calls while AITER_USE_GROUPED_GEMM is on:
legacy may hand them to grouped_gemm_gfx1250_a8w4 before dispatch.
- Differential: --env NAME=VALUE compares live legacy records under a
dispatch override; every legacy= region maps to its stage 1. The GPU
differential covers the new weight formats, SiLU swiglu_limit on
a4w4, a 1-stage SwiGLU OAI row discarded for bias, and compares a
failed JIT build by its module; --synth-table works for paths with no
gfx942 CK rows to rewrite.
- README: rows for the new segment, path and table modules and the
updated ones.
- Tests: the SiTUv2 and SwiGLU OAI 1-stage discards and declines, the
SiTUv2 post-reduction case, the prologue's SiLU limit, MXMOE a8w4 rows
(inline or prequantized fp8, discarded with expert_mask), and a8w4
leaving interleaved calls to the grouped path.
Known differences and limits:
- Left on legacy: 1-stage tuned rows (3.6), FHMoE rows (3.7), padded
keys on kernels that take no padding (CK, MXMOE, layout-v2 GEMM2),
CK 2-stage a16w4, CK-Tile alias rows outside the CK-Tile branches,
and, under AITER_BYPASS_TUNE_CONFIG=1, a4w4 SiTUv2 keys with a tuned
row (the branch legacy takes then is not ported). Under that variable
legacy also attaches an Opus row's route-bucket fields to the default
(a possible warning); v2 does not, and no shipped table has them.
- op_tests/test_moe_2stage.py::test_presorted_moe_hook counts sorts by
patching fused_moe.moe_sorting, which v2 does not call through. With
AITER_MOEV2=on its own-sort call runs on v2 and fails that assertion,
ending a --no-legacy run. Calls with a registered presort stay on
legacy.
- Legacy issues seen while testing, unchanged, each also seen with two
legacy runs: the MXFP4 sorts for few tokens do not give the same token
order every run (a4w4 (16, 6144, 512, 257, 9), (16, 4096, 512, 512,
10) and (16, 3584, 384, 896, 16, SiTUv2); a8w4 MXMOE (16, 7168, 384,
385, 7)); the FlyDSL a8w4 stage 1 ..._w3_gui_fp8 races on (64, 7168,
3072, E24, top6). Also: a8w4 on untagged separated weights raises in
the untuned branches; a tuned cktile_* kernelName1 with an Opus stage
2 runs ASM stage 1; the mxfp8 CK instances fail to compile; tuned
mxfp8 Swiglu drops its bias.
Tests:
- tests/test_moev2_*.py and test_moe_dispatch_snapshot.py: 154 tests,
150 passed. test_outputs_match_legacy[a8w8_pt] and [a8w8_ptok] fail
on the legacy cases that are not repeatable, as in step 3.3; [a4w4]
and [a8w4] on the legacy issues above (each failing case rerun and
matched to them).
- CPU gates, 0 problems on all 4 archs: key_checks.py 571,700 keys;
ranking_checks.py 202,831 ranked keys.
- GPU suites, AITER_MOEV2=off vs on: test_moe_2stage.py (-q 4, 6, 7, 8,
9 --no-flydsl-csv, --no-legacy), the MXFP4 sort, aux, dispatch,
codegen and glm5 EP dispatch tests, the FlyDSL MoE, a16wfp4, inter_dim
and mxfp8 passthrough tests, test_moe_sorting.py, test_moe_ep.py,
test_moe_local_expert_ids.py and test_moe_dp_share_expert.py.
- The same exit codes and check verdicts in both modes, except the
per-token swiglu_limit=7.0 check, which also flips between two runs
with v2 off, and --no-legacy's test_presorted_moe_hook (above).
- --no-legacy with the hook test skipped: 207 checks in both modes,
the same verdicts apart from the swiglu_limit check; both modes
exit 1 where the FlyDSL AOT cache is missing on this machine.
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.4):
- fused_moe.py is this base's file minus the seven moved definitions,
which equal this base's text. PR 8255's legacy moe_sorting already
returns local topk ids, so segments/sort.py takes from this step only
Sort's and SortAux's return_local_topk_ids, bias features and pads.
- PR 8255's review changes applied to this step's code:
- local.why_not takes the per-path allowances and names each refusal
(the activation format of the call too); the new paths and a4w4
have why_not and supported_archs; arch checks use get_gfx_runtime
alone; ranking_table.py, ck_tile.py and opus.py carry the NOTE
banner (ck_tile.py and opus.py with the shared-with-legacy wording);
- a clamping swiglu_limit (None, 0 and inf do not clamp) and the
global scales stay refused without act_params; key_args_supported
keeps clamps;
- the a16w4 NotImplementedError decline is decided on the preview
prologue, before anything is copied;
- compare_launches keeps PR 8255's tolerance and dataclass expansion,
with this step's own-buffer and split-K stage 1 exemptions; the GPU
cases keep the unified encoding (options dict with "variant") and
add the generic variants for a16w4, a16wi4, a8w4 and mxfp8.
- This base's legacy MXFP4 expert-parallel rules (#7542, ported in step
3.4) cover the MXMOE a8w4 rows too: under EP a BM16 row is discarded
as BM16 and a BM64 Silu row by the SiTUv2 rule, with legacy's
warnings. The output_aux EP raise legacy also applies to MXMOE + Opus
metadata has no v2 counterpart to mirror: no MXMOE stage 1 feeds an
Opus stage 2 in v2, so such rows are declined.
- README: status lists the nine registered paths.
- The golden delta equals the original step's exactly. The counts and GPU
results above are from the original base. On this base: CPU tests
184 passed (the GPU-only ones skip); differential 0 problems on all 4
archs, claiming the same keys as the original step on every arch
(and on gfx950 under AITER_FLYDSL_FORCE=0, AITER_MXMOE_FALLBACK=0,
AITER_SITUV2_A4W4_FP8_INTER=1 and AITER_OPUS_STAGE2_FP8=0, 0
problems); key_checks 571,700 keys, ranking_checks 212,754 ranked
keys and snapshot --check, 0 problems. The GPU differential (with the
variant cases, this base's EP behavior, and the cases where legacy and
v2 both raise, which this base's harness accepts only when listed) is
rerun at the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.6: 1-stage ASM fmoe (default, tuned, FLAT, g1u0) (not graduated)
The 1-stage ASM fmoe kernels run through aiter.moev2 with
AITER_MOEV2=<path>, wherever legacy runs them: the default 1-stage
regions, tuned 1-stage rows (xbf16 and FLAT too) and the g1u0 bf16 and
int8 keys. No path is graduated, so the default is unchanged. The local
grouped gfx1250 branch is not ported (step 4.6a); a8w4 leaves those
calls to legacy.
Behavior claim:
- Legacy dispatch is unchanged. fused_moe_1stage, _ASM_ACT_TAG and
_retarget_asm_activation move verbatim to segments/asm.py and
_moe_prepare_unsorted_input to segments/sort.py; legacy imports them
back. The goldens (126,095 / 147,042 / 171,118 / 122,377 keys on
gfx942 / gfx942_cu80 / gfx950 / gfx1201) are identical to the records
this base's own code writes.
- CPU differential, all 4 archs: 0 problems. Keys claimed: gfx950
87,674 (78,551 in step 3.5), gfx942 43,123 (36,500), gfx942_cu80
53,578 (46,775). Keys legacy runs 1-stage that v2 still declines:
gfx950 9,330 -> 338, gfx942 4,872 -> 89, gfx942_cu80 4,930 -> 15 (see
Known differences). 0 problems on gfx950 and gfx942 under
AITER_FLYDSL_FORCE=0, AITER_MXMOE_FALLBACK=0,
AITER_SITUV2_A4W4_FP8_INTER=1, AITER_OPUS_STAGE2_FP8=0 and
AITER_XBFLOAT16=1; under AITER_BYPASS_TUNE_CONFIG=1 only declines of
calls whose tuned 1-stage row v2 cannot run while legacy, bypassing
the table, runs them 2-stage (338 on gfx950, 89 on gfx942; 2,409 on
gfx950 in step 3.5).
- On a gfx950 GPU, gpu_differential.py with the shipped table, the
synthetic table, AITER_USE_NT=1 and AITER_BYPASS_TUNE_CONFIG=1:
a16w16 21 cases (69 synthetic), a16w4 25, a8w8_blockscale 31 (147
synthetic), a8w4 37, a4w4 52, a8w8_ptok 49 (97 synthetic). Both sides
launch the same kernels on the same inputs with the same outputs and
logs, except on legacy issues that two legacy runs also show (see
Known differences), the two a4w4 SiTUv2 declines under
AITER_BYPASS_TUNE_CONFIG=1 of step 3.5, and, in runs sharing a JIT
directory in parallel, the log of a CK build that fails landing in a
different case (as in step 3.5). gfx942 not run on a GPU.
What changed:
- Segments: asm.fmoe_1stage covers quant through reduce and builds
legacy's fused_moe_1stage call (kernel name, activation, quant type,
xbf16, FLAT mode, expert_mask). sort.flat is legacy's pass-through for
the FLAT modes (flat 1 and 2: unsorted topk, over-allocated moe_buf,
num_local_tokens in the num_valid_ids slot). ASM stage 1 is g1u1 only.
- Buf: a layout in `reads` may be a set. ASM stage 1 reads the default
or unsorted sort; the Opus and FlyDSL layout segments read default or
aux_sorted, so only the 1-stage fmoe follows sort.flat.
- Resolver: 1-stage plans from the default regions and tuned rows, with
legacy's log line. match_row takes plain ASM 1-stage rows (named
kernel, no stage 2), matching FLAT rows to sort.flat. It declines
post-reduction rows (flat=3), other 1-stage rows, rows whose flat or
xbf16 cell legacy cannot parse (legacy raises) and a 1-stage plan with
a finite SiLU limit (legacy raises).
- executor.run_one_stage follows legacy's 1-stage branch: contiguous
hidden_states, the host sort or the FLAT pass-through (given the
row's mode), expert_mask and the FLAT output copy.
- local: 1-stage plans have no lookup after the sort, as in legacy.
- Ranking: an ASM 1-stage structure in the fp8 per-token, 1x128, int8
and g1u0 regions; g1u0 tables for a16w16 and int8 per-token.
check_problems ignores 1-stage plans an entry does not list (only
tuned rows reach them).
- Paths: a16w16 and a8w8_ptok (int8) claim g1u0; a4w4, a16w4 and
a8w8_blockscale gain the FLAT and 1-stage segments; a8w4 declines
calls legacy sends to the grouped gfx1250 kernel (the narrower check
of the original step replaces step 3.5's).
- This base's legacy changes the original step did not cover, mirrored:
the post-reduction mode and expert_mask of fused_moe_1stage (the moved
code is the new one), num_local_tokens in the FLAT prep, moe_sorting
passing through only the modes without a host sort, the retarget of a
1-stage row tuned for the twin activation (with legacy's INFO line),
the SiLU-limit raise and the skipped second lookup.
- Differential: 1-stage and FLAT launch positions; the g1u0 legacy
branches. The GPU differential gains default, tuned, xbf16 and FLAT
1-stage cases.
- README: rows for the changed modules.
- Tests: 1-stage defaults and tuned rows (FLAT, xbf16, retarget), the
declines, the SiLU-limit decline, the skipped second lookup, the FLAT
sort pass-through, a strided input and the FLAT mode reaching the
sort, the ranking of 1-stage plans only tuned rows reach, and a8w4
leaving grouped gfx1250 calls to legacy.
Known differences and limits:
- Left on legacy: post-reduction rows (8 shipped a4w4 rows), 1-stage
rows outside the plain form (empty kernelName1, a stage 2), g1u0
calls outside the 1-stage regions (legacy's CK 2-stage is wrong for
g1u0), the grouped gfx1250 branch (step 4.6a), FHMoE rows (3.7),
calls with bias, padding or other features fmoe lacks whose key has a
tuned 1-stage row (legacy runs the row and drops the bias or padding),
and tuned 1-stage rows for keys outside legacy's default 1-stage table,
where v2 has no 1-stage plan: the Gelu calls the act-type-disabled
fallback gives a SiLU row (the gfx942 1x128 keys, which legacy
retargets to the Gelu twin; a8w8_ptok tkw1 Gelu on gfx950).
- op_tests/test_moe_2stage.py::test_presorted_moe_hook still ends a
--no-legacy run with AITER_MOEV2=on (step 3.5).
- Legacy issues seen while testing, unchanged, each also seen with two
legacy runs: the ASM 1x128 blockscale stage 1 is not repeatable on
gfx950 (the same 72 synthetic cases fail since step 3.2); the MXFP4
sorts for few tokens (a4w4 (16, 4096, 512, 512, 10), (16, 6144, 512,
257, 9), (16, 3584, 384, 896, 16, SiTUv2); a8w4 MXMOE (16, 7168, 384,
385, 7)); the ASM per-token fp8 stage 1 (a8w8_ptok (8|64|256, 5120,
1536, 40|41, 8|10)); the FlyDSL a8w4 stage 1 w3 kernels ((64, 7168,
3072, E24, top6), (2048, 7168, 384, E384, top6)). The FLAT sort drops
expert_mask; v2 does the same.
Tests:
- tests/test_moev2_*.py and test_moe_dispatch_snapshot.py: 169 tests,
165 passed. test_outputs_match_legacy [a4w4], [a8w4], [a8w8_pt] and
[a8w8_ptok] fail on the legacy issues above, as in step 3.5.
- CPU gates, 0 problems on all 4 archs: key_checks.py 571,700 keys;
ranking_checks.py 210,064 ranked keys.
- GPU suites, AITER_MOEV2=off vs on: test_moe_2stage.py (-q 0, 2, 3, 4,
5, 6, 7 --no-flydsl-csv, --no-legacy), test_moe.py, test_moe_tkw1.py,
test_moe_blockscale.py, the MXFP4 sort, aux, dispatch, codegen and
glm5 EP dispatch tests, the FlyDSL MoE, a16wfp4 and inter_dim tests,
test_moe_sorting.py, test_moe_ep.py, test_moe_local_expert_ids.py and
test_moe_dp_share_expert.py.
- The same exit codes and check verdicts in both modes, except the
swiglu_limit=7.0 checks of test_moe_2stage.py, which also flip
between two runs with v2 off; the first test_moe_tkw1.py check, a
2-stage case on the ASM per-token fp8 stage 1 that legacy does not
repeat (failed off, warning on; the same flip in step 3.3); and
--no-legacy's test_presorted_moe_hook (above).
- --no-legacy with the hook test skipped: 207 checks in both modes,
the same verdicts apart from a swiglu_limit check; both modes exit 1
where the FlyDSL AOT cache is missing on this machine.
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.5):
- fused_moe.py is this base's file minus fused_moe_1stage, _ASM_ACT_TAG
and _retarget_asm_activation, which equal this base's text and are
re-exported from segments/asm.py. PR 8255 already moved legacy
moe_sorting, its FLAT branch and _moe_prepare_unsorted_input to
segments/sort.py, so this step adds only Sort.flat and SortFlat there.
- PR 8255's review changes applied to this step's code: a16w16 and
a8w8_ptok pass the g1u0 allowance to local.why_not; asm.py carries the
NOTE banner with the shared-with-legacy wording; compare_launches
keeps PR 8255's tolerance and whole-graph guard and gains this step's
1-stage and FLAT launch layouts; the GPU cases keep the unified
encoding.
- a8w4 mirrors legacy's grouped gfx1250 checks exactly: a gfx1250-strict
build counts as gfx1250 (the original step checked gfx1250 alone), and
an expert_mask call with doweight_stage1, which legacy hands to the
generic MoE, is claimed. It reads get_gfx itself, as legacy's check
does, and why_not names the refusal.
- This base's legacy 1-stage branch and the 1-stage regions of
get_2stage_cfgs equal the original base's.
- The goldens are unchanged, as in the original step. The counts and GPU
results above are from the original base. On this base: CPU tests 199
passed, 9 skipped (the GPU-only ones); differential 0 problems on all
4 archs, with the same a16w4, a16wi4, a4w4, a8w4 and mxfp8 claims and
the same 1-stage and 2-stage hand-backs as the original step on
gfx950; a16w16, a8w8_pt, a8w8_ptok and a8w8_blockscale see about 9%
more keys, from this base's tuned tables (a8w8_pt included, which this
step does not change); key_checks 571,700 keys, ranking_checks 220,531
ranked keys and snapshot --check, 0 problems. The GPU differential is
rerun at the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.7: FHMoE path (fhmoe_, shared expert as the last row) (not graduated)
FHMoE calls (fused_moe with shared-expert tensors, which legacy sends
to fhmoe_) run through aiter.moev2 with AITER_MOEV2=fhmoe. No path is
graduated, so the default is unchanged.
Behavior claim:
- Legacy dispatch is unchanged. The FHMoE contract, metadata and table
helpers and the two FlyDSL FHMoE stage wrappers move verbatim to
aiter/moev2/segments/flydsl_fhmoe.py; aiter/fhmoe.py imports them
back. _fhmoe_impl gets the same v2 hook as fused_moe_; the fhmoe_ op
schema is unchanged. The goldens (126,095 / 147,042 / 171,120 /
122,377 keys on gfx942 / gfx942_cu80 / gfx950 / gfx1201) are
identical to the records this base's own code writes; gfx950 gains
two keys, the dedicated-table misses (both raise).
- CPU differential, all 4 archs: 0 problems. gfx950: fhmoe claims
1,804 keys; it declines 15,180 where legacy raises (non-FlyDSL plans,
dedicated-table misses) and 1,520 where legacy runs (see Known
differences). The other paths' counts are unchanged from step 3.6.
0 problems on gfx950 and gfx942 under AITER_FLYDSL_FORCE=0,
AITER_MXMOE_FALLBACK=0, AITER_SITUV2_A4W4_FP8_INTER=1,
AITER_OPUS_STAGE2_FP8=0 and AITER_XBFLOAT16=1; under
AITER_BYPASS_TUNE_CONFIG=1 only step 3.6's 1-stage declines (the same
338 gfx950 and 89 gfx942 keys).
- On a gfx950 GPU, gpu_differential.py --path fhmoe: 14 cases (MXFP4
interleaved and separated, DSV4 I384 tuned and beyond its table, HY4
MXFP8 with the shared expert clamped and unclamped, another MXFP8
geometry, the block size and clamp_shared errors) launch the same
kernels on the same inputs with the same outputs and logs, or raise
the same errors, with the shipped table, AITER_USE_NT=1 and
AITER_BYPASS_TUNE_CONFIG=1. All other paths rerun as in step 3.6 (the
shared code changed): a16w16 21 (69 synthetic), a16w4 25, a16wi4 11,
a4w4 52, a8w4 37, a8w8_blockscale 31 (147 synthetic), a8w8_pt 23 (72
synthetic), a8w8_ptok 49 (97 synthetic), mxfp8 20; the same results
as before, apart from the legacy issues under Known differences.
- op_tests/test_fhmoe.py: 119 passed with AITER_MOEV2=off and =on;
under AITER_MOEV2=fhmoe v2 runs 46 calls, raises the 2 errors the
tests expect and declines none.
What changed:
- Segments flydsl_fhmoe.gemm1, gemm1_q and gemm2: the FlyDSL MXFP4 and
MXFP8 stages run through the FHMoE wrappers (Silu, the shared expert,
dedicated tables). Segment.call_args(c) gives a stage the call
arguments its launch adds (the shared weights, shared_expert_id,
swiglu_limit, clamp_shared); run_mxfp4 starts the stage arguments from
them, as legacy starts from _stage1_extra_args/_stage2_extra_args.
Sort and the quant segments accept the shared expert and a dedicated
table.
- Path fhmoe (entry "fhmoe", gfx950): run follows _fhmoe_impl (the
contract, the activation format from the gate layout, the
clamp_shared check, the DSV4 I384 or MXFP8 dedicated table), then the
local dispatch with the table in the key and the selected block size
enforced. The problem has SharedExpertSpec("fused_row"). The
capability checks supports_dsv4_i384_fhmoe and
supports_mxfp8_fhmoe_config resolve through the path. claims declines
under AITER_ONLINE_TUNE, while a presort is registered (legacy
consumes it) and for the interleaved MXFP4 calls legacy's grouped
gfx1250 branch takes (the check moves from a8w4 to local).
- local: the FHMoE key; a lookup with no call (the capability probes)
skips the second-lookup decline, as legacy's probe calls only
get_2stage_cfgs.
- Ranking: an fhmoe entry (FlyDSL 2-stage where use_mxfp4_flydsl
holds; elsewhere legacy raises). Entries without `shared` match only
problems without a shared expert. The resolver declines a dedicated
table without an exact row, where legacy raises.
- api.fused_moe sends shared-expert calls to the fhmoe path after
legacy's argument checks (api.fhmoe_call), including this base's
herd_topk and deterministic errors, in legacy's order.
- This base's changes the original step did not cover, mirrored: the
hook sits in _fhmoe_impl (upstream wraps it in drop_presort_on_error
under the fhmoe_ op), the presort decline, the herd/deterministic
errors, and the second-lookup decline's token argument.
- Harness: the differential compares FHMoE keys separately and reports
outcomes (claimed, declined where legacy raises or runs); FHMoE keys
in the ranking checks; FHMoE GPU cases built as op_tests/test_fhmoe.py
builds them; the snapshot keys add a dedicated-table miss per
geometry.
- README: rows for the new and changed modules.
- Tests: the FHMoE helpers moved verbatim, the stages, the capability
checks against legacy, the API errors (herd_topk and deterministic
too), the grouped gfx1250 and presort declines.
Known differences and limits:
- Declined where legacy runs (gfx950 CPU differential, all on the
snapshot's feature variants; no base key): MXMOE rows path fhmoe has
no segment for (exclude_mxmoe 325, fp8_input_no_scales 190) and calls
no FHMoE plan serves (fp8_input 353; num_local_tokens, activation
scales and input activation scales 163 each, the a4w4 gap; scatter
163, which fhmoe_ rejects before its dispatch). Legacy runs them
unchanged.
- Legacy's grouped gfx1250 branch is not ported (step 4.6a):
interleaved MXFP4 FHMoE calls it would take stay on legacy.
- The six private FHMoE hooks on _fused_moe_impl stay for legacy.
- gpu_differential.py --synth-table has no fhmoe rows.
- op_tests/test_moe_2stage.py::test_presorted_moe_hook still ends a
--no-legacy run with AITER_MOEV2=on (step 3.5).
- Legacy issues seen while testing, unchanged, each also seen with two
legacy runs: the ASM 1x128 blockscale stage 1 (the same 72 synthetic
cases since step 3.2); the MXFP4 sorts for few tokens (a4w4 (16, 4096,
512, 512, 10), (16, 6144, 512, 257, 9), (16, 3584, 384, 896, 16,
SiTUv2); a8w4 (16, 7168, 384, 385, 7)); the ASM per-token fp8 stage 1
(a8w8_ptok (8|64|256, 5120, 1536, 40|41, 8|10)); the CK int8
per-tensor Gelu stage 1 (a8w8_pt (32, 4096, 384, 128, 8), as since
step 3.3); the FlyDSL a8w4 stage 1 w3 kernel ((64, 7168, 3072, E24,
top6)). In runs sharing a JIT directory in parallel, a CK module
another process is building fails to load (mxfp8 and a8w4 std_shuffle
cases; mxfp8 rerun alone: 20 of 20 ok).
Tests:
- tests/test_moev2_*.py and test_moe_dispatch_snapshot.py: 177 tests,
173 passed. test_outputs_match_legacy [a4w4], [a8w4], [a8w8_pt] and
[a8w8_ptok] fail on the legacy issues above, as in step 3.6.
- CPU gates, 0 problems on all 4 archs: key_checks.py 571,702 keys;
ranking_checks.py 220,216 ranked keys (10,152 FHMoE).
- GPU suites, AITER_MOEV2=off vs on: test_moe_2stage.py (-q 0 to 9
--no-flydsl-csv, --no-legacy), test_moe.py, test_moe_tkw1.py,
test_moe_blockscale.py, test_moe_per_tensor_a2_init.py, the MXFP4
sort, aux, dispatch, codegen and glm5 EP dispatch tests, the FlyDSL
MoE, a16wfp4, inter_dim and mxfp8 passthrough tests, test_fhmoe.py,
test_moe_sorting.py, test_moe_ep.py, test_moe_local_expert_ids.py and
test_moe_dp_share_expert.py.
- The same exit codes and check verdicts in both modes, except the
swiglu_limit=7.0 checks of test_moe_2stage.py, which also flip
between two runs with v2 off; the first test_moe_tkw1.py check (the
ASM per-token fp8 stage 1, as in step 3.3); and --no-legacy's
test_presorted_moe_hook (above).
- --no-legacy with the hook test skipped: 207 checks in both modes,
the same verdicts apart from a swiglu_limit check; both modes exit 1
where the FlyDSL AOT cache is missing on this machine.
- black and ruff (0.16.0) clean.
Ported onto main (which holds the squashed phases 0-2, PR 8255, and
steps 3.1-3.6):
- aiter/fhmoe.py's moved definitions equal this base's text (the file has
no upstream drift); it carries PR 8255's NOTE above the moev2 imports
and at the _fhmoe_impl hook, and flydsl_fhmoe.py the shared-with-legacy
NOTE.
- PR 8255's review changes applied to this step's code: path fhmoe has
why_not (claims = why_not is None) and supported_archs, and checks the
runtime arch; legacy_grouped_gfx1250 moves from a8w4 to local with
step 3.6's port fixes (gfx1250-strict, and the EP + doweight_stage1
early return); LocalDispatch.run passes the forced q_dtype_a and
config_file to both dispatch_key calls.
- Fixed while porting (the original step had them too):
- Every claimed FHMoE call raised KeyError 'w1_global_scale': the
fhmoe_ op has no NVFP4 global scales, so run's defaults now add them
as None, and api.fhmoe_call rejects shared-expert calls that set
them.
- herd_topk with NVFP4 global scales now raises legacy's error before
the call is built.
- why_not declines up front the arguments no FHMoE stage takes
(a1_scale, a2_scale, num_local_tokens, doweight_stage1), so a
declined call no longer logs the table checks twice.
- The goldens gain the same two gfx950 keys as in the original step. The
counts and GPU results above are from the original base. On this base:
CPU tests 207 passed, 10 skipped (the GPU-only ones); differential 0
problems on all 4 archs, with fhmoe claiming 1,804 gfx950 keys and
declining 15,180 where legacy raises and 1,520 where it runs, as in
the original step; the other paths' counts equal step 3.6 on this
base. key_checks 571,702 keys, ranking_checks 230,683 ranked keys
(10,152 FHMoE) and snapshot --check, 0 problems. The GPU differential
is rerun at the end of the port.
Co-authored-by: Cursor <[email protected]>
* [MoE] moev2 step 3.8: coverage report in CI (not graduated)
Step 3.8 of the moev2 revamp: a coverage report over the snapshot key
grid that fails CI on capability gaps and unranked segments and lists
the tuned rows that do not run. No path is graduated, so the default is
unchanged.
Behavior claim:
- No dispatch changes: the paths decline the same calls as before and
legacy runs them. The CPU differential on every arch has 0 problems.
The bf16 g1u0 keys without a 1-stage fmoe kernel now go to the named
legacy branch, and the differential checks that legacy runs CK stage 1
for them.
- Coverage, ranking and key checks: 0 problems on every arch.
What changed:
- aiter/moev2/dispatch/coverage.py:
- classify: how the resolver serves a problem a path takes. The kinds
are a plan, a gap (no plan from the path's segments), a ranking
region naming a legacy branch, a decline caused by the tuned row, or
a resolver raise (unshuffled gfx950 fp8 CK weights, as in legacy).
- row_status: whether the exact tuned row runs, and if not, why.
- segment_errors: fails a segmen…


Summary
Kimi K3 A8W4 (SiTUv2) MoE under expert parallelism (EP16/EP32/EP64) can now run the coupled MXMOE pipeline (MXMOE GEMM1 +
flydsl_moe2_layout_GEMM2) instead of falling back to default heuristics. The tuners gain A8W4 and real-EP routing so they can produce those rows, and the tuned rows are added tokimik3_a8w4_tuned_fmoe.csv.Non-EP dispatch is unchanged.
Motivation
expert_maskwas set. Under EP theexpertkey is the local expert count (896 / EP), so the NE-keyed aux-kernel shape check did not apply either. Every EP lookup therefore fell back to flydslv2 or to the default heuristics.token × topkroutes over the local experts. That is about EP times heavier than one rank's real load, so the selected tiles were tuned for the wrong M.kw2(8-wave) GEMM1 from 128 to 136 VGPRs and halved its resident workgroups per CU.Changes
Runtime (
aiter/fused_moe.py)get_2stage_cfgs, under EP, keeps an MXMOE row only if all of the following hold. Every other MXMOE row is rejected under EP, as on main.flydsl_moe2_layout_kernel with an atomic or reduce epilog. Native MXMOE GEMM2 and the scatter epilog are rejected.dispatch_policy=1, which hangs at >= 819 experts ([Bug] moe_sorting (Opus) with dispatch_policy=1 hangs the GPU when num_experts >= 819 #8014).get_2stage_cfgsskips the NE-keyedis_mxfp4_moe_shape_supportedcheck:expertis the local expert count, and the masked Opus sort plus the prequant GEMM1 replace every NE-keyed aux kernel._mxfp4_inline_sort_unsupportedacceptsexpert_maskand skips the generated aux-sort instance check, because EP sorts with the masked Opus kernel. Inline-sort GEMM1 exists only at BM16, so this path stays unreachable under EP until BM16 is supported._fused_moe_implraisesNotImplementedErrorunder EP only for native MXMOE GEMM2 and Opus stage2._mxfp4_a4w4_stage2_fwandfused_moe_2stagesforwardexpert_mask/topk_idsto the layout GEMM2 wrapper. Without them the reduce epilog sums unwritten remote-route slots.Kernel (
aiter/ops/flydsl/kernels/mxfp4_gemm1.py)BM * OUT_ROW_BYTES, checked by a compile-time assert.kw2GEMM1 drops to 112 VGPRs with no spills.Tuners (
gemm_moe_tune.py,mxfp4_staged_search.py)--mxfp4-flydsl) generates A8W4 candidates: FP8 activations,fp8outGEMM1, and interleaved gate/up, plus activation quantization. The staged-search GEMM1/GEMM2 contracts derive the activation dtype fromq_dtype_ainstead of requiring FP4.--ep-size N/--ep-seed Soptions, for both the layout-v2 tuner and the coupled tuner:tokenis the dispatch-buffer row count andexpertis the local expert count.expert × Nglobal experts and use the balanced routing ofamd_moe_bench_share/bench_moe.py. Rank 0's routes are laid out the same way astest_moe_ep.py --ep-mode reallays them out.--mxfp4-flydsl, only atomic/reduce layout GEMM2 is tuned.Config (
aiter/configs/model_configs/kimik3_a8w4_tuned_fmoe.csv)kw2GEMM1, which relies on the payload-store change above.Tests
op_tests/test_moe_ep.py:-a/--activation,--betaand--linear-betaoptions.torch_moehas no SiTUv2.local_routes/active_expertsare printed outside the timed region.op_tests/test_moe_mxmoe_ep.py:num_local_tokensdead tail, and NaN-filled stage2 buffers.op_tests/tuning_tests/test_fast_tuning.py: CPU tests for precision and sort-block pairing, A8W4 layout validation, EP candidate filtering, and the MXFP8 fast-scan fixture.aiter/aot/flydsl/gemm.py: restores the executable bit that [HIP] [FlyDSL] tune bmm and mxfp8 together ,update related tuned csv #7439 dropped.Performance
Setup
5173e7ac5.amd_moe_bench_sharewith the uniform router on a single GPU, simulating EP rank 0. Inputs are prequantized MXFP8, weights MXFP4, 30 samples per point. Seed 0 gives both sides identical routes.Configs compared
kimik3_a8w4_tuned_fmoe.csv(MXMOE GEMM1 + layout GEMM2).flydsl_moe1_afp8_wfp4_*) + layout GEMM2 rows for the same keys.flydsl_moe1kernel, with the same GEMM2. The EP16/EP64 baseline is therefore not a tuned one.Geomean change: EP16 +28.3%, EP32 +41.6%, EP64 +80.6%.
FC1+FC2 excludes the sort and fill kernels, and the baseline's separate
moe_reductionkernel at EP32 tokens 32–128. Counting all kernels in the call instead, the change is +7.7…+34.9% (EP16), +20.2…+89.0% (EP32) and +26.7…+77.5% (EP64).