Skip to content

[CK] [FlyDSL] [JIT] [MoE] Add a stage2 FP8 row table for AITER_FLYDSL_STAGE2_FP8=1 - #8669

Merged
JohnNikolay84 merged 4 commits into
ROCm:mainfrom
omirosh:qwen38-stage2-fp8-rows
Nov 26, 2026
Merged

JohnNikolay84 merged 4 commits into
ROCm:mainfrom
omirosh:qwen38-stage2-fp8-rows

Conversation

@omirosh

@omirosh omirosh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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:

Eval Switch on, FlyDSL rows Switch off Noise of one run
GSM8K chat, 5-shot, 1319 questions, flexible-extract 0.9742 0.9727 about 2 points
GPQA Diamond, one run, temperature 1.0 0.919 0.929 about 3 points
NIAH single_2, 64k / 128k 0.998 / 0.998 0.998 / 0.994 about 0.5 points

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.

PR Self-Review

Reviewed revision

d4e284b

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, 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]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 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.

@omirosh
omirosh requested a review from amd-bartgips November 25, 2026 09:17
@omirosh
omirosh marked this pull request as ready for review November 25, 2026 11:24
@omirosh
omirosh requested review from a team and a balanced review from Copilot November 25, 2026 11:24
@github-actions github-actions Bot 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
@aiter-bot

aiter-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision d4e284b23791 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

3 open issues
What changed in this PR

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.
File Description
op_tests/​tuning_tests/​test_config_shape_collision.py Adds collision checks for the new config family.
op_tests/​test_moe_stage2_fp8_rows.py Tests switch-dependent selection and token-tier fallback.
csrc/​ck_gemm_moe_2stages_codegen/​gemm_moe_tune.py Disables FP8 overrides when benchmarking explicit tables.
aiter/​jit/​core.py Registers the FP8 config path and family loader.
aiter/​fused_moe.py Adds conditional FP8 row selection with tier precedence.
aiter/​configs/​untuned_stage2_fp8_fmoe.csv Defines the untuned family’s header.
aiter/​configs/​tuned_stage2_fp8_fmoe.csv Defines the tuned family’s header.
aiter/​configs/​model_configs/​qwen3_8_2400b_fp4_tuned_stage2_fp8_fmoe.csv Adds FP8-mode rows for 8192, 16384 and 32768 tokens.

Review effort: Balanced

Comment thread aiter/fused_moe.py Resolved
Comment thread op_tests/test_moe_stage2_fp8_rows.py Resolved
Comment thread op_tests/test_moe_stage2_fp8_rows.py Resolved
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]>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:07
@github-actions github-actions Bot 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Restrict FP8 lookup to exact activation keys

aiter/​fused_moe.py:4729

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.

2 resolved since last review

Review effort: Balanced

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]>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:36
@omirosh

omirosh commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@JohnNikolay84
JohnNikolay84 merged commit 0450061 into ROCm:main Nov 26, 2026
63 of 64 checks passed
jcaraban pushed a commit that referenced this pull request Nov 26, 2026
…_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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants