You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[CK] [FlyDSL] [JIT] [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1 - #8669
With AITER_FLYDSL_STAGE2_FP8=1, fused_moe still runs the row of the main tuned table, and a one-stage row has no stage 2 that can write FP8 route output. So a tuned shape can hold the fastest row for the switch off or the fastest row for the switch on, not both. This PR adds a second table, tuned_stage2_fp8_fmoe, that get_2stage_cfgs reads only when the switch is on, and adds the three Qwen3.8-2.4T MXFP4 rows that need it. With the switch off, nothing changes.
Motivation
This is a tuned-config selection change: with AITER_FLYDSL_STAGE2_FP8=1, Qwen3.8-2.4T MXFP4 (E 513, top-k 11) at 8192, 16384 and 32768 tokens runs FlyDSL reduce rows from the new table in place of the one-stage Q256 rows of the main table, and the fused_moe call is 14% to 19% faster on one MI355X.
Rocm/aiter5988 moved these three shapes from FlyDSL two-stage rows to fmoe_bf16_pertokenMXfp4_g1u1_silu_prefill_1tg_4w_256mx1_128nx1_ps_fp32gate_route (flat=3). With the switch off, the Q256 rows are the fastest. With the switch on, the old FlyDSL rows are faster, because their stage 2 writes FP8 route output and the Q256 kernel ignores the switch:
Tokens
FlyDSL rows, switch off
Q256 rows (switch has no effect)
FlyDSL rows, switch on
8192
1222.4 us
1164.0 us
939.0 us
16384
2378.7 us
2065.4 us
1780.7 us
32768
4369.3 us
3868.9 us
3150.6 us
AITER main ffbd9c6ac, one MI355X, gemm_moe_tune.py --run_config, median of 2 GPUs. In SGLang serving with the switch on (8x MI355X, TP8, with and without NEXTN, geomean over 12 to 14 cells with ISL 8192 to 128000), the Q256 rows give 98.4% to 99.0% of the output throughput of the FlyDSL rows.
Today the only way to get the FlyDSL rows with the switch on is to point AITER_CONFIG_FMOE at a copy of the whole table. That copy then misses each later row change in AITER.
The same conflict can reach other models. Rocm/aiter8020 replaced the Kimi K3 MXFP4 row at 16384 tokens (E 384, top-k 16), a FlyDSL MXMOE stage 1 with a FlyDSL reduce stage 2, by a one-stage producer row (flat=3). The vLLM and ATOM recipes for Kimi K3 set AITER_FLYDSL_STAGE2_FP8=1, so a deployment of that shape with the switch now runs a row that ignores it. We did not measure it. For Qwen3.8-Flash-Next at 16384 tokens, Rocm/aiter8044 proposes a producer row (1094 to 1015 us) and Rocm/aiter8174 reports FP8 route output (1137.6 to 918.4 us). The two PRs use different harnesses, so the numbers do not compare directly, but the choice there also depends on the switch.
Other ways we looked at:
A _tag for FP8 rows in the main CSV. Rocm/aiter7720 makes the merge read _tag only for fallback or live rows, and two live rows with the same key collide.
Rocm/aiter8032 selects FP8 route output by the kernel name of a row. It is still one row for each shape, so the Q256 rows would have to go.
Rocm/aiter8174 changes a scatter stage 2 to the reduce stage 2 of the same tile. A one-stage row has no stage 2. The two PRs compose: after Rocm/aiter8174 merges, the lookup in this PR can also read its stage2_fp8 flag.
A load-time overlay, like AITER_SELECT=power (Rocm/aiter6970). It works only for each process, so it cannot serve the per-call flag of Rocm/aiter8174.
Changes
aiter/jit/core.py: AITER_CONFIG_FMOE_STAGE2_FP8 and AITER_CONFIGS.AITER_CONFIG_FMOE_STAGE2_FP8_FILE. The family works like tuned_swiglu_limit_fmoe: a header-only aiter/configs/tuned_stage2_fp8_fmoe.csv plus aiter/configs/model_configs/*tuned_stage2_fp8_fmoe*.csv. The glob of the main family (*tuned_fmoe*) does not match the new files, so the main table does not change.
aiter/fused_moe.py, get_2stage_cfgs: when the switch is on, look up the new table after the main lookup. Its row replaces the main row only when its token tier is the same as or larger than the tier of the main row, so the padded-M fallback cannot put a 32768 FP8 row over a 131072 main row. _lookup_cfg now also returns the tier it found. The lookup reads only the exact-key dict of the new table, not the act_type-agnostic dict of read_table. Each replacement logs one info line.
The new table is not read when the caller passes config_file, or when the call has a swiglu_limit (the clamp is a correctness requirement, so that table wins). It is read when AITER_CONFIG_FMOE is set, because an engine can set that variable to a merged copy of the default tables.
gemm_moe_tune.py: --run_config <file> times the rows of that file also with the switch on (the tuner empties the FP8 table). --run_config with no file times the default selection, the FP8 table included.
aiter/aot/flydsl/moe.py: with the switch on, the AOT build also replays the new table. The build replays the main, FHMoE and grouped tables and skips each row that does not reach FlyDSL, so it skipped the three Q256 rows and never built the FP8 rows.
aiter/configs/model_configs/qwen3_8_2400b_fp4_tuned_stage2_fp8_fmoe.csv: the three E 513 rows (8192, 16384 and 32768 tokens) that Rocm/aiter5988 replaced, copied unchanged from the main table before that PR.
Tests: see "Changed op tests" below.
Performance (if applicable)
Hardware
Workload/configuration
Before
After
Change
MI355X, 1 GPU
fused_moe, Qwen3.8-2.4T MXFP4, E 513, top-k 11, 8192 tokens, AITER_FLYDSL_STAGE2_FP8=1
1164.6 us (Q256)
939.0 us (FlyDSL reduce)
-19.4%
MI355X, 1 GPU
The same, 16384 tokens
2063.8 us
1783.2 us
-13.6%
MI355X, 1 GPU
The same, 32768 tokens
3862.4 us
3179.9 us
-17.7%
MI355X, 1 GPU
The same three shapes, switch off
1164.0 / 2065.4 / 3868.9 us (Q256)
1163.8 / 2064.5 / 3893.3 us (Q256)
0.0% to +0.6%
gemm_moe_tune.py --run_config with random routing, median of 2 GPUs of one node. With the switch on, "Before" is the main table (--run_config <main table>, which this PR keeps free of FP8 rows) and "After" is the default selection of this PR (--run_config with no file). With the switch off, "Before" is AITER main ffbd9c6ac on the same node. A second run of each arm agrees within 0.3%. The FP8 rows of this PR take the same time as the same rows on AITER main with the switch on (within 1%). These numbers are at d362a33b2. At 24a6d8a4d, after the merge of main, the same arms agree with them within 0.5%.
Accuracy
The new rows run the same kernels as the main table before Rocm/aiter5988, and only with the switch on. We ran the Qwen3.8 evals with that pair in SGLang (TP8, NEXTN), against the same model with the switch off:
The two arms ran on different nodes. All scores are in the noise. In the kernel benchmark, checkAllclose (atol and rtol 0.01) fails for 77.7% to 77.9% of the elements with FP8 route output and for 69.1% to 69.5% without it. The status is OK for all rows. Other models get no change until their owners add rows to the new table.
Testing
Unit tests added or updated
Performance benchmarks run
Tested on MI250X
Tested on MI300X
Tested on MI355X (gfx950)
Documentation
Docstrings updated
User guide updated
Performance guide updated
No documentation change is needed, with the reason stated below
No user guide lists the tuned-config families or the AITER_CONFIG_FMOE_* variables, so this PR adds none.
Dependencies
No new third-party dependencies added
New dependencies are listed and justified below
Breaking Changes
None. With the switch off, or with no row in the new table, the selection is the same as before.
With AITER_FLYDSL_STAGE2_FP8=1, get_2stage_cfgs now takes a row from tuned_stage2_fp8_fmoe when that table has one for the shape, at the same token tier as the main row or a larger one. Before, the switch could not change the row, so a one-stage row in the main table stopped the FP8 route output for its shape. The main table and the selection with the switch off do not change.
Validation and unverified scope
On one MI355X node at d4e284b23:
python3 op_tests/test_moe_stage2_fp8_rows.py (as aiter_test.sh runs it): 8 passed. With aiter/fused_moe.py of 24a6d8a4d, the new SiTUv2 test fails and the other 7 pass.
pytest op_tests/test_moe_mxfp4_inter_dim_dispatch.py op_tests/tuning_tests/test_config_shape_collision.py -k "stage2_fp8 or fmoe or mxfp4 or cktile": 29 passed. pytest tests/test_moe_dispatch_snapshot.py: 3 passed.
On the same node at 24a6d8a4d. The change of d4e284b23 does not change the lookup of a Silu call, because the new table has only Silu rows:
python3 csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py -i <untuned E 513 rows, 8192 to 32768 tokens> --run_config [<table>], with the switch off and on, see "Performance".
AOT: AITER_FLYDSL_STAGE2_FP8=1 python3 -m aiter.aot.flydsl.moe --csv <merged tuned_stage2_fp8_fmoe.csv> --row-tokens-only into an empty FlyDSL cache: 3 kernels, 6 replays OK. Then gemm_moe_tune.py --run_config with the switch on and FLYDSL_RUNTIME_RUN_ONLY=1 on that cache: the three FP8 rows run and the status is OK.
What remains unverified:
SGLang serving with this branch. The serving and eval numbers above use the same kernel pair through a full AITER_CONFIG_FMOE table on AITER 0e072ca50.
A full default AOT build with the switch on (all tables). The new test checks that its job list has the three rows, and the build of the new table alone passes.
The Kimi K3 and Qwen3.8-Flash-Next shapes above. This PR adds no rows for them.
MI350X.
get_2stage_cfgs caches its result for each shape. A process that changes the switch after the first call of a shape keeps the row of the first call. The stage 2 launcher reads the switch at each call.
PR-specific question
The new lookup runs only on the default path: AITER_FLYDSL_STAGE2_FP8=1, no config_file and no swiglu_limit. A row of the new table applies only to its exact get_2stage_cfgs key: gfx, CU count, padded token count, model_dim, inter_dim, expert, top-k, activation, dtype, both quant dtypes, quant type, g1u1 and doweight_stage1. The lookup does not use the act_type-agnostic dict of read_table, so a Silu row of the new table does not apply to a SiTUv2 or Swiglu call. The only other match is the existing padded-M fallback above 32768 tokens, and the tier check keeps a fallback FP8 row from replacing a main row of a larger tier. The three rows of this PR are gfx950 with 256 CUs, bf16 input with MXFP4 (fp4x2, per_1x32) activations and weights, model_dim 8192, inter_dim 256, E 513, top-k 11, at 8192, 16384 and 32768 tokens. The main table had these rows for the same keys before Rocm/aiter5988, so the kernels already served these shapes. Any other key, and every call with the switch off, gets the main row as before.
Changed op tests
op_tests/test_moe_stage2_fp8_rows.py (new): calls get_2stage_cfgs for the Qwen3.8 shape with the switch off and on. It checks the Q256 row with the switch off and the FlyDSL row (block_m, stage 2 kernel) with the switch on at 8192, 16384 and 32768 tokens. It also checks that 4096 tokens (no FP8 row) do not change, that 131072 tokens take the 32768 FP8 row through the fallback, that a main row at 131072 is not replaced by the 32768 FP8 row, and that a SiTUv2 main row with the same other keys is not replaced by the Silu FP8 row. A last test checks that the AOT job list of aiter/aot/flydsl/moe.py has the three rows with the switch on and not with the switch off. It runs in a new process, because the module reads the switch at import. The file needs a gfx950 GPU with 256 CUs (get_gfx_runtime()), because the rows are keyed on them, and it runs under python3 <file>. No other test covers the new lookup.
op_tests/tuning_tests/test_config_shape_collision.py: adds the new family to the list of families whose rows must not collide.
AI assistance (Claude) was used to measure and draft this change. All changes reviewed.
A tuned fmoe row serves both modes of AITER_FLYDSL_STAGE2_FP8. For some
shapes, the fastest row depends on the mode. Qwen3.8 MXFP4 E 513 at 8192
to 32768 tokens: the one-stage post-reduce rows of
ROCm#5988 are the fastest with the switch
off. FlyDSL reduce rows with FP8 route rows are faster with it on.
Add the family tuned_stage2_fp8_fmoe (AITER_CONFIG_FMOE_STAGE2_FP8).
With AITER_FLYDSL_STAGE2_FP8=1, get_2stage_cfgs reads it after the main
table, like the swiglu_limit table. Its row replaces the main row when
the row is for the same token tier or a larger one.
- Add the Qwen3.8 rows: the FlyDSL reduce rows of the parent of
ROCm#5988.
- gemm_moe_tune.py --run_config times the given table only.
- Add a dispatch test and the family to the shape collision test.
Co-authored-by: Cursor <[email protected]>
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 8669 --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.
github-actionsBot
changed the title
[MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1
[CK] [JIT] [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1
Nov 25, 2026
PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers
Behavior and intent
With `AITER_FLYDSL_STAGE2_FP8=1`, `get_2stage_cfgs` now takes a row from `tuned_stage2_fp8_fmoe` when that table has one for the shape, at the same token tier as the main row or a larger one. Before, the switch could not change the row, so a one-stage row in the main table stopped the FP8 route output for its shape. The main table and the selection with the switch off do not change.
Validation and unverified scope
On one MI355X node at `d4e284b23`:
- `python3 op_tests/test_moe_stage2_fp8_rows.py` (as `aiter_test.sh` runs it): 8 passed. With `aiter/fused_moe.py` of `24a6d8a4d`, the new SiTUv2 test fails and the other 7 pass.
- `pytest op_tests/test_moe_mxfp4_inter_dim_dispatch.py op_tests/tuning_tests/test_config_shape_collision.py -k "stage2_fp8 or fmoe or mxfp4 or cktile"`: 29 passed. `pytest tests/test_moe_dispatch_snapshot.py`: 3 passed.
On the same node at `24a6d8a4d`. The change of `d4e284b23` does not change the lookup of a Silu call, because the new table has only Silu rows:
- `python3 csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py -i <untuned E 513 rows, 8192 to 32768 tokens> --run_config [<table>]`, with the switch off and on, see "Performance".
- AOT: `AITER_FLYDSL_STAGE2_FP8=1 python3 -m aiter.aot.flydsl.moe --csv <merged tuned_stage2_fp8_fmoe.csv> --row-tokens-only` into an empty FlyDSL cache: 3 kernels, 6 replays OK. Then `gemm_moe_tune.py --run_config` with the switch on and `FLYDSL_RUNTIME_RUN_ONLY=1` on that cache: the three FP8 rows run and the status is OK.
What remains unverified:
- SGLang serving with this branch. The serving and eval numbers above use the same kernel pair through a full `AITER_CONFIG_FMOE` table on AITER `0e072ca50`.
- A full default AOT build with the switch on (all tables). The new test checks that its job list has the three rows, and the build of the new table alone passes.
- The Kimi K3 and Qwen3.8-Flash-Next shapes above. This PR adds no rows for them.
- MI350X.
- `get_2stage_cfgs` caches its result for each shape. A process that changes the switch after the first call of a shape keeps the row of the first call. The stage 2 launcher reads the switch at each call.
PR-specific question
The new lookup runs only on the default path: `AITER_FLYDSL_STAGE2_FP8=1`, no `config_file` and no `swiglu_limit`. A row of the new table applies only to its exact `get_2stage_cfgs` key: gfx, CU count, padded token count, model_dim, inter_dim, expert, top-k, activation, dtype, both quant dtypes, quant type, g1u1 and doweight_stage1. The lookup does not use the act_type-agnostic dict of `read_table`, so a Silu row of the new table does not apply to a SiTUv2 or Swiglu call. The only other match is the existing padded-M fallback above 32768 tokens, and the tier check keeps a fallback FP8 row from replacing a main row of a larger tier. The three rows of this PR are gfx950 with 256 CUs, bf16 input with MXFP4 (fp4x2, per_1x32) activations and weights, model_dim 8192, inter_dim 256, E 513, top-k 11, at 8192, 16384 and 32768 tokens. The main table had these rows for the same keys before [Rocm/aiter5988](https://github.com/ROCm/aiter/pull/5988), so the kernels already served these shapes. Any other key, and every call with the switch off, gets the main row as before.
Changed op tests
- `op_tests/test_moe_stage2_fp8_rows.py` (new): calls `get_2stage_cfgs` for the Qwen3.8 shape with the switch off and on. It checks the Q256 row with the switch off and the FlyDSL row (block_m, stage 2 kernel) with the switch on at 8192, 16384 and 32768 tokens. It also checks that 4096 tokens (no FP8 row) do not change, that 131072 tokens take the 32768 FP8 row through the fallback, that a main row at 131072 is not replaced by the 32768 FP8 row, and that a SiTUv2 main row with the same other keys is not replaced by the Silu FP8 row. A last test checks that the AOT job list of `aiter/aot/flydsl/moe.py` has the three rows with the switch on and not with the switch off. It runs in a new process, because the module reads the switch at import. The file needs a gfx950 GPU with 256 CUs (`get_gfx_runtime()`), because the rows are keyed on them, and it runs under `python3 <file>`. No other test covers the new lookup.
- `op_tests/tuning_tests/test_config_shape_collision.py`: adds the new family to the list of families whose rows must not collide.
AI assistance (Claude) was used to measure and draft this change. All changes reviewed.
PR state
PASS — pull request is marked ready for review
Copilot findings
PASS — no active Copilot finding lacks a substantive author reply
Code and op-test hygiene
PASS — no committed artifact or conflict marker detected
Required CI
PASS — Black: passed
PASS — Ruff: passed
PASS — Repository dependency: passed
PASS — Aiter Test Gate: passed
Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The selected FP8 paths lack default AOT prebuild coverage, risking run-only cache misses, while their regression tests can skip compatible GPUs and do not execute under the default CI invocation.
This PR adds a separate tuned-config family for FP8 stage-2 MoE output, allowing selected Qwen3.8 MXFP4 shapes to use FlyDSL two-stage rows when AITER_FLYDSL_STAGE2_FP8=1 without replacing the default one-stage rows.
Changes:
Adds FP8-specific table loading and token-tier-aware selection, preserving explicit-config and SwiGLU-limit precedence.
Supplies three Qwen3.8 tuning rows and prevents explicit-table benchmarks from using FP8 overrides.
Adds dispatch regression tests and config-family collision checks.
The AOT build replays only the main, FHMoE and grouped tables, and it
skips each row that does not reach FlyDSL. The main rows of the stage2
FP8 shapes are one-stage ASM rows, so the build never compiled the
FlyDSL rows that the runtime selects with the switch on.
- aiter/aot/flydsl/moe.py: add the stage2 FP8 family to DEFAULT_CSVS
when the switch is on.
- op_tests/test_moe_stage2_fp8_rows.py: check that the AOT jobs include
the Qwen3.8 rows only with the switch on. Use get_gfx_runtime() for
the skip. Add a __main__ entry, because aiter_test.sh runs
"python3 <file>".
Co-authored-by: Cursor <[email protected]>
github-actionsBot
changed the title
[CK] [JIT] [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1
[CK] [FlyDSL] [JIT] [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1
Nov 25, 2026
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The FP8 lookup’s activation-agnostic fallback can override a same-tier row for a different activation, violating exact-key dispatch scope and requiring a primary-dictionary-only lookup plus regression coverage.
The FP8 lookup also consults read_table's activation-agnostic fallback, so the shipped 8192-token SiLU row can replace a same-tier SiTUv2 main row with otherwise identical keys. This changes dispatch for activations absent from the FP8 table, contrary to the stated exact-key scope. Use only the FP8 table's primary dictionary while retaining token-tier fallback, and add a different-activation regression case.
The stage2 FP8 lookup also read the act_type-agnostic dict of read_table.
Then a Silu row of the table could replace the main row of another
activation (for example SiTUv2) with the same other keys.
Keep only the primary dict. The token-tier fallback stays.
Add a SiTUv2 regression test.
Review: ROCm#8669
Co-authored-by: Cursor <[email protected]>
The "previously missed issue" of the last Copilot review (exact activation keys) is fixed in d4e284b.
The stage2 FP8 lookup now reads only the exact-key dict of tuned_stage2_fp8_fmoe. It does not read the act_type-agnostic dict of read_table. Thus a Silu row of this table does not replace the main row of a SiTUv2 or Swiglu call. The token-tier fallback stays.
test_stage2_fp8_row_keeps_main_row_of_other_activation adds a SiTUv2 main row at 8192 tokens and checks that the switch keeps it. With aiter/fused_moe.py of 24a6d8a, this test fails. At d4e284b, the 8 tests of op_tests/test_moe_stage2_fp8_rows.py pass on MI355X.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed to assess run-only deployment readiness because the production MoE dispatch change cannot be GPU-validated here and the full default FP8-enabled AOT build remains unverified.
…_STAGE2_FP8=1 (#8669)
* [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1
A tuned fmoe row serves both modes of AITER_FLYDSL_STAGE2_FP8. For some
shapes, the fastest row depends on the mode. Qwen3.8 MXFP4 E 513 at 8192
to 32768 tokens: the one-stage post-reduce rows of
#5988 are the fastest with the switch
off. FlyDSL reduce rows with FP8 route rows are faster with it on.
Add the family tuned_stage2_fp8_fmoe (AITER_CONFIG_FMOE_STAGE2_FP8).
With AITER_FLYDSL_STAGE2_FP8=1, get_2stage_cfgs reads it after the main
table, like the swiglu_limit table. Its row replaces the main row when
the row is for the same token tier or a larger one.
- Add the Qwen3.8 rows: the FlyDSL reduce rows of the parent of
#5988.
- gemm_moe_tune.py --run_config times the given table only.
- Add a dispatch test and the family to the shape collision test.
Co-authored-by: Cursor <[email protected]>
* [MoE] AOT: replay the stage2 FP8 rows when AITER_FLYDSL_STAGE2_FP8=1
The AOT build replays only the main, FHMoE and grouped tables, and it
skips each row that does not reach FlyDSL. The main rows of the stage2
FP8 shapes are one-stage ASM rows, so the build never compiled the
FlyDSL rows that the runtime selects with the switch on.
- aiter/aot/flydsl/moe.py: add the stage2 FP8 family to DEFAULT_CSVS
when the switch is on.
- op_tests/test_moe_stage2_fp8_rows.py: check that the AOT jobs include
the Qwen3.8 rows only with the switch on. Use get_gfx_runtime() for
the skip. Add a __main__ entry, because aiter_test.sh runs
"python3 <file>".
Co-authored-by: Cursor <[email protected]>
* [MoE] Use only exact act_type rows of the stage2 FP8 table
The stage2 FP8 lookup also read the act_type-agnostic dict of read_table.
Then a Silu row of the table could replace the main row of another
activation (for example SiTUv2) with the same other keys.
Keep only the primary dict. The token-tier fallback stays.
Add a SiTUv2 regression test.
Review: #8669
Co-authored-by: Cursor <[email protected]>
---------
Co-authored-by: Cursor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
AITER_FLYDSL_STAGE2_FP8=1,fused_moestill runs the row of the main tuned table, and a one-stage row has no stage 2 that can write FP8 route output. So a tuned shape can hold the fastest row for the switch off or the fastest row for the switch on, not both. This PR adds a second table,tuned_stage2_fp8_fmoe, thatget_2stage_cfgsreads only when the switch is on, and adds the three Qwen3.8-2.4T MXFP4 rows that need it. With the switch off, nothing changes.Motivation
This is a tuned-config selection change: with
AITER_FLYDSL_STAGE2_FP8=1, Qwen3.8-2.4T MXFP4 (E 513, top-k 11) at 8192, 16384 and 32768 tokens runs FlyDSLreducerows from the new table in place of the one-stage Q256 rows of the main table, and thefused_moecall is 14% to 19% faster on one MI355X.Rocm/aiter5988 moved these three shapes from FlyDSL two-stage rows to
fmoe_bf16_pertokenMXfp4_g1u1_silu_prefill_1tg_4w_256mx1_128nx1_ps_fp32gate_route(flat=3). With the switch off, the Q256 rows are the fastest. With the switch on, the old FlyDSL rows are faster, because their stage 2 writes FP8 route output and the Q256 kernel ignores the switch:AITER main
ffbd9c6ac, one MI355X,gemm_moe_tune.py --run_config, median of 2 GPUs. In SGLang serving with the switch on (8x MI355X, TP8, with and without NEXTN, geomean over 12 to 14 cells with ISL 8192 to 128000), the Q256 rows give 98.4% to 99.0% of the output throughput of the FlyDSL rows.Today the only way to get the FlyDSL rows with the switch on is to point
AITER_CONFIG_FMOEat a copy of the whole table. That copy then misses each later row change in AITER.The same conflict can reach other models. Rocm/aiter8020 replaced the Kimi K3 MXFP4 row at 16384 tokens (E 384, top-k 16), a FlyDSL MXMOE stage 1 with a FlyDSL
reducestage 2, by a one-stage producer row (flat=3). The vLLM and ATOM recipes for Kimi K3 setAITER_FLYDSL_STAGE2_FP8=1, so a deployment of that shape with the switch now runs a row that ignores it. We did not measure it. For Qwen3.8-Flash-Next at 16384 tokens, Rocm/aiter8044 proposes a producer row (1094 to 1015 us) and Rocm/aiter8174 reports FP8 route output (1137.6 to 918.4 us). The two PRs use different harnesses, so the numbers do not compare directly, but the choice there also depends on the switch.Other ways we looked at:
_tagfor FP8 rows in the main CSV. Rocm/aiter7720 makes the merge read_tagonly for fallback or live rows, and two live rows with the same key collide.scatterstage 2 to thereducestage 2 of the same tile. A one-stage row has no stage 2. The two PRs compose: after Rocm/aiter8174 merges, the lookup in this PR can also read itsstage2_fp8flag.AITER_SELECT=power(Rocm/aiter6970). It works only for each process, so it cannot serve the per-call flag of Rocm/aiter8174.Changes
aiter/jit/core.py:AITER_CONFIG_FMOE_STAGE2_FP8andAITER_CONFIGS.AITER_CONFIG_FMOE_STAGE2_FP8_FILE. The family works liketuned_swiglu_limit_fmoe: a header-onlyaiter/configs/tuned_stage2_fp8_fmoe.csvplusaiter/configs/model_configs/*tuned_stage2_fp8_fmoe*.csv. The glob of the main family (*tuned_fmoe*) does not match the new files, so the main table does not change.aiter/fused_moe.py,get_2stage_cfgs: when the switch is on, look up the new table after the main lookup. Its row replaces the main row only when its token tier is the same as or larger than the tier of the main row, so the padded-M fallback cannot put a 32768 FP8 row over a 131072 main row._lookup_cfgnow also returns the tier it found. The lookup reads only the exact-key dict of the new table, not the act_type-agnostic dict ofread_table. Each replacement logs one info line.config_file, or when the call has aswiglu_limit(the clamp is a correctness requirement, so that table wins). It is read whenAITER_CONFIG_FMOEis set, because an engine can set that variable to a merged copy of the default tables.gemm_moe_tune.py:--run_config <file>times the rows of that file also with the switch on (the tuner empties the FP8 table).--run_configwith no file times the default selection, the FP8 table included.aiter/aot/flydsl/moe.py: with the switch on, the AOT build also replays the new table. The build replays the main, FHMoE and grouped tables and skips each row that does not reach FlyDSL, so it skipped the three Q256 rows and never built the FP8 rows.aiter/configs/model_configs/qwen3_8_2400b_fp4_tuned_stage2_fp8_fmoe.csv: the three E 513 rows (8192, 16384 and 32768 tokens) that Rocm/aiter5988 replaced, copied unchanged from the main table before that PR.Performance (if applicable)
fused_moe, Qwen3.8-2.4T MXFP4, E 513, top-k 11, 8192 tokens,AITER_FLYDSL_STAGE2_FP8=1gemm_moe_tune.py --run_configwith random routing, median of 2 GPUs of one node. With the switch on, "Before" is the main table (--run_config <main table>, which this PR keeps free of FP8 rows) and "After" is the default selection of this PR (--run_configwith no file). With the switch off, "Before" is AITER mainffbd9c6acon the same node. A second run of each arm agrees within 0.3%. The FP8 rows of this PR take the same time as the same rows on AITER main with the switch on (within 1%). These numbers are atd362a33b2. At24a6d8a4d, after the merge of main, the same arms agree with them within 0.5%.Accuracy
The new rows run the same kernels as the main table before Rocm/aiter5988, and only with the switch on. We ran the Qwen3.8 evals with that pair in SGLang (TP8, NEXTN), against the same model with the switch off:
The two arms ran on different nodes. All scores are in the noise. In the kernel benchmark,
checkAllclose(atol and rtol 0.01) fails for 77.7% to 77.9% of the elements with FP8 route output and for 69.1% to 69.5% without it. The status is OK for all rows. Other models get no change until their owners add rows to the new table.Testing
Documentation
No user guide lists the tuned-config families or the
AITER_CONFIG_FMOE_*variables, so this PR adds none.Dependencies
Breaking Changes
None. With the switch off, or with no row in the new table, the selection is the same as before.
PR Self-Review
Reviewed revision
d4e284b
Behavior and intent
With
AITER_FLYDSL_STAGE2_FP8=1,get_2stage_cfgsnow takes a row fromtuned_stage2_fp8_fmoewhen that table has one for the shape, at the same token tier as the main row or a larger one. Before, the switch could not change the row, so a one-stage row in the main table stopped the FP8 route output for its shape. The main table and the selection with the switch off do not change.Validation and unverified scope
On one MI355X node at
d4e284b23:python3 op_tests/test_moe_stage2_fp8_rows.py(asaiter_test.shruns it): 8 passed. Withaiter/fused_moe.pyof24a6d8a4d, the new SiTUv2 test fails and the other 7 pass.pytest op_tests/test_moe_mxfp4_inter_dim_dispatch.py op_tests/tuning_tests/test_config_shape_collision.py -k "stage2_fp8 or fmoe or mxfp4 or cktile": 29 passed.pytest tests/test_moe_dispatch_snapshot.py: 3 passed.On the same node at
24a6d8a4d. The change ofd4e284b23does not change the lookup of a Silu call, because the new table has only Silu rows:python3 csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py -i <untuned E 513 rows, 8192 to 32768 tokens> --run_config [<table>], with the switch off and on, see "Performance".AITER_FLYDSL_STAGE2_FP8=1 python3 -m aiter.aot.flydsl.moe --csv <merged tuned_stage2_fp8_fmoe.csv> --row-tokens-onlyinto an empty FlyDSL cache: 3 kernels, 6 replays OK. Thengemm_moe_tune.py --run_configwith the switch on andFLYDSL_RUNTIME_RUN_ONLY=1on that cache: the three FP8 rows run and the status is OK.What remains unverified:
AITER_CONFIG_FMOEtable on AITER0e072ca50.get_2stage_cfgscaches its result for each shape. A process that changes the switch after the first call of a shape keeps the row of the first call. The stage 2 launcher reads the switch at each call.PR-specific question
The new lookup runs only on the default path:
AITER_FLYDSL_STAGE2_FP8=1, noconfig_fileand noswiglu_limit. A row of the new table applies only to its exactget_2stage_cfgskey: gfx, CU count, padded token count, model_dim, inter_dim, expert, top-k, activation, dtype, both quant dtypes, quant type, g1u1 and doweight_stage1. The lookup does not use the act_type-agnostic dict ofread_table, so a Silu row of the new table does not apply to a SiTUv2 or Swiglu call. The only other match is the existing padded-M fallback above 32768 tokens, and the tier check keeps a fallback FP8 row from replacing a main row of a larger tier. The three rows of this PR are gfx950 with 256 CUs, bf16 input with MXFP4 (fp4x2, per_1x32) activations and weights, model_dim 8192, inter_dim 256, E 513, top-k 11, at 8192, 16384 and 32768 tokens. The main table had these rows for the same keys before Rocm/aiter5988, so the kernels already served these shapes. Any other key, and every call with the switch off, gets the main row as before.Changed op tests
op_tests/test_moe_stage2_fp8_rows.py(new): callsget_2stage_cfgsfor the Qwen3.8 shape with the switch off and on. It checks the Q256 row with the switch off and the FlyDSL row (block_m, stage 2 kernel) with the switch on at 8192, 16384 and 32768 tokens. It also checks that 4096 tokens (no FP8 row) do not change, that 131072 tokens take the 32768 FP8 row through the fallback, that a main row at 131072 is not replaced by the 32768 FP8 row, and that a SiTUv2 main row with the same other keys is not replaced by the Silu FP8 row. A last test checks that the AOT job list ofaiter/aot/flydsl/moe.pyhas the three rows with the switch on and not with the switch off. It runs in a new process, because the module reads the switch at import. The file needs a gfx950 GPU with 256 CUs (get_gfx_runtime()), because the rows are keyed on them, and it runs underpython3 <file>. No other test covers the new lookup.op_tests/tuning_tests/test_config_shape_collision.py: adds the new family to the list of families whose rows must not collide.AI assistance (Claude) was used to measure and draft this change. All changes reviewed.