Repository navigation
[Triton/Gluon] [Plugin] Route fused_dual_rmsnorm_mxfp8_quant - #7875
Conversation
The op writes through yq/sq/yk and returns them, so registering it over the full signature would be an op returning its own argument -- which a custom op's schema forbids and register_fake rejects. The routed contract is therefore the allocating form, and naming any output buffer bypasses routing, the way pa_fwd(backend=...) already does. ATOM's only call site names none of them. Co-Authored-By: Claude Opus 5 (1M context) <[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 |
The docstring claimed register_fake may not return an argument. Measured: it may, and doing so works. What is true is narrower and the reason the bypass exists: the schema declares results do not alias inputs, opcheck reports the contradiction, and a fake that allocates leaves the caller's buffer unwritten under compile while returning the right value -- no error, stale buffer. Dropping the buffers from the contract removes the contradiction rather than picking a side of it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Compiled calls and provider routing with supplied output buffers lack regression coverage, and the documented yk dtype conflicts with native and fake output behavior.
2 open issues
What changed in this PR
This PR adds plugin routing for fused_dual_rmsnorm_mxfp8_quant, allowing providers to serve ATOM’s allocating MXFP8 path while preserving native execution for caller-supplied output buffers.
Changes:
- Splits the wrapper into public dispatch, routed allocation, and unchanged native execution.
- Adds a fake implementation for custom-op registration and documents the buffer bypass.
- Adds the allocating signature to the plugin contract baseline.
| File | Description |
|---|---|
tests/plugin_contracts.json |
Records the new routed contract and fingerprint. |
aiter/ops/triton/quant/fused_mxfp8_quant.py |
Adds routing, fake output allocation, and native buffer bypass. |
Review effort: Balanced
Copilot review. Both the K-side description and the Returns line of the routed contract promised bf16 for yk, but an fp16 k yields fp16 in the native allocation and in the fake. Providers must implement the actual dtype, so the contract now says what it is: yk follows k.dtype. Co-Authored-By: Claude Code <[email protected]>
Copilot review: the MXFP8 tests only made allocating eager calls, so neither
the fake nor the buffered routing boundary had regression coverage.
Four tests, each pinning WHICH path ran rather than only that the call
returned something. The risk here is one-directional: landing on the
buffered path by naming a buffer gets AITER's own kernel, which is what
naming it asked for. The failure that matters is the reverse -- a call that
looks routed quietly not being routed.
* the allocating form is what a provider serves -- provider enabled, and
the decision is asserted to be ("provider", "aklr") with one select call;
* naming any one output buffer bypasses routing -- parametrised over yq,
sq and yk separately, because the branch reads all three and a test
passing them together would still pass with two conditions dropped. The
provider stays enabled and must come out with zero select calls;
* the buffered form writes and returns the caller's buffers -- asserted on
`data_ptr`, not on values. A fake that allocates compiles fine and
returns the right value while leaving the caller's buffer unwritten;
comparing values alone cannot see that;
* the routed form runs inside a compiled region -- shape, dtype and value
against the eager call, so a fake whose metadata drifts from the kernel
fails here.
The bypass tests replace the native body, so they need no device: what is
under test is which branch the public name picks. What the kernel computes
is covered by the `data_ptr` test under `@requires_cuda`.
Verified on gfx942, torch 2.9.1: 6 passed; black and ruff clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Five contracts carried an optional output buffer and returned it. That shape cannot be registered as a custom op: the schema declares that results do not alias inputs, so opcheck rejects it, and under compile a fake that allocates leaves the caller's buffer unwritten while still returning the right value -- no error, stale buffer, nothing says so. Each public spelling keeps its buffer argument and bypasses routing when one is named, as #7875 does. The routed contract drops it and gains a fake, so the op registers and a caller's graph no longer splits when a provider is enabled. gemm_a8w8_blockscale_bpreshuffle v1 -> v2 mla_sparse_prefill v1 -> v2 mla_sparse_prefill_v41 v2 -> v3 inverse_rope_group_quant v1 -> v2 pa_decode_bf16 v1 -> v2 Each declares the older version in supersedes=: the only change is removing an OPTIONAL buffer, so a provider built for the older shape sees it as None and allocates, which is the new semantics exactly. (rmsnorm v1 was left out of its own supersedes for the opposite reason: a v1 kernel handed a v2 call writes the caller's input.) _NOT_REGISTERED drops from 12 entries to 7; registered routed ops go from 7 to 12. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…8291) * [RFC #7240] Drop the output buffer from five routed contracts Five contracts carried an optional output buffer and returned it. That shape cannot be registered as a custom op: the schema declares that results do not alias inputs, so opcheck rejects it, and under compile a fake that allocates leaves the caller's buffer unwritten while still returning the right value -- no error, stale buffer, nothing says so. Each public spelling keeps its buffer argument and bypasses routing when one is named, as #7875 does. The routed contract drops it and gains a fake, so the op registers and a caller's graph no longer splits when a provider is enabled. gemm_a8w8_blockscale_bpreshuffle v1 -> v2 mla_sparse_prefill v1 -> v2 mla_sparse_prefill_v41 v2 -> v3 inverse_rope_group_quant v1 -> v2 pa_decode_bf16 v1 -> v2 Each declares the older version in supersedes=: the only change is removing an OPTIONAL buffer, so a provider built for the older shape sees it as None and allocates, which is the new semantics exactly. (rmsnorm v1 was left out of its own supersedes for the opposite reason: a v1 kernel handed a v2 call writes the caller's input.) _NOT_REGISTERED drops from 12 entries to 7; registered routed ops go from 7 to 12. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Address the review: keep the public registration, declare mutation, pin it Five findings from the bot review of 5416969, each verified before fixing. **The public name stopped being registered.** Moving `@torch_compile_guard` onto the renamed `_gemm_a8w8_blockscale_bpreshuffle_native` moved the registration with it -- the guard registers under the decorated function's own name -- so `torch.ops.aiter.gemm_a8w8_blockscale_bpreshuffle` and the public spelling's `_eager_body` both disappeared, and `op_tests/test_gemm_host_dispatch_cache.py` used both. The guard now sits on the public dispatcher, which carries the name. Confirmed by comparing the registered names against an unpatched main tree: the same three are present on both. Worth noting that CI did not catch this. The Aiter Test Gate went green on the revision where those two attributes were already gone. **The schemas claimed every input was mutated.** The new routes passed `fake=` but not `mutates_args=[]`, so each registered as `(Tensor(a0!) XQ, Tensor(a1!) WQ, ...)` and earned an `auto_functionalized_v2` wrap under compile -- on ops whose unguarded public spellings previously traced through. Four of the five now declare `[]`, which is what their own docstrings say. `pa_decode_bf16` deliberately does not. Dropping `out` removes the buffer it RETURNED, but `split_o`, `split_lse` and `work_info` still reach the asm binding as split-KV scratch and nothing in the tree establishes they are read-only. `route()` says the conservative default costs a wrap while a declared list that lies is undefined behaviour, so the wrap is the cheaper of the two until someone can state it per buffer. **The nested group32 call became provider-offerable.** `gemm_a8w8_blockscale` reached its bpreshuffle sibling through `_eager_body` to avoid dispatching a second time; with the split, that body is the dispatcher, which routes when no buffer is named -- a second dispatch, and a different kernel inside what the caller asked AITER to compute. It now targets the native body directly. The comment and the test's patch target move with it. **Nothing asserted the contracts reach torch.** The AST gate checks that `fake=` was passed and the registry check reads the plugin's own dict; neither calls into torch, and `_as_custom_op` returns None silently on failure. A new parametrised test resolves each of the five under `torch.ops.aiter_routed` and compares the registered parameter list against the recorded contract -- against the baseline rather than a list of likely buffer names, because `x_scale` is an output buffer for one of these ops and an input for another. **No CI label.** `ci:all` added, so the label-gated downstream jobs run against the new opaque nodes rather than nothing. Verified: `tests/test_plugin_contracts.py tests/test_plugin_routed_ops.py op_tests/test_mla_sparse_prefill_v41_asm.py op_tests/test_gemm_host_dispatch_cache.py` is 137 passed, 145 skipped on gfx942. black and ruff clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Let the registry hold superseded op versions of its own `test_status_lists_what_is_deprecated_and_when_it_goes` asserted that `status()["deprecations"]` held exactly the two entries it created, which held only while no op in the tree declared `supersedes=`. These five now do, so the test selects its own two subjects instead. The coverage that assertion really provided -- that a superseded op version is announced at all -- moves to the contract test, where it is checked per op against that op's own version. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [RFC #7240] Drop the output buffer from pa_fwd, and cover its routed path `pa_fwd` is the sixth contract with an optional output buffer it returns, and the last one this series leaves. Registered, that is an op returning one of its own arguments while its schema declares results do not alias inputs. v1 -> v2 removes the buffer from the contract. Both public spellings keep their signatures; naming `out_` bypasses routing and runs AITER's own kernel, which is what naming it asked for. v1 is declared in `supersedes=`: the only change is removing an OPTIONAL buffer, so a v1 provider sees `out_=None` and allocates, which is v2's semantics exactly. `_NOT_REGISTERED` goes from 19 entries to 18; registered routed ops 15 -> 16. Unlike the five in the previous commit, this op has callers that pass the buffer -- five, all in `op_tests` -- so after this change they exercise the bypass and nothing exercises the routed path. Six tests restore that coverage, each pinning WHICH path ran rather than that the call returned: * both spellings route when no buffer is named. `pa_fwd_asm` reads like a backend pin and is not: it predates the neutral name, so an ordinary call through it routes. Testing only `pa_fwd` would leave half the callers unrouted without anyone noticing. * naming `out_` bypasses, from either spelling. * `kernelName` bypasses on its own, kept separate from the `out_` reason so the two cannot be merged into one. * the buffered form returns the caller's buffer, asserted on `data_ptr`. A fake that allocates returns the right value while leaving that buffer unwritten; comparing values alone cannot see it. Verified: `tests/test_plugin_contracts.py tests/test_plugin_routed_ops.py` is 83 passed; `pa_fwd` appears in `torch.ops.aiter_routed` after a real `import aiter`; `op_tests/test_pa_block_id_truncation.py`, which passes `out_`, is 56 passed 8 skipped on gfx942. black and ruff clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>


Routes
fused_dual_rmsnorm_mxfp8_quant, which ATOM calls on the V4 MXFP8 path (atom/model_ops/layernorm.py), usingroute(..., fake=...)from #7850.The out-param form cannot be a routed contract
This op both writes through
yq/sq/ykand returns them:Registered over the full signature, that is an op returning one of its own arguments, while the schema it is registered under declares that its results do not alias its inputs. Measured, rather than argued:
opcheckreports the contradiction either way:Argument out is not defined to alias output but was aliasing.An earlier revision of this PR said
register_fakemay not return an argument. That is not true — it may, and it works. The true statement is narrower, and it is the one that motivates the bypass: the contradiction is real, the silent half of it is the dangerous half, and neither resolution belongs in a contract.So the contract is the allocating form, and passing any of the three buffers bypasses routing:
The mechanism is not new:
pa_fwd(backend=...)already bypasses routing when a caller pins what to run. Naming output buffers is the same kind of instruction. The reason is written in the docstring, not just the conclusion, so the next person reading "why do these three parameters skip routing" does not have to re-derive it.ATOM's only call site passes none of them, so every call it makes is routed.
Structure
Three parts, mirroring
pa_fwd/_pa_fwd_routed/_pa_fwd_nativefrom #7807:_fused_dual_rmsnorm_mxfp8_quant_native— the existing body, renamed, unchanged;_fused_dual_rmsnorm_mxfp8_quant_routed— 7 parameters, carries@routeand the contract docstring;fused_dual_rmsnorm_mxfp8_quant— the public name, picks a branch.Validation
On gfx942, torch 2.9.1, against this tree:
_nativedata_ptrchecked), values agree with the routed branchtests/test_plugin_contracts.py,tests/test_plugin_selector_arity.pyrouted_contracts(), 17 -> 18black,ruff checkThe fake allocates
(M, KQ)fp8 e4m3fn,(M, KQ // 32)uint8 and(M, KK)ink's dtype — read off the same expressions the kernel path uses, not off the docstring.Limits
The buffered branch is covered by identity rather than by value alone: a fake that
allocates returns the right value while leaving the caller's buffer unwritten, which
comparing values cannot see.
ci:allis set, and this touchesaiter/ops/triton/**,so the Triton suite runs.
🤖 Generated with Claude Code
PR Self-Review
Reviewed revision
54f7a44a16Behavior and intent
ATOM calls this op on the V4 MXFP8 path and no provider can serve it. Routing it needs one decision first: the op writes through
yq/sq/ykand returns them, so an op registered over the full signature would return one of its own arguments — which a custom op's schema forbids,register_fakerefuses, andopcheckrejects. The routed contract is therefore the allocating form, and naming any output buffer bypasses routing.That bypass is not a new rule:
pa_fwd(backend=...)already skips routing when a caller pins what to run, and naming the buffers to write is the same kind of instruction. ATOM's only call site names none of them, so every call it makes is routed.Validation and unverified scope
Verified on gfx942, torch 2.9.1, against this tree:
_native: all three outputs bit-identical;data_ptrcompared, not inferred), values agreeing with the routed branch;_fused_dual_rmsnorm_mxfp8_quant_routedregisters —OpOverloadPacketundertorch.ops.aiter_routed;tests/test_plugin_contracts.pyandtests/test_plugin_selector_arity.py: 20 passed;routed_contracts()rather than edited, 17 -> 18;blackandruff checkclean.Added in
54f7a44a16, answering a Copilot review that the MXFP8 tests only madeallocating eager calls, so neither the fake nor the buffered boundary had regression
coverage — four tests in
tests/test_plugin_routed_ops.py, each pinning which pathran rather than only that the call returned something:
("provider", "aklr"), one select call;yq,sq,ykseparately, because the branch reads all three and a test passing them together
would still pass with two conditions dropped; the provider must come out with zero
select calls;
data_ptr,not on values;
eager call, so a fake whose metadata drifts from the kernel fails there.
6 passedon gfx942 / torch 2.9.1;blackandruff checkclean.Unverified: the bypass tests replace the native body, so they pin which branch the
public name picks, not what the kernel computes — the latter is what the
data_ptrtest under
@requires_cudacovers. There is no dedicatedop_tests/target for thisop to name.
The boundary this introduces, and what covers it
The split itself: one public name, two paths, and a caller lands on the wrong one only by passing a buffer — in which case it gets AITER's own kernel, which is what naming the buffer asked for. The risk is the reverse direction, a routed call quietly not being routed, and that is covered by the
data_ptrcheck: the bypass branch is proven to be the branch that returns an argument, so the routed branch provably is not.The fake's shapes are read off the same expressions the kernel path uses —
KQ // _QUANT_BLOCK_SIZE,k.dtype— rather than off the docstring, so a change to either moves both together.PR-specific question
Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
No configuration or tuning keys change, and no selection logic is touched. The one branch this PR adds reads whether
yq,sqandykareNone— never a shape, a dtype, an arch or a tuning key._fused_dual_rmsnorm_mxfp8_quant_nativeis the original body, renamed and otherwise unchanged, so every shape reaches the same Triton launch with the sameBLOCK_SIZE_KQ/BLOCK_SIZE_KK/NUM_PRGMSit computed before.The evidence is the equivalence run: the routed branch and
_nativeproduce bit-identical output for all three tensors, and the bypass branch returns the exact buffers it was handed (data_ptrcompared). Since selection cannot depend on anything this PR introduces, there is no shape for which it could differ.Changed op tests
None. The regression coverage added in
54f7a44a16lives intests/test_plugin_routed_ops.py, beside the other routed-contract tests, because whatit pins is a routing boundary rather than kernel numerics. No
op_tests/file changed.