Repository navigation
[Triton/Gluon] [OPUS] [FlyDSL] Route seventeen more ops through the kernel plugin interface - #8075
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 |
There was a problem hiding this comment.
🟡 Changes recommended
The new public dispatch paths lack mocked-provider tests for routing, argument forwarding, and bypass behavior, allowing disconnected routes or incorrect pin handling to pass the current checks.
1 open issue
What changed in this PR
Extends the kernel plugin interface from RFC #7240 so external providers can serve ten more AITER operations, while preserving public call signatures and existing kernel implementations.
Changes:
- Adds versioned routes for GEMM, MoE, top-k, attention, and MHC operations, with explicit backend selections bypassing routing where applicable.
- Fixes legacy Triton imports to reuse loaded modules and avoid duplicate route registration.
- Documents provider contracts, declares fake and mutation behavior, and updates the contract baseline.
| File | Description |
|---|---|
tests/test_plugin_contracts.py |
Records registration exemptions for the new contracts. |
tests/plugin_contracts.json |
Adds ten version-1 contract entries. |
aiter/tuned_gemm.py |
Routes shared GEMM dispatch and checks output-buffer use. |
aiter/ops/triton/gluon/mla_gluon.py |
Routes eligible MLA decode calls; keeps prefill native. |
aiter/ops/triton/gemm/basic/gemm_a8w8_blockscale.py |
Adds blockscale GEMM routing below explicit backend selection. |
aiter/ops/triton/gemm/basic/gemm_a16w16.py |
Adds activation GEMM routing beneath the compile guard. |
aiter/ops/triton/attention/pa_mqa_logits.py |
Routes paged FP8 logits and clarifies output semantics. |
aiter/ops/triton/__init__.py |
Reuses canonical modules for legacy import aliases. |
aiter/ops/topk.py |
Routes biased grouped top-k with fake and mutation declarations. |
aiter/ops/quant.py |
Sends eligible MXFP8 quantization through routed group quantization. |
aiter/ops/pa_sparse_prefill_opus.py |
Connects eligible FP8 sparse-prefill calls to the shared route. |
aiter/ops/mla_sparse_prefill.py |
Adds v4 sparse-prefill routing while retaining native backend selection. |
aiter/ops/mhc.py |
Routes unpinned fused post/pre calls and adds a fake implementation. |
aiter/mla.py |
Routes MLA decode and documents output ownership. |
aiter/fused_moe.py |
Routes guarded MoE execution and documents provider obligations. |
Review effort: Balanced
| if backend is None: | ||
| return _gemm_a16w16_routed( |
aef9a9a to
2c12d2f
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new contract allows returning o instead of split logits even though existing callers inspect split dimensions and partial values, so providers must preserve those semantics or reject calls requiring partial logits.
2 open issues
Review effort: Balanced
2c12d2f to
373c7a4
Compare
|
@aiter-bot review |
|
aiter-bot — queued behind 1 review(s); expect to start in about 26 min. The box reviews one PR at a time. |
zufayu
left a comment
There was a problem hiding this comment.
Placement looks right. I checked the things that usually go wrong: _v4_auto_tries_asm is shared rather than duplicated, mla_decode_fwd does not call the already-routed mla_decode_fwd_v4_nm* (no nested route), and guard-over-route on fused_moe_ matches mhc_pre/mhc_post. Four things.
1. Two of the seven _NOT_REGISTERED entries don't need to be there
The other five hold up. But four of the seven sit outside any torch_compile_guard — mla_decode_fwd, gemm_a8w8_blockscale_out, and these two — and those are where an enabled provider actually adds Python to a caller's graph. Two of the four are avoidable.
fp8_paged_mqa_logits. #7881's "adding annotations moves the fingerprint" cost applies to an op that already has a published fingerprint; a new route has none, so the listed reason doesn't transfer. And it's easier than the entry suggests: deepgemm_fp8_paged_mqa_logits has no return statement at all — it writes out_logits and returns None, so there is no aliasing to resolve — and kv_cache is a plain tensor (.size(), .view(), slicing). That leaves kv_cache: torch.Tensor, -> None, mutates_args=["out_logits"] and a fake returning None: the shape biased_grouped_topk already uses in this PR. You are annotating two other parameters on this same function already.
mla_paged_decode. Worth flagging before you reach for #7875: that PR makes the contract the allocating form and bypasses the route when a buffer is named, but mla_gluon has no allocating form — o is a required positional with no default, and the function returns (o, lse). Applied literally, every call takes the bypass and the op never routes. What removes the aliasing here is mutates_args=["o"] on the routed wrapper returning lse alone (torch.Tensor | None), with the public wrapper reassembling (o, lse) — again the biased_grouped_topk shape.
Seven new entries become five, each either already opaque through a guard or genuinely blocked.
2. fused_moe can leave a registered presort behind
_fused_moe_impl opens with "Consume a caller's presort first, so every path (including early returns and errors) clears it", and register_presorted_moe's docstring promises the same. The route sits on fused_moe_, above it, so a served call is the first path that returns without clearing.
match_presorted_moe validates on topk_ids_ptr / topk_weights_ptr / M / block_m / num_experts / topk — pointers and shapes. A decode loop reuses the same routing buffers every step, so a leftover registration passes that check on the next native call and is used with stale contents: no presorted_moe_ignored warning, no exception, wrong routing. A provider serving some layers and declining others is the default shape, not an edge case.
An unconditional pop_presorted_moe() in the public fused_moe after the call restores the invariant in one line and changes no signature: the registration is for "the next fused_moe call", and the served call is that call. Fine as a separate PR — it just shouldn't rest on a docstring.
3. Two things for the PR body
- Two new routes are neither registered nor under a guard:
mla_decode_fwdandgemm_a8w8_blockscale_out. Both are genuinely blocked, I think (mla_decode_fwdis unannotated and its first result may be a view ofo;configis a dict). But #7881's own wording is that such a route "splits a caller's graph the day a provider is enabled", and the entries record why each cannot be registered, not what that costs. The twogemm_a16w16entries do say "already one opaque op"; these two can't, which is the distinction worth making explicit. A line on whether your framework callers have them inside a compiled region would close it. pa_sparse_prefill_fp8_opuschanges what a public opus-pinned name does. Thepa_sparse_prefill_opusprecedent is justified by "opus is the only backend this contract has"; v4 has two, so that doesn't carry over._v4_auto_tries_asmrequires gfx1250, so on gfx950 every call to this name goes to a provider, with no per-call opt-out (nobackend=, and it is star-exported fromaiter/__init__.py). Probably the right trade — but it belongs in the body rather than under "Breaking Changes: None".
4. Minor
gemm_a16w16 called with out= doesn't get the data_ptr check that gemm_a16w16_out now has — a provider answering in its own tensor leaves out unwritten there too, just without the error. And the _AliasLoader fix takes effect with no provider enabled and changes import semantics for every deprecated Triton module path (the old and new names used to end up as two module objects with separate module-level state, and now share one) — worth naming the Triton tests you ran that touch module-level caches or registries.
CI
The JIT op smoke red is not yours. aiter/ops/flydsl/__init__.py:8 does a bare import flydsl at module scope and fused_moe.py imports aiter.ops.flydsl.kernels.mega_moe_gfx1250.types eagerly, so collecting op_tests/windows/test_moe_small_m_direct.py fails with ModuleNotFoundError: No module named 'flydsl' on the Windows gfx1201 runner. It is pre-existing on main and only surfaces when a PR touches fused_moe.py. A separate fix is going up; rerun after it lands.
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #8075 — Route ten more ops through the kernel plugin interface
Review (advisory): 🔴 HIGH RISK
Validation (deterministic): NOT RUN — the PR changes runtime code but ships no test target; the changed dispatch paths are executed at run time (not a data-only diff), the PR's own tests mock every native body so no automated test runs a real kernel through the routes, and this box has no GPU (rocminfo reports no gfx device, import aiter fails), so nothing could execute here either
Perf (advisory): NOT RUN — no perf target for the same reason there is no test target (the PR changes runtime code but ships no test target), and no GPU on this box to measure by hand; the added per-call dispatch hop on per-layer hot paths is unmeasured
Size: 1296 lines / 16 files — over the review bar
Design (advisory): SPLIT — the natural seams: the _backward_compat_find_spec import fix (aiter/ops/triton/init.py) is load-bearing and merges alone; then the GEMM routes (aiter/tuned_gemm.py + the Triton gemm pair), the MoE/topk/quant routes (aiter/fused_moe.py, aiter/ops/topk.py, aiter/ops/quant.py), the MLA routes (aiter/mla.py, mla_gluon.py, mla_sparse_prefill.py, pa_sparse_prefill_opus.py, pa_mqa_logits.py), and the MHC route (aiter/ops/mhc.py); tests/plugin_contracts.json and the _NOT_REGISTERED table ride with the first stack to land
Human: recommend zufayu review the ten route placements and out-buffer contract declarations of PR #8075 — they authored aiter/plugin/init.py and the prior routing PRs (#7854, #7875, #7926), and the question is whether each route sits at the right seam (under the guard vs on the public entry, below the backend pins) and whether mla_decode_fwd's "a provider may return o" permission and gemm_a16w16_out's data_ptr check state the contract right
🔴 [verified] The PR puts a plugin query in front of the default dispatch path of aiter/fused_moe.py, aiter/mla.py, aiter/ops/quant.py and aiter/tuned_gemm.py — ops ATOM/SGLang/vLLM consume — yet carries no ci:* label (labels: Triton/Gluon, OPUS) so every downstream job is skipped, and the only reviews so far are copilot's; a routing or import regression that aiter's own suite misses would break sglang/vLLM silently after merge, and the _backward_compat_find_spec change directly affects the old Triton import paths SGLang still uses. Reviewer must add ci:all (DeepSeek is exercised by atom+sglang+vllm) and @-mention the de-facto owners (la for fused_moe.py/tuned_gemm.py by git top-committer) requesting sign-off before merge.
o in the first return slot ("a provider may return o there") with no restriction to return_logits=False — in-repo no caller reads the split partials (return_logits=True appears only in tests asserting it raises), but if a downstream consumer does read the per-split partials, a provider following this contract silently hands it a view of o instead. Author must restrict the permission to return_logits=False calls or confirm no downstream consumer reads the partial logits.
📝 [verified] The PR ships no test target the validator can run, and every native body in the new tests in tests/test_plugin_routed_ops.py is monkeypatched or provider-served, so no automated test executes a real kernel through the ten routes — the no-provider path is covered by the existing op_tests in CI, but the only provider-served GPU evidence is the author's manual pre-rebase MI355X run. Reviewer should ask for one device-executed routed case per op family so the routed-to-native forwarding is exercised with real kernels.
2 finding(s) posted inline, on the lines they are about:
aiter/tuned_gemm.py:29— The patch no longer applies to the merge targetaiter/fused_moe.py:1622— No base-vs-head timing exists for the dispatch hop the ten routes add on per-layer hot paths…
) `op_tests/windows/test_moe_small_m_direct.py` landed on main at 02:29 UTC today (#4740). It re-exports `op_tests.test_moe_small_m_direct`, which imports `aiter.fused_moe`, which imports FlyDSL unconditionally -- 39 names across three `aiter.ops.flydsl` modules. FlyDSL ships Linux-only wheels, and `requirements.txt` says so: `flydsl==0.4.2; sys_platform != "win32"`. The Windows smoke runner therefore logs `Ignoring flydsl: markers 'sys_platform != "win32"' don't match your environment` and never installs it, so pytest raises `ModuleNotFoundError: No module named 'flydsl'` while COLLECTING the module. A collection error is not a skip: it fails the whole smoke job. Guarding the import inside `aiter/fused_moe.py` instead would need fallbacks for all 39 names and leave the module half-defined, so the skip belongs here, next to the platform that deliberately lacks the dependency. It costs no coverage Windows had -- `aiter.fused_moe` has never been importable there. The daily scheduled run (13:00 UTC) is green through 2026-11-16 because it last ran before #4740 merged; today's would be the first to hit this. PR #8075 found it earlier only because it carries `ci:all`, which is what lets this job run on a pull request at all. Verified: black and ruff clean; 47 tests still collect on Linux, where FlyDSL is present, so the happy path is unchanged. Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
373c7a4 to
7afdcc8
Compare
ROCm/aiter#8075 now registers mla_paged_decode as a custom op that writes o in place and returns lse alone, so no result aliases an input; a custom op cannot return None for a tensor, so the op returns an empty fp32 tensor when return_lse is off. AKLR's run still writes its output into o, and now returns that lse instead of (o, lse).
…8179) `aiter/fused_moe.py` gained `@drop_presort_on_error` on the routed custom op in #8075, but the import block below it lists only `drop_presort_after`. Importing the module therefore raises at decoration time: aiter/fused_moe.py:2824: in <module> @drop_presort_on_error NameError: name 'drop_presort_on_error' is not defined `import aiter` still works -- `aiter/__init__.py` does not import `fused_moe` -- so this surfaces only for callers that reach the module, which includes `tests/test_plugin_routed_ops.py`. That file now fails during collection, so the plugin suite cannot run on main at all. Both names are defined side by side in `aiter/presorted_moe.py`; only one was listed. Verified: `import aiter.fused_moe` succeeds, and `tests/test_plugin_routed_ops.py tests/test_plugin_contracts.py` is 77 passed. black and ruff clean. Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ROCm/aiter#8075 now registers mla_paged_decode as a custom op that writes o in place and returns lse alone, so no result aliases an input; a custom op cannot return None for a tensor, so the op returns an empty fp32 tensor when return_lse is off. AKLR's run still writes its output into o, and now returns that lse instead of (o, lse).
…KLR's provider serves ROCm/aiter#8075 routes flash_attn_varlen, mla_prefill_ps, mla_reduce, gemm_a8w8_bpreshuffle, causal_conv1d_split_qkv and the two KDA recurrences through aiter.plugin; #8179 restores the import aiter.fused_moe needs. This aiter pins flydsl==0.5.0 (a0c4b69c pinned 0.4.2).
main (ROCm#8075) routes fused_moe through the kernel plugin interface at version 1 and records that signature in tests/plugin_contracts.json. This PR adds w1_global_scale / w2_global_scale to it, so the contract gate failed after the merge ("signature of fused_moe changed without an op_version bump"). - fused_moe_ route: version=2. v1 is not superseded: a v1 provider cannot bind the two new arguments (the arity check rejects it), and a *args forwarder that binds them would serve an NVFP4 call as MXFP4. - Routed docstring documents the two arguments for providers. - tests/plugin_contracts.json: fused_moe entry regenerated with the gate's own routed_contracts() (new signature, fingerprint, version 2). - test_plugin_routed_ops.py: _serve declares the version the op is routed at instead of 1, so the fused_moe cases are still served under v2. Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n route aiter/fused_moe.py conflicted with three main commits: - #8075 (ee71544) routes fused_moe_ through the kernel plugin interface and decorates the public fused_moe with drop_presort_after instead of drop_presort_on_error. Taken as is. fused_moe_'s _eager_body is now the plugin's routed wrapper, so the eager call that skips the torch.ops dispatch still asks the providers first; the plan cache and scratch sort sit below the route, in the native body. The op test checks that the directly called body is the fused_moe route. - #7135 (ca7cfa1) sizes the config lookup by config_M / config_topk (_config_shape). The plan's recorded get_2stage_cfgs arguments use them, and a call with _config_shape takes no plan, like one with _stage2_override. - #8179 (a6c759b) imports drop_presort_on_error again; taken as is.
Conflict in aiter/tuned_gemm.py with ee71544 (#8075), which routes `_gemm_a16w16` through the kernel plugin interface (op "gemm_a16w16"). Both sides added an import at the same place and code right above `_gemm_a16w16`: this branch the eager fast path, main the @_route decorator. Kept both, with the decorator on `_gemm_a16w16`. The fast path calls hipBLASLt without reaching `_gemm_a16w16`, so it would skip the route. It now declines while any provider is enabled and the kill switch is off, and the call goes through the custom op to the route, which asks the providers and records its decision. It runs only in the state where the route's dispatch calls the native body and records nothing: AITER_PLUGINS=0 or nothing enabled by configure(). That is read from the same config snapshot the dispatch reads, once per call. op_tests/test_tuned_gemm_eager.py gains check_plugin_route: with a provider enabled for gemm_a16w16, `tgemm.mm` with and without out= runs the provider; when it declines, the custom op runs with its bits; with nothing enabled again the fast path takes the call. Without the new check in `_hipblaslt_eager` the first of these fails.


Summary
Route seventeen more ops through the kernel plugin interface (RFC #7240), so that a provider can serve them, and fix a bug that stops a Triton module from adding a route.
Motivation
AKLR (AMD-AGI/AKLR) is a provider of this interface (AMD-AGI/AKLR#226). It has qualified MI355X kernels for these aiter functions, which sglang and vLLM call, but aiter does not route the functions. A provider cannot serve an op that is not routed. The last seven are the ones Kimi-K3 calls on MI355X (vLLM 0.32.1 with aiter 0.1.26; SGLang 0.5.22) that AKLR has kernels for: its MLA prefill, its fp8
in_projGEMM, and KDA's convolution and decode.Changes
_backward_compat_find_specreturned the spec of the new module path, so the import system ran the module a second time under the old name. A routed op in the module then raisedalready routedon the second import. Now the old name gets the module that is already loaded.gemm_a16w16tuned_gemm._gemm_a16w16(tgemm.mm,gemm_a16w16,gemm_a16w16_out)_NOT_REGISTERED: out buffer, callers are intorch_compile_guardopsgemm_a16w16_activationgemm_a16w16, body under its guard_NOT_REGISTERED: out buffergemm_a8w8_blockscale_outgemm_a8w8_blockscale_NOT_REGISTERED: out buffer, dictconfigfused_moefused_moe_, under itstorch_compile_guardbiased_grouped_topkops.topk.biased_grouped_topktopk_weights,topk_idsmla_decode_fwdmla.mla_decode_fwd_NOT_REGISTERED: no annotations, out buffermla_paged_decodemla_gluonwhenhas_peand noattn_sink_NOT_REGISTERED: out bufferfp8_paged_mqa_logitsdeepgemm_fp8_paged_mqa_logits_NOT_REGISTERED:kv_cachehas no annotationmla_sparse_prefill_v4mla_sparse_prefill_v4withbackend=None;pa_sparse_prefill_fp8_opuswhen the automatic choice is opus_NOT_REGISTERED: out buffermhc_fused_post_pre_mhc_fused_post_pre_routedmutates_args=[]flash_attn_varlenflash_attn_varlen_func_NOT_REGISTERED: no annotations, out buffer, autograd.Function beneathmla_prefill_psmla_prefill_ps_asm_fwd, over its ctypes binding_NOT_REGISTERED: out buffersmla_reducemla_reduce_v1, over its HIP binding_NOT_REGISTERED: out buffersgemm_a8w8_bpreshufflegemm_a8w8_bpreshuffle, under itstorch_compile_guardcausal_conv1d_split_qkvcausal_conv1d_split_qkv_triton_tile_fn_NOT_REGISTERED:metadatahas no annotation, writesconv_statesfused_recurrent_kdaattention.kda.fused_recurrent_kda_NOT_REGISTERED: out buffer, state in place, dictconfigfused_recurrent_kda_packed_decodeattention.kda.fused_recurrent_kda_packed_decode_NOT_REGISTERED: out buffer, state in place, dictconfigbackend=argument orforce_fused=Trueskips the route, as forpa_fwd. gfx1250 keeps its kernel forpa_sparse_prefill_fp8_opus.per_1x32_mx_quant_hip: the fp8, e8m0, unshuffled path calls the routedper_group_quant. It is the same kernel call with the same allocations. No new op.gemm_a16w16_outnow checks that the result isout.mla_prefill_ps_asm_fwdandmla_reduce_v1were@compile_opsbindings. The bindings move to private names, andfc_namekeeps their symbols; the public names become routed Python functions over them. AITER's own split-KV MLA decode also reachesmla_reduce.flash_attn_varlen_func's docstring now opens the function; it used to follow theblock_tablecheck, so it was not a docstring.fused_moedocstring tells a provider to pop a presort registered withregister_presorted_moeitself.biased_grouped_topkreturnsNone; the Triton blockscaledtypeistorch.dtype | None; thedeepgemm_fp8_paged_mqa_logitsschedules aretorch.Tensor | None.tests/plugin_contracts.jsonis regenerated withrouted_contracts(): 17 new entries, the 23 other entries do not change.Testing
tests/plugin_contracts.json)Documentation
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
1443ad3
Behavior and intent
With no provider enabled, every call runs aiter's own code, as before. With a provider enabled, aiter asks it before these ops. The Python dispatch layer of several backends changes, as in #7728 and #7807; no kernel changes.
Validation and unverified scope
pytest tests/test_plugin*.py: 164 passed, 1 skipped (test_plugin_routed_ops.pyneeds a built aiter). black and ruff: no new findings.fused_moe(≤ 3.1e-2, MXFP4 weights),biased_grouped_topk(same experts),gemm_a16w16(7.2e-3), Tritongemm_a16w16(2.9e-7), Tritongemm_a8w8_blockscale(2.4e-4),mla_decode_fwdafter the rebase onto [ASM] [HIP] [JIT] Add gfx1250 R1 NVFP4 MLA decode and cache producers #7987 (1.6e-2),mla_paged_decode(6.3e-3),mla_sparse_prefill_v4(3.6e-3),mhc_fused_post_pre(6.1e-3).per_1x32_mx_quant_hipat m1792 n7168: the sameyand scale bytes as before the change with no provider, and with the provider servingper_group_quant.tests/test_plugin*.py223 passed, every route's public name included. The op tests of the seven new routes pass:test_causal_conv1d_prefill_split_qkv.py58 passed;triton_tests/attention/test_kda.py71 passed;test_gemm_a8w8_bpreshuffle_out.py53 passed,_pad_k.py43 passed;test_mla_reduce.pyall PASS; MLA_PS_RESULT; MHA_VARLEN_RESULT.fp8_paged_mqa_logitsserved by a provider (AKLR declined the tested points),mla_decode_fwd's NVFP4 keyword-only path with a provider (AKLR declines it; checked on CPU), and gfx1250.PR-specific question
Changed op tests
None.