Repository navigation
[Triton/Gluon] Move fast_launch to utils and key what Triton specializes on - #8061
Conversation
fast_launch skips Triton's per-call dispatch for any kernel, and other code (ATOM's Qwen3.8 HC launches) needs it too. Move it to aiter/ops/triton/utils/fast_launch.py unchanged and update its callers: flash_kda and the gfx950 / gfx1250 Gluon K1 and K2 kernels. Co-authored-by: Cursor <[email protected]>
… for hooks Add to the key the knobs that enter Triton's compile options or specialization, the type of every non-tensor argument (True, 1 and 1.0 were one key), and the shape and strides of tensors for kernels under autotune / heuristics. Take the ordinary path for launch, pre-run and stages-inspection hooks and under torch.compile, recompile-check changed globals as Triton does, and do not cache a config with a pre_hook. Accept positional arguments. Add by_specialization=True: a plain kernel keys its non-constexpr ints by Triton's classes (1, multiple of 16, i32 / i64 / u64) and its floats and bools by type, so a caller whose sizes change on every call does not miss on each size. op_tests/triton_tests/utils/test_fast_launch.py checks that equal keys imply equal Triton cache keys (from Triton's own binder) and each guard. Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Two critical issues remain: reading an unavailable optional Triton knob can raise AttributeError before dispatch, and tuple cache-key collisions can reuse an incompatible compiled kernel.
2 open issues
What changed in this PR
Moves fast_launch into shared Triton utilities so KDA and downstream callers can reuse one launcher, while strengthening cache keys and preserving dispatch side effects.
Changes:
- Adds positional arguments and an opt-in specialization-based cache mode.
- Adds cache guards for hooks, tracing, changed globals, and autotune pre-hooks.
- Updates KDA imports, documents the shared helper, and adds launcher tests.
| File | Description |
|---|---|
op_tests/triton_tests/utils/test_fast_launch.py |
Adds cache-key, hook, launch, and graph-replay tests. |
op_tests/triton_tests/kimi_delta_attn/test_flash_kda.py |
Updates the shared launcher import. |
op_tests/triton_tests/kimi_delta_attn/test_fast_launch.py |
Updates the shared launcher import. |
aiter/ops/triton/utils/fast_launch.py |
Adds the shared launcher with stronger keys and guards. |
aiter/ops/triton/README.md |
Lists the shared launcher utility. |
aiter/ops/triton/_triton_kernels/kimi_delta_attn/flash_kda.py |
Uses the shared launcher path. |
aiter/ops/triton/_triton_kernels/kimi_delta_attn/fast_launch.py |
Removes the old KDA-local launcher module. |
aiter/ops/triton/_gluon_kernels/gfx950/kimi_delta_attn/flash_kda_k2.py |
Updates the gfx950 K2 launcher import. |
aiter/ops/triton/_gluon_kernels/gfx950/kimi_delta_attn/flash_kda_k1.py |
Updates the gfx950 K1 launcher import. |
aiter/ops/triton/_gluon_kernels/gfx1250/kimi_delta_attn/flash_kda_k2.py |
Updates the gfx1250 K2 launcher import. |
aiter/ops/triton/_gluon_kernels/gfx1250/kimi_delta_attn/flash_kda_k1.py |
Updates the gfx1250 K1 launcher import. |
Review effort: Balanced
…d launcher" This reverts commit c142f87, together with the launcher-only lines 39463e7 added to atom/utils/triton_launch.py and tests/test_triton_launch.py. The HC launches go back to kernel[grid]. The cached launcher moves into aiter's fast_launch (ROCm/aiter#8061); the HC launches will switch to it in a separate PR after that lands. Co-authored-by: Cursor <[email protected]>
Per the review on #3429, ATOM no longer carries its own Triton dispatch bypass: the 13 prefill wrappers (GDN l2norm / causal conv1d + metadata / gating, output-gate quant, QSA helpers, scorers and sparse attention, q/k norm) wrap their kernels with `aiter.ops.triton.utils.fast_launch.fast_launch(kernel, by_specialization=True)` (ROCm/aiter#8061) and pass the launch options per call, so the per-option launcher tables go away. Launches its key cannot describe take Triton's ordinary path inside fast_launch. atom/utils/triton_launch.py and its tests are removed; the key-vs-Triton guard tests live in aiter. tests/test_fast_launch_wrappers.py keeps the GPU checks: each wrapper bitwise against plain `kernel[grid]` (`fast_launch.bypassed()`), a repeat run without a miss, and CUDA-graph replay. Co-authored-by: Cursor <[email protected]>
…unch Moved here from #3429, which dropped its HC launcher until ROCm/aiter#8061 lands: `hc_combine_norm` (single- and multi-row), `scaled_silu`, `hc_gated_mean` and `hc_gated_mean_quant` wrap their kernels with `fast_launch(kernel, by_specialization=True)`. tests/test_fast_launch_wrappers.py: the HC launches bitwise against the launches written out as plain `kernel[grid]`, against the same wrappers on Triton's ordinary path with a repeat run that never misses, and replayed in a CUDA graph. Co-authored-by: Cursor <[email protected]>
…ny state Under torch.compile(fullgraph=True), Dynamo traces the launch function. It read the kernel's pre_run_hooks (through _plain) before asking torch.compiler.is_compiling(), and Dynamo cannot branch on that list: "Data-dependent branching" on GetAttrVariable(TritonKernelVariable(), pre_run_hooks). Check is_compiling() first, so a traced launch goes to kernel[grid] before the wrapper touches its hooks, cache or flags. Found when ROCm/ATOM#3431 wrapped kernels that Qwen3-Next reaches under @support_torch_compile. Test: launches under torch.compile(fullgraph=True) with the eager and inductor backends, both key modes and all three call styles, with an entry already cached, are bit-equal to eager and record no miss. They fail with the check back in its old place or removed. Co-authored-by: Cursor <[email protected]>
|
Fix for a torch.compile problem found while wiring ROCm/ATOM#3431 onto Problem. On 7c54c82, a Fix. Tests (MI308X, one GPU, Triton 3.8, torch 2.10):
cc @valarLip |
…builds that have it aiter accepts triton>=3.6.0, and upstream Triton 3.6, 3.7 and 3.8 have no compilation.fpsan_homomorphic_casts knob (AMD's 3.8.0 build and upstream 3.9 have it). On those builds _key raised AttributeError, so every launch through fast_launch failed, the flash_kda ones included. JITFunction.run puts the knob in the compile options only on the builds that have it, so decide once at import whether it exists and key it only then. The test oracle mirrors run the same way, and the knob-change case for TRITON_FPSAN_HOMOMORPHIC_CASTS skips on a build without the knob. Test, one MI308X: - upstream Triton 3.7.1 wheel: utils/test_fast_launch.py 40 failed / 1 passed before, 40 passed / 1 skipped after; kimi_delta_attn test_fast_launch.py 19 failed before, 19 passed / 1 skipped after, as with the image's aiter before this PR. - AMD Triton 3.8.0: utils/test_fast_launch.py 41 passed, as before. Limit: aiter CI installs AMD's 3.8.0, which has the knob, so CI does not run the path without it.
…nary path Triton specializes each item of a tuple argument ((2,) is i32, (2.0,) is fp32), but the key holds a tuple by its value and (2,) == (2.0,). So a launch with (2.0,) reused the kernel compiled for (2,), and its launcher raised "TypeError: 'float' object cannot be interpreted as an integer" where the ordinary path compiles a second kernel. No caller passes a tuple today, so do not cache a launch with a tuple argument: like an argument that cannot be hashed, it keeps the wrapper on the ordinary path. The check runs on a miss only, so a cached launch costs the same as before. Test: (2,) then (2.0,) through one wrapper, in both key modes, gives x * 2 each time and leaves no entry. Without the check both cases fail. utils/test_fast_launch.py: 43 passed (AMD Triton 3.8.0), 42 passed and 1 skipped (upstream Triton 3.7.1), one MI308X.
…in by type Self-review of this PR: - The module docstring still gave flash_kda as the reason for the file. fast_launch is a shared helper in utils/ now, so say why in general terms and leave the kernel out. - _hooked found a HookChain by probing for a "calls" attribute. Triton has HookChain in every supported version (3.6 to 3.9), so check the type: a chain runs when it has a hook, and anything else runs when it is not None. The result is the same as before for None, an empty chain, a chain with a hook and a plain callable. Test, one MI308X: utils/test_fast_launch.py 43 passed (AMD Triton 3.8.0), 42 passed and 1 skipped (upstream Triton 3.7.1). Mutants: _hooked always False fails 1 test, an empty chain counted as a hook fails 4.
|
1. The fpsan knob. Confirmed. Upstream Triton 3.6.0, 3.7.x and 3.8.0 have no 2. Tuple arguments. Confirmed. Triton specializes each item of a tuple: Self-review against the maintainer guidelines (
Tests, one MI308X (gfx942), with this branch as a symlink overlay over the image's aiter, and AMD Triton 3.8.0 unless stated:
Not covered. aiter CI installs AMD's 3.8.0, so CI does not run a Triton build without the fpsan knob. I ran that path by hand on the 3.7.1 wheel only, not on 3.6.0 or on pytorch-triton-rocm. The gfx950 / gfx1250 Gluon files did not run here; this round does not change them. Note for the merge. The three earlier commits have Waiting for: CI on cc @valarLip |
ATOM measured a fast_launch hit at about 4.5 us more host time per launch than the CachedLauncher it replaces (33.5 vs 28.9 us in service), with about 600 launches per forward. A hit did more Python work than the old launcher. This commit cuts that work. The key holds the same facts, and the conditions for taking the ordinary path stay the same. - With by_specialization, each call-site layout (the number of positional arguments and the keyword names) gets two itemgetters, built once, that split the runtime arguments from the constexpr arguments. The constexpr values and their types go into the key as two tuples instead of two items per argument. A tensor passed for a constexpr is still keyed by dtype, alignment and storage size, not by identity; a set of constexpr type tuples already seen without a tensor keeps that check off the common path. - An entry is a NamedTuple that already holds the launcher, the function handle, the packed metadata and the names after the positional arguments. - The driver's device and stream getters are bound on the first launch. The device and the stream are still read on every launch. - The global-value check runs only for a kernel that reads globals. Tests: two cases for the new key code. A reordered keyword layout keys each argument by its own parameter, and a tensor passed for a constexpr does not end up in the key. The 1 / True / 1.0 case now runs in both key modes. Two tests read entries by field name. Test, one MI308X: - utils/ and kimi_delta_attn/ test_fast_launch.py: 66 passed, 1 skipped (AMD Triton 3.8.0); 65 passed, 2 skipped (upstream Triton 3.7.1). - 26 mutants of fast_launch.py, the earlier 17 and 9 for the new code: all fail a test. The exception is the fpsan knob read unconditionally, which only fails on 3.7.1, where the knob is missing. - ATOM tests/test_fast_launch_wrappers.py (ROCm/ATOM#3431): 163 passed. - Host time per call, hot loop, 7 ATOM wrappers: CachedLauncher 154.3 us, parent 169.7 us, this commit 159.2 us. Interleaved: 191.5, 209.6 and 194.0 us.
|
Finding. ROCm/ATOM#3431 moves 20 prefill kernels from ATOM's
Change (
Verification (one MI308X, gfx942):
Host time per call, measured on
Per launch, the gap to End to end, the TTFT runs were not repeated on
Details are in the "Hit-path host overhead" section of the description, which also lists how the last prototype differs from this commit. cc @valarLip |
|
The end-to-end numbers in the description were measured on prototypes of this change. They are now replaced with runs on Setup: MI308X at TP2, issue protocol, no profiler, one stack at a time, each configuration started twice. The ATOM tree is the post-review merge
cc @valarLip |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (4)
- Stop keying tensor shapes and strides on the KDA launches; this slows the default path by about 50% per cache hit.
aiter/ops/triton/utils/fast_launch.py:284-286(if wrapped: append(tuple(v.shape)); append(v.stride())). Trigger: every KDA prefill. All four launchers at_triton_kernels/kimi_delta_attn/flash_kda.py:1142-1145wrap@triton.heuristics/@triton.autotunekernels, so they take this branch on every hit. A CPU in-process A/B with the realHeuristics(Autotuner(JITFunction))and the prepare signature (14 tensors), with base-vs-base and head-vs-head controls under ±0.2 µs, measured on four cores: +6.7 to +10.2 µs per hit (+48 to +58%) over e89e5b6. Head without the shape key is equal to base. The KDA heuristics only testis not None, and the autotune keys are ints/bools (Triton'sAutotuner.runkeys on those values plusstr(dtype)), so KDA gains no correctness from it. Your own table already shows 12.3–12.9 → 14.3–15.2 µs for exact keyword launches, and this path was not measured at head. Fix (verified on CPU): addfast_launch(kernel, key_shapes=True)and passkey_shapes=Falseat the four KDA sites, with a comment that their heuristics read no shape.test_a_heuristic_on_a_tensor_shape_is_keyedstill passes under the default. Do not key onlyAutotuner.keys: a heuristics-only kernel then reuses a stale config. Also fix the docstring at:26-27, which says autotune can read shapes; only@triton.heuristicscan. - Correct the knob sentence in the module docstring.
fast_launch.py:17-21says the key holds "the knobs that enter Triton's compile options or specialization".knobs.runtime.override_archandknobs.languagefp-fusion enterHIPBackend.parse_optionsbut are not keyed, by fast_launch or by Triton's in-processrun()key. Say "the knobsJITFunction.runputs in its cache key". - Make the knob oracle non-circular.
op_tests/triton_tests/utils/test_fast_launch.py:76-88hand-copies the kwargsrun()injects, so a knob a later Triton adds torun()is missed by both the oracle and fast_launch, andtest_key_follows_the_knobs_in_tritons_keystays green. Take the injected kwargs from a real launch through apre_run_hook(they are injected before the hooks run) and assert the set is ⊆ {debug, instrumentation_mode, fpsan_homomorphic_casts}. - Raise
OverflowErrorin_wide_int_spec, notTypeError.fast_launch.py:119with:203-208: underby_specialization, one runtime int outside [-263, 264) sets_disabled=Truefor good. Triton itself raisesOverflowErrorfor that one call only, so every later valid launch then loses the cache.
Pre-existing (not required for this PR): constexpr 0.0 and -0.0 share an entry (equal and same hash, though Triton's compute_cache_key keys them apart; same on main, no caller passes a float constexpr). Under TRITON_INTERPRET=1, fast_launch() raises AttributeError at fast_launch.py:160-162 (jit.fn on an InterpretedFunction), which breaks the import of flash_kda. Main has the same bug, but it now sits in a shared util. fusions/attn_res.py:72-91 keeps its own _LAUNCH_CACHE.
Reviewed at 7324631 (Deep; 2 hunters + independent pass B + 2 verifiers, CPU probes with Triton 3.9). Already fixed: Copilot fpsan knob (:77, :270); Copilot tuple key (:353-357).
|
@valarLip I addressed the four requested items in
Final-source regression on MI308X: combined helper/KDA tests 166 passed / 11 skipped on AMD Triton 3.8.0 and 165 passed / 12 skipped on upstream 3.7.1; downstream ATOM wrapper tests 163 passed on each. Black, Ruff and diff-check passed. No new serving/GSM8K result is claimed; the description keeps its old measurements tied to their original revisions. |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (3)
- Add a test for the new omitted-argument path in
_capture.fast_launch.py:200-204and:447-451now fill omitted parameters fromjit.signaturedefaults, and an empty*argsfrom(). No committed test kernel has a defaulted parameter or*args, and every KDA and Gluon call site passes its defaults or gets them from a heuristic. So three mutants pass every test:kw.get(n)(a hit passesNone),kw[n](KeyError), and dropping theVAR_POSITIONALbranch (a hit passesinspect.Parameter.empty).- Add a GPU case in
op_tests/triton_tests/utils/test_fast_launch.pywith a kernel likek(x, out, n, *rest, BLOCK: tl.constexpr = 64, SCALE=2.0). Launch it ask[grid](x, out, n)twice. Assert that the second launch hits (recording()empty) and gives the same output as underfast_launch.bypassed(). - Skip the
*argspart when the plain launch raisesTypeError(the 3.7.1 wheel).
- Add a GPU case in
- Fix four comments that are no longer true.
fast_launch.py:179-180: nothing here uses "the argument binder" any more. Say "the JITFunction that owns the signature, the pre-run hooks and the globals the kernel reads."fast_launch.py:161:frozen"(defaults, autotuner choices)" also holds heuristic choices. Say "(defaults, heuristic and autotuner choices)".fast_launch.py:70-71:HIPBackend.is_within_2gbonly checks storage size. The i32 range comes from Triton's int specialization. Say "2 GiB - 1: the largest storageHIPBackend.is_within_2gballows buffer ops on; with_MIN_INT32, also the i32 range Triton specializes a non-constexpr int on."kimi_delta_attn/test_fast_launch.py:150-152: the reason given is "The binder hands back every argument". Say "The pre-run hook sees every argument of the launch, which is the obvious thing to keep …".
- Fix the spacing in the suggested squash message. It has "AMD Triton3.8.0", "upstream3.7.1", "on3.7.1" and "onAMD3.8.0", and "AMD3.8.0" twice in the self-review. Also change "; it is not an end-to-end latency claim" to "; they are not end-to-end latency claims".
Not required (on main before this PR): seen[-1] picking the autotuner's final launch has no test with two or more configs.
Reviewed at cdf8131 (Deep; pass A: 2 hunters, perf A/B, ecc:review-pr, 2 verifiers, C2; independent pass B with its own hunters, 4 verifiers, C2 and perf). Item 1 from r51 is fixed. A miss is now 40 / 46 µs below main for prepare / segment, and 14–51 µs below main on seg_scan and Gluon K1/K2 (8 concurrent pairs on one pinned core, controls within ±2.3 µs). The hit is unchanged from 36ddc4d. The rebuilt entries match the old binder's by identity in 66 probed cases. The r51 comment, test and squash items are fixed. Our r51 "54 skips" was wrong; 55 is right. The :70-71 comment was there in earlier rounds and we missed it. CI: all required checks green; utils/test_fast_launch.py ran 56 tests, all passed (MI35X shard 4).
Cover default BLOCK/SCALE and empty varargs with real cache-hit GPU launches in both key modes. Keep defaults tested on Triton versions that reject ordinary varargs launches, and update stale comments.
|
Addressed review 5992833462 in
Local MI308X validation:
AMD skips only the second-GPU case. Upstream additionally skips its absent fpsan knob and the two empty-varargs cases after the ordinary launch raises The exact Black, Ruff, AST parsing and diff-check pass. The production module's AST is unchanged from |
valarLip
left a comment
There was a problem hiding this comment.
✅ LGTM
Nothing left to change. All three items of my review at cdf8131f73 are fixed at a2dc96f08c:
- Omitted-argument test:
op_tests/triton_tests/utils/test_fast_launch.py:66-79adds_defaulted_kernel/_defaulted_varargs_kernel(BLOCK: tl.constexpr = 64, SCALE=2.0, empty*rest), and:386-415checks a real second-launch hit against a bypassed launch and2*xin both key modes, after it fills the output with NaN. Only the varargs case skips on aTypeError. CI (Triton Tests MI35X, shard 4) ran all four cases, and all passed. None skipped. - Comments:
fast_launch.py:70-71,:161and:179-180, andkimi_delta_attn/test_fast_launch.py:150-152now match the code.HIPBackend.is_within_2gbchecks only the storage size (Triton 3.9 source). Each pre-run hook gets the launch's(*args, **kwargs). - Squash text: the version spacing and the plural "they are not end-to-end latency claims" are fixed.
The production module changes only in comments since cdf8131f, so the hit and miss numbers from the last round still apply. Required CI is green, there are no open review threads, and the PR merges cleanly into current main with no remaining importer of the old kimi_delta_attn/fast_launch.py.
Reviewed at a2dc96f (Deep, delta re-review: hunter + independent pass B, CPU only, no findings). Already fixed: every item from the 11-19 and 11-20 rounds (shape key, globals identity check, miss cost, hook inlining, docstrings, tests, squash text).
…iton's key `aiter.ops.triton.utils.fast_launch` (ROCm/aiter#8061) keys a launch on what Triton specializes on (with by_specialization=True, ints by their 1 / multiple-of-16 / width class), plus the device and the knobs Triton keys on, and keeps the ordinary path for hooks and torch.compile. Wrap the deferred decode-ids fill and the KV-indices expansion with it; the call sites stay `kernel[grid](...)`. ATOM's own FastLaunch and its stand-in tests go; the hip_copy test moves to its own file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fast_launch moved to aiter/ops/triton/utils in #8061; the #6498 import path no longer exists on main (also fixes ruff I001). Co-authored-by: Sealeen Zhang <[email protected]>
….triton.utils main moved fast_launch to aiter/ops/triton/utils/fast_launch.py (#8061). The split-KV merge still imported it from the old kimi_delta_attn path under an ImportError guard, so on main the import failed silently and every merge launch went through Triton's full per-call dispatch. Import it from the new module, without the guard.
…iton's key `aiter.ops.triton.utils.fast_launch` (ROCm/aiter#8061) keys a launch on what Triton specializes on (with by_specialization=True, ints by their 1 / multiple-of-16 / width class), plus the device and the knobs Triton keys on, and keeps the ordinary path for hooks and torch.compile. Wrap the deferred decode-ids fill and the KV-indices expansion with it; the call sites stay `kernel[grid](...)`. ATOM's own FastLaunch and its stand-in tests go; the hip_copy test moves to its own file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… epoch is sealed at capture start An aiter older than ROCm/aiter#8061 has no fast_launch; the two launches then go through Triton's own dispatch instead of failing every import of model_runner and the attention backends. A publish no longer checks capture on the epoch's own stream, so the runner checks once before each capture (decode and prefill recordings) that its epoch is sealed (PublicationOwner.check_sealed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply the tested ROCm/ATOM#3431 and ROCm/aiter#8061 backport in the shared ROCm package overlay for both disaggregated and colocated serving.
Resolve the flash_kda.py conflicts: keep this branch's Gluon pipeline and use main's _IS_GFX1250_FAMILY (gfx1250-strict) arch test. fast_launch now comes from aiter/ops/triton/utils (main #8061), which replaces this branch's copy.
Apply the tested ROCm/ATOM#3431 and ROCm/aiter#8061 backport in the shared ROCm package overlay for both disaggregated and colocated serving.
…ctives on aiter custom all-gather / reduce-scatter, cached GPU arch lookup (#3429) * perf(sglang/qwen4-exp): read the GPU arch once in the BF16 GEMM config hook The gfx950 hipBLASLt bypass wraps aiter's get_GEMM_A16W16_config and asked torch.cuda.get_device_properties(0) on every call, i.e. on every BF16 GEMM (about 290 per Qwen3.8-Flash-Next prefill forward). The query costs about 8-11 us of host time per GEMM. The arch cannot change while the process runs, so cache it. Co-authored-by: Cursor <[email protected]> * perf(qwen4-exp): run the sequence-parallel collectives on PyNccl The token-sharded HC streams all-gather every sub-layer input and reduce-scatter every sub-layer output: about 105 all-gathers and 92 reduce-scatters per 2112-token TP2 prefill forward, plus the QSA row gather. They went through GroupCoordinator.all_gather/reduce_scatter_tensor with use_custom=False, i.e. torch.distributed's ProcessGroupNCCL, which costs 43-82 us of host time per call (bookkeeping, a side stream and two events). Issue them on the TP group's PyNccl communicator instead (aiter's device_communicator.pynccl_comm): the same RCCL collective on the current stream, 19-45 us per call including the output allocation. The result is bitwise identical. Groups without a usable PyNccl communicator, and dtypes it does not map, keep the torch.distributed path. Graph capture never shards, so captured decode graphs are unchanged. Co-authored-by: Cursor <[email protected]> * perf(qwen4-exp): launch the HC Triton kernels through a cached launcher kernel[grid](...) runs all of Triton's JITFunction.run on every call: it re-derives each argument's specialization (on ROCm that calls back into Python per tensor), formats the options into the cache key, checks the kernel's globals and builds launch metadata before the launch itself. That is 20-26 us of host time per launch, against about 6 us for the compiled kernel's launcher, and a Qwen3.8-Flash-Next prefill forward makes about 290 HC launches (combine + norm, scaled SiLU, gated mean). Add atom.utils.triton_launch.CachedLauncher: the first launch of each specialization goes through kernel[grid], and the compiled kernel is kept under a key built from what Triton's own key is built from (device, the knobs in the compile options, per tensor dtype / 16-byte alignment / the 2 GiB buffer-ops range, per int ==1 / %16, constexpr types and values). Later launches with that key call the launcher directly. Hooks, kernels with checked globals or unmodelled parameters, torch.compile tracing, callable grids and other argument kinds keep going through Triton. A CPU test checks the key against Triton's binder so that a Triton upgrade that changes what it specializes on fails it; GPU tests check the HC wrappers bitwise against plain kernel[grid] launches (aligned and not, prefill and small batches) and under CUDA graph capture. Host time per HC launch: 25-34 us -> 18-22 us (hot, 1056-row SP shard). Co-authored-by: Cursor <[email protected]> * fix(qwen4-exp): read the TP group's PyNccl directly and skip it under simulated TP Review on #3429: read group.device_communicator.pynccl_comm instead of probing it with getattr, and drop the copied NCCL dtype table and its branches (SP only sends BF16 streams, int32 QSA groups and BF16 sums). Take PyNccl only when the TP group has as many devices as TP ranks, so simulated TP keeps its patched, zero-padding collectives. Co-authored-by: Cursor <[email protected]> * docs(qwen4-exp): drop host-time figures, complete the launcher bypass list Point the _live_gfx and CachedLauncher host-time notes at #3429 instead of figures that will go stale, list non-int32 ints and non-scalar constexprs among the launches CachedLauncher leaves to kernel[grid], and say the key guard test only runs where Triton is installed. Co-authored-by: Cursor <[email protected]> * Revert "perf(qwen4-exp): launch the HC Triton kernels through a cached launcher" This reverts commit c142f87, together with the launcher-only lines 39463e7 added to atom/utils/triton_launch.py and tests/test_triton_launch.py. The HC launches go back to kernel[grid]. The cached launcher moves into aiter's fast_launch (ROCm/aiter#8061); the HC launches will switch to it in a separate PR after that lands. Co-authored-by: Cursor <[email protected]> * perf(qwen4-exp): run the SP collectives on the TP group's custom all-gather / reduce-scatter GroupCoordinator.all_gather / reduce_scatter_tensor with use_custom=True, instead of calling the group's PyNccl communicator directly. On MI308X TP2 (hidden 2560 bf16, 1024-12288 tokens) the custom kernels take 3-7% less device time than PyNccl on all-gather and 7-12% less on reduce-scatter. A reduce-scatter above 64 MiB (T > 13107) falls back to NCCL inside the group. * fix(qwen4-exp): honor custom collective availability in sequence parallel Bind one use_custom decision per SP object from ATOM_USE_CUSTOM_ALL_GATHER and the enabled custom communicator, and pass it to gather and scatter. This preserves the opt-out and uses the group's NCCL path when device or custom communication is unavailable. Simulated TP keeps its group shims. Cover enabled, opted-out, missing and disabled communicators in the SP call tests, and exercise the real single-device simulated-TP zero fill. Validation on MI308X: 55 related tests passed; real TP2 produced bitwise PyNccl-equivalent output for 250 shape/configuration cases per rank, with custom/NCCL call counts checked and SP disabled during graph capture. Five in-memory gate/call mutations were caught. Black and Ruff pass. Normal enabled computation is unchanged; serving/GSM8K was not rerun. * fix(qwen4): check custom SP eligibility for every tensor Use aiter eligibility queries on contiguous all-gather inputs and padded reduce-scatter inputs so rejected tensors take the direct NCCL path. Document the shared custom-collective opt-out and test size boundaries. * Fix request intake and prefill test fixture defaults --------- Co-authored-by: Cursor <[email protected]>
…rfills the GPU (#7946 @ 88c4ddf, head 2026-11-13T18:08:12Z) Applied as the diff 74a3010..88c4ddf (3 files) onto the rebased 1116 tree; PR state: draft, author gbyu-amd, base main. (cherry picked from commit 572a65d) Rebase onto main 12-03: imports fast_launch from aiter.ops.triton.utils.fast_launch; main's #8061 moved it there from _triton_kernels/kimi_delta_attn/.
…7916 @ 7e2f22e, head 2026-11-16T05:44:05Z) Applied as the diff 8bbce0d..7e2f22e (8 files) onto the rebased 1116 tree; PR state: open, author Liang-jianhao97, base main. (cherry picked from commit becedb0) Rebase onto main 12-03: main #8061 moved fast_launch from _triton_kernels/kimi_delta_attn/ to utils/fast_launch.py and already takes the ordinary path while a launch hook is set (this PR's _launch_hooks_idle). The old file stays deleted; this PR's other fast_launch change, falling back to the ordinary launch when CompiledKernel.run raises TypeError (launcher ABI changed), is ported into utils/fast_launch.py as a per-wrapper disable. kda_one_token.py and test_kda_one_token.py import utils.fast_launch. bench_kda.py keeps main's gating / recurrent case backends (#7990) and adds this PR's one_token / generic backends, --padded, and a shape check per family; --timing rotating takes both families.
…-15T03:50:39Z) Applied as the diff 33ae4ce..9c0c33e (5 files) onto the rebased 1116 tree; PR state: open, author Liang-jianhao97, base feat/gfx1250-kda-packed-writeback. (cherry picked from commit abf0b0f) Rebase onto main 12-03: imports fast_launch from aiter.ops.triton.utils.fast_launch; main's #8061 moved it there from _triton_kernels/kimi_delta_attn/.
…ersistent split-KV - carry_state (thd entry): the epilogue merges this launch's partial softmax into the caller's running (O, LSE) in place; a sequence with no keys in the launch keeps its rows. Chunked-context prefill then needs no merge_attn_states and no per-chunk O/LSE. - Grid: the m-tile count is padded to an odd number so one m-tile's heads spread over all 8 XCDs. Bitwise identical output. - Persistent split-KV launch (thd, batch <= 32; AITER_FMHA_A8W8_PERSISTENT=0 restores the grid): #CU workgroups decode a (batch, m-tile, head, KV part) work list in-kernel; split parts are LSE-merged by fmha_ps_merge.py, and under carry_state the running state is folded into part 0 in the epilogue. MI455X, Kimi-K3 MLA (96 heads, qk 192 / v 128), ms per layer-step (new-token causal call + 25-28 context chunk calls): FMHA + merges, 3 steps: 25.08 / 20.69 / 24.35 -> 14.10 / 13.18 / 12.48 FMHA only: 18.61 / 15.85 / 18.26 -> 13.76 / 13.23 / 12.36 causal prefill without cache (odd grid): -6..-27% Per call: 586x32768 552-600 -> 460-473 us, 195x32768 687 -> 234 us. Accuracy: vs the previous kernel O max abs <= 8.4e-4, LSE <= 1.9e-6; vs an fp32 reference rel-L2 2.2e-2 (unchanged, FP8 P). (cherry picked from commit b84b19e) Rebase onto main 12-03: imports fast_launch from aiter.ops.triton.utils.fast_launch; main's #8061 moved it there from _triton_kernels/kimi_delta_attn/.
… output-gate, QSA and q/k-norm Triton wrappers on aiter's fast_launch Use aiter's shared `fast_launch(kernel, by_specialization=True)` for twenty existing Triton kernel launchers in the Qwen HC/GDN/output-gate/QSA/qk-norm wrappers. Kernel arguments, launch options and grid values are preserved; repeated calls avoid Triton's full host dispatch path. The dependency is ROCm/aiter#8061, merged as `6b29fd7983ad0aa5543afa63c72e29976484a1e3`. This PR remains Draft. Full question-paired model accuracy and remaining model acceptance are incomplete. The historical Native MTP3 TTFT grid at `b00a789573079` improves in 45/60 cells and regresses in 15; all 372 formal output pairs match. These results are not measurements of the main-synchronized implementation. ## Motivation `kernel[grid](...)` runs all of Triton's `JITFunction.run` on every call: the binder, cache-key formatting, the globals check and the launch metadata. A c=1 Qwen3.8-Flash-Next prefill forward makes about 780 Triton launches this way. Counting the launches of one SGLang target forward (8192/6080, 2112 new tokens, TP2) in a profiler trace: - 289 are hyper-connection (HC) launches; - about 300 come from the GDN, output-gate, QSA and q/k-norm wrappers below; - 180 are the FLA chunk kernels, which #3426 replaces with FlyDSL when MTP is on. Native also runs the QSA scorer and sparse attention as Triton kernels. That gives it 337 such launches in the 2096-token step and 324 in the 16-token step. ## Changes Each kernel has one module-level launcher. Wrappers pass the same arguments and per-call launch options; the shared API handles key selection and ordinary-Triton fallback. ATOM carries no local dispatcher or optional-import fallback. - HC: the single/multi-row `hc_combine_norm`, `scaled_silu`, `hc_gated_mean` and `hc_gated_mean_quant` wrappers. - GDN: `l2norm_fwd`, `causal_conv1d_fn`, `compute_causal_conv1d_metadata` and `fused_gdn_gating`. The convolution grid is the tuple its previous function returned, using the same fixed block sizes. - Output gates: `sigmoid_rmsnorm_quant`, `sigmoid_mul_quant` and `sigmoid_mul`. `sigmoid_mul` and `scaled_silu` share the `_gated_pointwise_kernel` launcher. - QSA helpers: mRoPE, cache writes, group compression, selected-block expansion and compressed-slot mapping; both Triton scorers and sparse attention. - `fused_qk_norm` / `DualRMSNorm`, retaining the existing warp choice. `tests/test_fast_launch_wrappers.py` compares each wrapper with the same kernel on ordinary Triton via `fast_launch.bypassed()`, checks first compilation and repeat hits, and exercises graph capture/replay for decode wrappers. It covers prefill/SP/tail sizes, input alignment, convolution state layouts, fresh/resumed state, both scorers, split-K attention, output-gate layouts and the 1024/8192-row switches. This is a GPU test file; CPU CI skips it without the GPU stack. ## Main synchronization and validation The feature is synchronized with main `ed0e6f6ed3d539e2ead77ffeca290652266df7e7`. Its own diff is seven production modules plus the original wrapper test. Main's TP-row refactor, GDN replay flush arguments, norm implementations and HC geometry support are preserved. Removing the original launcher substitutions (and expressing the original fixed convolution grid equivalently) makes all seven module ASTs match main. All twenty launcher mappings and targeted kernel ASTs match `b00a789573079`; the wrapper test file is byte-identical to that version. Syntax, Black, Ruff and whitespace checks pass. No new GPU or model run was made for this synchronization; source equivalence does not establish current-main model accuracy or performance. At `b00a789573079`, the 2026-11-27 MI308X run passed all 163 wrapper GPU cases / 489 phases, without skips, xfails, errors or failures. It used the original tests and normal conftest, the fixed e8 image, merged AITER `fb3f506d390414433da9aa437b2a1af4beb3fa21`, Torch `2.10.0+rocm7.2.4` and Triton `3.8.0`. This establishes wrapper correctness for that recorded version, including its graph cases. The model runs below remain separate evidence. ## Native TTFT at b00a789 (2026-12-02) Base `739165651cdd` -> head `b00a789573079` completed the original six fresh-service groups per arm on host20 physical GPUs 6/7: TP2/EP2/MTP3, input/cache-hit token pairs 8192/6080 and 10240/7104, output 200, concurrency 1/2/4/8/16, seeds 503/504/505, fixed e8 image and AITER `fb3f506d3904`. Each arm has 372 formal and 372 warmup requests. All 372 content/reasoning pairs, inputs, request payloads and usage match. The two original clients differ: `ten` improves TTFT in 27/30 seed/workload cells; `bench` improves in 18/30. For `bench`, the three-seed arm medians regress at 8192/c4 (909.33 -> 980.42 ms, +7.82%) and 10240/c2 (824.43 -> 921.37 ms, +11.76%). The largest individual-cell regression is 18.37%; a uniform TTFT benefit is not established. [All 60 TTFT/TPOT/throughput pairs, three-seed summaries and statistic definitions](#3431 (comment)). Full 1,319-question accuracy and model graph-path coverage remain open. The [earlier five-request check and separate untimed 19/20-wrapper diagnostic](#3431 (comment)) remain separate evidence. Earlier performance and accuracy below are historical. ## Earlier performance evidence Setup: MI308X (gfx942), Triton 3.8, one GPU. Host time per call, without the profiler, in µs. Calls run in bursts of 16 with a sync in between, over 5 interleaved rounds; the figure is the median of the round medians. "Cold" puts 8 MiB of cache traffic and unrelated Python between two calls. The baseline is #3429 at `fa5ebfe15`, where every wrapper is on plain `kernel[grid]`; the other column is this PR on `fast_launch(by_specialization=True)` at `4bd4fe4c8`, with #8061 at `7c54c82f4`. | wrapper (per-rank shape) | `kernel[grid]` hot / cold | `fast_launch` hot / cold | |---|---:|---:| | `causal_conv1d_fn` (2112 tokens) | 71.1 / 105.8 | 53.4 / 83.4 | | `qsa_sparse_paged_gqa` (2096 rows, 1 split) | 72.9 / 113.6 | 57.4 / 94.3 | | `qsa_paged_mqa_logits` MFMA (2096) / stacked (16) | 67.2 / 108.5, 68.9 / 110.9 | 53.6 / 90.9, 55.2 / 93.8 | | `qsa_compress_groups` (2112) | 47.9 / 81.5 | 37.3 / 66.4 | | `qsa_apply_mrope` (attention Q/K, 2112) | 47.6 / 83.1 | 38.2 / 70.1 | | `sigmoid_rmsnorm_quant` (2112 × 24 × 128) | 36.4 / 65.9 | 28.9 / 54.4 | | `fused_qk_norm` (2112) | 34.9 / 63.7 | 25.7 / 50.4 | | `hc_combine_norm` (2112 / 16) | 33.0 / 59.4, 32.6 / 58.6 | 24.8 / 48.1, 24.2 / 47.5 | | `fused_gdn_gating` (2112) | 32.7 / 59.6 | 23.3 / 44.9 | | `sigmoid_mul_quant` (2112 × 3072) | 30.7 / 56.7 | 24.7 / 47.7 | | `scaled_silu` (2112) | 29.5 / 56.5 | 23.8 / 47.5 | | `hc_gated_mean_quant` (16) / `hc_gated_mean` (2112) | 38.9 / 67.5, 26.1 / 50.7 | 32.0 / 57.6, 21.6 / 43.4 | | `qsa_expand_block_indices` (1056) | 33.2 / 64.7 | 25.5 / 53.5 | | `qsa_store_rows` (2112) / `qsa_compressed_slots` | 24.8 / 50.1, 23.0 / 50.8 | 20.6 / 43.4, 18.2 / 42.0 | | `l2norm_fwd` (2112 × 8 × 128) | 24.4 / 52.4 | 20.1 / 43.5 | `sigmoid_mul` is not in the table: this checkpoint's prefill does not run it. The table above uses #8061 at `7c54c82f4`. There, `fast_launch` saved less per call than the ATOM-local `CachedLauncher` of the previous revision, because its extra guards cost about 2–9 µs. For example, `causal_conv1d_fn` measured 69.6 → 44.1 µs hot with `CachedLauncher` and 71.1 → 53.4 µs with `fast_launch`. #8061 `7324631fc8` makes a hit about as cheap as `CachedLauncher`. Summed over 7 of these wrappers, a hot loop gives 154.3 µs for `CachedLauncher`, 169.7 µs for #8061 `6cccc0974` and 159.2 µs for `7324631fc8`. End to end, this PR was measured with the new launcher by ablation: the same integration tree with and without it. - Setup: MI308X, TP2, issue protocol (cold 8192 c=1, then warm 8192/6080 and 10240/7104 at c=1 and c=4, round 0 dropped), no profiler, one stack at a time, each configuration started twice in palindromic order. - With this PR: ATOM integration tree `700d662e6`, a merge of the PR branches that includes this PR at `943dae39f` and #3429 at `fa5ebfe15`. - Without this PR: `63ce29825`, the same merge without this PR. - Both use the same aiter overlay with #8061 at `7324631fc8`. TTFT, pooled median in ms: | | with this PR | without | with − without | |---|---:|---:|---:| | SGLang 8192/6080 c=1 | 153.0 | 164.9 | −11.9 | | SGLang 8192/6080 c=4 | 508.4 | 520.2 | −11.8 | | SGLang 10240/7104 c=1 | 200.9 | 202.2 | −1.3 | | SGLang 10240/7104 c=4 | 780.8 | 794.6 | −13.7 | | SGLang cold 8192 c=1 | 442.7 | 443.2 | −0.4 | | Native 8192/6080 c=1 | 300.8 | 315.1 | −14.3 | | Native 10240/7104 c=1 | 410.7 | 434.6 | −23.9 | | Native cold 8192 c=1 | 661.4 | 689.0 | −27.5 | Native c=4 is left out: after it is split by how the requests were batched, each group has only 1–6 waves. GSM8K with this PR on #8061 `7324631fc8` (limit 200, 5-shot), flexible / strict and MTP accept rate: - SGLang 0.985 / 0.985 and 0.717; - Native 0.985 / 0.985 and 0.718. The kernels and their arguments are unchanged. All 302 bitwise cases are equal: each wrapper called twice (compiling, then from the cache) and compared byte for byte with #3429's `kernel[grid]` wrapper on the same inputs, across 6 wrapper groups including HC. ## Notes - Decode. Some of these wrappers also run in the decode CUDA graphs: mRoPE, cache writes, gating, q/k norm, scorer, attention and HC. The first launch of a key goes through `kernel[grid]`. Later launches call the same compiled kernel's launcher on the current (capture) stream, so the graphs are unchanged. - torch.compile. `fused_qk_norm` (`DualRMSNorm`, used by Qwen3-Next), `l2norm_fwd`, `causal_conv1d_fn` and `fused_gdn_gating` are shared ops that a model under `@support_torch_compile` can trace. Since #8061's `1b63b6344`, a traced launch goes to `kernel[grid]` before `fast_launch` reads any of its state, so `fullgraph=True` traces them as before. Qwen4Exp itself runs eager in both stacks. - Not covered here: - the FLA chunk kernels (#3426); - aiter's `_mla_decode_fwd_reduce_kernel`; - `_gemma_rmsnorm_kernel`, the PLE kernels and HC's small-batch kernels (1–7 launches each per forward); - the non-quantizing `sigmoid_rmsnorm`, which this checkpoint's prefill does not run. cc @valarLip

Motivation
This PR makes AITER's KDA launch cache a shared
fast_launchhelper for Triton and Gluon callers. It also fixes cache keys and guards that could reuse a specialization for different argument types or skip Triton hooks. ROCm/ATOM#3431 uses this helper for its prefill wrappers and remains a draft until this PR lands.A cache miss previously called Triton's binder once for the normal launch and again to build the saved launch entry. The entry-construction change at
cdf8131fremoves that second call: parameter names and defaults are fixed at construction, and the entry reads the last real launch's hook arguments. The cached hit path is unchanged.Technical details
fast_launchfrom the KDA kernel directory toaiter/ops/triton/utils/fast_launch.py. KDA and the gfx950/gfx1250 Gluon K1/K2 callers import the shared helper.by_specialization=Trueis restricted to plain JIT kernels. It keys runtime scalars by Triton's specialization classes; constexprs and launch options remain keyed by type/value. This lets changing prefill sizes share a compiled entry.key_shapes=Falseomits tensor shape/stride keys only where heuristics do not read them. KDA's heuristics only test forNone; its autotune keys contain ints, bools and tensor dtypes. A heuristic may read dtype or 16-byte alignment. Full data pointers, storage offsets and tensor values are not keyed.jit.signature; heuristic/autotune choices come from the last real pre-run hook. Omitted argument values are kept by identity. There is no second binder or device-cache lookup in_capture.The separate launch cache in
fusions/attn_res.pyis outside this PR. Existing limits also remain: a heuristic overriding a caller-supplied keyword sees the caller value on a hit; extra positional*argsare flattened on a hit; reinterpret arguments are keyed by identity; pre-run hooks are shared between threads.Test plan
cdf8131f, compare saved names, frozen-value identities, remaining parameter names and hit argument identities against the previous binder calculation after real launches. Add local signature probes for defaults, keyword-only parameters, do_not_specialize, specialization, heuristics/two-config autotune,*args, and recorded Gluon K1/K2 wrapper calls.Omitted-argument regression validation
Revision:
a2dc96f08c421d226c337829811f436323ba89bb(review 5992833462 follow-up). This revision adds four committed GPU cases and corrects four comments; the production module's AST is unchanged fromcdf8131f.Two independent kernels cover omitted
BLOCK: tl.constexpr = 64and runtimeSCALE=2.0, with and without empty*rest, in exact andby_specializationmodes. Each uses a bypassed ordinary launch as its reference, launches with only(x, out, n), records one capture, poisons the output with NaNs, and requires the second launch to have an empty recording and match both the reference and2*xexactly. ATypeErrorfrom the ordinary varargs launch skips only that varargs case; ordinary-default coverage remains enabled.Local MI308X/gfx942 validation on 2026-11-20, 20:11:59–20:13:05 UTC:
test_fast_launch.pyfilesThe AMD full-suite skip needs a second GPU. Upstream also skips the absent fpsan knob and the two ordinary-varargs cases. The default-only cases pass on both builds.
Three temporary, process-local mutants of the exact reviewer expressions were run against the four committed cases on AMD:
kw.get(n, default)→kw.get(n)BLOCK=Nonekw.get(n, default)→kw[n]KeyErrorforBLOCKorrest() if p.kind is p.VAR_POSITIONAL else p.default→p.defaultinspect.Parameter.emptyas a sequence; the 2 ordinary-default cases passThese are real test-call failures, with no setup/collection errors or mutant skips. The mutants only patch the individual test process; no product/overlay mutation remains. This coverage is separate from the local old-binder oracle and historical mutation sweeps below.
Black 26.10.1, Ruff 0.16.0, AST parsing and diff-check pass. No performance, serving, GSM8K, flash_kda or downstream ATOM rerun was needed for this test/comment change. Their earlier measurements retain the original revisions below. As of 2026-11-24 08:52 UTC, head
a2dc96f08c421d226c337829811f436323ba89bbreports 37 successful and 17 skipped checks, with none failed or pending; Aiter Test and Triton Test completed successfully. The skipped downstream ATOM/SGLang/vLLM checks do not establish downstream coverage. Human re-review remains pending.Entry-construction validation at cdf8131
Revision:
cdf8131f7306bcc994953c4b6590e8503f05be3b. On MI308X/gfx942:The main suite's capture counts are 47 axpy, 1 counted-global, 54 KDA prepare, 9 KDA scan, 105 KDA segment and 2 offset launches per version. Extended probes include 24 Gluon captures per version: K1, K2 AB and K2 C for both gfx950/gfx1250, shape-key option on/off and two pointer configurations. These use the actual wrapper arguments and JIT pre-run hooks, then stop before compilation; they do not execute gfx950/gfx1250 kernels on MI308X.
AMD's extended probes also run keyword-only numerical calls and check four varargs captures. On the 3.7.1 wheel, direct JIT compilation of the keyword-only constexpr probe fails with
BLOCK is not defined, so only its binding is checked. The same wheel rejects the tested empty/extra-varargs calls before compilation; direct JIT and fast_launch both raise TypeError and leave no wrapper entry. These are baseline wheel limits.At
cdf8131f, three temporary in-memory binding mutants were checked on AMD 3.8.0: ignoring hook values fails 3 cases; dropping defaults fails 10; losing the empty-varargs default fails 2. Each fails the independent old-binder comparison, with no source or overlay mutation left behind. This is separate from the historical 40-guard mutation sweep below, which was not repeated atcdf8131for in this follow-up.At
cdf8131f, a local GPU-unavailable-after-collection simulation collected 56 helper tests: 1 passed and 55 skipped on each Triton version. The interpreter case is the one passing test. These counts apply only to that 56-case revision; the simulation was not rerun after adding the four omitted-argument cases. It does not establish that the package imports on a physically GPU-free host, because package collection itself asks the Triton driver for a target.At
cdf8131f, Black 26.10.1, Ruff 0.16.0 and diff-check passed. No new serving/GSM8K run was made: that revision changes host-side entry construction and documentation; real KDA and ATOM kernel-wrapper regression suites cover the affected launch path. The end-to-end measurements below retain their original revision labels.Paired miss and hit measurement at cdf8131
Comparison:
36ddc4daa→cdf8131f7306bcc994953c4b6590e8503f05be3b, AMD Triton 3.8.0, MI308X/gfx942. Times are host thread CPU microseconds per call (time.thread_time_ns), not GPU execution time or end-to-end latency. Each pair uses two processes sharing one pinned CPU core; cores 20/21 and the starting version alternate. This project had no other benchmark/test workload during the run; unrelated host/GPU jobs remained, so the same-file controls quantify observed drift.Misses use real KDA prepare/segment launches and recorded call-site arguments. Only the wrapper cache is cleared; JIT/autotuner caches are warm. There are 8 pairs per row, with each process reporting the median of 15 rounds × 300 calls.
The version columns are separate medians; the delta is the median of the per-pair differences, so it need not equal the subtraction of the two column medians. Relative to the old column median, the paired delta is −26.3% for prepare and −25.8% for segment. No new comparison against main is claimed.
Hits use the real JIT definitions, wrapper arguments and global-dependency metadata, with a stub compiled entry, driver and no-op launcher. There are 4 pairs per row, each process reporting the median of 15 rounds × 5000 calls.
The hit source path is unchanged; these small differences overlap the observed controls and do not establish a hit-path improvement. Every pair completed successfully. The diagnostic binding oracle was disabled during all timings.
Historical validation (before cdf8131)
All runs were on one MI308X (gfx942). This branch was installed as a symlink overlay over the image's aiter; the kimi_delta_attn and utils files of the image are the same as on main. Triton is AMD's 3.8.0 build unless stated.
op_tests/triton_tests/utils/test_fast_launch.pyat36ddc4daa: 56 passed. On the upstream Triton 3.7.1 wheel: 55 passed, 1 skipped (the fpsan knob case). The 4 tests added atd0ec01df6fail on7324631fc'sfast_launch.py; the two globals tests added ata68d79af0fail ond0ec01df6's. The 144-state hook test also passes ona68d79af0'sfast_launch.py, so the inlined checks dispatch as before. The former GPU-unavailable skip count was stale; the 56-case simulation atcdf8131fis reported above. (On a host with no GPU at all,op_tests/triton_tests/__init__.pyfails to import, as on main:mla_decode_ref.pyasks the Triton driver for its target.) At1b63b6344the 3.7.1 wheel gave 40 failed, 1 passed.kimi_delta_attn
test_fast_launch.py+test_flash_kda.pyat36ddc4daa: 110 passed and 11 skipped on both Triton builds (106 and 11 with the image's aiter; the 4 new cases are the launcher checks). The skips are the Gluon K2 / pass C routes, which gfx942 does not use, and the two-GPU test. On the 3.7.1 wheel, kimi_delta_attntest_fast_launch.py: 23 passed, 1 skipped (19 and 1 with the image's aiter; at1b63b6344: 19 failed). I did not run the gfx950 / gfx1250 Gluon files; their only change is the import line.CI at
1b63b6344(MI35X, AMD Triton 3.8.0):utils/test_fast_launch.py41 passed, kimi_delta_attntest_fast_launch.py19 passed and 1 skipped (Triton shard 3).Mutation check at
36ddc4daa, 40 mutants offast_launch.py. The first 17 remove the type, the knobs, the== 1case, the int width, the alignment bit, the storage bit, the launch-enter hook check, the globals check, the configpre_hookcheck, the wrapped-kernel shape key and the tuple check; they move theis_compiling()check to the end of the hook condition or remove it; they read the stream once instead of on each call; they read the fpsan knob on every build; and they drop both launch-hook checks or count an empty chain as a hook. The next 9 remove the alignment or storage bit in theby_specializationloop or the type in the exact loop. They look up the layout without the keyword names, or shift the names after the positional arguments by one. They key a constexpr tensor by identity, either by dropping the check or by skipping it after the first launch. They drop the constexpr types, or bind a stale stream getter. 3 more ignorekey_shapes, raiseTypeErroragain for an out-of-range int, or do not turn the cache off for an interpreted kernel. 5 run the full globals comparison on every hit, treat a rebind as a change without the comparison, never compare after a rebind, never refresh the objects seen, or drop the keyword arguments from a keyword-only callable grid. The last 6 test the exit hook withtype(h) is HookChain, drop the exit-hook, stages-hook or pre-run-hook check, drop the stride from the wrapped-kernel key, or collect no autotuner in__init__. On the 3.7.1 wheel all 40 fail at least one test. On AMD's 3.8.0, 39 fail; the unconditional fpsan read passes there, because that build has the knob. The 9 mutants offlash_kda.pyall failtest_no_config_choice_reads_a_shapealone on both builds; 4 of them (a heuristic onshape[0] > 1,numel() > 8,dim() == 2orshape[0] <= 64) passed the version of that test ata68d79af0.[Sgl Atom][Native][perf] cut Qwen4Exp prefill host overhead: HC, GDN, output-gate, QSA and q/k-norm Triton wrappers on aiter's fast_launch ATOM#3431 at
943dae39fon36ddc4daa: its 163 wrapper tests pass on both Triton builds, with no change on the ATOM side.ruff 0.16.0 and black are clean.
Host time, µs per launch (median of 7 × 16 calls, 3 runs), measured at
7c54c82f4:kernel[grid](...)fast_launchbefore this PR, keywordsby_specialization, positionalThe new guards and knob reads cost about 2 µs. About 0.4 µs of this is the two env-backed knobs, which Triton also reads on each call.
Historical hit-path host overhead
ROCm/ATOM#3431 replaces ATOM's
CachedLauncherwithfast_launch(kernel, by_specialization=True)for 20 prefill kernels. That is about 600 launches per forward. A host-time hook measured this in service (the hook adds 1.1–1.5 µs per call to both). At6cccc0974, a hit cost 4.3–4.8 µs more per launch thanCachedLauncher: 33.5–34.4 vs 29.3–29.6 µs. That is about +2.5–2.9 ms per forward.7324631fcremoves most of this.Host time per call, µs (median of 3000 calls, mean of 3 interleaved rounds, one MI308X, one pinned CPU core), measured on
7324631fc. The 7 wrappers are HCcombine_norm/gated_mean,scaled_silu,sigmoid_rmsnorm_quant,fused_qk_norm,fused_gdn_gatingandl2norm_fwd, at the shapes of one 2112-token prefill at TP2. The ATOM trees are local merges of the ATOM PR branches: one before review, withCachedLauncher, and one after review, with ROCm/ATOM#3429 atfa5ebfe15and #3431 at943dae39f. Both use the same aiter build, which has this branch at6cccc0974and other open aiter PRs. Onlyfast_launch.pyis replaced for the last column.CachedLauncher6cccc09747324631fcA rerun on
d0ec01df6with the same setup and the same aiter build (another GPU and session):CachedLauncher154.0 / 191.3,7324631fc161.0 / 197.7,d0ec01df6159.0 / 193.5 (hot / interleaved). The ATOM wrappers useby_specialization, whose pathd0ec01df6does not change. Ona68d79af0(same setup, GPU 1):CachedLauncher155.6 / 195.6,d0ec01df6159.6 / 198.7,a68d79af0158.8 / 198.4. On36ddc4daa(same setup, GPU 1, 3 rounds):CachedLauncher153.3 / 192.7,a68d79af0158.5 / 200.2,36ddc4daa157.6 / 193.5. These kernels read no globals.At
7324631fc, the measured hit was about 0.7 µs (hot) and 0.4 µs (interleaved) slower thanCachedLauncher, down from 2.2 and 2.6 µs. The likely remainder is the keyword launch options (num_warps=...).CachedLauncherbound them when it was built, andfast_launchreads them on each call. Not measured one by one.Historical KDA and Gluon K1 hit
Host time of one hit, µs, measured at
36ddc4daaagainst thefast_launchon main (e89e5b6cc) and againsta68d79af0. The kernels are the real ones: the Gluon K1k1_prepare_gluonof gfx950 and of gfx1250 (a plain@gluon.jitwith 15 / 14 layout globals), called with the keyword arguments itsgluon_k1_preparepasses, and the four flash_kda Triton launchers, called with the keyword arguments and grid recorded from oneflash_kda_fwdcall (varlen, segmented, 2112 tokens). The first call stores an entry with a no-op launcher, so only the key and the hit path are timed, and the kernel'sused_global_valsis filled as a compile does. The driver is a stub. Each pair of versions runs as two processes, one version each, time-sharing one pinned core; the core (two cores) and the launch order alternate over 8 runs, and each process reports the median of 15 rounds of 5000 calls in its own thread CPU time (wall time would hold the other process's slices). The table gives the medians over the 8 runs. Same-file controls (main against main,36ddc4daaagainst itself) are within −0.12 to +0.07 µs.a68d79af0− main36ddc4daa− main36ddc4daa−a68d79af0The inlined hook checks save up to 0.22 µs in that measured revision. The rest of the fixed per-hit work is reads that the key or the guards need:
torch.compiler.is_compiling()(about 90 ns), the env-backedamd.use_buffer_opsknob (about 180 ns; Triton reads it on each launch too), and the 5 attribute reads of the hook checks (about 25 ns each). For Gluon K1, the identity check over 14–15 globals costs about 0.8 µs (ata68d79af0); the equality check it replaced cost about 8.5 µs.Host time of one miss, µs, on the GPU: the kda_prepare and kda_segment launchers with the keyword arguments and grid recorded from one
flash_kda_fwdcall that launches everything. Each timed call empties the wrapper's cache first, so it is a miss that compiles nothing (Triton's and the autotuner's caches are warm), as in a prefill with a newT. Same method as above (8 runs, 15 rounds of 300 calls, thread CPU time); same-file controls are within −0.27 to +0.30 µs.a68d79af0− main36ddc4daa− main36ddc4daa−a68d79af0Most of the rest is the tuple scan: with it removed, a miss measured +3.3 µs (prepare) and +4.2 µs (segment) against main, in process. The scan costs about 55 ns per argument, mostly in
isinstanceon the non-tensor ones. Folding it into_keywould put that check on every hit, so it stays on the miss path.At
7324631fc, keying every tensor's shape and strides made a prepare hit +7.5–7.8 µs (+59–61%);d0ec01df6took that out withkey_shapes=False.End to end, measured on
7324631fc; not rerun ond0ec01df6,a68d79af0or36ddc4daa. Their changes to theby_specializationpath that the ATOM wrappers take are the hook checks of36ddc4daa, which the 7-wrapper microbench above covers. TTFT was measured under the issue protocol (cold 8192 c=1, then warm 8192/6080 and 10240/7104 at c=1 and c=4; round 0 dropped), without a profiler, on MI308X at TP2. Each stack ran alone, and each configuration was started twice in palindromic order. The values are pooled medians in ms.700d662e6, with [Sgl Atom][Native][perf] cut Qwen4Exp prefill host overhead: SP collectives on aiter custom all-gather / reduce-scatter, cached GPU arch lookup ATOM#3429fa5ebfe15and Add Kimi-K2 Thinking entry to per-model kernel benchmark sweep #3431943dae39f) on the aiter build above, withfast_launch.pyfrom7324631fc.fast_launch.pyfrom6cccc0974.CachedLauncher: the pre-review ATOM merge on the same aiter build.CachedLauncher6cccc09747324631fcCachedLauncherNative cannot be quantified from these runs. Each configuration was started four times. In this session, the old head did not reproduce its earlier regression against
CachedLauncher: it measured −2.5 / +1.6 / −0.8 ms at 8192/6080 c=1, 10240/7104 c=1 and cold 8192, where earlier runs gave +7.4 / +12.3 / +8.0 ms. So the saving against6cccc0974cannot be measured here. What can be said is that the new head is not slower thanCachedLauncher: it measured −1.4 / −4.1 / −1.5 ms.GSM8K on
7324631fc(limit 200, 5-shot), flexible / strict and MTP accept rate:Earlier runs at
6cccc0974gave SGLang 0.990 / 0.985 and 0.721, Native 0.985 / 0.985 and 0.721. The SGLang difference is one question out of 200. The kernels and their arguments are the same; only the host lookup differs.Suggested squash message
Use the PR title and this body when squashing. Existing commits have not been rewritten.
PR Self-Review
Reviewed revision
a2dc96f
Behavior and intent
fast_launchmoves from_triton_kernels/kimi_delta_attn/toutils/, so ATOM and other callers use one launcher instead of a copy. Its key now holds what Triton keys on: the knobs, the type of each argument, and the shapes for a kernel under@triton.heuristics/@triton.autotune(the KDA launchers opt out withkey_shapes=False, since their heuristics read no shape). Launches that need Triton's side effects take the ordinary path: hooks, torch.compile tracing, rebound globals, config pre-hooks, tuple arguments and interpreted kernels. A hit checks globals by identity, so a global changed in place is not caught on a hit. Before, a cached launch could run a kernel compiled for other arguments, or skip a hook. The earlier7324631fcmicrobench placed a hit 0.4–0.7 µs above ATOM's oldCachedLauncher, down from 2.2–2.6 µs at6cccc0974. Those figures remain historical; the paired hit check atcdf8131fis separate. The entry-construction change atcdf8131fbuilds omitted arguments from signature defaults and actual hook values without a second binder call.Validation and unverified scope
At
a2dc96f08c421d226c337829811f436323ba89bb, the committed omitted-argument cases pass 4/4 on AMD Triton 3.8.0 and 2/4 on upstream 3.7.1, with only its 2 ordinary-varargs cases skipped. The full helper/KDA fast_launch files pass 83/1 skipped and 80/4 skipped respectively. The exact three requested mutants cause 4/4/2 real test failures on AMD. Production AST is unchanged fromcdf8131f.At
cdf8131f7306bcc994953c4b6590e8503f05be3b, local MI308X/gfx942 results are 166 passed/11 skipped (AMD Triton 3.8.0) and 165 passed/12 skipped (upstream 3.7.1) for the combined helper/KDA suites, plus 163 ATOM wrapper tests on each. Thecdf8131fentry-construction section lists its binding oracle/probe counts and three local-oracle binding mutants. The historical 40-guard sweep was at36ddc4daa: all 40 fail on 3.7.1, 39 on AMD 3.8.0, where the unconditional fpsan-read mutant survives because the knob exists. It was not rerun here.The paired miss/hit A/B at
cdf8131fuses host thread CPU time, paired pinned-core runs and same-file controls. Historical probe timings belong to7c54c82f4; the earlier wrapper and hit/miss tables belong to their stated heads. End-to-end TTFT/GSM8K remains at7324631fc. No gfx950/gfx1250 Gluon kernel ran on this MI308X: only their wrapper/JIT argument captures and stub-launch hit timings were checked. Triton 3.6/3.9 and pytorch-triton-rocm remain unverified. Current-head CI has completed (see the omitted-argument regression section); skipped downstream checks remain unverified. Human re-review remains pending.PR-specific question
The new helper suite checks observable launch behavior and compares cache keys against Triton's binder for the tested variants. The historical guard mutations at
36ddc4daafail on the 3.7.1 wheel (40/40) and AMD 3.8.0 (39/40); the unconditional fpsan read survives only on the build that has that knob. The 144-state hook test also passes on the earliera68d79af0, because that refactor must preserve dispatch; it fails the incorrect hook-check mutants. The stride test catches a missing stride key, and the KDA heuristic test catches four shape/property readers missed by its earlier version.The current follow-up adds committed numerical cache-hit coverage for omitted signature defaults and empty varargs, and checks the three exact mutants requested in review 5992833462. It does not rely on the earlier local binder oracle to cover this path.
The entry-construction revision at
cdf8131fpreserved the existing suite and used a separate local oracle that reconstructs each saved entry with the previous real binder, including object identity. Its three binding mutants fail by losing the chosen hook value, a default, or the empty-varargs default. The probe and its unsupported-wheel checks are reported separately from committed CI tests. Before this PR, the existing KDA tests used fast_launch through flash_kda_fwd with keyword arguments and exact keys; they did not cover the helper's full hook/key/call-layout behavior.Changed op tests
op_tests/triton_tests/utils/test_fast_launch.py(new): the tests of the shared helper. It compares the key with Triton's own cache key for many argument variants, and it checks each knob and guard, hits and misses in both key modes and withkey_shapes=False, torch.compile tracing, tuple arguments and CUDA-graph replay. It uses small probe kernels. The latest four cases cover omitted BLOCK/SCALE defaults and empty varargs in both key modes, requiring a real hit and exact output against a bypassed launch after poisoning the output. It usestriton.autotuneandtriton.heuristicswith one config only, to check how the helper treats a wrapped kernel; it does not tune.op_tests/triton_tests/kimi_delta_attn/test_fast_launch.py: the import path changes, and the check that an entry holds no tensor reads the entry's fields by name and now covers every field. Its tensor-lifetime explanation now correctly refers to the pre-run hook. A new parametrized test checks, for the four flash_kda launchers, what lets them passkey_shapes=False: no heuristic reads any property of an argument (each runs onobject()and onNonefor every argument), and no autotuner prunes or models configs. It stays the end-to-end test of the flash_kda launch cache.op_tests/triton_tests/kimi_delta_attn/test_flash_kda.py: only the import path changes.cc @valarLip