Repository navigation
[FlyDSL] [CI] Launch FlyDSL AOT cache entries through _run_compiled - #8451
Conversation
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]>
🏷️ 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 |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 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]>
- Keep both tests/test_flydsl_aot_launch.py (ROCm#8451) and tests/test_flydsl_aot_replay.py in split_tests.sh
Motivation
#8356 added
FlyDSLAotCache, and #8435 extends it to more launchers by rewriting each call site intoFlyDSLAotCache.launch(key, make_exe, ...)with a hand-built key. This PR keepsFlyDSLAotCacheunchanged 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:_run_compiled(3 lines) launches a bound launcher through its cache. Unbound launchers only pay onegetattr(~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.kernelAST 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=0binds nothing:aot_factoryreturns the factory itself, so_run_compiledand factory calls cost exactly what they do on main. Directlauncher(...)calls are untouched.fx.Stream. A thread-local guard keeps the cache's JIT fallback from re-entering the cache.Converted:
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 tospecialization_key.docs/flydsl_aot_cache.md§4/§5/§6 now describe the factory entry.Test results (MI308X gfx942; FlyDSL 0.5.2 unless noted)
tests/test_flydsl_aot_launch.py(new): gfx942 MoE prefill in JIT / AOT miss / AOT hittests/test_flydsl_aot_cache.pyflyc.compile) and asserts a hit calls the factory 0 timesop_tests/test_flydsl_moe_gfx942.py, AOT on, fresh cache, with thegemm2_1x4fix belowop_tests/test_flydsl_moe_a16wfp4.pyop_tests/test_gemm_a8w8_bpreshuffle_pad_k.pypython -m aiter.aot.flydsl.gemmon sampled tuned rows (bmm, preshuffle)_ns4tail split, mxpsh incl. plain and fused split-K).rodata) are byte-identicalaiter.aot.flydsl.gemm(bpreshuffle_wmma, a4w4, bmm_mxfp8, mxfp8_32/128, hgemm; 24 rows) andaiter.aot.flydsl.moe(grouped, 6 rows)num_local_tokensfailures as base); all 104 FlyDSL cache artifacts byte-identicalHost cost: in mode 0, a factory call costs what the bare
functoolscache does (0.1 µs). In mode 1,.lazycosts 0.23 µs (5 positional arguments) to 1.2 µs (14 keyword arguments, about what the explicit key'ssorted(items)cost), andflydsl_preshuffle_gemm_a8on 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
.lazyand eager launches build each key once; a first launch inside CUDA graph capture builds or loads and replays correctly; lru eviction rebinds.Notes
gemm2_1x4Down kernel needs the fix onfix/flydsl-051-gfx942-down-scale-views; without itop_tests/test_flydsl_moe_gfx942.pyfails on main through the JIT as well. The new test's prefill rows do not reach that path and pass on main.aot_launchrecord it as a source (the cache's import scan), so editingaot_launch.pyrebuilds 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.impl__flydsl_gfx942__rows inaiter/aot/flydsl/moe.py; prebuilding those entries is left to a follow-up.🤖 Generated with Claude Code