Repository navigation
[FlyDSL] [gfx1250] Launch the GEMM and grouped-MoE kernels through the AOT cache - #8678
Conversation
🏷️ 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 |
5ddfea0 to
1378944
Compare
55a9534 to
3a9ca3e
Compare
3a9ca3e to
a63a784
Compare
…e AOT cache The gfx1250 FlyDSL GEMM kernels, and the kernels the grouped MoE rows reach, traced on their first call in every process. The replays (aiter.aot.flydsl.gemm, aiter.aot.flydsl.moe) compiled them, but nothing launched through the AOT cache, so a launch could load none of it. They now launch through FlyDSLAotCache, like the gfx942/gfx950 launchers: a launch loads the entry a prebuild wrote and otherwise takes the JIT path as before. GEMM: - gemm_a16w16 and gemm_a16w16_tdm already had a cached launcher factory: it becomes an aot_factory and the launch uses factory.lazy(). The TDM factory takes a torch.device instead of a device index, so that one entry on disk serves every device. - The a8w8 (mxfp8, plain bpreshuffle, batched) and a4w4 launchers are module-level @flyc.jit functions with constexpr launch arguments, bound by the wrappers' _lazy_import. Each gets a factory with no argument that imports its kernel module; the constexprs stay in specialization_key. A hit then skips the kernel module's import (about 0.7 s for each a8w8 module). The a8w8 split-K reduce gets a factory of its own, apart from the ASM GEMM's use of the same kernel, which no replay prebuilds. - preload_a4w4_kernel preloads the bound launcher under the key its launches look up. Grouped MoE (the three kernels with the most specializations): - launch_gemm_a8w4_tdm, the grouped GEMM: bind_aot in the kernel file. The launch already passes every constexpr in specialization_key. - build_moe_fused_quant_preshuffle_route_ksplit_module and build_moe_gather_reduce_module: aot_factory on the builder; the wrappers' cached getters return builder.lazy(...). - These caches are created in the kernel files, so that the host-side variables the wrappers read (debug switches, table paths) are not inputs of the entries. Constexpr launch arguments that come from callers (the mxfp8 flags, the grouped GEMM's specs) are coerced to one type: the cache compares their values, so False and 0 under one key would raise. Sources and variables of the ten caches are declared in aiter/aot/flydsl/sources.py. Only AOT-related code changes; no kernel computation changes. Left on the JIT path, since no replay prebuilds them: the attention kernels (fmha, MLA, PA decode), the gather projection, the ASM GEMM's split-K reduce and the other kernels of the grouped rows. An EP launch of the grouped GEMM bakes its arena handle, a value of the process: it has no entry and traces as before, with the error of a missing entry. Validated compile-only for gfx1250 on a gfx942 host: both replays prebuild, a second run writes nothing, verify and mode 0 pass. Not run on gfx1250 hardware at this revision. Co-Authored-By: yadaish <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
a63a784 to
45db591
Compare
…umer main (ROCm#8678) launches the GEMM and the split-K reduce through the AOT cache launchers; _launch_splitk_reduce takes splitk_reduce_launcher the same way. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e AOT cache The mxfp8_32 B = 1 kernels the tuned rows select (weight streaming, decode, balanced decode, full M) still launched on the JIT path: the gfx1250 replay compiled them but wrote no entry, and every process traced them on their first call. Each launcher now has an aot_factory with no argument that imports its kernel module, as the a8w8 launchers of ROCm#8678 do, and the launch uses factory.lazy(). Every constexpr was already in specialization_key, with one type. The specialization keys held the device index. They hold the torch.device now: in memory it keeps one launcher per device, as the JIT path needs, and on disk only its type, so one entry serves every GPU. The four caches and their sources are declared in aiter/aot/flydsl/sources.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts resolved (all from #8678, AOT-cache launchers): - mxfp8 and plain bpreshuffle wrappers: keep this branch's launch arguments (runtime cluster_m, c_pad, quad_early, no_loop_cbar, rank0) and launch through gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy() and splitk_reduce_launcher.lazy(); keep both import lists. - Normalize c_pad, quad_early, no_loop_cbar and fused_splitk to int/bool like main's other constexprs: the AOT key compares them by value. Merged cleanly but needed changes: - aot/flydsl/sources.py: gemm_a8w8_gfx1250 also lists splitk_fused_epilogue_gfx1250.py, which the generic kernel now imports. - test_gemm_a8w8_mxfp8_bpreshuffle.py: count reduce launches through splitk_reduce_launcher.lazy (_compile_splitk_reduce is gone).
Conflicts resolved (all from #8678, AOT-cache launchers), as in #8246's merge 94fefb8: - mxfp8 and plain bpreshuffle wrappers: keep this branch's launch arguments and launch through gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy() and splitk_reduce_launcher.lazy(). The compute launch keeps bounded_n and a_scale_unaligned in specialization_key; _lazy_import also binds tensor_shim.data_ptr. Merged cleanly but needed changes (taken from #8246's merge): - aot/flydsl/sources.py: gemm_a8w8_gfx1250 also lists splitk_fused_epilogue_gfx1250.py, which the generic kernel imports. - test_gemm_a8w8_mxfp8_bpreshuffle.py: count reduce launches through splitk_reduce_launcher.lazy (_compile_splitk_reduce is gone).
…e AOT cache The mxfp8_32 B = 1 kernels the tuned rows select (weight streaming, decode, balanced decode, full M) still launched on the JIT path: the gfx1250 replay compiled them but wrote no entry, and every process traced them on their first call. Each launcher now has an aot_factory with no argument that imports its kernel module, as the a8w8 launchers of ROCm#8678 do, and the launch uses factory.lazy(). Every constexpr was already in specialization_key, with one type. The specialization keys held the device index. They hold the torch.device now: in memory it keeps one launcher per device, as the JIT path needs, and on disk only its type, so one entry serves every GPU. The four caches and their sources are declared in aiter/aot/flydsl/sources.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e AOT cache The mxfp8_32 B = 1 kernels the tuned rows select (weight streaming, decode, balanced decode, full M) still launched on the JIT path: the gfx1250 replay compiled them but wrote no entry, and every process traced them on their first call. Each launcher now has an aot_factory with no argument that imports its kernel module, as the a8w8 launchers of ROCm#8678 do, and the launch uses factory.lazy(). Every constexpr was already in specialization_key, with one type. The specialization keys held the device index. They hold the torch.device now: in memory it keeps one launcher per device, as the JIT path needs, and on disk only its type, so one entry serves every GPU. The four caches and their sources are declared in aiter/aot/flydsl/sources.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…15808c7, head 2026-11-19T10:14:52Z) Applied as the diff ce334d0..15808c7 (26 files) onto the rebased 1116 tree; PR state: open, author aoli26, base main. Squash-applied: #8246's branch merges main (ce334d0, this tree's base) and carries rebased copies of aoli26's #7827 (head 9d38b5c, every added line present here) and #7868 (head 570805d; 3 of its added lines are superseded by #8246's later edits), so this one diff applies the #7827 -> #7868 -> #8246 stack as #8246 has it. (cherry picked from commit f58bb7e) Rebase onto main 12-03: kept at the 15808c7 snapshot (the PR head is now c4f8a6d, see the rebase report). Main's #8678 (AOT launchers) and #7449 (deferred split-K partials) conflict with it in the two wrappers: bpreshuffle_gemm_gfx1250.py takes both fused_splitk and main's partials (a launch with partials runs unfused, main's _launch_splitk_reduce / reduce_splitk_partials_gfx1250 kept, skipped when fused); mxfp8_bpreshuffle_gemm_gfx1250.py keeps fused_splitk_ok (generic kernel included) and launches gemm_a8w8_launcher.lazy() with this PR's argument layout (arg_out, runtime cluster_m, fused_splitk). Same as the PR author's own merge of main, without the later lean_stripe_fits guard. aiter/aot/flydsl/sources.py: the gemm_a8w8_gfx1250 cache now also hashes kernels/splitk_fused_epilogue_gfx1250.py, which the kernel imports (as on the PR head). Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce), as on the PR head.
#8978) * K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows (#8778 @ ea7a5d8) #8778 (aoli26; base main; open) applied to k3-455-dev as its net change on its 19 files at head ea7a5d8 (2026-11-26T14:47:07Z), 3-way against the PR's main base adbb6ac. The 8 files k3-455-dev had changed (all only by #8246 @ 15808c7) take the PR's version, so all 19 files equal the PR head. It carries the newer #8246 (ccc4270), the table PRs #8579 / #8586 / #8601 and main's #8566 (its compute guard, which #8778 replaces); no other main change rides in. Validated in the K3 1P1D integration branch (aiter zejun/k3-455-dev 627e1eb) on 16 MI455X (wuhuikx/LLM-Booster#578). The PR head has moved on since (204ce9d: merges of #8246 @ 0d6cf15 and of main, which brings #8737); those can follow when #8778 lands. Co-authored-by: zejunchen-zejun <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update K3 FP8 kernels to c997 and add exact-M tuning Preserve the existing dev wrappers and bucket tables. Add 162 accepted retuned exact configurations and 3 c997-default compatibility records, with CPU dispatch coverage for all 675 measured points. Backport the three kernel files from c99781c without merging main history. Integrated-head GPU validation remains outstanding. --------- Co-authored-by: aoli26 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zhang <[email protected]> (cherry picked from commit 1cc9d02) Rebase onto main 12-03: the 19 files keep this commit's content; only main's later changes are added: the AOT launcher factories of #8678 (mxfp8 / batched wrappers launch gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy(), splitk_reduce_launcher.lazy(); _lazy_import keeps _data_ptr), #7449's deferred split-K entry points and #8636's ragged-K fallback. gemm_a8w8_gfx1250.py: this commit's rank0 split-K epilogue and flush_addr (it already carries #8737's flush). gemm_op_a8w8.py: main's #8566 guard in get_mxscale_bpreshuffle_config (no padded row below a compute kernel's M tile) is removed, as on the #8778 head, because the c997 compute kernel serves underfilled tiles; test_gemm_host_dispatch_cache.py takes #8778's test_mxscale_compute_row_serves_underfilled_m_tile in place of main's two guard tests. kimik3 mxscale tuned CSV: this commit's rows (626 changed or added) replayed by key; the result equals this commit's table. Rebase onto main 12-03: main #7449 moved the bpreshuffle row lookup into _bpreshuffle_config(XQ, WQ); this commit's Kimi-K3 exact-row lookup there needs x_scale, w_scale and Y, so _bpreshuffle_config takes them (the deferred split-K path passes a meta tensor of the output's shape and dtype, so it picks the same row as gemm_a8w8_bpreshuffle). Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce).
A shared expert whose down projection reads MXFP8 runs the gate_up GEMM (bf16 [M, 2I]), silu_and_mul and quantize_fp8 as three launches. The batched mxfp8_32 gfx1250 kernel now applies the SwiGLU before its fused group-32 MXFP8 epilogue, so the three become one GEMM. Kernel (kernels/gemm_a8w8_gfx1250.py), new fuse_act_mul / act_limit constexprs (batched mxfp8_32, 32x32 B scale, fuse_quant_out, no K tail): - B is the unmodified [gate; up] weight. Each CTA gathers its tile_n B rows, and their scale rows, as tile_n/64 blocks of [32 gate rows, the matching 32 up rows] through one nested TDM view, so a wave's 64 columns hold gate and up of the same 32 outputs in the same lanes. - The epilogue rounds the accumulators to bf16 and forms bf16(silu(bf16(min(g, L))) * clamp(u, -L, L)) as aiter silu_and_mul does (L = 0: no clamp), then quantizes each 32-column group with ROCm#7667's emit_mxfp8_acc_pair_to_lds / emit_mxfp8_scale_rows_store; only the e4m3 TDM store stays local, shared with the accumulator-quant epilogue. - Against the bf16 GEMM + silu_and_mul + quantize_fp8 chain, a SwiGLU value can sit one bf16 step from silu_and_mul's (exp/rcp rounding), so an e4m3 code can differ by one step; where that value is its group's amax at 448 * 2**k, the group's e8m0 scale moves by one instead (and so all 32 codes). - The kernel name gets a _silu<limit>q suffix, so it never collides with the plain GEMM; fuse_act_mul defaults to off. Host (batched_gemm_a8w8_gfx1250.py): - run_gate_up_silu_mxfp8_32_gfx1250: the raw launch. Operand dtypes, strides, shapes, devices, alignment, the limit and the kernel name are checked before the arch check; the e8m0 x_scale / w_scale checks run after it. swiglu_limit is read as the f32 silu_and_mul receives. kernel_name=None picks the tile from the runtime row count. - gate_up_silu_supported(n2, k): gfx1250 with the measured CU count at the measured [2I, K]; independent of the row count. - gate_up_silu_kernel_for(m, n2, k): the table tile for the measured device and shape only, else None. A host helper for code that sees the real row count; not for branching in a traced forward. - The table tiles end in _pl (the pipelined K loop). Op (batched_gemm_op_a8w8.py): functional registered op gate_up_silu_mxfp8_32 (mutates_args=[]) that picks the tile from the runtime row count and returns the e4m3 / e8m0 outputs. Tests: op_tests/test_flydsl_gate_up_silu_host.py (CPU: gating, picker, limit and operand validation, functional op under fullgraph dynamic shapes) and test_gate_up_silu_fused in op_tests/test_flydsl_batched_gemm.py (gfx1250: every tile bucket, limits 10, 0 and 5.02, vs the unfused chain). Rebased onto main: the launch goes through gemm_a8w8_launcher.lazy(), the AOT-cache factory ROCm#8678 put in place of the module-level launcher. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follow-up to #8565 and #8600, on
main. Supersedes #8567 and #8777 (closed).What
The gfx1250 FlyDSL GEMM kernels, and the kernels the grouped MoE rows reach, traced on their first call in every process. The replays (
aiter.aot.flydsl.gemm,aiter.aot.flydsl.moe) compiled them, but nothing launched through the AOT cache, so a launch could load none of it. They now launch throughFlyDSLAotCache, like the gfx942/gfx950 launchers: a launch loads the entry a prebuild wrote and otherwise takes the JIT path as before.gemm_a16w16_gfx1250gemm_a16w16_gfx1250.gemm_a16w16aot_factory;.lazy()gemm_a16w16_tdm_gfx1250gemm_a16w16_tdmtorch.deviceinstead of a device index, so one entry on disk serves every devicegemm_a8w8_gfx1250,gemm_a8w8_256x256_gfx1250mxfp8_bpreshuffle_gemm_gfx1250,bpreshuffle_gemm_gfx1250,batched_gemm_a8w8_gfx1250specialization_keygemm_a8w8_splitk_reduce_gfx1250gemm_a4w4_gfx1250,gemm_a4w4_256x256_gfx1250a4w4_mxscale_bpreshuffle_gemm_gfx1250grouped_gemm_a8w4_tdm_gfx1250launch_gemm_a8w4_tdm, the grouped GEMMbind_aotin the kernel file; the launch already passes every constexpr inspecialization_keymoe_fused_quant_preshuffle_route_ksplitbuild_moe_fused_quant_preshuffle_route_ksplit_moduleaot_factoryon the builder; the wrapper's getter returnsbuilder.lazy(...)moe_gather_reducebuild_moe_gather_reduce_module@flyc.jitfunctions bound by the wrappers'_lazy_import; there was no factory to decorate, which is why those diffs are larger than a gfx950 conversion. Their factories import the kernel module, so a hit skips that import (about 0.7 s for each a8w8 module).grouped_moe_gfx1250.py/moe_kernels.py: the file that creates a cache is one of its sources, and those wrappers read a dozen host-side variables (debug switches, table paths) that would then have to be inputs of the entries.Falseand0under one key would raise.preload_a4w4_kernelpreloads the bound launcher under the key its launches look up.aiter/aot/flydsl/sources.py.aot_cache.py,aot_launch.pyandtensor_shim.pyare untouched.Not in this PR
Validation
Compile-only for gfx1250 on a gfx942 host (FlyDSL 0.5.3). The host has Python 3.10 / Triton 3.7 / torch 2.8, so the tree was imported with a local placeholder for
gl.amd.cdna5; only FlyDSL code ran.ruff==0.16.0andblack==26.10.1pass on the changed files.tests/test_flydsl_aot_launch.pyandtests/test_flydsl_aot_replay.py: 60 passed, including the checks that the table matches the caches created and that every cache declares the kernel files and variables its sources use. The 4 cases oftest_a_split_k_tdm_gemm_replay_reaches_flydslfail on this host, onmainas well:torch.cuda.stream()of torch 2.8 reaches the GPU runtime under the dry run.GPU_ARCHS=gfx1250 python -m aiter.aot.flydsl.gemmon 41 tuned rows (plain bpreshuffle, mxfp8_32 general and compute-bound, a4w4 general and compute-bound, bmm mxfp8_128, bf16): 41 ok. A second run writes nothing;verifyand mode0pass. (5 fused-quant variants of the bmm rows are refused by the runtime in every mode, as onmain.)GPU_ARCHS=gfx1250 python -m aiter.aot.flydsl.moeon 44 rows of the grouped tables (232 jobs): 87, 21 and 21 objects for the three grouped-MoE caches. A second run writes nothing;verifyand mode0pass.gemm_a16w16_tdmunderdry_run("gfx1250", 256), withtorch.cuda.streamstubbed for the reason above: one object; a second run writes nothing;verifypasses.preload_a4w4_kernelin a prebuild writes the entry; the launch of that config then writes nothing.Not run on gfx1250 hardware at this revision.
A launch with no entry traces with one error per key, as for every converted launcher: a tuner's candidates (run tuners under
AITER_FLYDSL_AOT_CACHE=0) and shapes with no tuned row.🤖 Generated with Claude Code