Skip to content

[Prototype] Close three conformance gaps against RFC #7240 - #7460

Closed
zufayu wants to merge 10 commits into
ROCm:mainfrom
zufayu:codex/aklr-rfc-conformance
Closed

zufayu wants to merge 10 commits into
ROCm:mainfrom
zufayu:codex/aklr-rfc-conformance

Conversation

@zufayu

@zufayu zufayu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Part 7 of the series. This one came out of reading RFC #7240 itself rather
than the proposal answering it, which turned up three places where the
implementation did not do what the interface describes.

part content status
1–6 the interface #7437 #7440 #7443 #7446 #7450 #7451
7 (this PR) conformance gaps against the RFC here

Stacks on #7451. Review the last commit only. #7086 and #7123 are untouched.

Routed signatures were never checked for stability

The RFC lists this among the checks that block every AITER PR:

verification that routed public signatures still match their contracts

route() captures the signature at decoration, so it always agrees with
itself — the check was vacuously true. A routed op's public signature is its
contract: a provider implements against the parameter names, order, kinds and
defaults it sees. Changing it moved the contract under every installed provider,
with no op_version bump and nothing in the interface to notice.

tests/test_plugin_contracts.py reads the routed signatures out of the source
and compares them with a committed baseline. A static scan, not an import:
no GPU, no toolchain, and no list of "modules that route ops" for somebody to
forget to extend — it cannot miss a route that exists.

  • a changed signature fails unless version= moved with it, and the message
    shows both signatures;
  • a routed op that disappears fails as a contract removal, which needs a
    deprecation window rather than a deletion;
  • a newly routed op fails until its contract is recorded.

The baseline is empty here because nothing in this branch routes an op. The gate
was validated against the two ops #7123 routes, including a non-literal default:

rmsnorm         out:positional, input:positional, weight:positional,
                epsilon:positional, gemma_norm:positional=False
pertoken_quant  x:positional, scale:positional=None, x_scale:positional=None,
                scale_dtype:positional=dtypes.fp32, …

A provider could only declare one API version

A Provider declares: … supported Provider API versions;

Plural — and "Allow Providers and AITER to release independently" is a stated
goal, which needs one provider release to cover several AITER versions. The
Protocol had api_version: int.

Providers now declare api_versions and are served on the newest version both
sides share
. The single api_version spelling still works and says so once,
through the same window machinery #7450 added, so this is itself a deprecation
rather than a break.

AITER still decides what it accepts (API_VERSION plus
SUPERSEDED_API_VERSIONS); the provider declares what it supports; the
intersection decides. Neither side can widen the other's half.

A duplicate provider name was a tie to break

Two entry points answering to one name made AITER_PLUGIN_ENABLE,
AITER_PLUGIN_FORCE and every Decision ambiguous, and let install order decide
which served — in an interface whose priority rule is that the enable list is the
only order source.

The second is now skipped, with a reason in status(). Skipped, not raised:
the RFC requires that a broken install never break import aiter. That is the
opposite of the duplicate op-name rule in #7446, where the ambiguity is in
AITER's own code and failing at import is the right answer.

Also

