Skip to content

[FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default - #8353

Closed
jatseng-ai wants to merge 1 commit into
ROCm:mainfrom
jatseng-ai:fix-8334-clamped-silu-ck-routing
Closed

jatseng-ai wants to merge 1 commit into
ROCm:mainfrom
jatseng-ai:fix-8334-clamped-silu-ck-routing

Conversation

@jatseng-ai

@jatseng-ai jatseng-ai commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On gfx942 a clamped per-token FP8 SiLU that CK can clamp is routed to the FlyDSL whole-graph default, whose metadata has stage1=None. The dispatch test added by #7361 dereferences it and crashes. Route those calls back to CK.

Motivation

test_plain_fp8_swiglu_limit_dispatch reads md.stage1.keywords. On main, a clamped per-token FP8 SiLU on gfx942 takes the FlyDSL whole-graph default from #7820 / #8178, whose metadata has stage1=None, so the test fails with AttributeError: 'NoneType' object has no attribute 'keywords'. MI300X shard 5 is red on main for this reason — most recently run 45246107786 (2026-11-23), where the other seven shards passed.

The route is also the wrong one for these calls. The whole-graph backend clamps the BF16 activations it reads; the call and the tuned rows from #7361 ask for the per-token path, where the clamp lands after quantization. That is a difference in quantization point, not an accuracy defect — the accuracy claim in #8334 is retracted, and #8350 fixes the test reference so cross-backend cases are compared on the backend's own terms.

Changes

  • Keep the gfx942 FlyDSL whole-graph default only where CK rejects the shape (inter_dim not a multiple of 128, including V4.1-Flash at 576). CK's runtime-limit stage-1 takes the rest.
  • The new predicate is the one the NotImplementedError gate below already uses, which is what defines what that stage-1 accepts, so the two cannot drift.
  • A tuned impl__flydsl_gfx942__ row still wins. This does not revert [CK] [JIT] [aiter] Clamp FP8 per_Token / per_Tensor SiLU on #7019's runtime swiglu_limit #7361.

Performance (if applicable)

Not applicable: dispatch only. The affected calls move to the CK runtime-limit stage-1 that #7361 tuned and measured.

Testing

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

See below for what was verified and on what hardware.

Documentation

  • No documentation change is needed, with the reason stated below

Dispatch fix; the swiglu_limit contract is unchanged.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None.

PR Self-Review

Reviewed revision

a90643b

Behavior and intent

A clamped per-token FP8 SiLU that CK can clamp stays on the CK runtime-limit stage-1 instead of the gfx942 FlyDSL whole-graph default. Calls CK cannot clamp (inter_dim not a multiple of 128) still take that default, and a tuned FlyDSL row still wins.

Validation and unverified scope

Reproduced and fixed on an MI308X (gfx942, 80 CU), driving get_2stage_cfgs directly at the dispatch test's shape (2048, 768, 128, 8):

main (0d92e85) this branch
per_Token, tokens 1/64/1024, limits 7.0/5.0 6/6 return stage1=None with full_impl set — the route the test dereferences 0/6
per_Tensor, same grid CK CK

With the fix, per_Token token=64 L=7 resolves to stage1.func is ck_moe_stage1, run_1stage false, ksplit 0. inter_dim=192 still takes FlyDSL for per_Token (full_impl set, stage1=None) and still raises NotImplementedError naming swiglu_limit for per_Tensor. swiglu_limit None / 0.0 / inf leave run_1stage unchanged.

op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch passes on this branch and fails against main's aiter/fused_moe.py.

validate-kernel-pr was run on this exact head (a90643b5684f, base 0d92e854495d, target op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch, head and base on the same worktree and GPU with the patch reversed for the baseline). It reports no correctness finding. The verdict is INCONCLUSIVE rather than a pass for three reasons, none of which is the diff: GPU activity counters are unavailable in this container so idleness was inferred from resident VRAM, no shape-grid hook is configured, and the test-policy analyzer itself raised ValueError: could not convert string to float: 'E'.

Unverified here: the numerical sweep test_plain_fp8_swiglu_limit and the rest of test_moe_2stage — the gfx942 machine available to me has 3rdparty/composable_kernel uninitialized, so the CK MoE modules do not build on it, and at 80 CU no row in a8w8_plain_tuned_swiglu_limit_fmoe_gfx942.csv (all keyed cu_num=304) is selected. The dispatch half above is CU-independent and is what the red shard crashes on.

Depends on #8531: landing this first turns MI300X shard 5 from the AttributeError into Unknown or incompatible CK MoE kernel, because a 304-CU limit-7 call then selects a tuned gfx942 row that the gfx942;gfx950 wheel never built.

PR-specific question

What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?

op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch fails on base: it asserted the Qwen bypass (inter_dim 512) takes the FlyDSL whole-graph default, which is the routing this PR corrects. Verified both ways on an MI308X (gfx942): the test passes on this branch and fails against main's aiter/fused_moe.py.

op_tests/test_moe_2stage.py::test_plain_fp8_swiglu_limit_dispatch fails on base by crashing: it dereferences md.stage1.keywords for a route whose metadata has stage1=None. That is the red shard on main (run 45246107786).

No canonical test covers this. test_plain_fp8_swiglu_limit is the numerical check for the same shapes and asserts output values, not which backend ran, so it stays green whichever backend takes the call — which is exactly how the misroute survived from #7820 until the dispatch test was added by #7361.

Changed op tests

op_tests/test_moe_2stage.py covers the gfx942 per-token inter_dim 192 case taking FlyDSL while per-tensor still raises. That split is what this change does, and no existing test asserted it.

op_tests/test_flydsl_moe_gfx942.py covers the bypass split: Qwen inter_dim 512 stays on CK, V4.1-Flash inter_dim 576 stays on FlyDSL. The previous assertion required FlyDSL for the Qwen bypass, which is the bug.

Both are edits to existing dispatch tests, not new files.

@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 8353 --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-actions github-actions Bot changed the title [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default Nov 20, 2026
zufayu
zufayu previously approved these changes Nov 20, 2026
@zufayu zufayu added the ci:mi300x Run MI300X standard and OPUS CI on PRs label Nov 20, 2026
@ROCm ROCm deleted a comment from aiter-bot Nov 20, 2026
@aiter-bot

aiter-bot commented Nov 20, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision a90643b5684f · 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

A clamped per-token FP8 SiLU that CK can clamp stays on the CK runtime-limit stage-1 instead of the gfx942 FlyDSL whole-graph default. Calls CK cannot clamp (`inter_dim` not a multiple of 128) still take that default, and a tuned FlyDSL row still wins.

Validation and unverified scope

Reproduced and fixed on an MI308X (gfx942, 80 CU), driving `get_2stage_cfgs` directly at the dispatch test's shape `(2048, 768, 128, 8)`:

| | main (`0d92e85`) | this branch |
|---|---|---|
| per_Token, tokens 1/64/1024, limits 7.0/5.0 | 6/6 return `stage1=None` with `full_impl` set — the route the test dereferences | 0/6 |
| per_Tensor, same grid | CK | CK |

With the fix, per_Token token=64 L=7 resolves to `stage1.func is ck_moe_stage1`, `run_1stage` false, `ksplit` 0. `inter_dim=192` still takes FlyDSL for per_Token (`full_impl` set, `stage1=None`) and still raises `NotImplementedError` naming `swiglu_limit` for per_Tensor. `swiglu_limit` None / 0.0 / inf leave `run_1stage` unchanged.

`op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch` passes on this branch and fails against main's `aiter/fused_moe.py`.

`validate-kernel-pr` was run on this exact head (`a90643b5684f`, base `0d92e854495d`, target `op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch`, head and base on the same worktree and GPU with the patch reversed for the baseline). It reports no correctness finding. The verdict is `INCONCLUSIVE` rather than a pass for three reasons, none of which is the diff: GPU activity counters are unavailable in this container so idleness was inferred from resident VRAM, no shape-grid hook is configured, and the test-policy analyzer itself raised `ValueError: could not convert string to float: 'E'`.

Unverified here: the numerical sweep `test_plain_fp8_swiglu_limit` and the rest of `test_moe_2stage` — the gfx942 machine available to me has `3rdparty/composable_kernel` uninitialized, so the CK MoE modules do not build on it, and at 80 CU no row in `a8w8_plain_tuned_swiglu_limit_fmoe_gfx942.csv` (all keyed `cu_num=304`) is selected. The dispatch half above is CU-independent and is what the red shard crashes on.

Depends on #8531: landing this first turns MI300X shard 5 from the `AttributeError` into `Unknown or incompatible CK MoE kernel`, because a 304-CU limit-7 call then selects a tuned gfx942 row that the `gfx942;gfx950` wheel never built.

PR-specific question

What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?

`op_tests/test_flydsl_moe_gfx942.py::test_num_local_tokens_dispatch` fails on base: it asserted the Qwen bypass (`inter_dim` 512) takes the FlyDSL whole-graph default, which is the routing this PR corrects. Verified both ways on an MI308X (gfx942): the test passes on this branch and fails against main's `aiter/fused_moe.py`.

`op_tests/test_moe_2stage.py::test_plain_fp8_swiglu_limit_dispatch` fails on base by crashing: it dereferences `md.stage1.keywords` for a route whose metadata has `stage1=None`. That is the red shard on main (run 45246107786).

No canonical test covers this. `test_plain_fp8_swiglu_limit` is the numerical check for the same shapes and asserts output values, not which backend ran, so it stays green whichever backend takes the call — which is exactly how the misroute survived from #7820 until the dispatch test was added by #7361.

Changed op tests

`op_tests/test_moe_2stage.py` covers the gfx942 per-token `inter_dim` 192 case taking FlyDSL while per-tensor still raises. That split is what this change does, and no existing test asserted it.

`op_tests/test_flydsl_moe_gfx942.py` covers the bypass split: Qwen `inter_dim` 512 stays on CK, V4.1-Flash `inter_dim` 576 stays on FlyDSL. The previous assertion required FlyDSL for the Qwen bypass, which is the bug.

Both are edits to existing dispatch tests, not new files.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

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
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu zufayu removed the ci:mi300x Run MI300X standard and OPUS CI on PRs label Nov 20, 2026
@jatseng-ai

Copy link
Copy Markdown
Contributor Author

The dispatch crash is fixed here. MI300X shard 5 then fails one step later, and that failure is not this routing change.

test_plain_fp8_swiglu_limit passes per-token limit 1.0 (no tuned row, default heuristic, prebuilt runtime-limit module) and dies on limit 7.0:

RuntimeError: Unknown or incompatible CK MoE kernel: moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_v1_Nswizzle0_Quant2_MulRoutedWeight0_silu_F8_F8_B16

At 304 CUs, limit 7 uses the tuned gfx942 rows from #7361. ci:mi300x prebuilds with GPU_ARCHS=gfx942;gfx950, and get_gfx() returns the last entry, so the wheel's CK MoE module contains the gfx950 TypeCast list and not those gfx942 MulABScale instances. The default heuristic still runs on gfx942, which is why the untuned limit passes. The configurable limit is intact. Dropping the tuned rows would only hide this and lose the tuned tile.

#8397 emits both arch lists into that module and leaves the heuristic on get_gfx(). A tuned row still wins. The lookup check passes for both GPU_ARCHS orders. A dual-arch hipcc build of the module is still open.

@jatseng-ai
jatseng-ai force-pushed the fix-8334-clamped-silu-ck-routing branch from ca91b9f to f0e28ec Compare November 20, 2026 17:22
@github-actions github-actions Bot changed the title [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default [CK] [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default Nov 20, 2026
@github-actions github-actions Bot added the CK label Nov 20, 2026
@jatseng-ai jatseng-ai changed the title [CK] [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances Nov 20, 2026
@jatseng-ai

jatseng-ai commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

This branch is rebased onto current main and now has both commits:

  • 99c87b686 keeps CK-capable clamped per-token SiLU on the CK stage-1
  • f0e28ecae emits the gfx942 CK MoE instances into a GPU_ARCHS=gfx942;gfx950 build, so the tuned limit-7 rows have a kernel to dispatch

Routing alone still dies on Unknown or incompatible CK MoE kernel for the tuned MulABScale tile. The instance-list change alone still crashes the dispatch test on stage1 is None. Both are in this PR so MI300X CI covers them together. The rebase dismissed the earlier approval.

@jhinpan

jhinpan commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

The MI300X run of this PR fails in test_moe_2stage.py (shard 5) at test_plain_fp8_swiglu_limit(per_Token, token=1, swiglu_limit=7.0):

RuntimeError: Unknown or incompatible CK MoE kernel: moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_v1_Nswizzle0_Quant2_MulRoutedWeight0_silu_F8_F8_B16; regenerate instances or retune this configuration

The routing change itself works there: the case just before it (limit 1.0, default CK config) passes. I found this while testing #6277, which carries a cherry-pick of this PR.

Cause. The CI wheel is built with GPU_ARCH_LIST: gfx942;gfx950. For a multi-arch GPU_ARCHS, get_gfx() returns the last entry (chip_info.py#L79-L82). So get_gemm1_kernels_list (L384, L407) builds every prebuilt CK MoE module from the a8w8_gfx950 list (L151). That list has no MPerBlock=16 tiles. The gfx942 list a8w8 (L167-L182) has three, including 256x16x64x256.

Five rows in a8w8_plain_tuned_swiglu_limit_fmoe_gfx942.csv use 256x16x64x256. The prebuilt module_moe_ck2stages_abi2_f8_f8_preshuffle_on_b16_silu_per_token_mulWeightStage2_runtime_swiglu_limit does not contain it, and the exact lookup for a clamped call raises (gemm_moe_ck2stages.cu#L56).

Check. Codegen only, no GPU: gen_instances.py -a f8 -b f8 -c b16 -q per_token -act silu -m 2 --runtime-swiglu-limit.

GPU_ARCHS Stage-1 instances 256x16x64x256
gfx942;gfx950 (wheel) 8 absent
gfx942 (native JIT) 14 present

This matches @zufayu's note in #8334: the instance exists in a locally JIT-built module but not in the prebuilt wheel.

Possible fixes:

  • Retune the gfx942 clamp rows using only tiles present in both lists. This is the smallest change.
  • Generate each target's tile list in multi-arch builds (the TODO in chip_info.py).
  • Skip prebuilding these modules for multi-arch wheels, so they JIT-build for the native arch.
  • Allow the heuristic fallback inside the runtime-limit module. Every stage-1 instance there is built with the runtime limit (gen_instances.py#L957-L959), so a fallback kernel still clamps.

Without the exact-match requirement, the same gap falls back to the heuristic kernel silently. Other gfx942 tuned rows with 16-row tiles may therefore lose their tuned kernel in the multi-arch wheel too. I have not checked that.

@jatseng-ai

Copy link
Copy Markdown
Contributor Author

The MI300X job linked above built ca91b9f88, the routing-only commit. Head is now f0e28ecae. That commit emits both the gfx942 and gfx950 CK MoE instance lists in a GPU_ARCHS=gfx942;gfx950 build, and guards the gfx942-only tiles so they are not compiled for gfx950.

On an MI300X (gfx942, 304 CU) with GPU_ARCHS=gfx942;gfx950, per-token limit 7.0 selects moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_v1_Nswizzle0_Quant2_MulRoutedWeight0_silu_F8_F8_B16 at tokens 1 and 64, and the 256x64 row at 1024. The launch returns. Logits distance to clamp-before-SiLU is about 1e-5. The parent commit, same arch string, reproduces the error in this comment after a successful build whose module does not contain that tile. GPU_ARCHS=gfx950;gfx942 on the parent does not compile: the unguarded gfx942 tiles fail the KPack/wave-size static assert when gfx950 is also a target.

This does not change the blockscale per_1x128 path or the bf16 FlyDSL path. The gfx942 FlyDSL default added here is per-token FP8 only, and only where CK cannot apply the clamp. On a native gfx942 build of this head, blockscale limits 7, 5, 3, and 1 still bind on the CK runtime-limit module and match clamp-before-SiLU, with the same single no-limit ASM row as before. A bf16 clamp still routes to FlyDSL. The instance-list change widens the lookup and leaves the heuristic on the last GPU_ARCHS entry, so it does not retarget a blockscale row.

Retuning those gfx942 rows onto a shared tile, or dropping the exact-match check, would give up the tuned kernel. This branch keeps the row and ships the instance.

@jatseng-ai

Copy link
Copy Markdown
Contributor Author

Recording the decisions on this thread:

jhinpan’s shard-5 log is the routing-only SHA. Head f0e28ecae is the map fix. The unexplained kernel on #8334 is this. Nothing further is planned here for that miss. Remaining work is a fresh review (the rebase dismissed the earlier approval) and the numerical sweep boxes in the test plan.

@jatseng-ai

Copy link
Copy Markdown
Contributor Author

gfx942 numerical sweep on this head, after the rebase.

f0e28ecae, MI300X (304 CU), GPU_ARCHS=gfx942;gfx950, fresh AITER_JIT_DIR. Dual-arch hipcc of both ..._per_token_..._runtime_swiglu_limit and ..._per_tensor_..._runtime_swiglu_limit succeeded. test_plain_fp8_swiglu_limit_dispatch passed. Official 30 cases passed. Extra L=3.0 and 5.0 (no CSV row; must still clamp) also passed.

Per-token L=7 at tokens 1 and 64 selected the tuned moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_…. L=1/3/5 logged no row … using default config and still clamped (unclamped row err 2.3–88, L=1 swapped-order ≥ 0.35). None / 0 / inf stayed unclamped.

quant 2 = per_Token, 1 = per_Tensor:

|   quant_type |   token |   swiglu_limit | gfx    |   unclamped row err |   swapped row err |   fused_moe err |   fused_moe row err |
|-------------:|--------:|---------------:|:-------|--------------------:|------------------:|----------------:|--------------------:|
|            2 |       1 |            nan | gfx942 |           nan       |        nan        |     0.00390625  |          0.00430624 |
|            2 |       1 |              0 | gfx942 |           nan       |        nan        |     0.00634766  |          0.00441305 |
|            2 |       1 |            inf | gfx942 |           nan       |        nan        |     0.00341797  |          0.00433616 |
|            2 |       1 |              1 | gfx942 |            88.7607  |          0.350676 |     0           |          0.00425029 |
|            2 |       1 |              7 | gfx942 |             1.48157 |        nan        |     0.000488281 |          0.00433328 |
|            2 |      64 |            nan | gfx942 |           nan       |        nan        |     0.269569    |          0.030854   |
|            2 |      64 |              0 | gfx942 |           nan       |        nan        |     0.268738    |          0.0309592  |
|            2 |      64 |            inf | gfx942 |           nan       |        nan        |     0.269409    |          0.0310051  |
|            2 |      64 |              1 | gfx942 |            80.6006  |          0.348088 |     0           |          0.00484589 |
|            2 |      64 |              7 | gfx942 |             1.25397 |        nan        |     0.00025177  |          0.00489542 |
|            2 |    1024 |            nan | gfx942 |           nan       |        nan        |     0.27111     |          0.0360519  |
|            2 |    1024 |              0 | gfx942 |           nan       |        nan        |     0.270883    |          0.0360968  |
|            2 |    1024 |            inf | gfx942 |           nan       |        nan        |     0.271217    |          0.0360928  |
|            2 |    1024 |              1 | gfx942 |            74.6902  |          0.346443 |     0           |          0.034752   |
|            2 |    1024 |              7 | gfx942 |             1.10882 |        nan        |     0.00387812  |          0.0278257  |
|            1 |       1 |            nan | gfx942 |           nan       |        nan        |     0.00341797  |          0.00441414 |
|            1 |       1 |              0 | gfx942 |           nan       |        nan        |     0.00488281  |          0.004252   |
|            1 |       1 |            inf | gfx942 |           nan       |        nan        |     0.00488281  |          0.00426376 |
|            1 |       1 |              1 | gfx942 |            88.2047  |          0.350404 |     0           |          0.00431919 |
|            1 |       1 |              7 | gfx942 |             1.46647 |        nan        |     0           |          0.00427299 |
|            1 |      64 |            nan | gfx942 |           nan       |        nan        |     0.00373077  |          0.00478705 |
|            1 |      64 |              0 | gfx942 |           nan       |        nan        |     0.00369263  |          0.00475784 |
|            1 |      64 |            inf | gfx942 |           nan       |        nan        |     0.0036087   |          0.00486469 |
|            1 |      64 |              1 | gfx942 |            79.182   |          0.348255 |     0           |          0.00504497 |
|            1 |      64 |              7 | gfx942 |             1.26387 |        nan        |     0.00037384  |          0.00530767 |
|            1 |    1024 |            nan | gfx942 |           nan       |        nan        |     0.0039134   |          0.00522011 |
|            1 |    1024 |              0 | gfx942 |           nan       |        nan        |     0.00390863  |          0.00526672 |
|            1 |    1024 |            inf | gfx942 |           nan       |        nan        |     0.00392675  |          0.00541848 |
|            1 |    1024 |              1 | gfx942 |            74.4516  |          0.346838 |     0           |          0.00501059 |
|            1 |    1024 |              7 | gfx942 |             1.0955  |        nan        |     0.000265598 |          0.00524908 |

Unclamped per_Token at 64+ is the known ASM 1-stage (~27% outside 0.05); row error stayed under 0.05. gfx950 sweep is still open.

@jatseng-ai

jatseng-ai commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

gfx950 (MI355X, 256 CU) on this head f0e28ecae. Dual-arch hipcc is done. The official 30-case test_plain_fp8_swiglu_limit sweep was not this run.

Dual-arch compile (gen_instances.py --runtime-swiglu-limit, empty AITER_JIT_DIR):

GPU_ARCHS commit files MulABScale the 12 CSV names 256x16 tile
gfx942;gfx950 f0e28ecae 49 33, every one __gfx942__ all present present, guarded
gfx950;gfx942 f0e28ecae 49 33, all guarded all present present, guarded
gfx950 f0e28ecae 16 0 all 12 absent absent
gfx942;gfx950 base 50bfa78d0 16 0 all 12 absent absent
gfx950;gfx942 base 50bfa78d0 33 33, unguarded all present present, unguarded

Both orders on head compiled (~118s, .so ~13.5 MB). The CI-shaped base build (gfx942;gfx950) is the missing-tile wheel. The reverse order on base emits the gfx942 list unguarded.

Stock unclamped (swiglu_limit=None, per_Token, (2048, 768, 128, 8), N=20): statistically indistinguishable from base. Not bitwise. Token 1 is CK 2-stage with stage-2 AtomicAdd at topk 8; tokens 64/1024 are ASM 1-stage (same .co bytes on both commits). fused_moe(deterministic=True) does not apply here (MXFP4-only). This is not a clamp check.

Lookup on this GPU: live dtypes.fp8 is e4m3fn. Forcing get_gfx_runtime=gfx942, CU=304, and e4m3fnuz selects moe_ck2stages_gemm1_256x16x64x256_…MulABScale… at tokens 1/64. Leaving the gfx950 dtype in place does not (kernelName1 empty, block_m 32). A gfx950 process will not launch the gfx942 tile by accident.

Host-side test_num_local_tokens_dispatch under a gfx942 patch: Qwen inter_dim 512 stays CK; V4.1 inter_dim 576 stays FlyDSL. The test file itself returns immediately on this GPU (get_gfx() != gfx942). No FlyDSL kernel was launched.

Still open on this PR: test_plain_fp8_swiglu_limit 30-case on gfx950 under dual-arch (GPU_ARCHS=gfx942;gfx950). On that run, L=7 must log no row for ('gfx950', …) with swiglu_limit=7 and launch heuristic TypeCast, not the gfx942 256x16…MulABScale name.

@jatseng-ai

jatseng-ai commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Correction on scope: the remaining gfx950 30-case box is optional coverage for this module, not a gate for landing this PR or for a tag that includes #7361. The serving path this unblocks is MI300X (gfx942), already swept on this head.

gfx950 is in this PR because CI wheels are GPU_ARCHS=gfx942;gfx950. That requirement is the compile/guard (done: both orders hipcc, MulABScale __gfx942__ guarded, native e4m3fn lookup does not pick the gfx942 tile).

@gyohuangxin gyohuangxin added the ci:mi300x Run MI300X standard and OPUS CI on PRs label Nov 21, 2026
@jatseng-ai

Copy link
Copy Markdown
Contributor Author

Both sweep boxes in the test plan are now ticked. The gfx950 one was the last open item.

gfx950 (MI355X, 256 CU), head f0e28ecae, GPU_ARCHS=gfx942;gfx950, fresh AITER_JIT_DIR, ROCm 7.2.4, live dtypes.fp8 e4m3fn. Checkout clean at the head SHA; no file in the tree was modified.

test_plain_fp8_swiglu_limit_dispatch passed. The official 30 cases passed. Extra L=3.0 and L=5.0 (no CSV row, must still clamp) passed, 12 further cases. Exit 0.

Kernel selection is what this run had to show. At every limit the lookup logged no row for ('gfx950', 256, ...) with swiglu_limit=...; using default config, and the only stage-1 kernel launched in the whole run was the heuristic

moe_ck2stages_gemm1_256x32x64x256_1x4_TypeCast_v1_Nswizzle0_Quant2_MulRoutedWeight0_silu_F8_F8_B16

MulABScale does not appear anywhere in the log. The gfx942 tiles are in the dual-arch module and stay behind __gfx942__ on this GPU.

Clamping holds at every limit. At L=1, unclamped row err 74.2-90.2 with fused_moe err 0, and swapped row err 0.344-0.352, so clamp-before-SiLU is separated from clamp-after. At L=7, unclamped row err 1.15-1.52 with fused_moe err <= 9.8e-4. The untuned extras clamp too: L=3 6.85-8.52, L=5 2.37-3.02, fused_moe err 0 to 9.9e-5. None / 0 / inf stay unclamped.

quant 2 = per_Token, 1 = per_Tensor:

quant_type token swiglu_limit gfx unclamped row err swapped row err fused_moe err fused_moe row err
2 1 nan gfx950 nan nan 0.00292969 0.00457412
2 1 0 gfx950 nan nan 0.00390625 0.00446187
2 1 inf gfx950 nan nan 0.00439453 0.00448999
2 1 1 gfx950 90.2199 0.351571 0 0.00451855
2 1 7 gfx950 1.51678 nan 0.000976562 0.00469887
2 64 nan gfx950 nan nan 0.299904 0.0326131
2 64 0 gfx950 nan nan 0.299622 0.0328062
2 64 inf gfx950 nan nan 0.30027 0.0325918
2 64 1 gfx950 82.0452 0.34791 0 0.00499221
2 64 7 gfx950 1.31347 nan 0.000671387 0.00627831
2 1024 nan gfx950 nan nan 0.269897 0.036322
2 1024 0 gfx950 nan nan 0.270009 0.0363584
2 1024 inf gfx950 nan nan 0.26989 0.0362624
2 1024 1 gfx950 74.5318 0.347094 0 0.00565554
2 1024 7 gfx950 1.14801 nan 0.000424385 0.00658228
1 1 nan gfx950 nan nan 0.0117188 0.00479001
1 1 0 gfx950 nan nan 0.0102539 0.00476948
1 1 inf gfx950 nan nan 0.00976562 0.00480627
1 1 1 gfx950 90.0768 0.350933 0 0.00449976
1 1 7 gfx950 1.50441 nan 0.000488281 0.00429659
1 64 nan gfx950 nan nan 0.00538635 0.00560579
1 64 0 gfx950 nan nan 0.00521851 0.00568612
1 64 inf gfx950 nan nan 0.0051651 0.00556981
1 64 1 gfx950 82.6227 0.349572 0 0.00512652
1 64 7 gfx950 1.29657 nan 0.000328064 0.00511285
1 1024 nan gfx950 nan nan 0.00514793 0.0100597
1 1024 0 gfx950 nan nan 0.00519657 0.0101036
1 1024 inf gfx950 nan nan 0.0052228 0.0101628
1 1024 1 gfx950 74.2373 0.343942 0 0.00625444
1 1024 7 gfx950 1.1526 nan 0.000417233 0.0067317

Per_Token no-limit at 64+ is the known ASM 1-stage, same character as the gfx942 run; row error stays under 0.037.

The dual-arch ..._per_token_..._runtime_swiglu_limit module built on this GPU in 93.0 s and the per_tensor one in 96.0 s, both from an empty JIT dir.

Together with the gfx942 sweep above, both numerical boxes in the test plan are complete on this head.

@zufayu
zufayu requested a review from gyohuangxin November 21, 2026 11:38
@zufayu
zufayu force-pushed the fix-8334-clamped-silu-ck-routing branch from f0e28ec to a298b9a Compare November 23, 2026 03:24
@github-actions github-actions Bot changed the title [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances [CK] [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances Nov 23, 2026
@zufayu
zufayu force-pushed the fix-8334-clamped-silu-ck-routing branch from a298b9a to 43bb9ba Compare November 23, 2026 09:57
zufayu
zufayu previously approved these changes Nov 23, 2026
Comment thread op_tests/test_moe_ck_codegen_arches.py Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this folder is for op test instead of unit test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@zufayu test flydsl moe gfx942????

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.

This file is the dispatch test for the gfx942 FlyDSL MoE backend added in #7820 — aiter/ops/flydsl/fused_moe_gfx942.py, kernels in aiter/ops/flydsl/kernels/moe_gemm_2stage/gfx9_fp8/, with AOT coverage for gfx942.

The PR touched it because its assertion encoded the bug. test_num_local_tokens_dispatch required the Qwen bypass (inter_dim 512) to take the FlyDSL whole-graph default — that is the route whose metadata has stage1=None, and dereferencing it is what crashed test_plain_fp8_swiglu_limit_dispatch on main. The change narrows the assertion: inter_dim 512 now stays on CK, while V4.1-Flash at 576, which CK cannot clamp, still takes FlyDSL. Checked both ways on a gfx942 box — it passes with the fix and fails against main's aiter/fused_moe.py.

On your other comment: you were right, and op_tests/test_moe_ck_codegen_arches.py was deleted. The codegen half shipped with no test of its own.

This landed in #8531 (this PR was closed as superseded). Main's MI300X shard 5 and MI35X shard 6 are green again as of run 45474327228.

If you meant something else — whether this file belongs in op_tests/ at all, or whether gfx942 should have a FlyDSL MoE path — say which and I'll follow up.

@jhinpan

jhinpan commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@jatseng-ai This PR is the only open fix for the test_moe_2stage.py failure on MI300X. Two items need an action.

  1. Wheel build. Merge main. The module that fails, module_fp8_mqa_logits, came from [HIP] [JIT] Add gfx950 prefill FP8 MQA logits #7183 (job). [HIP] [JIT] Revert " Add gfx950 prefill FP8 MQA logits" #8504 reverted [HIP] [JIT] Add gfx950 prefill FP8 MQA logits #7183 after you pushed 43bb9ba. A trial merge into main 8c2471a has no conflicts.
  2. op_tests/test_moe_ck_codegen_arches.py. You can move it to tests/ and add it to split_tests.sh, or remove it.
    • Three reviewers want it out of op_tests/: valarLip here, coderfeli and zufayu on #8476.
    • CI runs no case from it. aiter_test.sh starts it with python3 <file>, and the file has no entry point (0.035 s on MI300X).

Evidence. Your two commits and #8485 passed all 8 MI300X shards in #8476 (run). I closed #8476 because it is a duplicate of this PR.

@zufayu
zufayu force-pushed the fix-8334-clamped-silu-ck-routing branch 2 times, most recently from 87061c2 to 2483e46 Compare November 24, 2026 02:33
@github-actions github-actions Bot changed the title [CK] [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances Nov 24, 2026
@github-actions github-actions Bot removed the CK label Nov 24, 2026
@zufayu zufayu changed the title [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU on CK and ship its gfx942 instances [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default Nov 24, 2026
On gfx942 a clamped per-token FP8 SiLU that CK can clamp (FP8, inter_dim a
multiple of 128) is routed to the FlyDSL whole-graph default from ROCm#7820 /
ROCm#8178. That backend's metadata has stage1=None, so
test_plain_fp8_swiglu_limit_dispatch, which reads md.stage1.keywords,
crashes with AttributeError: 'NoneType' object has no attribute 'keywords'
-- MI300X shard 5 on main, most recently run 45246107786.

The route is also the wrong one for these calls: the whole-graph backend
clamps the BF16 activations it reads, a different quantization point from
the per-token path the call and the tuned rows from ROCm#7361 ask for. (The
accuracy claim in ROCm#8334 about that backend is retracted; it is accurate
against its own reference, see ROCm#8350.)

Keep the whole-graph default only where CK rejects the shape (inter_dim
not a multiple of 128, including V4.1-Flash at 576). The new predicate is
the same one the NotImplementedError gate below uses, which is what
defines what CK's runtime-limit stage-1 accepts. A tuned
impl__flydsl_gfx942__ row still wins. This does not revert ROCm#7361.

Fixes ROCm#8334

Co-authored-by: Cursor <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu force-pushed the fix-8334-clamped-silu-ck-routing branch from 2483e46 to a90643b Compare November 24, 2026 03:34
@github-actions github-actions Bot changed the title [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default [FlyDSL] [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default Nov 24, 2026
@zufayu

zufayu commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Superseded by #8531, which now carries both commits.

Splitting this into a routing PR and a codegen PR made each one unmergeable: neither half turns MI300X shard 5 green on its own. Measured on CI, one half at a time:

branch shard 5
main AttributeError: 'NoneType' object has no attribute 'keywords'
codegen only (#8531 at 48efa54) the same AttributeError — it does not touch dispatch
routing only (this PR at a90643b) Unknown or incompatible CK MoE kernel: moe_ck2stages_gemm1_256x16x64x256_1x4_MulABScale_…

Every other MI300X and MI35X shard passed on both. #8531 now has both commits, so shard 5 is expected to go green there.

@valarLip — your comment on op_tests/test_flydsl_moe_gfx942.py is not resolved by this close. The same change is in #8531 and the question still stands; it will be answered there.

@zufayu zufayu closed this Nov 24, 2026
zufayu added a commit that referenced this pull request Nov 24, 2026
…ship its gfx942 instances, and de-flake split-K graph replay (#8531)

Three independent failures a CI run hits:

- MI300X shard 5 crashed with AttributeError: 'NoneType' object has no attribute 'keywords'. A clamped per-token FP8 SiLU on gfx942 took the FlyDSL whole-graph default, whose metadata has stage1=None. Keep that default only where CK rejects the shape (inter_dim not a multiple of 128).
- With routing fixed, a 304-CU limit-7 call selects the tuned gfx942 256x16...MulABScale row from #7361, which a GPU_ARCHS=gfx942;gfx950 wheel never built: Unknown or incompatible CK MoE kernel. Emit every built arch's CK MoE instance list into the lookup; heuristic dispatch still follows get_gfx().
- MI35X shard 6 flaked on test_flydsl_hgemm's bit-exact split-K graph replay. BF16 output with split_k > 1 accumulates via BufferAtomicPkAdd, so the result is atomic-order dependent (#8374). Accept one BF16 ULP there only, with a finiteness check and a guard that the replay did not reuse the captured input.

Supersedes #8353 and #8351.

Fixes #8334
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:mi300x Run MI300X standard and OPUS CI on PRs FlyDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants