Skip to content

[FlyDSL] [gfx1250] Launch the GEMM and attention kernels through the AOT cache - #8567

Closed
coderfeli wants to merge 6 commits into
fix/flydsl-aot-key-guardsfrom
feat/flydsl-aot-gfx1250-gemm-attention
Closed

coderfeli wants to merge 6 commits into
fix/flydsl-aot-key-guardsfrom
feat/flydsl-aot-gfx1250-gemm-attention

Conversation

@coderfeli

Copy link
Copy Markdown
Collaborator

Stacked on #8537 (base fix/flydsl-aot-key-guards); retarget to main once that merges.

What

The gfx1250 FlyDSL GEMM and attention launchers traced and compiled on their first call in every process. They now launch through FlyDSLAotCache (export_to_c objects), like the gfx942/gfx950 GEMM and MoE launchers of #8537. Only AOT-related code changes; no kernel computation changes.

  • GEMM: a8w8 (mxfp8, plain bpreshuffle, batched) and its split-K reduce, a4w4, gemm_a16w16, gemm_a16w16_tdm, gather_kv_b_proj. Module-level launchers keep their constexprs in specialization_key; the wrappers no longer import the kernel modules, so a hit skips the kernel definitions.
  • Attention: fmha a16w16 / a8w8 (thd, paged, bshd), MLA pagesize1 (fp8, bf16), pagesize64 and the decode reduce, PA decode tile and reducer (gfx1250 only).
  • preload_a4w4_kernel runs the launch path compile-only, so the tuner's parallel precompile builds the entries its launches load (tensor_shim._compile_only()).
  • aot_cache.py: each sidecar records its fingerprint directory, disk key and the SHA-256 of its object; a mismatched or legacy pair is a miss and is rebuilt. Existing caches rebuild once.
  • Docs (docs/flydsl_aot_cache.md §5.5) and the flydsl-aot-export skill updated.

Validation

  • Compile-only for gfx1250 on a gfx942 host, before the merge of main: 42 AOT unit tests pass; the tuned GEMM replay (29 rows, 64 objects) and the attention / remaining GEMM launches (16 objects) build, a second run builds nothing, verify passes, no JIT fallback.
  • gfx1250 hardware: see §5.5 of the doc. The sampled matrix (36 cases, AOT hit / verify / JIT bitwise equal) was run with a separate MLA pagesize64 kernel fix applied, which is not in this PR; the doc states it is not a full hardware pass of this revision.
  • After merging main: not run locally. main needs Triton 3.9.0 (Python >= 3.11); the validation host has Python 3.10 / Triton 3.7.0 and cannot import main. The one conflict, aiter/aot/flydsl/dry_run.py (both sides fixed the fake-address overlap), keeps main's version; this branch's tests pass with it on the pre-merge tree. CI is the check for the merged tree.

Not in this PR

  • The MLA pagesize64 first-launch NaN (kernel issue, present on the JIT path too) goes to a separate PR.
  • gfx1250 grouped MoE, conv3d and the gfx942/gfx950 PA decode tiles stay on the JIT path.

🤖 Generated with Claude Code

coderfeli and others added 6 commits November 24, 2026 08:32
…AOT cache

The gfx1250 GEMM and attention launchers traced and compiled on their first
call in every process. They now launch through FlyDSLAotCache (export_to_c
objects), like the gfx942/gfx950 GEMM and MoE launchers.

- a8w8 GEMM (mxfp8, plain bpreshuffle, batched) and its split-K reduce,
  a4w4 GEMM, gemm_a16w16, gemm_a16w16_tdm, gather_kv_b_proj: aot_factory
  launchers, launched with factory.lazy(). Module-level launchers keep
  their constexprs in specialization_key. The wrappers no longer import
  the kernel modules, so a hit skips the kernel definitions.
- fmha a16w16 / a8w8 (thd, paged, bshd): the _ensure_*_kernel functions
  and their _launch_fns dict become cached launcher factories.
- MLA pagesize1 (fp8, bf16), pagesize64 and the decode reduce.
- PA decode: the gfx1250 tile launcher is bound where it is built, keyed
  by its traits; the reducer goes through the cache on gfx1250 only.
- preload_a4w4_kernel runs the launch path compile-only, so the tuner's
  parallel precompile builds the entries its launches load. tensor_shim
  gains _compile_only() for it, shared with _preload_compiled.

Validated compile-only for gfx1250 on a gfx942 host (see
docs/flydsl_aot_cache.md, 5.5): the tuned GEMM replay and the attention
launches build their entries, a second run builds nothing, and verify mode
passes. Not yet run on gfx1250 hardware.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Bind each exported object to its specialization key, target/toolchain
fingerprint and SHA-256 before loading. Reject mismatched or legacy pairs
and rebuild them; keep hashing off the resident dispatch path.

Fix fake-storage address overlap during GEMM replay and the uninitialized
pending-PV read in the gfx1250 MLA PS64 pipeline. Check PS64 output before
warmup, add cache-identity regressions, fix PA lint, and update the AOT
skill and hardware-validation documentation.
Restore the pre-existing MLA PS64 computation and op test. Keep the AOT replay and object-identity fixes, and document that the independent PS64 NaN issue remains unresolved in both AOT and JIT. Qualify historical hardware results that included the removed kernel fix.
…-aot-gfx1250-gemm-attention

aiter/aot/flydsl/dry_run.py: main and this branch each gave the dry run's
fake tensors disjoint address ranges. Keep main's version; this branch's
regression test for it (aliases and independent storages) passes with it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-gemm-attention

The base now has each AOT cache declare its sources (schema 7); nothing is
tracked at run time.

- Every gfx1250 cache declares sources=: its kernel module and the files
  under kernels/ that module imports, the closure the base's import check
  verifies. None of these kernels reads an environment variable outside the
  fingerprint, so none declares env=.
- aot_cache.py: the object identity checks (fingerprint, key, object
  SHA-256 in the sidecar) are kept on top of the declared-sources lookup
  and build.
- pa_decode_kernel.py: the tile launcher is bound without make_exe. The
  fresh build existed to record the files the kernel definition runs, which
  the declared sources replace; a miss no longer defines the kernel twice.
- tests, docs and the skill keep both sides.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Use the declared-source AOT API from fix/flydsl-aot-key-guards-hgemm.
Include tensor_shim IR helpers, LDS capacity definitions and MX type
constants in the gfx1250 cache sources so their edits select new objects.
Expose the target wave size in dry_run device properties so PA reducers
can be precompiled without a GPU.

Add five regressions that fail before these corrections, update the AOT
skill and validation documentation, and retain the existing object identity
guards. Production launcher and kernel function bodies are unchanged.

Validation: 59 CPU tests passed, 4 skipped; 720 GEMM and 21 attention/reducer
objects passed offline hit and verify with zero rebuilds; 34 hardware cases
passed six AOT/JIT rounds with bitwise equal outputs. The known PS64 NaN
reproduces in both modes and remains outside this AOT-only change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants