Repository navigation
Conversation
…d compile hints An exported object ignores a launcher's Constexpr launch arguments, so an entry built with one value was loaded by a later process that passed another. Record the values an entry was built with in its sidecar and accept a disk entry only for a call that passes them; one in-memory key launched with two values raises. Strings, None and tuples are keyed too. Also: - a specialization_key the cache cannot key on disk (an Enum, a numpy scalar) launches through the JIT path instead of raising on every launch - factory.cache_clear() drops the launchers the cache loaded and keeps the factory on the JIT path for the rest of the process - bitcode a kernel links with link_extern is hashed into its entry, and the ROCm device bitcode into the fingerprint - the fingerprint follows FlyDSL's own list of cache-invalidating variables (LLVM_GFX1250_ANY_XNACK_CODEGEN) - CompilationContext.compile_hints of the caller are part of the disk key - CI runs the op tests under AITER_FLYDSL_AOT_CACHE=verify The cache schema goes from 5 to 6: existing entries are rebuilt once. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…inked bitcode - A loaded launcher with constexpr launch arguments raises when a later launch of the key passes another number of arguments: a constexpr the first launch left to its default was not compared. - A tuple constexpr is compared as the disk entry is, so (True, 2) is not (1, 2). - A linked bitcode file may be newer than the process (extracted on first use): it is hashed as the compile read it, and no longer keeps the entry from being written. - The device bitcode digest follows the environment instead of being cached per process. - bind_aot leaves a factory result that is not one launcher (a tuple or a dict of them) on the JIT path instead of raising. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…h the AOT cache Every FlyDSL launcher the GEMM and MoE AOT replays compile for gfx942 and gfx950 now launches through FlyDSLAotCache, so a later process loads the exported object instead of tracing the kernel again: - gemm_a16w16_gfx950 (the default HGEMM): launched through _run_compiled with its config items as the specialization key, in place of its own flyc.compile cache (run_cached, removed) - the band and skinny HGEMM, the a8w8 4-wave and 8-wave GEMMs - the MX 2-stage MoE and FHMoE GEMMs, the a4w4 stage 1, the MX stage 2 (mxmoe_dispatcher.get_g2) and the stage-2 reduce Compile-only on gfx942 with the full replays, each run twice on one cache directory: gfx950 GEMM 5240 entries, gfx950 MoE 2882, gfx942 GEMM 80, gfx942 MoE 132; the second run builds none, no launcher is compiled by the JIT path and none falls back. Runtime on gfx950 is still to be checked. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…conversion - gemm_a16w16_gfx950 keys its launches by the device too: a JIT handle launches only on the device it was compiled on. - mxmoe_dispatcher.get_g2 lets the cache compile the launcher an entry is built from, so the files that compile runs are recorded with the entry. - A launcher with constexpr launch arguments may leave trailing runtime arguments to their defaults; only a launch with more arguments, or too few for the baked ones, raises. - Constexpr values other than ints, bools and strings are compared as the disk entry is (-0.0 is not 0.0). - A factory whose result cannot be bound is not asked to bind it again on every call. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A launch through the cache cost about 4 us more host time than the JIT path for a factory with 20 keyword arguments (MI308X, trivial kernel: 13.4 us against 9.4 us), most of it hashing the factory's arguments again: - A binding keeps the objects the cache loaded for it, by specialization key, so a launch no longer hashes the whole key; cache.invalidate() bumps an epoch that drops them. - factory.lazy() keys its handles with functools.cache, as the factory keys its launchers. - The factory wrapper binds a launcher only if it is not bound yet, which costs one attribute read on later calls. Now 9.9 us through factory.lazy() and 11.1 us through an unchanged call site, against 9.3 us on the JIT path. Also fixes four statements in the docs that the code contradicted. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ing race - gemm_a16w16_gfx950 goes back to its own flyc.compile cache (run_cached), as on main. It passes its tensors as flyc.from_dlpack dynamic-layout arguments, and a function loaded with flyc.load_module takes 27 us to launch with three of them, against 9.6 us for the JIT one: a launch would cost about 55 us of host time instead of 35 us (MI308X, empty kernel). - A binding kept a kernel read from the cache under the epoch that followed a concurrent invalidate(), and then launched it for good. It now keeps a kernel only under the epoch it read before the launch, and lets go of what it holds when the epoch moves. Docs: host time of a launch for the argument kinds the converted kernels pass, and the replays' artifacts compared with AITER_FLYDSL_AOT_CACHE=0. Co-Authored-By: Claude Fable 5.2 <[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 |
…ribute in a test) Co-Authored-By: Claude Fable 5.2 <[email protected]>
…fy-only hook pass verify - gemm_a16w16_gfx950 launches through _run_compiled and the cache again, with its config items and device as the specialization key. Its dynamic-layout tensor arguments now carry their torch tensor (`torch_tensor`, as FlyDSL's TorchTensorJitArg does), which FlyDSL's launch-argument fills read instead of making a DLPack view per fill. On MI308X with a launcher of the same shape, a launch with prebuilt arguments takes 22 us through a loaded object and 23.5 us through the JIT, against 35 us on the JIT path before and 68-80 us through a loaded object without the attribute. Row- and column-major layouts give the same results on both paths. - A compile hook that stops flyc.compile (an AOT replay that only identifies the kernels a call requests) leaves nothing to export. That is not an export failure: the key takes the JIT path, under verify too. op_tests/test_gemm_group32_interface.py relies on it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Corrects the numbers given with the previous commit, which were taken on a loaded machine. On a quiet MI308X, a launch of a launcher with the HGEMM's argument shape (three dynamic-layout tensors, a constexpr struct, arguments prebuilt) takes 11.9 us on the JIT path and 12.5 us through a loaded object when the arguments carry `torch_tensor`, and 30.8 us through a loaded object when they do not. The attribute does not change the JIT path. The full gfx950 GEMM replay now writes 5240 entries, compiles no launcher on the JIT path, and leaves the same 4874 FlyDSL artifacts, byte for byte, as with AITER_FLYDSL_AOT_CACHE=0. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A procedure and checklist for moving a FlyDSL launch onto the export_to_c AOT cache and for reviewing such a change: the three launcher patterns, what must be in the key or specialization_key, compile-only validation without the target GPU, and a table of the cache's errors and fallbacks. AGENTS.md and the FlyDSL review instructions point to it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Picks up the Triton 3.9.0 bump (#8266): CI installs that Triton wheel, and without the matching aiter/utility/fp4_utils.py op_tests/test_gemm_a4w4.py fails to compile its quant kernel.
An entry used to record the files its build ran (sys.setprofile) and
compare them on a lookup. What a build runs depends on what the process
ran before (a memoized factory, a module already imported), so the
recorded set could miss a file, and an edit to it left stale entries.
Each cache now lists the files its launchers are built from, as
FlashInfer's gen_jit_spec(name, sources) does:
@aot_factory("my_kernel", sources=["kernels/my_kernel.py", ...])
- The contents of the declared files, and the values of the variables
named in env=, are hashed into the digest that names an entry. An edit
makes new entries for that cache only; going back finds the earlier
ones. The file creating the cache is always a source.
- Nothing is detected at run time. A forgotten source is checked for
when an entry is built: a declared kernel file that imports an
undeclared kernel file, or linked bitcode that is not declared, raises
_UndeclaredSourceError in every mode. A unit test runs the import
check over every cache in the tree.
- A declared .py edited after the process imported aiter's FlyDSL code
keeps that cache on the JIT path for the process.
- bind_aot loses its rebuild argument, aot_factory's extra_sources is
now sources, and the cache schema is 7.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Summary
Follow-up to #8451 (FlyDSL AOT cache through
_run_compiled). Two parts:Constexprlaunch arguments, so an entry built with one value was loaded by a later process that passed another. The cache now records what an entry bakes in and only serves calls that match.gfx1250 is not touched.
Cache fixes
Constexprlaunch arguments not in the key: another process silently loads the wrong objectbaked) and compared on lookup. Within a process, one key launched with another value raises. Ints, floats, bools, strings,Noneand tuples are supportedspecialization_keyholding an Enum or numpy scalar raised on every launchfactory.cache_clear()kept the loaded kernelslink_externnot in the keyLLVM_GFX1250_ANY_XNACK_CODEGENnot in the fingerprintCompilationContext.compile_hintsnot in the keybind_aotraiselazy()keys its handles withfunctools.cache. Now +0.5 us throughlazy(), +1.8 us through an unchanged call siteThe cache schema goes from 5 to 6, so existing entries are rebuilt once.
CI now runs the op tests under
AITER_FLYDSL_AOT_CACHE=verify(.github/scripts/aiter_test.sh): an entry a test loads from disk is re-traced and compared byte for byte, and an export or load failure fails the test instead of falling back to the JIT path.Launchers moved to the cache (gfx942 / gfx950)
gemm_a16w16_gfx950bind_aot; launched through_run_compiledwith its config items and device as the specialization key, in place of its privateflyc.compilecache (run_cached, removed). Its dynamic-layout tensor arguments now carrytorch_tensor(see launch overhead)gemm_a16w16_band_gfx950,gemm_a16w16_skinny_gfx950aot_factorygemm_a8w8_fp8_8wave,gemm_a8w8_int8_4waveaot_factorymixed_moe_gemm1/2,mixed_fhmoe_gemm1/2aot_factorymxfp4_moe_gemm1aot_factorymxmoe_gemm2mxmoe_dispatcher.get_g2)bind_aotunderget_g2's keymoe_reductionaot_factoryOther call sites are unchanged.
Validation
On MI308X (gfx942), FlyDSL 0.5.3, at the head of this branch.
Coverage. Compile-only replays, each run twice on one cache directory, with every
flyc.compilelogged:GPU_ARCHS=gfx950 python -m aiter.aot.flydsl.gemmGPU_ARCHS=gfx950 python -m aiter.aot.flydsl.moeGPU_ARCHS=gfx942 python -m aiter.aot.flydsl.gemmGPU_ARCHS=gfx942 python -m aiter.aot.flydsl.moeCompiled kernels are unchanged. The same replays with
AITER_FLYDSL_AOT_CACHE=0leave the same FlyDSL artifacts, byte for byte: 4874 for the gfx950 GEMM (794 of them the HGEMM), 80 for the gfx942 GEMM, 2747 for the gfx950 MoE and 100 for the gfx942 MoE. No artifact is present in only one mode for the GEMMs; for the MoE the=0run used--row-tokens-only, and all of its artifacts are in the full run, identical.Launch overhead. Host time of one launch, an empty kernel, arguments built on every call, pinned cores:
torch_tensor, constexpr struct (arguments prebuilt)torch_tensorThe HGEMM rows are a launcher of the HGEMM's argument shape run on gfx942 (row- and column-major tensors give the same results on both paths). A function loaded with
flyc.load_modulemakes a DLPack view of afrom_dlpackargument in every fill unless the argument carries its tensor astorch_tensor.On the GPU, under
verify, each run twice on one cache directory (the second run re-traces every entry the first built):op_tests/test_flydsl_moe_gfx942.py(138 entries),op_tests/test_flydsl_moe_a16wfp4.py(46),op_tests/test_gemm_a8w8.py(80),tests/test_flydsl_aot_launch.py,tests/test_flydsl_aot_cache.py. No stale entry and no fallback.The
verifydefault in CI. All 85op_tests/test_*.pythat mention FlyDSL were run on gfx942 withAITER_FLYDSL_AOT_CACHE=1and then withverifyon the same cache directory. No test passes under1and fails underverify, no launch falls back, no entry is stale. (20 of the 85 fail in both modes here, from this checkout's missing CK submodule and similar.) One test did fail only underverifyon an earlier commit:test_gemm_group32_interface.pyruns an AOT replay hook that stopsflyc.compileto identify kernels, whichverifytreated as an export failure; the cache now takes the JIT path for it in every mode.Concurrency. Two replays started together on one empty cache built 123 and 9 of the 132 gfx942 MoE entries, each once, left no temporary directory, and a third built none.
Not covered
tests/test_flydsl_aot_cache.pycompares the output of a preshuffle GEMM across the JIT path, a cache miss, a hit andverify. In one run of about fifteen, with 16 other op tests sharing the GPUs, the split-K case (64x1024x2048,split_k=2) differed in one of the four modes; the test does not report which. It did not reproduce in 3100 launches of that case (JIT, hit andverify, fresh processes, with and without other load on the GPU), which all gave one output.verifyon gfx950 and gfx1250 runners. The sweep above is gfx942 only.pa_decode_plan, gfx950 FP8 flash attention, GDN), MegaMoE, a8w4comm_fused_moe.Known behaviour changes
run_cachedserialised the first compile of an HGEMM config with a lock;_run_compiled's JIT path does not, so with the cache off two threads may both compile a config. Results are unaffected.Constexprlaunch arguments that is launched under one key with two values now raises_BakedArgumentError; the JIT path silently ran the first.aot_factorywrapper no longer moves a launcher to the JIT path when a factory returns the same launcher object for two argument sets; it stays under its first key. The object is the same kernel either way.🤖 Generated with Claude Code