Falling back to the generic binder now logs once. An op whose signature cannot be
generated against pays roughly sixty times the per-call cost (#7440), and nothing
said so.

Deliberately not implemented

The RFC also describes an architecture, dtype, layout and shape coverage
declaration
. No form is defined for it, and a declaration surface is permanent
public contract — easier to add later than to undo. A comment on the Protocol
records it; select() answers coverage per call until the form is settled. Worth
a decision in the RFC discussion rather than in a PR.

Testing

pytest -q tests/ — 224 passed, 14 added. CPU-only. black --check and
ruff check clean. Hot-path cost unchanged: 2.44us serving, 0.141us with
AITER_PLUGINS=0, against 4.97us for one Signature.bind.

🤖 Generated with Claude Code

zufayu and others added 10 commits October 28, 2026 16:58
Installing a provider never makes it the default: dispatch now serves a
provider only when it is explicitly enabled (AITER_PLUGIN_ENABLE) or
forced (AITER_PLUGIN_FORCE). This makes the ownership boundary concrete:
AITER owns the op contract and execution rules, providers own their
kernels and qualification evidence, frameworks and users own enablement.

- document the ownership boundary in the module docstring
- isolate invalid candidates returned by select(): fall back to native
  with reason "invalid-candidate" instead of raising AttributeError
- document that entry points must target an instance or zero-arg factory
- tests: installed-but-not-enabled is inert (select never called);
  non-candidate select() results fall back to native

Co-Authored-By: Claude Code <[email protected]>
Dispatch read four environment variables per call and rebuilt a set and a
frozenset each time, costing 2.49us of the hot path (measured). It also stored
enabled providers in a frozenset, which destroyed the enable list order, so
candidates were tried in alphabetical provider-name order instead of the
configured preference order.

Configuration is now an immutable snapshot built at first dispatch. Dispatch
reads one reference per call, so a call always runs against exactly one
generation; configure() and reload_config() build a new snapshot and swap the
reference under the config lock, leaving the hot path lock-free. Measured cost
of the gates drops to 0.048us. The eligible provider list is cached per
(op, config generation), get-or-build, and a build race is benign.

enabled is now an ordered tuple and the eligible list is built by walking it,
so the enable list order is the preference order it was specified to be.

Also:
- configure(*, source, enable, disable): source is required provenance; enable
  replaces the previous framework default, disable unions with the user's. All
  keyword-only, since a required parameter cannot follow a defaulted one.
- reload_config() re-reads the environment deliberately. Mid-process changes
  are not otherwise observed.
- A reload producing an identical snapshot does not bump the generation; a
  no-op bump would flush the eligible cache and churn provider resources.
- An empty environment value counts as unset, so AITER_PLUGIN_ENABLE="" falls
  through to the framework default rather than denying everything.

test_provider_arbitration_is_deterministic asserted that alpha wins from
"alpha, zebra" -- alphabetical order already produced that, so the test passed
against the bug. It is replaced by a case whose enable order contradicts
alphabetical order.

Co-Authored-By: Claude Code <[email protected]>
inspect.Signature.bind is generic: it re-derives the parameter mapping on every
call. Measured against the two signatures ROCm#7123 routes, that is 4.57us for
rmsnorm and 6.05us for pertoken_quant -- on its own more than any plausible
dispatch budget, and the step that dominated the hot path.

The signature is already known when route() decorates the op, so the binder is
now generated once, at decoration. The generated function produces exactly what
bind() + apply_defaults() produce, raises the same TypeError on a malformed
call, and costs 0.076us / 0.083us. Defaults travel through the generated
function's namespace rather than through source text, because a default such as
dtypes.fp32 has no parseable repr. Signatures with *args/**kwargs, or with a
parameter that would collide with an injected default, fall back to
Signature.bind.

This sits below the API boundary: providers receive the same canonical
arguments, callers call the same way, and api_version does not move.

tests/test_plugin_overhead.py measures the whole path and prints the numbers,
which is what RFC ROCm#7240's first milestone actually asks for. On a Xeon
Platinum 8480C with Python 3.12.12, overhead over a direct native call:

    provider serves        1.79us
    no provider enabled    1.42us
    AITER_PLUGINS=0        1.19us
    one Signature.bind     4.85us

So the 1us design budget is not met yet, and the per-step projection that
suggested it would be (~0.9us) was optimistic: it omitted the Python call chain
and the per-call bookkeeping that only an end-to-end measurement sees. Decision
construction plus the ContextVar set is 0.787us of what remains, and is now the
largest single item.

The gate asserts what can be defended on unknown hardware: the whole aiter-side
overhead must cost less than one Signature.bind of the same signature, measured
in the same process. That fails the moment generic canonicalization, a per-call
getenv, or a rebuilt provider list returns, on any runner. The 1us budget is
reported rather than asserted until CI runner hardware is characterised.

Co-Authored-By: Claude Code <[email protected]>
…g layer

Three changes that share the dispatch path.

**A misbehaving provider no longer denies service to a well-behaved one.** A
select() exception, and a candidate that is not a KernelCandidate or is owned by
somebody else, both removed the whole op from provider routing: the first one
encountered returned to native and the remaining providers were never asked.
That is correct with one provider and wrong with several. Both are now
pre-execution misbehaviour that removes that provider from this call only.

Native fallback happens when no provider serves. Reason precedence is two tiers:
either provider error outranks provider-declined -- a decline is normal
operation, an error is something someone must fix -- and within the error tier
the first one encountered is recorded, each keeping its own reason string.
Ranking provider-select-error against invalid-candidate would be arbitrary: both
mean the provider is broken, and either ranking still depends on iteration
order.

**The kill switch is now a free path.** With AITER_PLUGINS=0 dispatch checks one
cached flag and calls native, recording nothing: the feature is off, so there is
nothing to observe. Measured overhead over a direct native call drops from
1.19us to 0.141us. A per-op disable still records its Decision -- that op was
routed and deliberately turned off, which is what an operator is watching.

**Decision carries config_source**, naming the layer that produced the route:
"env", "configure:<source>", or "default-deny". An op-disabled route names the
layer that disabled it rather than the enable layer, so disabled_ops is now a
mapping from op name to its source; when both the framework and the user disable
an op, the user's act is the one named.

Measured on a Xeon Platinum 8480C, Python 3.12.12, overhead over a direct native
call: the serving path moves from 1.79us to 1.96us, paying one function call for
the isolation boundary and one more Decision field. The kill-switch path is
8.4x cheaper.

Co-Authored-By: Claude Code <[email protected]>
RFC ROCm#7240 fixes what is observable but not how it is delivered. One record,
four reads: every layer consumes the same frozen Decision, and there are no
separate formats.

    last_decision()    per call        what served this call (already existed)
    status()           introspection   why is, or is not, X routed
    explain(op, ...)   introspection   the same question without executing
    decision_counts()  aggregation     what ran, how often, with what outcome
    on_decision(cb)    aggregation     inline, native routes included
    route-change log   audit trail     did routing flip when config changed

Reporting anything per op presumes routed ops are enumerable, which nothing
made true: Op and the contract lived only in route()'s closure. route() now
registers the op, and a duplicate op name is an error at import. Silent
last-wins would make routing depend on import order, which is exactly what the
enable list exists to avoid, and two routes claiming one name make op_version
unable to describe the contract anyway.

status() reports installed providers including the ones that were skipped and
why -- an installed provider that never serves is the first thing an operator
asks about, and that answer was previously only in the logs.

explain() dry-runs gates, eligibility and selection and returns the Decision the
call would produce plus why each provider declined. It never calls run(), never
records a Decision, and never counts one. It relies on select() being pure,
which is already a provider obligation.

on_decision() callbacks are called inline. A callback exception is swallowed,
logged once per callback rather than once per call, and counted in status(): a
telemetry bug must never break a kernel launch.

The route-change log is scoped to the config generation. Within one generation
the route is a deterministic function of the call arguments, so call-to-call
variation is provider behaviour -- visible in decision_counts() -- and not an
audit event. One line per op per generation, only when the route differs.

Every Decision now goes through a single _record(), so the four reads cannot
drift apart.

Cost, measured on a Xeon Platinum 8480C with Python 3.12.12: the serving path
moves from 1.96us to 2.42us. The layer is 0.46us, of which the counter
increment is the largest single piece at 0.166us, the route-change check 0.063us
and the empty callback loop 0.038us. This is the number the design estimated at
0.110us by counting the increment alone.

Co-Authored-By: Claude Code <[email protected]>
A CUDA graph replay runs no Python, so a captured op contributes one count for
the whole life of the graph however many times it replays. The counts are a
complete record of what was decided; read as a call mix they are wrong by
orders of magnitude for captured decode.

Co-Authored-By: Claude Code <[email protected]>
RFC ROCm#7240's open question 5 asks for deprecation windows. Dispatch had none: a
provider whose api_version did not equal AITER's exactly was skipped, and a
provider declaring an older op_version was simply not eligible. Both failures
were silent about what to do next.

SUPERSEDED_API_VERSIONS maps a still-accepted provider API version to the
release that removes it. A provider inside the window loads and warns once,
naming that release; one outside is skipped with a reason naming the versions
this aiter does accept.

route(supersedes={old_version: release}) does the same for an op contract. A
provider still on the old version serves and warns once, naming the release that
stops accepting it. Only AITER can make that declaration: AITER owns the
contract, so only AITER can say that a provider written against an older version
is still acceptable for calls on this one. A provider cannot grant itself a
grace period, and a contract cannot supersede its own version.

Both warn once per subject rather than once per call, and the warning always
names the removal point, so nobody learns a deadline from a crash.

The policy -- the design proposes two aiter minor releases -- stays with
maintainers. What the mechanism requires is only that the window exists, is
declared, and is named at runtime; the release string is free-form so the
policy can change without the code changing.

status() gains "api_versions_accepted" and "deprecations", so what is on borrowed
time and until when is data, not a log line somebody has to have been watching
for.

One thing deliberately not invented: an enabled provider on an op version this
contract no longer accepts falls back with reason "no-provider", which is
literally true but does not distinguish it from nothing being installed. The
design enumerates no reason for that case; a test records the gap rather than
inventing a string for it.

Co-Authored-By: Claude Code <[email protected]>
Every other test substitutes _entry_points, so the one seam between this
interface and the outside world -- importlib.metadata, the entry-point group
name, and loading an entry point that names an instance or a zero-argument
factory -- was the least covered part of it. A wheel that declares the group
slightly differently, or a metadata API that changes shape, would have been
caught by nothing.

These tests write real .dist-info directories onto sys.path and let discovery
find them the way it finds an installed wheel: both entry-point targets serve,
an installed provider is still not enabled by default, and an entry point in a
different group is ignored.

CPU-only, no GPU and no actual install.

Co-Authored-By: Claude Code <[email protected]>
Reading the RFC itself rather than our proposal answering it turned up three
places where the implementation did not do what the interface describes.

**Routed signatures were never checked for stability.** The RFC lists it among
the checks that block every AITER PR: "verification that routed public
signatures still match their contracts". route() captures the signature at
decoration, so it always agrees with itself -- the check was vacuously true. A
routed op's public signature is its contract, so changing it moved the contract
under every installed provider with no op_version bump and nothing to notice.

tests/test_plugin_contracts.py reads the routed signatures out of the source and
compares them with a committed baseline. It is a static scan rather than an
import: no GPU, no toolchain, and no list of "modules that route ops" for
somebody to forget to extend. A changed signature fails unless version= moved
with it; a removed routed op fails as a contract removal. Validated against the
two ops ROCm#7123 routes, including a non-literal default (dtypes.fp32).

**A provider could only declare one API version.** The RFC says a provider
declares "supported Provider API versions", plural, and lists independent
release cadence among its goals -- which needs one provider release to cover
several AITER versions. Providers now declare api_versions and are served on the
newest version both sides share. The single api_version spelling still works and
says so once, through the same window machinery.

**A duplicate provider name was a tie to break.** Two entry points answering to
one name made AITER_PLUGIN_ENABLE, AITER_PLUGIN_FORCE and every Decision
ambiguous, and let install order decide which served. The second is now skipped
with a reason in status(). Skipped, not raised: the RFC requires that a broken
install never break `import aiter`, which is the opposite of the duplicate
op-name rule, where the ambiguity is in AITER's own code.

Also: falling back to the generic binder now logs once. An op whose signature
cannot be generated against pays roughly sixty times the per-call cost, and
nothing said so.

Deliberately not implemented: the architecture, dtype, layout and shape coverage
declaration the RFC also describes. No form is defined for it, and a declaration
surface is public contract -- easier to add than to undo. A comment on the
Protocol records it; select() answers coverage per call until the form settles.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7460 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 13e9df105cd2 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu

zufayu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #7465, which now carries this work with its commits intact. The series was split by when it was written; it is now split by who reviews it — the interface (#7465), the CI gate (#7466), and routing plus the jit/core.py change (#7484).

@zufayu zufayu closed this Nov 5, 2026
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 5, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 5, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 7, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 7, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 7, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 7, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 8, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 8, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 8, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 8, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 9, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 9, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit to zufayu/aiter that referenced this pull request Nov 10, 2026
The two ops RFC ROCm#7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
ROCm#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (ROCm#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>
zufayu added a commit that referenced this pull request Nov 10, 2026
…ed op report its signature (#7484)

* Let a compiled op report its own signature, and keep imported routes

Two things a routed production op needs before it can be routed at all.

**A compiled op's public signature was (*args, **kwargs).** torch_compile_guard
returns a closure and does not use functools.wraps, so inspect.signature() of
any @compile_ops function reported the closure's parameters rather than the
op's. The guard already knows the original as calling_func_; both branches now
expose it as __wrapped__.

This is not cosmetic for this interface. route() captures the public signature
as the op contract. Against (*args, **kwargs) a per-op binder cannot be
generated at all, so every call falls back to Signature.bind -- sixty times the
cost -- and, worse, apply_defaults() has no defaults to apply, so a provider's
select() would see a different number of arguments depending on how the caller
spelled the call. The contract would be unusable.

Side effects are small: both wrappers are plain Python functions, not
OpOverloadPacket, so the assignment cannot raise; it happens after
torch.library registration; and nothing else in the tree reads __wrapped__ on
these. The visible change is that introspecting a compiled op now gives its
real parameters, which is what it always should have given.

**_reset_for_testing() cleared ops routed by importing aiter.** The autouse
fixture calls it per test, so production routes registered at import vanished
after the first test: status()["routed_ops"] and explain("rmsnorm", ...) would
report them as unrouted for every test after that. Import-time routes are now
captured on the first reset and restored on every one; test-registered ops are
still cleared.

tests/test_jit_signature.py covers the first, and skips where AITER is not
built, so the CPU-only gate stays buildless. Both of its tests fail without the
__wrapped__ change.

Co-Authored-By: Claude Code <[email protected]>

* Route rmsnorm and pertoken_quant, and record their contracts

The two ops RFC #7240's first milestone names. Both stay native by default:
routing only changes what happens once a provider is explicitly enabled.

tests/plugin_contracts.json now records their signatures, so the gate from
#7460 stops being vacuous and starts guarding something. Either signature
changing without an op_version bump now fails CI.

The end-to-end tests live in tests/test_plugin_routed_ops.py rather than in
tests/test_plugin.py, because they import torch and call the real ops. The
interface's own tests have to stay buildless so they can gate every PR without
a GPU runner (#7466), and mixing these in would have ended that.

That exposed an interaction worth naming: pytest.importorskip("aiter") does not
skip when tests/conftest.py has already put a stub under that name, so tests
needing a real build ran against the stub and failed instead of skipping. The
stub is now marked, and requires_built_aiter() checks for it. Verified both
ways: a built checkout runs 240 tests, a checkout with no compiled module runs
88 and skips the two modules that need one.

What this routes, stated plainly because the PR description is where a provider
author will look:

- rmsnorm is the low-level HIP binding, not a public entry point. It is reached
  from rms_norm and rmsnorm2d_fwd only when _use_hip_common() holds; the opus
  path never passes through it, and the output buffer is already allocated by
  the caller. A provider covers that subset, not the op.
- rmsnorm2d_fwd_with_add, the residual-add path, goes through add_rmsnorm
  instead and is not routed at all.
- pertoken_quant is the torch reference implementation rather than a production
  kernel, and it is reused by per_block_quant_wrapper, so serving it also
  serves the per-block quant torch path.

Co-Authored-By: Claude Code <[email protected]>

* Serve a routed contract from an installed provider

RFC #7240's first milestone is complete when, among other things, "one external
reference Provider serves the two routed contracts". Every other condition was
covered; this one was not, and it is the only one that shows the interface is
usable rather than merely present.

A reference provider now arrives the way a real one would -- a package and a
.dist-info on sys.path, found through importlib.metadata, with nothing
monkeypatched into discovery -- and serves aiter.rmsnorm end to end: enabled by
environment, selected, recorded with its kernel id and artifact digest, and
checked against the op's own arithmetic so the test proves it computed the op
rather than merely claimed the route.

The same provider declines pertoken_quant, and declines rmsnorm per call for a
shape it does not cover. Both are ordinary operation rather than failure, and
both are visible: provider-declined in the record, and the reason per provider
in explain(). A provider that is installed, enabled and simply not serving this
call is the state an operator most often needs explained, so it is the state
most worth having a test for.

The provider source is written out in full in the test rather than imported
from a fixture, because it is also the smallest complete answer to "what does a
provider have to ship" -- a name, the API versions it supports, the op versions
it serves, a select() that may decline, and an evidence reference AITER records
without interpreting.

Co-Authored-By: Claude Code <[email protected]>

* Route the residual-add path, and expose signatures from the guard itself

rmsnorm2d_fwd_with_add is the per-layer residual-add path vLLM, SGLang and ATOM
call -- its own docstring says so -- and it was the most conspicuous gap in what
this milestone routes. It dispatches to a different kernel than rmsnorm and has
a second output, so it is a separate contract rather than a shape of the first
one: op "rmsnorm_with_add".

Routing it needed the signature fix to move. torch_compile_guard is used
directly here rather than through compile_ops, so the __wrapped__ assignments in
jit/core.py did not reach it and its public signature was still
(*args, **kwargs) -- unroutable, because no binder can be generated and no
default can be applied. The guard now exposes calling_func on every path it
returns, which covers both its own users and compile_ops'; the two assignments
in jit/core.py are redundant and gone.

All three entry points now report their own parameters: rmsnorm, rmsnorm2d_fwd
and rmsnorm2d_fwd_with_add.

The reference provider serves both contracts from one release, which is the
shape an out-of-tree provider actually has -- it covers part of an op family,
not all of it. It declines pertoken_quant and declines per call for a shape it
does not cover, and the tests check that each contract is answered on its own
terms: separate kernel ids, separate provenance, separate counts.

What is still not covered, so that it is not mistaken for coverage: the opus
branch of either path, which a provider never sees because the HIP check
precedes it.

Co-Authored-By: Claude Code <[email protected]>

* Route rmsnorm where the op begins, not where one backend does

The route was on `rmsnorm`, which is the HIP binding behind
`module_rmsnorm_quant`. It is a public name only because `aiter/ops/rmsnorm.py`
is star-imported; what it actually is, is one backend's entry point.

Mounting a route there means a provider declaring op "rmsnorm" sees neither
public spelling of the op. `rms_norm` and `rmsnorm2d_fwd` both call
`_rms_norm_fwd_dispatch` directly -- deliberately, so the no-add path pays a
single torch_compile_guard -- and that function chooses between the HIP binding
and opus. Everything above the binding bypassed the route, and the opus branch
could never reach a provider at all. The op name was backend-neutral while what
it resolved to was not, which is the same defect #7150 exists to remove, one
level further down.

The route now sits on `_rms_norm_fwd_dispatch`: below both public spellings,
above the backend choice. Both spellings are covered, both branches are, and
downstream is unaffected -- vLLM calls `rms_norm`, ATOM calls `rmsnorm2d_fwd`,
and neither changes.

**Version 2, and deliberately not a supersedes of version 1.** The contracts
are different shapes, not different spellings of one: v1 took an output buffer
first and returned nothing, v2 takes the input first and returns the result. A
provider written against v1 handed a v2 call would treat the input tensor as
its output buffer. `supersedes=` means "still acceptable", which this is not.

The contract gate caught the change and required the bump, which is what it is
for.

Two tests called `aiter.rmsnorm` directly with CPU tensors and passed only
because the provider intercepted them -- with the route moved, they reached the
real ROCm kernel and dumped core. They now go through a public spelling, which
is what they meant to exercise.

Co-Authored-By: Claude Code <[email protected]>

* Check the kernel takes the contract, and let the version stay quiet

A declared op version is a provider's claim that it implements this contract.
Nothing checked the claim, and the failure when it is wrong is silent: a kernel
written for a write-out contract, handed a functional one, has argument counts
that line up by accident and writes its result into the caller's input.
Verified: four positional arguments into a five-parameter function with one
default raises nothing and corrupts the input.

So dispatch now checks it. Before a candidate is accepted, its run is bound
against the contract's shape -- how many positional arguments, which
keyword-only names -- and a kernel that cannot take the call is refused with
reason "contract-mismatch" rather than handed the call. A *args/**kwargs
forwarder binds anything and passes, which is right: it does accept the call.
Checked once per (run, op) and remembered, so the hot path is one dict lookup;
measured at 0.14us, and the gate's ratio is unchanged at 0.56 of a
Signature.bind.

This catches shape, not meaning. A contract whose parameters are unchanged but
whose semantics moved is what the version number is for, and nothing automatic
can see it. The two are complements, which is why both are here.

With the check in place the version can stop being ceremony:

- `route(op=...)` defaults to version 1. An op whose contract has never moved
  says nothing about versions, and the number appears where it carries
  information -- on the one op here that has moved.
- A provider may list op names instead of mapping them to versions:
  `op_versions = {"rmsnorm"}` means whichever version is current. Most providers
  have nothing to say about versions and should not have to say it; one
  spanning a contract change still declares explicitly. Naming an op claims that
  op only, not the ones it did not name.

Letting a provider mean "current" is safe because of the check: a provider that
declared "current" and was built against an older shape is refused rather than
run. Without the check it would have been a blank cheque.

Co-Authored-By: Claude Code <[email protected]>

* Stop last_decision() answering with a record the kill switch invalidated

With AITER_PLUGINS=0 dispatch records nothing, which is what makes that path
cost 0.141us. The consequence was that last_decision() went on returning
whatever was recorded before the switch was turned off, with nothing about the
answer saying it was stale. It is a convincing wrong answer, which is worse
than no answer, and it misled the first demo written against it.

Reporting None there is the honest answer, and it is a stronger statement than
"this call decided nothing": with the feature off, nothing is being decided at
all. A record taken before the switch describes a world that no longer holds.

The check is on the read rather than on the dispatch path. Clearing the record
per call would have cost 0.056us on every one of them, and recording a Decision
anyway 0.973us, to make a handful of reads correct -- the kill switch exists to
cost nothing. Reading costs 0.011us and reads are rare, so the cost goes where
the question is asked. Measured: the kill-switch path is unchanged at 0.141us.

The record is hidden rather than destroyed, so turning the switch back off
restores it.

Co-Authored-By: Claude Code <[email protected]>

* Have the reference provider read each contract on its own terms

Its select() read args[0] for both contracts to find the hidden size. That
works today by coincidence: the functional contract takes the input first and
the write-out one takes the output, and both happen to carry the hidden size in
the same axis. It would break silently the first time a contract's parameter
order moved, and the failure would be a wrong coverage decision rather than an
error.

The provider source in this file is written out in full because it doubles as
the answer to "what does a provider ship". Something written to be copied
should demonstrate the careful version, so it now names which argument carries
the shape for each contract, and the comment says why reading one position for
both is the wrong habit.

Co-Authored-By: Claude Code <[email protected]>

* Route the two blockscale GEMM entries

The GEMM pilot routes gemm_a8w8_blockscale and
gemm_a8w8_blockscale_bpreshuffle as they already exist. AITER exposes the
shuffled-b weight layout as its own public function; that is a layout rather
than a backend, and whether the two should converge is #7150's question.
Routing them unchanged keeps this pilot out of a public API change.

The two are not independent: gemm_a8w8_blockscale with isBpreshuffled
delegates to the other one's E8M0 route, so both are recorded in the contract
baseline rather than only the entry a caller is likeliest to name.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Record in the baseline that no routed op accepts an older version

rmsnorm is at version 2 and accepts only version 2; the gate now reads that
from the file rather than from a default. A later edit adding version 1 back
has to change this line, which is the point: it moves no signature and no
fingerprint, so nothing else would show it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Pin what a captured graph does to a routing decision

"capture" appeared nowhere in this tree -- not in the module, not in a test --
while the RFC names graph capture as part of the contract. It is the quietest
failure mode in the design: replay runs no Python, so whatever dispatch
decided on the capturing call is what the graph does for its whole life, and
because replay records no Decision, nothing afterwards says which call decided
it. A first call that landed inside capture could freeze an op on the wrong
route with no observable trace.

Measured on an MI355X before writing the tests: select() is called once during
capture and zero times across three replays, and last_decision() after replay
still describes the capturing call.

Two tests hold it:

- a provider selected at capture stays selected; replays add no Decision at
  all, and the reading still describes the capturing call, which is precisely
  why an operator cannot tell replays apart from it;
- AITER_PLUGINS=0 does not reach an already-captured graph. The switch stops
  future dispatch; it cannot un-bake a kernel, because there is no dispatch
  left inside the graph to stop. Anyone reaching for it during an incident
  needs to know the graphs have to be rebuilt.

Both run on a real device (8x gfx942 here) rather than being skipped, and both
were mutation-checked: breaking each assertion's premise turns them red.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Stop charging every caller for a route nobody enabled

On the day this merges, every caller is in the state where no provider is
enabled -- and that state walked eligibility and built a frozen Decision for a
call that no provider could possibly serve. Measured here: 1.902us per routed
call against the kill switch's 0.137us. Five routed ops, rmsnorm twice per
layer, is roughly 0.23ms of CPU per decode step in eager mode. It is a pure
loss: nobody paying it gets anything back.

An empty enable list and the kill switch say the same thing -- no provider can
serve this call -- so dispatch now treats them as one branch and goes straight
to native. 1.902us -> 0.149us, which is what the kill switch costs.

Profiling first, because the expensive half was not the one I expected:

  _config()        0.036us
  _eligible()      0.109us   (cache hit)
  _run_native()    1.613us   of which Decision(...) alone is 0.863us

A frozen dataclass costs more to build than everything else on the path put
together. Skipping the branch skips both.

The cost is that these calls record no Decision, so last_decision() and
decision_counts() stay empty while nothing is enabled. Same trade the kill
switch already makes. explain() and status() still answer in full, on demand,
and three tests now say so rather than leaving it to the commit message.

Two things fell out of the change that were defects, not consequences:

- last_decision() would have returned the *stale* provider route after
  configure(enable=()) turned routing off. Its docstring already argued why
  that is worse than returning nothing -- for the kill switch. The read now
  applies the same rule to both states.
- the route-change log lost its most useful line. An op with no entry was
  treated as having no comparable past, so the first provider route after a
  framework enables one was recorded as a silent baseline. What it was doing
  before is not unknown -- it was running native -- so that transition is now
  an audit line, which is the one an operator most wants.

Tests: the three that used default-deny as a convenient "no provider" fixture
now use an enabled provider that declares another contract version, so the
recording path keeps its coverage instead of losing it to the shortcut. The
overhead file gains a second machine-independent gate: nothing-enabled must
cost within 3x of the kill switch, which the 1.9us path would fail.

pytest -q tests/ -- 318 passed, 1 skipped, 463 subtests, on 8x gfx942.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants