Skip to content

[FlyDSL] Launch and preload the gfx950 MegaMoE through the AOT cache - #8680

Closed
coderfeli wants to merge 3 commits into
mainfrom
feat/flydsl-aot-mega-moe
Closed

coderfeli wants to merge 3 commits into
mainfrom
feat/flydsl-aot-mega-moe

Conversation

@coderfeli

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #8565. The launchers the gfx950 MegaMoE replay (python -m aiter.aot.flydsl.mega_moe) compiles now launch and preload through the FlyDSL export_to_c AOT cache, so a serving process loads prebuilt objects instead of tracing them.

Motivation

MegaMoE was the last AOT replay whose launchers took the JIT path: every process traced them on first use or in preload_aot_bundles().

Changes

Cache Launcher How
mega_moe_prepare compile_mega_moe_prepare (also the fast EP8 prepare it returns) aot_factory
mega_moe_stage1_bundle compile_mega_moe_stage1_bundle aot_factory; its Stage1Config variants are keyed by their field values
mega_moe_small_m_stage1, mega_moe_large_m_stage1 compile_mega_moe_stage1 of mega_moe_small_m.py / mega_moe_large_m.py aot_factory
mega_moe_stage2, mega_moe_stage2_aligned_pair compile_mega_moe_stage2, compile_mega_moe_stage2_aligned_pair aot_factory (replaces module-level dicts)
mega_moe_mx_quant build_per_1x32_mx_quant_module aot_factory
mega_moe_combine the combine after the fused GEMM2 (skip_stage1) aot_factory; the op keeps the function it gets

Shared code:

  • tensor_shim._preload_compiled called flyc.compile itself, so a bound launcher never reached the cache. For a bound launcher it now builds the entry in a prebuild, and in a process that serves loads the entry without launching it; with no entry it preloads on the JIT path as before (one error logged).
  • tensor_shim._compile_and_keep: the same for a caller that keeps the compiled function and calls it directly (the combine).
  • aot_launch.preload_bound, FlyDSLAotCache.preload.

Not converted: the fixed-slot stage 1, compile_gemm1, the scale-sort quant, dispatch and the regular combine() (the replay does not compile them; aiter.dist uses the last two outside MegaMoE), and the TP, internode and gfx1250 MegaMoE.

Performance (if applicable)

Host time of the lookups that changed, per launch, CPU only: stage 2 2.7 → 1.6 us, stage-1 bundle 1.7 → 2.5 us, prepare 0.32 → 0.36 us, quant 0.11 → 0.18 us. The combine's hot path is unchanged. Kernel code is unchanged (same FlyDSL IR; see Testing). No GPU timing was taken.

Testing

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

All compile-only, on MI308X (gfx942) with FlyDSL 0.5.3 and no MORI, GPU_ARCHS=gfx950. MegaMoE runs on gfx950 with MORI only, so nothing here launched a MegaMoE kernel.

  • python -m aiter.aot.flydsl.mega_moe --experts-per-rank 48 --mtpr 8192 (16 jobs), twice on one cache directory: 674 entries (prepare 352, small-input stage 1 112, stage 2 96, combine 80, bundle 16, large-input stage 1 8, aligned pair 8, quant 2); the second run builds 0; no launch takes the JIT path. Run twice independently with the same result.
  • Every flyc.compile of that replay logged: 1176 calls, all made by the cache.
  • Key probe (each of the 1176 launches re-exported and compared per disk digest): 674 digests, none with two objects.
  • The same replay under AITER_FLYDSL_AOT_CACHE=verify on that directory: no stale entry.
  • Default build (python -m aiter.aot.flydsl.mega_moe, 234 jobs): 7655 entries, 634 MB, 444 s; a second run builds 0 in 148 s.
  • FlyDSL artifacts with the cache off and on: the same 594 + 80 names (the names are the traced IR's hash). The 80 combine artifacts are byte-identical. The GPU binary in 34 to 43 of the 594 differs between any two runs, between two cache-off runs as much as between off and on: LLVM does not make the same bytes of some prepare kernels twice.
  • tests/test_flydsl_aot_launch.py and tests/test_flydsl_aot_cache.py under 1, verify and 0 (34 / 34 / 27 passed, 7 skipped).
  • Static checks: 33 caches, none missing a source file or a variable.

Unverified:

  • Runtime on gfx950 with MORI: results, preload_aot_bundles() in a serving process, the combine's kept function.
  • per_1x32_mx_quant is also the internode MegaMoE's quant, so that now launches through mega_moe_mx_quant; a size the intranode replay does not build logs one error and traces.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

docs/flydsl_aot_cache.md (§4.4, new §5.5, §7) and .claude/skills/flydsl-aot-export/SKILL.md.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

  • _preload_compiled of a launcher bound to the cache returns the loaded function (or None in a prebuild) instead of FlyDSL's compiled handle.
  • The combine launchers of the fused path are cached per module instead of per op instance.

🤖 Generated with Claude Code

coderfeli and others added 2 commits November 25, 2026 10:46
The launchers the MegaMoE replay (aiter.aot.flydsl.mega_moe) compiles now
launch through the export_to_c cache: prepare, the stage-1 bundle, the
small- and large-input stage 1, stage 2, the aligned-pair stage 2, the
1x32 MX quant and the combine after the fused GEMM2.

MegaMoE warms its kernels up with tensor_shim._preload_compiled, which
called flyc.compile itself, so a bound launcher never reached the cache:
- _preload_compiled of a bound launcher builds its entry in a prebuild,
  and in a process that serves loads the entry without launching it; with
  no entry it preloads on the JIT path as before.
- _compile_and_keep does the same for a caller that keeps the compiled
  function and calls it directly (the combine).
- The Stage1Config variants of the bundle are keyed by their field values.

The fixed-slot stage 1, compile_gemm1, the scale-sort quant, dispatch and
the regular combine are not compiled by the replay and stay on the JIT
path, as do the TP, internode and gfx1250 MegaMoE.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderfeli
coderfeli requested a review from a team November 25, 2026 10:46
@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 8680 --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.

@aiter-bot

aiter-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision b5eed1df842f · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What is the most important boundary or failure mode introduced by this change, and what evidence covers it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

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

coderfeli added a commit that referenced this pull request Nov 25, 2026
…s branch

The conv dispatch keeps the function its first launch got through
tensor_shim._compile_and_keep, which replaces aot_launch.loaded_kernel:
a key with no entry no longer goes through _run_compiled on every launch.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderfeli

Copy link
Copy Markdown
Collaborator Author

Merged into #8600 (branch head 5da81ff), which now carries this change together with the conv dispatch fix that depends on it.

@coderfeli coderfeli closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants