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 tests can miss first-use mutations because they snapshot state after the first cached launch, and the selected dimensions exercise only bandwidth-bound cache reuse, leaving compute-bound reuse untested.
2 open issues
What changed in this PR
This PR reduces host overhead in gfx1250 non-persistent Gluon GEMM by caching reusable layout metadata. Public APIs, GPU kernels, and other dispatch paths remain unchanged.
Changes:
- Add a bounded, 128-entry cache keyed by six scalar layout inputs.
- Use cached metadata in the non-persistent Gluon wrapper.
- Add regression tests for cache behavior, numerical results, graph replay, compilation, and metadata lifetime.
| File | Description |
|---|---|
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py |
Add cache and GEMM integration regression tests. |
aiter/ops/triton/gemm/basic/gemm_a16w16.py |
Cache layout metadata for non-persistent gfx1250 Gluon GEMM. |
Review effort: Balanced
| # avoids spending GPU memory on an unrelated large-matrix test. | ||
| for kernel_type, rows in (("bandwidth_bound", 37), ("compute_bound", 129)): | ||
| x, w, _, _, _ = generate_gemm_a16w16_inputs( | ||
| rows, 128, 512, dtype=dtype, layout=layout, output=False |
| snapshot = [dataclasses.asdict(v) for v in layouts] | ||
| hashes = [hash(v) for v in layouts] |
|
check #6480 and #6500 which cache a private layout builder in the Gluon kernel module; here the wrappers keep the per-call cost. and secondly can we remote the additional UTs, we are trying to keep our CI run time minimal. |
|
No activity for 15 days, so this is now labelled |
Boss2002n
left a comment
There was a problem hiding this comment.
Must fix before merge
- Merge conflicts with main (wrapper, test): #7289 changed the same lines. In the wrapper it added
import osand thecreate_store_layoutimport, and in the test file it added new tests at the end. The PR cannot merge as it is. Fix: rebase on main, and keep main'simport osandcreate_store_layoutimport.
Nice to fix
- Move the cached layout builder into
_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16.pyas a privatefunctools.cachefunction, asgemm_mxfp4.pydoes, and call it from the wrapper (wrapper). Then the batched and grouped wrappers can reuse it later. - Delete the five cache tests (test). They check cache internals, not GEMM results, and the existing Gluon tests already cover the cached path. This also removes the false "both kernel variants" comment: with N=128, K=512, both M values run
bandwidth_bound. - Answer the open review comments.

Summary
Cache the tensor-independent layout metadata constructed by the gfx1250
non-persistent BF16/FP16 GEMM Python wrapper.
create_wmma_layoutsandcreate_shared_layoutsrebuilt the same Gluondataclasses on every invocation. cProfile identified repeated layout
construction /
_unwrap_if_constexprcalls in the M3 router GEMM host path.Add a private
lru_cache(maxsize=128)keyed by:(block_m, block_n, block_k, layout, elem_bits, num_warps).persistent dispatch, Triton dispatch and GPU kernel bodies are unchanged.
the gfx1250-only path does not need a device ordinal in the key.
fields/hashes before and after launch/compile, rather than assuming that a
frozen dataclass makes its nested lists immutable.
no exactly-once or cross-thread identity contract is assumed.
Related: https://github.com/wuhuikx/LLM-Booster/issues/188
This is separate from the existing sparse attention-plan reuse and index-score
tuning, and from #7080/#7082 and ATOM#2781.
Host-call measurement
Actual patched public GEMM call, warmed
[2517,6144] @ [128,6144].T,BF16, gfx1250. Layout caching enabled/disabled through the helper's original
implementation, in interleaved base/cache, cache/base, base/cache order.
Seven samples per arm, 100 asynchronous public calls per sample, synchronize
before each sample; host enqueue timing, not GPU execution latency.
cProfile is a separate diagnostic, not the source of these reported timings.
Full-model trace confirmation
MiniMax-M3-MXFP4, TP4, gfx1250 (256 CU/device), EAGLE3 with 3 speculative
tokens, FP8 KV, ptpc_fp8 non-MoE linears. Same ATOM checkout with the SwiGLU
FP32 fix in both arms. Exact 2517-token disjoint prompts within each service;
identical seeds/input hashes across base and cache arms. No fake acceptance
rate. Warmups excluded.
Three profiled batches in one service start per arm, all four ranks.
Each selected annotation is
prefill[bs=1 tok=2517 ctx=2517 nctx=3.2M].Every rank/recording has 58 BF16 GEMM host calls and 120 start-sync calls.
Trace aggregates are the median of three batch summaries, each a median
across four ranks. The host event duration reduction is approximately
44.5%. These are host-event durations, not an exclusive CPU/critical-path
decomposition, and cannot be summed across concurrent ranks as wall savings.
GPU dispatch controls:
BLOCK_M128 / BLOCK_N128 / BLOCK_K64 / NUM_BUFFERS6 / TNconfiguration:median GPU duration 23.334 -> 23.054 us (broadly unchanged).
37.495 -> 37.495 us.
Return-to-base control: restarting the unpatched service reproduced
host GEMM medians of 136.008 / 134.377 / 134.797 us and per-step sums of
8.053 / 7.892 / 7.885 ms. Median TTFT over its same 30 prompts was 91.95 ms.
This supports a localized host overhead reduction rather than kernel tuning.
Limits on request-level claims
The first base/cache pair shows 3.78% lower observed median TTFT for this
single-request, 2517-token, one-output-token workload. Batch 0 was slightly
slower with caching; later batches were faster. The return baseline is a
useful control, but three batches are not three independent service-start
replicates and rank traces are not independent timing samples.
This is not a general throughput claim or a prediction for other concurrency,
context lengths, decode graph replay, models or machines. CUDA graph replay
does not rerun this Python helper. No GSM8K/model-quality result is claimed.
All 30 paired one-token response hashes matched, a narrow output check only.
Validation
cached/uncached bit-exact comparisons and graph replay.
0 and 1 (separate runs) on the release checkout.
equality/hash values, concurrent misses, all four layout modes, both Gluon
kernel types, FP16/BF16, preallocated outputs, graph replay after changing
inputs, nested metadata mutation checks and tensor weakrefs after teardown.
torch.compilecorrectness is exercised on the publicGEMM API with cache misses/hits and different M.
--target-version py312), Ruff andgit diff --checkpassed.Provenance / reproducibility
Full-model A/B used aiter
bbef5a6f2d3733b293c80d2cee6a8d464e88bc01plus only the candidate wrapper change. ATOM is pinned main+#2710 with the
SwiGLU fix identical in both arms. Image:
rocm/fw-bringup-mlperf:gfx1250-atom-20261023, isolated FlyDSL 0.4.0 overlay.Release base:
48295fab6e1d06d4bb4aa76418075c68bede0860.The modified wrapper and test file were unchanged between the experiment
base and release base; the production wrapper SHA256 is identical in both
candidate checkouts. The entire newer-main model stack was not separately
benchmarked.
Excluded run: an initial candidate-model attempt loaded base aiter in
spawned workers because
AITER_META_DIRinserted/code/aiterahead of thecandidate path. That recording is marked invalid and excluded. The corrected
configuration sets both
PYTHONPATHandAITER_META_DIRto the candidate;an explicit parent/spawn-child probe verified matching module paths and the
cache helper before the corrected full-model recording. Match both settings
when reproducing; parent-only imports do not prove spawned worker identity.
Raw traces, matched-input manifests, host samples, excluded-run diagnostics,
return-baseline results and independent gpt-6-astra review reports remain
outside the repository. No benchmark reports are added under docs.
Validated release commit:
4aace7695a6da9c7f13c562d9301e9ba11f97bbe.