Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
The backend changes need separation, and the M-class cache needs regression tests that verify unchanged kernel selection.
2 open issues
What changed in this PR
This PR reduces Python overhead in AITER’s gfx1250 GEMM and MoE launch paths without changing kernel bodies.
Changes:
- Cache kernel selection, parsed configurations, Gluon layouts, and stream wrappers.
- Avoid nested custom-op dispatch while preserving rebound module functions.
- Reduce untuned-config lookup work and defer debug-message formatting.
| File | Description |
|---|---|
aiter/tuned_gemm.py |
Enables direct-body dispatch for nested Triton GEMM calls. |
aiter/ops/triton/gemm/basic/gemm_a16w16.py |
Caches Gluon layouts and supports direct-body dispatch. |
aiter/ops/gemm_op_a8w8.py |
Shortens config misses, deduplicates warnings, and avoids nested dispatch. |
aiter/ops/flydsl/moe_kernels.py |
Uses cached current-stream wrappers. |
aiter/ops/flydsl/kernels/tensor_shim.py |
Adds a pointer-conversion fast path for plain tensors. |
aiter/ops/flydsl/grouped_moe_gfx1250.py |
Defers debug formatting and uses cached stream wrappers. |
aiter/ops/flydsl/grouped_gemm_mxfp4.py |
Uses the shared stream-wrapper cache. |
aiter/ops/flydsl/batched_gemm_a8w8_gfx1250.py |
Caches kernel-name parsing and selection by M class. |
aiter/ops/flydsl/_stream.py |
Adds wrapper caching while querying the current stream each call. |
Review effort: Balanced
| m_class = tuple( | ||
| (-(-m // tm) if sat is None else min(-(-m // tm), sat)) for tm, sat in params | ||
| ) | ||
| key = (b, n, k, bool(w_scale_32x32), m_class, (m & 1) if parity else 0, m > 0) |
| _STREAMS: dict = {} | ||
|
|
||
|
|
||
| def current_stream(device=None): |
… wrappers Complements ROCm#6946 (compiled FlyDSL launcher cache, merged) with the host-side savings it does not cover: - batched mxfp8_32 GEMM: memoise the untuned-shape heuristic per M class (ceil(M / tile_m) per candidate tile, saturated past the M-block limit, plus M parity when an A-preshuffle candidate exists) instead of per exact M, and cache kernel-name parsing. Prefill hands every linear a new M each step; the pick is identical to the per-M heuristic. - get_mxscale_bpreshuffle_config: answer an N/K with no tuned row at any M without walking the padded-M levels, and log an untuned weight shape once per (N, K, w_scale_block) instead of once per M. - gemm_a8w8_blockscale -> gemm_a8w8_blockscale_bpreshuffle and tuned_gemm.gemm_a16w16 / gemm_a16w16_out -> triton gemm_a16w16_: the outer custom op's body calls the nested op's body directly instead of a second torch.ops dispatch. torch_compile_guard exposes the body it registered as ``_eager_body``; a rebound module attribute is still honoured. - triton gemm_a16w16 gluon path: memoise the WMMA/shared layouts per tile config. - grouped_gemm_gfx1250_a8w4: build debug strings only when AITER_GROUPED_DEBUG is on and skip the arch-override env reads on gfx1250. op_tests/test_gemm_host_dispatch_cache.py checks each cache against the uncached answer (CPU contracts plus bitwise GPU comparisons). Co-Authored-By: Claude Opus 5.5 <[email protected]>
62180cc to
482aa1b
Compare
|
Superseded by #7006 (FlyDSL-only split; the Triton gemm_a16w16 changes are dropped). |
…ppers (#7006) FlyDSL-only split of #6948 (the Triton gemm_a16w16 changes are dropped). Complements #6946 (compiled FlyDSL launcher cache). - batched mxfp8_32 GEMM: memoise the untuned-shape heuristic per M class (ceil(M / tile_m) per candidate tile, saturated past the M-block limit, plus M parity when an A-preshuffle candidate exists) instead of per exact M, and cache kernel-name parsing. Prefill hands every linear a new M each step; the pick is identical to the per-M heuristic. - get_mxscale_bpreshuffle_config: answer an N/K with no tuned row at any M without walking the padded-M levels, and log an untuned weight shape once per (N, K, w_scale_block) instead of once per M. - gemm_a8w8_blockscale -> gemm_a8w8_blockscale_bpreshuffle: the outer custom op's body calls the nested op's body directly instead of a second torch.ops dispatch. torch_compile_guard exposes the body it registered as ``_eager_body``; a rebound module attribute is still honoured. - grouped_gemm_gfx1250_a8w4: build debug strings only when AITER_GROUPED_DEBUG is on and skip the arch-override env reads on gfx1250. op_tests/test_gemm_host_dispatch_cache.py checks each cache against the uncached answer (CPU contracts plus bitwise GPU comparisons). Co-authored-by: Claude Opus 5.5 <[email protected]>


What
Complements #6946 (merged; caches compiled FlyDSL launchers and covers the MoE launch paths). This PR keeps only the host-side savings #6946 does not cover. No kernel changes; kernel selection and outputs are unchanged.
batched_gemm_a8w8_gfx1250): the heuristic depends on M only throughceil(M / tile_m)per candidate tile (saturated past the M-block limit), plus M parity when an A-preshuffle candidate exists, so that tuple is the cache key; kernel-name parsing is cached too. Identical result to the per-M heuristic; prefill hands every linear a new M each step.get_mxscale_bpreshuffle_config: early return for an N/K with no tuned row at any M, and the "untuned" warning is logged once per (N, K, w_scale) instead of once per M.gemm_a8w8_blockscale→gemm_a8w8_blockscale_bpreshuffle,tuned_gemm.gemm_a16w16/gemm_a16w16_out→ tritongemm_a16w16_) viatorch_compile_guard's new_eager_bodyattribute, instead of a secondtorch.opsdispatch. A rebound module attribute is still honoured.gemm_a16w16gluon path: WMMA / shared layouts memoised per tile config.grouped_gemm_gfx1250_a8w4:_grouped_dbgstrings are built only whenAITER_GROUPED_DEBUGis on, and the arch-override env reads are skipped on native gfx1250.Dropped from the earlier version of this PR: the
_stream.py/current_streamrewrites (same call sites as #6946) and theptr_argfast path (no measurable gain). Fixed the Black / Ruff (UP033) failures that gated CI.Why
DeepSeek-V4.1-Flash serving on MI455X (gfx1250, ATOM TP4): prefill steps were dominated by Python dispatch in the op wrappers rather than GPU work.
Host us/call, gfx1250, DSV4.1 TP4 shapes, M=1758 (#6946 → #6946 + this PR):
Outputs bitwise identical.
Testing
Applied on current
main(which includes #6946; the commit applies cleanly), gfx1250 (MI455X):op_tests/test_gemm_host_dispatch_cache.py(each cache checked against the uncached answer; CPU contracts plus bitwise GPU comparisons): 43 passed.op_tests/test_gemm_group32_interface.py: 119 passed, 50 skipped.op_tests/test_flydsl_batched_gemm.py(script, 90 shapes): all error columns 0, accuracy columns identical to the run on [FlyDSL] Cache compiled FlyDSL launchers on host paths #6946's head.black --checkandruff check(0.16.0, repo config) clean on the changed files.🤖 Generated with Claude Code