Repository navigation
[FlyDSL] [AOT] Cover the gfx942 whole-graph MoE rows - #8495
Conversation
The MoE replay skipped every impl__flydsl_gfx942__ row, so the gfx942 whole-graph kernels had no AOT entry and test_moe_2stage fails under FLYDSL_RUNTIME_RUN_ONLY=1 (no usable AOT cache for launch_batch1). - moe.py: replay impl__flydsl_ rows too. - per_tensor_quant_hip: refuse num_rows with NotImplementedError, which the replay reports as a refused caller-side variant, not an assert. - moe_2stage_down_prefill_1x4: clear its FlyObjCache at each trace. The cache kept MLIR objects of the first trace, and a second trace in the same process (as the replay does) built on them and crashed.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🔵 Needs a closer look
The repeated-trace lifetime fix and whole-graph AOT launches require gfx942 compile/replay and cache-reuse validation that this review environment cannot independently perform.
No open issues 🎉
What changed in this PR
This PR extends MoE ahead-of-time (AOT) replay to gfx942 whole-graph FlyDSL rows, addressing the cache-coverage gap behind the on-demand compilation workaround in #8485.
Changes:
- Include
impl__flydsl_rows in MoE AOT replay. - Raise
NotImplementedErrorfor unsupported per-tensor quantization calls withnum_rows, allowing replay to classify them as refused variants. - Clear the Down prefill kernel’s IR cache at each trace to prevent stale objects from being reused.
| File | Description |
|---|---|
aiter/ops/quant.py |
Use an explicit unsupported-call exception for num_rows. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/gfx9_fp8/gemm2.py |
Reset cached IR before tracing the Down prefill kernel. |
aiter/aot/flydsl/moe.py |
Recognize whole-graph FlyDSL rows for AOT replay. |
Review effort: Balanced
Summary
The MoE AOT replay skipped every
impl__flydsl_gfx942__*row, so none of the gfx942 whole-graph FlyDSL kernels had an AOT entry.test_moe_2stage.pychecks the cache for those rows, so it fails underFLYDSL_RUNTIME_RUN_ONLY=1withno usable AOT cache for launch_batch1(MI300X shard 5 of #8353, worked around in #8485). This PR replays those rows and fixes the two failures that replaying them exposes.Motivation
_reaches_flydslonly accepts kernel names starting withflydsl_/cktile_. Whole-graph rows (impl__flydsl_gfx942__...) launch FlyDSL kernels fromfused_moe_gfx942, so all 157 of them in the merged table (4 at 304 CUs, 153 at 80 CUs) were never replayed.per_tensor_quant_hiprefusesnum_rowswith anassert. A per-tensor row called withnum_local_tokensdrops its whole-graph config, and the CK path then calls this function withnum_rows. The replay reports a runtime refusal (NotImplementedError) as a refused caller-side variant, but any other error as a build failure.moe_2stage_down_prefill_1x4shares oneFlyObjCacheacross traces. Itsfunctools.cachekeeps the MLIR objects of the first trace. The replay traces a launcher again in the same process, and the second trace builds on the stale IR: a segfault, an MLIRProperty type mismatchassertion, orMmaMakeFragmentOp: expected a TiledMmaType and a memref. The other two Down kernels (gemm2_1x4.py,gemm2_8x1.py) already useFlyObjCache(cache_ir=False).Changes
aiter/aot/flydsl/moe.py:_reaches_flydslalso acceptsimpl__flydsl_rows.aiter/ops/quant.py:per_tensor_quant_hipraisesNotImplementedErrorfornum_rowsinstead of asserting. Callers that pass it still fail, now with the error the runtime uses for unsupported calls.aiter/ops/flydsl/kernels/moe_gemm_2stage/gfx9_fp8/gemm2.py: clear the Down prefill kernel'sFlyObjCacheat the start of each trace. Every trace now starts from the empty cache the first trace had, so the generated code is unchanged.Performance (if applicable)
Not applicable: the exported objects of the changed kernel are byte-identical before and after (see Testing).
Testing
All runs on MI308X (gfx942, 80 CUs), ROCm 7.2, torch 2.9.1, FlyDSL 0.5.3 (the official wheel and a source build). The 304-CU rows were exercised with
CU_NUM=304.impl__rows of the merged table (GPU_ARCHS=gfx942 python -m aiter.aot.flydsl.moe --csv <impl__ rows>, fresh cache): before 481 ok / 75 failed; after 524 ok / 0 failed / 32 refused (per-tensor +num_local_tokens), with both FlyDSL builds.--checkon the built cache: 0 failed.fused_moeunderFLYDSL_RUNTIME_RUN_ONLY=1fails with the CI error on an empty cache and passes with the built cache (max relative error 1.0%, cosine 0.99998 againsttorch_moe).op_tests/test_flydsl_moe_gfx942.py, full run: 228checkAllclosepassed, 0 failed; all 153 whole-MoE rows report err 0, 47 of them on the changed prefill Down kernel..ofiles are byte-identical before and after.Documentation
The AOT README already states that the MoE replay covers every tuned row reaching FlyDSL; this makes the code match it.
Dependencies
Breaking Changes
None.
per_tensor_quant_hip(num_rows=...)raisesNotImplementedErrorinstead ofAssertionError; nothing catches the latter.PR Self-Review
Reviewed revision
c526587
Behavior and intent
The gfx942 MoE AOT build now prebuilds the whole-graph FlyDSL kernels of the tuned
impl__rows, so the runtime andtest_moe_2stage.pyhit the cache instead of needing a JIT. Kernel numerics and codegen are unchanged; the only runtime-visible change is the exception type above.Validation and unverified scope
See Testing. Not verified: MI300X hardware, a full
setup.pywheel build, and a replay of the whole MoE table (only the 157impl__rows were replayed). The 32 refused variants remain a runtime limitation: a per-tensor caller passingnum_local_tokenson gfx942 is still refused by the CK path.PR-specific question
Changed op tests
None.