Skip to content

[FlyDSL] [CI] Launch FlyDSL AOT cache entries through _run_compiled - #8451

Merged
coderfeli merged 3 commits into
mainfrom
felix/flydsl-aot-factory
Nov 23, 2026
Merged

coderfeli merged 3 commits into
mainfrom
felix/flydsl-aot-factory

Conversation

@coderfeli

@coderfeli coderfeli commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

#8356 added FlyDSLAotCache, and #8435 extends it to more launchers by rewriting each call site into FlyDSLAotCache.launch(key, make_exe, ...) with a hand-built key. This PR keeps FlyDSLAotCache unchanged and moves the opt-in to the launcher factory, so call sites keep calling _run_compiled.

What changes

New aiter/ops/flydsl/aot_launch.py:

@aot_factory("moe_gfx942_gemm")      # cache name
@functools.cache
def _get_compiled_kernel(N, K, ...):  # its arguments are the key
    return compile_gemm(...)
  • _run_compiled (3 lines) launches a bound launcher through its cache. Unbound launchers only pay one getattr (~20 ns).
  • factory.lazy(...) returns a handle instead of calling the factory, so a hit never runs it. Without it, a fresh process pays ~230 ms of @flyc.kernel AST rewriting per kernel module on its first hit. The factory runs only to build an entry or on the JIT fallback.
  • bind_aot(launch, cache, key) covers launchers built inside a wrapper (sorted_sum, flydsl_absmax, flydsl_quant_per_tensor).
  • AITER_FLYDSL_AOT_CACHE=0 binds nothing: aot_factory returns the factory itself, so _run_compiled and factory calls cost exactly what they do on main. Direct launcher(...) calls are untouched.
  • A factory argument the cache cannot key (e.g. a numpy scalar) leaves that launcher on the JIT path.
  • Safety: one launcher bound under two keys logs a warning and stays on the JIT. A torch stream passed last is wrapped in fx.Stream. A thread-local guard keeps the cache's JIT fallback from re-entering the cache.

Converted:

  • GEMM, already on the AOT cache: preshuffle_gemm_a8, gemm_a8w8_blockscale, gemm_a8w8_mxfp8_8wave (including tail split), mxscale_preshuffle_gemm / _fused / _splitk_reduce, bmm_a8w8_mxscale_gfx950. Each keeps its cache name and in-memory key; the extra dtype/device parts move to specialization_key.
  • MoE, previously JIT only: the gfx942 whole-MoE Gate/Up and Down GEMMs, sorted reduction, absmax and per-tensor quant; the a16wmix stage 1 and stage 2.

docs/flydsl_aot_cache.md §4/§5/§6 now describe the factory entry.

Test results (MI308X gfx942; FlyDSL 0.5.2 unless noted)

Check Result
tests/test_flydsl_aot_launch.py (new): gfx942 MoE prefill in JIT / AOT miss / AOT hit pass; outputs bitwise equal across modes; hit builds nothing, falls back nowhere and calls no GEMM factory
tests/test_flydsl_aot_cache.py pass; now counts real traces (flyc.compile) and asserts a hit calls the factory 0 times
op_tests/test_flydsl_moe_gfx942.py, AOT on, fresh cache, with the gemm2_1x4 fix below pass, 138 entries, no JIT fallback
op_tests/test_flydsl_moe_a16wfp4.py 277 passed, 30 skipped (same as base)
op_tests/test_gemm_a8w8_bpreshuffle_pad_k.py 33 passed; the same 4 fail on base (the CK-tile JIT module does not build in this environment)
gfx950 compile-only, python -m aiter.aot.flydsl.gemm on sampled tuned rows (bmm, preshuffle) 72 ok on base and head; the 25 GPU code objects are byte-identical
gfx950 compile-only, by-name runners (blockscale bf16/fp16, mxfp8 8-wave incl. _ns4 tail split, mxpsh incl. plain and fused split-K) 45/45 ok on base and head; the 34 GPU code objects (.rodata) are byte-identical
gfx1250 compile-only, aiter.aot.flydsl.gemm (bpreshuffle_wmma, a4w4, bmm_mxfp8, mxfp8_32/128, hgemm; 24 rows) and aiter.aot.flydsl.moe (grouped, 6 rows) same outcomes as base (24 ok; 32 ok / the same 4 num_local_tokens failures as base); all 104 FlyDSL cache artifacts byte-identical
AOT export-failure fallback correct result through the JIT, no recursion

Host cost: in mode 0, a factory call costs what the bare functools cache does (0.1 µs). In mode 1, .lazy costs 0.23 µs (5 positional arguments) to 1.2 µs (14 keyword arguments, about what the explicit key's sorted(items) cost), and flydsl_preshuffle_gemm_a8 on a hit takes about 1.5 µs more per launch than base (37.6 vs 36.1 µs). A hit's first call is unchanged with .lazy. On the gfx942 MoE, warm-cache start is 2.9 s against 7.7 s through the JIT.

Two independent reviews found no crash, deadlock or wrong-kernel path. Their findings are fixed in the third commit. Also checked: threads mixing .lazy and eager launches build each key once; a first launch inside CUDA graph capture builds or loads and replays correctly; lru eviction rebinds.

Notes

  • gfx950 kernels are validated compile-only, as in [FlyDSL] [CI] [Build] Add an on-disk AOT cache for the FlyDSL GEMM launchers #8356; runtime on gfx950 hardware is still to be checked, as is a16wmix on gfx950 (only its compile-level op test ran here).
  • On FlyDSL 0.5.1 and 0.5.2, the gfx942 MoE gemm2_1x4 Down kernel needs the fix on fix/flydsl-051-gfx942-down-scale-views; without it op_tests/test_flydsl_moe_gfx942.py fails on main through the JIT as well. The new test's prefill rows do not reach that path and pass on main.
  • Existing entries are rebuilt once: the key layout changed, so their digests differ. The old files are left in place.
  • Modules that import aot_launch record it as a source (the cache's import scan), so editing aot_launch.py rebuilds their entries once.
  • cache_clear() on a decorated factory resets the factory only; state a launcher bakes in beyond the factory's arguments must be in the key, as for entries on disk.
  • This PR does not replay tuned impl__flydsl_gfx942__ rows in aiter/aot/flydsl/moe.py; prebuilding those entries is left to a follow-up.

🤖 Generated with Claude Code

Opt kernels into FlyDSLAotCache at their launcher factory instead of at
every call site. aot_factory(name) keys a factory's launchers by its
arguments; bind_aot binds a launcher built inside a wrapper.
_run_compiled launches a bound launcher through the cache, so call sites
keep calling _run_compiled. factory.lazy(...) returns a handle that does
not call the factory, so a hit never runs it. AITER_FLYDSL_AOT_CACHE=0
binds nothing and leaves the JIT path unchanged. FlyDSLAotCache itself
is unchanged.

Move the preshuffle, blockscale, mxfp8 8-wave, mxscale preshuffle and
batched mxscale GEMMs from explicit FlyDSLAotCache.launch calls to their
factories, with the same cache names and keys. Opt in the gfx942
whole-MoE GEMM, sorted reduction and per-tensor quantization launchers,
which ran only through the JIT, and the a16wmix MoE stages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderfeli
coderfeli requested a review from a team November 22, 2026 13:42
@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 8451 --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 22, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision da5f65b078f5 · 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 permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  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 and others added 2 commits November 22, 2026 13:56
- Under AITER_FLYDSL_AOT_CACHE=0, aot_factory returns the factory itself,
  so a call costs what the bare functools cache does.
- Build with the cached factory (functools.partial), as the JIT path calls
  it, so AOT replays that only identify kernels keep one launcher per key.
- A factory argument the cache cannot key (e.g. a numpy scalar) leaves the
  launcher on the JIT path instead of failing every launch.
- Keep cache_info on the wrapper; document what cache_clear resets.
- Key lazy handles by positional args alone when there are no keywords.
- Run tests/test_flydsl_aot_launch.py in CI, check on a hit that every
  launcher still goes through the cache, and test unkeyable arguments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot changed the title [FlyDSL] Launch FlyDSL AOT cache entries through _run_compiled [FlyDSL] [CI] Launch FlyDSL AOT cache entries through _run_compiled Nov 22, 2026
@github-actions github-actions Bot added the CI label Nov 22, 2026
@coderfeli
coderfeli merged commit 44301b6 into main Nov 23, 2026
121 of 122 checks passed
@coderfeli
coderfeli deleted the felix/flydsl-aot-factory branch November 23, 2026 03:08
yuychang added a commit to yuychang/aiter that referenced this pull request Nov 23, 2026
- Keep both tests/test_flydsl_aot_launch.py (ROCm#8451) and tests/test_flydsl_aot_replay.py in split_tests.sh
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.

5 participants