Skip to content

[Build] [RFC #7240] Kernel provider interface: configuration, priority, provenance, observability - #7465

Merged
zufayu merged 19 commits into
ROCm:mainfrom
zufayu:codex/aklr-defect-fixes
Nov 9, 2026
Merged

zufayu merged 19 commits into
ROCm:mainfrom
zufayu:codex/aklr-defect-fixes

Conversation

@zufayu

@zufayu zufayu commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Implements the dispatch half of RFC #7240 — configuration, priority, provenance,
version handshakes and observability — on top of the #7086 prototype, and fixes
what reviewing it afterwards turned up.

Two companion PRs carry the parts that need different reviewers: #7466 runs
these tests as a CPU-only gate, and #7484 routes the first ops and changes
aiter/jit/core.py. This one touches aiter/plugin/ and its tests only.

It also carries a fix to the contract gate that routing work turned up: the
gate's decorator detection required both op= and version=, so a route
written as @route(op="rmsnorm") was invisible to it. Since version defaults
to 1 and is written only once it has moved, the recommended spelling was the
one left unprotected. The gate belongs to this PR's reviewer, so the fix sits
here rather than with the routes that exposed it.

The commits are the decomposition; each is self-contained with its reasoning.

What the RFC asked for, and what is here

open question answer
Q2 activation model default-deny with explicit enablement; configure(*, source, enable) is the only way to enable a provider, and AITER_PLUGINS=0 the only environment control
Q3 priority the enable list order is the preference order, first-accept-wins; no provider-declared priority, which would be quality arbitration by the back door
Q4 provenance provider / kernel_id / artifact_digest / qualification, plus config_source naming the layer that produced the route
Q5 deprecation windows SUPERSEDED_API_VERSIONS and route(supersedes=...); the runtime warning always names the removal release
Q6 hot-path cost measured, and gated in CI
Observability delivery (the RFC's named gap) one record, four reads: last_decision(), status(), explain(), decision_counts() / on_decision(), plus a route-change log

Q1 is a naming question for the RFC discussion, not a code change.

One owner for enablement, one switch in the environment

The RFC specifies four environment controls (AITER_PLUGINS,
AITER_PLUGIN_DISABLE, AITER_PLUGIN_FORCE, AITER_PLUGIN_ENABLE) plus
configure(). Implementing them together showed the set does not hold up:

  • FORCE was redundant. Eligibility filtered providers by one name with
    _supports(); ENABLE walked a list of names with _supports(). With a
    single-name list the two computed the same thing, differing only in the
    reason string when nothing matched.
  • ENABLE duplicated configure() and lost what makes it worth having.
    Enablement is a policy decision and a decision should name its owner. An
    environment variable cannot say who set it, so a route enabled that way
    reported config_source="env" and nothing more.
  • DISABLE named ops while ENABLE and FORCE named providers. Nothing
    in the shared prefix said which, so the obvious gesture for shutting a
    provider off — AITER_PLUGIN_DISABLE=<provider> — was accepted and did
    nothing. A control that looks like it worked is worse than no control. This
    was found by making the mistake while writing an unrelated test.

So enablement has one owner, configure(*, source, enable), and the
environment keeps AITER_PLUGINS=0 alone: it can only take routing away,
never grant it. Installing a provider makes it available; a wheel arriving as
somebody's transitive dependency must not be able to change which kernels run,
while an operator must be able to stop routing without editing framework code.

ATOM is the precedent for that split: 291 environment variables, none of which
activate its plugin — activation is _set_framework_backbone(), called by the
integration — and the only plugin-related ones, ATOM_DISABLE_VLLM_PLUGIN*,
subtract.

This diverges from the RFC's §Configuration and needs an RFC revision,
which is raised in #7240 rather than assumed here. Per-op opt-out goes with
DISABLE; if wanted again it belongs in the enable list as a provider:op
entry rather than as a second namespace.

Hot-path cost

Signature.bind was the dominant cost and was assumed irreducible. It is not:
the signature is known when route() decorates the op, so the binder is
generated once instead of re-derived per call.

Measured on a Xeon Platinum 8480C, Python 3.12.12, overhead over a direct native
call:

prototype here
gates 2.49us 0.048us
canonicalization 4.57us 0.076us
provider serves, total ~7.9us 2.42us
AITER_PLUGINS=0 — 0.141us

The 1us design budget is not met, and that is stated rather than hidden:
Decision construction plus the ContextVar set is 0.787us of what remains and
is now the largest single item. The CI 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 — rather
than an absolute threshold that would go red on a slow runner and teach people
to ignore it.

Three estimates were corrected by measurement along the way, each low by 2–4x.
Per-step projections underestimate; the end-to-end number is the one that counts.

Behaviour changes from #7086, stated because they are observable

  • The enable list order now decides. Enabled providers were kept in a
    frozenset, so candidates were tried in alphabetical provider-name order
    rather than the configured one — Q3's answer was specified but not
    implemented. The test that should have caught it asserted alpha wins from
    "alpha, zebra", which alphabetical order already produced.
  • The kill switch records nothing. last_decision() returns None there
    rather than reason="plugins-disabled". Deliberate — the feature is off — but
    breaking for anything that read that string.
  • A misbehaving provider no longer denies service to a well-behaved one. A
    select() error or an invalid candidate removes that provider from the call,
    not the op from routing.
  • Environment changes are snapshotted. reload_config() re-reads
    deliberately; mid-process edits are not observed.

Defects found reviewing the result

The last commit fixes four, found by reading the accumulated implementation
cold:

  • a deadlock: entry_point.load() ran while holding a non-reentrant lock,
    so a provider that touched aiter while importing hung the thread with no
    traceback and no log;
  • a malformed wheel belonging to somebody else raised into kernel calls and,
    because discovery was left unfinished, raised again on every later call;
  • a superseded op version matched the oldest acceptable one, and the answer
    depended on the order supersedes= happened to be written in;
  • explain() diverged from dispatch while documenting itself as its dry run.

Each has a regression test; the deadlock's fails on a timeout rather than
hanging the suite.

The contract check has already caught a real one

The candidate check is cheap and easy to dismiss as belt-and-braces. It is not.
In the AKLR pilot on MI355X, gemm_a8w8_blockscale called with
isBpreshuffled=True was offered the provider's run function for the other
entry point: the shuffled layout is a flag inside this contract and also a
separate public function of its own, and the provider had bound its kernel to
the layout rather than to the contract. Seven arguments were about to be handed
to a six-argument kernel.

The check refused the candidate before anything ran:

[aiter.plugin] Provider aklr offered [email protected] for
gemm_a8w8_blockscale, which does not take this contract

reason="contract-mismatch", the provider named, the call routed native,
nothing corrupted. Reproduced here as a unit shape — a seven-parameter contract
offered a six-parameter run — and the native result comes back rather than the
wrong kernel's.

The defect was the provider's and was fixed there. What matters for this PR is
that "argument counts line up by accident often enough that the failure is
otherwise silent" is not a hypothetical: it happened on the first provider to
try this interface, and this check is what stood between it and a kernel reading
arguments that meant something else. Note also what the routing log says in this
case — ('native', None, None) -> ('native', 'aklr', None) — which is the line
that tells an operator their enabled provider was asked and did not serve.

import aiter failed on Python 3.11

Found by this PR's self-review, on a revision where every gate was green.

_RoutedOp.superseded defaulted to MappingProxyType({}) as a plain dataclass
default, which makes class creation raise ValueError: mutable default <class 'mappingproxy'> for field superseded — so import aiter failed outright on
every 3.11 install, and setup.py declares python_requires=">=3.10".

Why nothing caught it:

what dataclasses rejects mappingproxy
3.10 list, dict, set, by type not one of them accepted
3.11 any default whose type declares no __hash__ declares none refused
3.12 same rule as 3.11 gained __hash__ in CPython 3.12 accepted

CI runs 3.10 and 3.12 — exactly the two versions that accept what 3.11 refuses.
No amount of green here says anything about the version in between.

field(default_factory=...) fixes it: the check reads f.default, and with a
factory there is no default to read.

The test that now holds it is worth a look, because the obvious spelling is
useless. Mirroring 3.11 — assert the type declares __hash__ — passes on 3.12
for this exact value, so it would run in CI and catch nothing. It asks instead
whether the default can be hashed, which reads the same on every version: a
mappingproxy declares __hash__ on 3.12 and still raises when hashed.
Mutation-checked by restoring the plain default, which turns it red naming
_RoutedOp.superseded.

Testing

pytest -q tests/ — 298 passed, 1 skipped, 463 subtests (90 of them the
plugin tests). Six tests went with the three controls they described, and four
arrived with them: two pinning that the environment cannot enable a provider
and can still stop one, and two telling an enabled-but-unsupported provider
apart from none installed.
The dispatch figure above is the mean of six runs spanning 2.36-2.51us; a
single run is not worth quoting at this resolution. black --check and ruff check clean on the
files this touches.

🤖 Generated with Claude Code

PR Self-Review

Reviewed revision

8e22818fd

Behavior and intent

Providers could not be routed to at all: aiter/plugin/ was a prototype with
no configuration model, no provenance, no version handshakes and no way to ask
why a call went native. This PR implements those, and then fixes what reviewing
the result turned up.

Two observable behaviors change relative to the #7086 prototype, both
deliberate and both breaking for anyone who depended on them:

  • under AITER_PLUGINS=0, last_decision() returns None rather than a
    Decision with reason="plugins-disabled". Dispatch records nothing when the
    feature is off, which is what makes that path cost 0.14µs;
  • a provider whose select() raises no longer sends the call straight to
    native; the next enabled provider is asked. One misbehaving provider must not
    deny service to a well-behaved one.

Enablement is also consolidated: configure(*, source, enable) is the only way
to turn a provider on, and AITER_PLUGINS=0 the only environment control.
This diverges from the RFC's current §Configuration, which specifies four
environment variables; the divergence and its reasons are raised in #7240
rather than assumed here.

Nothing routes by default. Every change above is inert until a framework calls
configure().

Validation and unverified scope

python -m pytest -q tests/ on a checkout with no compiled module — 298
passed, 1 skipped, 463 subtests. black --check and ruff check clean on
aiter/plugin/ and tests/test_plugin*.py. Dispatch overhead measured with
tests/test_plugin_overhead.py on a Xeon Platinum 8480C, Python 3.12.12:
2.42µs serving, mean of six runs spanning 2.36–2.51µs.

Each commit in the series was re-run against the plugin tests during rebase, so
the series is bisectable rather than only green at the tip.

Unverified: no GPU path is exercised by this PR — it is CPU-only by
construction, and the ops it routes arrive in #7484. The 1µs hot-path budget in
#7240 is not met and that is stated rather than hidden; Decision
construction plus the ContextVar set is the largest remaining single item.
Concurrent dispatch is not covered, and the earlier wording here claimed it
was. The only threaded test is the discovery deadlock
(tests/test_plugin_discovery.py:170); nothing exercises concurrent
configure() or concurrent dispatch, under threads or processes.

What that leaves unverified is bounded, and it is telemetry rather than
routing. Routing itself reads one immutable config snapshot per call, so a
concurrent configure() can only mean a call runs against the previous
generation — stated in _Config, and the point of the snapshot. The unguarded
writes are the observability bookkeeping: _decision_counts[...] += 1 is a
read-modify-write that the GIL does not make atomic, so counts can be low under
contention, and _log_route_change reads, compares and writes _route_log
without holding anything, so a route change can be logged twice or skipped at a
generation boundary. Neither can select the wrong kernel.

PR-specific question

Which exact workload keys consume these configuration changes, and what
evidence shows that unrelated shapes keep their previous selection?

No workload key consumes them, and no shape changes selection. The
configuration here is provider enablement, not kernel tuning: it has no shape,
dtype or layout dimension, and it does not participate in AITER's tuned-config
lookup. With no provider enabled — the state of every existing deployment,
since enablement requires an explicit configure() call that no framework
makes today — dispatch returns the native callable, which is the same callable
and the same tuned selection as before this PR. The routed ops themselves are
added in #7484, not here, so on this branch there is no op whose selection
could move.

Changed op tests

None. No file under op_tests/ is changed. The tests added here are under
tests/, which is where this repository runs pytest-style tests; op_tests/
files outside the aiter_test.sh allowlist are executed as plain scripts and a
pytest-style file placed there would silently collect zero cases.

@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 7465 --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

aiter-bot commented Nov 4, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 8e22818fdd56 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Providers could not be routed to at all: `aiter/plugin/` was a prototype with
no configuration model, no provenance, no version handshakes and no way to ask
why a call went native. This PR implements those, and then fixes what reviewing
the result turned up.

Two observable behaviors change relative to the #7086 prototype, both
deliberate and both breaking for anyone who depended on them:

- under `AITER_PLUGINS=0`, `last_decision()` returns `None` rather than a
  Decision with `reason="plugins-disabled"`. Dispatch records nothing when the
  feature is off, which is what makes that path cost 0.14µs;
- a provider whose `select()` raises no longer sends the call straight to
  native; the next enabled provider is asked. One misbehaving provider must not
  deny service to a well-behaved one.

Enablement is also consolidated: `configure(*, source, enable)` is the only way
to turn a provider on, and `AITER_PLUGINS=0` the only environment control.
This diverges from the RFC's current §Configuration, which specifies four
environment variables; the divergence and its reasons are raised in #7240
rather than assumed here.

Nothing routes by default. Every change above is inert until a framework calls
`configure()`.

Validation and unverified scope

`python -m pytest -q tests/` on a checkout with no compiled module — 298
passed, 1 skipped, 463 subtests. `black --check` and `ruff check` clean on
`aiter/plugin/` and `tests/test_plugin*.py`. Dispatch overhead measured with
`tests/test_plugin_overhead.py` on a Xeon Platinum 8480C, Python 3.12.12:
2.42µs serving, mean of six runs spanning 2.36–2.51µs.

Each commit in the series was re-run against the plugin tests during rebase, so
the series is bisectable rather than only green at the tip.

Unverified: no GPU path is exercised by this PR — it is CPU-only by
construction, and the ops it routes arrive in #7484. The 1µs hot-path budget in
#7240 is **not** met and that is stated rather than hidden; `Decision`
construction plus the `ContextVar` set is the largest remaining single item.
Concurrent dispatch is **not** covered, and the earlier wording here claimed it
was. The only threaded test is the discovery deadlock
(`tests/test_plugin_discovery.py:170`); nothing exercises concurrent
`configure()` or concurrent dispatch, under threads or processes.

What that leaves unverified is bounded, and it is telemetry rather than
routing. Routing itself reads one immutable config snapshot per call, so a
concurrent `configure()` can only mean a call runs against the previous
generation — stated in `_Config`, and the point of the snapshot. The unguarded
writes are the observability bookkeeping: `_decision_counts[...] += 1` is a
read-modify-write that the GIL does not make atomic, so counts can be low under
contention, and `_log_route_change` reads, compares and writes `_route_log`
without holding anything, so a route change can be logged twice or skipped at a
generation boundary. Neither can select the wrong kernel.

PR-specific question

*Which exact workload keys consume these configuration changes, and what
evidence shows that unrelated shapes keep their previous selection?*

No workload key consumes them, and no shape changes selection. The
configuration here is provider enablement, not kernel tuning: it has no shape,
dtype or layout dimension, and it does not participate in AITER's tuned-config
lookup. With no provider enabled — the state of every existing deployment,
since enablement requires an explicit `configure()` call that no framework
makes today — dispatch returns the native callable, which is the same callable
and the same tuned selection as before this PR. The routed ops themselves are
added in #7484, not here, so on this branch there is no op whose selection
could move.

Changed op tests

None. No file under `op_tests/` is changed. The tests added here are under
`tests/`, which is where this repository runs pytest-style tests; `op_tests/`
files outside the `aiter_test.sh` allowlist are executed as plain scripts and a
pytest-style file placed there would silently collect zero cases.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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 and others added 13 commits November 7, 2026 11:26
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]>
**A provider that touches aiter while importing deadlocked the process.**
_provider_lock was a plain Lock and entry_point.load() -- third-party import
code -- ran while holding it, so a provider that called back into dispatch
re-entered and hung the thread. No traceback, no log, stuck inside a kernel
call. Discovery now runs outside the lock, which is taken only to publish the
result, and the lock is reentrant as well. A race only means the same set is
discovered twice; the first to publish wins. A regression test loads a provider
that calls plugin.status() at module scope and fails on a timeout rather than
hanging the suite: it is skipped with a circular-import reason, which is the
right answer where a deadlock is neither visible nor recoverable.

**A malformed wheel belonging to somebody else raised into kernel calls.**
Every entry point's load() was isolated, but the enumeration around them was
not, and metadata.entry_points() reads every installed distribution. One broken
entry_points.txt propagated out of dispatch -- and left _provider_records as
None, so the next call raised again, forever. It is now isolated like the rest,
publishes an empty set, and reports itself in status().

**A superseded op version matched the oldest acceptable one**, because the
supersedes= mapping was walked in literal order. A contract superseding both 1
and 2 told a provider already on 2 that it was on 1, naming a removal release a
cycle too early and asking for a re-validation it had already done. It now takes
the newest acceptable version, the rule discovery already used for API versions.

**explain() diverged from dispatch**, while documenting itself as the Decision
the call would produce: it never named the provider it blamed, and it returned
a "plugins-disabled" reason that dispatch cannot produce. It now names the
provider, and reports no Decision at all under the kill switch -- which is what
dispatch does there. Explanation.decision is therefore Optional.

Also from the same review:

- The contract gate accepted any version difference, so one bump without
  rewriting the baseline licensed every later signature change for that op.
  It now requires the version to move forward *and* the baseline to be
  rewritten with it. Type annotations and the return annotation join the
  fingerprint: a provider implements against those too. Route decorators are
  resolved from the file's imports instead of matched by name suffix, so an
  alias is found and a same-named unrelated decorator is not.
- qualification is optional. The interface says AITER *may* record a
  provider-supplied evidence reference, not that a provider must have one;
  requiring it only produced placeholder strings.
- Provider attribute reads are isolated. The name is read once at discovery and
  cached on the record, so logging inside an except block cannot throw again
  and escape the boundary, and status() reports an unreachable provider instead
  of being the one call that fails when routing has already degraded.
- A dry run no longer spends the one-shot deprecation warning, and -- found by
  the test for it -- no longer caches the quiet result, which would have
  swallowed the warning for every later call.
- AITER_PLUGIN_FORCE is stripped like every other control; ENTRY_POINT_GROUP is
  exported, since a provider author has to know it; two unread fields and a
  redundant sort are gone.

Co-Authored-By: Claude Code <[email protected]>
The gate's decorator detection required both op= and version= keywords, so a
route written as @route(op="rmsnorm") was invisible to it. Since version
defaults to 1 and is written only once it has moved, that left the recommended
spelling -- the common one -- entirely unprotected: its signature could change
without the gate noticing.

Detection now keys on op= alone and reads version as 1 when the keyword is
absent, which is what the decorator itself does. The regression test writes a
route without a version and asserts the scan still finds it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Four environment variables had accreted around enablement: AITER_PLUGINS,
AITER_PLUGIN_ENABLE, AITER_PLUGIN_FORCE and AITER_PLUGIN_DISABLE. Each was
defensible alone and the set was never re-examined. Reviewing them together:

- FORCE was redundant. _build_eligible filtered providers by one name with
  _supports(); ENABLE walked a list of names with _supports(). With a
  single-name list the two paths computed the same thing, differing only in
  the reason string reported when nothing matched.
- ENABLE duplicated configure() while losing what makes configure() worth
  having. Enablement is a policy decision, and a decision should name its
  owner; an environment variable cannot say who set it, so a route enabled
  that way reported config_source="env" and nothing more.
- DISABLE named ops while ENABLE and FORCE named providers. Nothing in the
  shared prefix said which, so the obvious gesture for shutting a provider
  off -- AITER_PLUGIN_DISABLE=<provider> -- was accepted and did nothing. A
  control that looks like it worked is worse than no control.

Enablement now has one owner, configure(*, source, enable), so every route
names the framework that asked for it. The environment keeps AITER_PLUGINS=0
alone: it can only take routing away, never grant it. That asymmetry is the
point. Installing a provider makes it available; a wheel arriving as
somebody's transitive dependency must not be able to change which kernels run,
while an operator must be able to stop routing without editing framework code.

ATOM is the precedent: 291 environment variables, none of which activate its
plugin -- activation is _set_framework_backbone(), called by the integration --
and the only plugin-related ones, ATOM_DISABLE_VLLM_PLUGIN*, subtract.

Per-op opt-out goes with DISABLE. If it is wanted again it belongs in the
enable list as a provider:op entry rather than as a second namespace.

Hot path: 2.42us serving (six runs, 2.36-2.51) against 2.50us (2.44-2.54)
before. The ranges overlap, so this is no worse rather than a measured win.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu force-pushed the codex/aklr-defect-fixes branch from b5b618f to 1d82ea1 Compare November 7, 2026 11:32
zufayu and others added 3 commits November 8, 2026 00:33
A provider that is installed, enabled, and simply declares the wrong op
version was indistinguishable from nothing being installed at all. Both
answered reason="no-provider", and explain() -- the read whose entire job is
saying why a call went native -- returned no declines, because the
eligibility filter dropped the excluded providers without keeping why.

That is the commonest misconfiguration there is: a provider wheel built
against another contract version. The information was in hand and thrown
away, so finding it meant reading op_versions against the contract by eye.

The eligibility build now keeps the exclusions and the reason a native route
should record, in one cached _Eligibility per (op, generation):

- "provider-op-unsupported" when enabled providers are installed but none
  serves this op version, with per-provider detail naming the versions it does
  serve;
- "no-provider" when an enabled name has no installed provider, with
  "enabled but not installed" against that name;
- "provider-not-enabled" unchanged.

status() reports the same detail per routed op, next to the eligible list.

The hot path does not pay for it: eligibility is already cached per (op,
config generation), so the reasons are computed once per generation, and the
native branch now reads one precomputed string instead of re-deriving the
reason from three conditions. Dispatch overhead is unchanged (2.55-2.67us
over four runs, against 2.58-2.68 before).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Removing three environment variables rested on one claim: the environment can
take routing away but never grant it. Nothing tested that claim. Every test
touching enablement was a conversion of an existing one, so reading
AITER_PLUGIN_ENABLE back into _build_config would have left the suite green.

Two tests, one per half:

- setting AITER_PLUGIN_ENABLE, _FORCE and _DISABLE against an installed
  provider leaves the call native with config_source="default-deny", and the
  provider is never asked;
- what configure() turned on, AITER_PLUGINS=0 plus reload_config() turns off,
  asserted by the call going native rather than only by what was recorded.

The second half had no coverage at all: the kill-switch test that existed
never enabled anybody, so it proved "off when never on".

Found by review rather than by writing them alongside the removal, which is
where they belonged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The group was aiter.kernel_providers, the only place a user-facing name said
"provider" rather than "plugin" -- and it is the one line a plugin author
writes, in their pyproject.toml.

Two words were doing one job. They are better as two layers: a kernel plugin
is the unit that ships and registers, KernelProvider is the interface it
implements. That is the pytest relationship, where a plugin implements hooks
the host calls, rather than the vLLM one, where a plugin is loaded and called
for its side effects on the host. Ours is asked and may decline; it patches
nothing. The type names stay as they are, because they name the interface.

The group is aiter.plugins, unqualified. AITER is a kernel library, so a
plugin to it is a kernel plugin; qualifying the group by a kind with no second
member would spend a longer name every time on a distinction that does not
exist. vLLM qualifies its four groups because platforms, model registries, io
processors and stat loggers are genuinely different subsystems. If a second
kind ever appears here it gets its own group, which is additive; renaming this
one would not be.

Many plugins in one group is the expected shape, and already works: several
may be installed and several enabled at once, asked in the order the framework
listed.

Now is the only free moment to settle this. The group name appears in exactly
one place in this tree, and in one line of any plugin's packaging metadata; no
such line has shipped yet.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu force-pushed the codex/aklr-defect-fixes branch from c0ea5b6 to 83e0a85 Compare November 8, 2026 00:36
rmsnorm's contract went to version 2 and deliberately did not list version 1
in supersedes=, because a kernel written for the v1 write-out contract, handed
a v2 call, treats the caller's input tensor as its output buffer. Nothing
catches that: the argument counts line up, both arguments are tensors, and the
signature check only asks whether the call binds, which it does.

That reasoning lived in a commit message. It was the one judgment in this
design supported by argument rather than by a test.

Three tests now hold it:

- a provider declaring only the superseded version is never asked for a
  version-2 call, and the caller's input comes back untouched;
- the counterfactual, where the only change is adding v1 back to supersedes=:
  the same provider is asked, serves, and writes the caller's input. The test
  asserts the corruption rather than describing it, so what the omission buys
  is visible;
- the contract gate now records which versions a contract still accepts and
  fails when that set changes without the baseline being rewritten. Adding a
  version back moves no signature and no fingerprint, so nothing in the gate
  would otherwise have noticed.

The first two model the shape faithfully: both contracts take a mutable
sequence first, which is what makes confusing them silent rather than a
TypeError. An earlier draft used mismatched types and "passed" by raising,
which would have tested nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
explain() exists to say what dispatch would do, and the two were saying it
separately: a Decision built field by field in both places, and one precedence
rule expressed twice -- in dispatch as a first-error tuple, in explain as a
scan back out of the declines dictionary. A comment stood where the shared
function belonged: "Same precedence as dispatch, and the same provider named
with it." Changing one side and forgetting the other makes explain lie, which
is the only thing it is for.

Both now call _selected() for the candidate's Decision and _native_outcome()
for why a native route happened. explain keeps dispatch's bookkeeping rather
than deriving it, so the rule is one object rather than two agreeing ones.
Dispatch allocates nothing new: the declines dictionary stays in explain.
Overhead is unchanged at 2.44us (2.41-2.50 over four runs).

Mutation-checking the result found the rule nobody had tested: keeping the
last error rather than the first left the whole suite green. A test now pins
it on both paths -- a broken provider does not deny the next one its turn, the
first failure is the one reported, and explain names the provider dispatch
named. Breaking either call site turns it red.

Two leftovers from removing the environment controls, both dead:

- test_enable_list_order_is_honoured_through_configure duplicated
  test_enable_list_order_is_the_preference_order once there was no environment
  ordering left to contrast with, and asserted strictly less;
- a reload_config() that reloaded nothing, under a comment explaining that a
  mid-process environment change needs it. configure() swaps the snapshot
  itself, and no environment variable can enable anything now.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu marked this pull request as ready for review November 9, 2026 05:46
@zufayu
zufayu requested a review from a team November 9, 2026 05:46
@github-actions github-actions Bot changed the title [RFC #7240] Kernel provider interface: configuration, priority, provenance, observability [Build] [RFC #7240] Kernel provider interface: configuration, priority, provenance, observability Nov 9, 2026
@github-actions github-actions Bot added the Build label Nov 9, 2026
@zufayu

zufayu commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@aiter-bot review

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROCm/aiter PR #7465 — [Build] [RFC #7240] Kernel provider interface: configuration, priority, provenance, observability

Review (advisory): 🔴 HIGH RISK
Validation (deterministic): NOT RUN — triage: the PR changes runtime code but ships no test target (CPU-only plugin layer; validate-kernel-pr has no target for it); the changed path is not executed at run time on this branch — nothing imports aiter.plugin until #7484 routes an op — so the missing target is not itself a defect
Perf (advisory): MEASURED — tests/test_plugin_overhead.py's rmsnorm signature on this box (Python 3.11.2, CPU torch, the one incompatible dataclass default patched off the dispatch path): serving overhead 2.66µs vs one Signature.bind 7.10µs, no-provider 1.93µs, kill switch 0.15µs — min of 5 repeats × 20,000 calls; head-only (the module is new, no base exists), so this reproduces the PR's own comparison and cannot show a regression; the PR's claimed 2.42µs on a Xeon/3.12.12 is corroborated within ~10%
Size: 3008 lines / 7 files — over the review bar
Design (advisory): SPLIT — the natural seams: dispatch core (route/_dispatch/_eligible/_build_canonicalizer) with tests/test_plugin.py; configuration and provenance (configure/_Config/Decision) plus the observability readers; discovery and version handshakes with tests/test_plugin_discovery.py; the contract gate (tests/test_plugin_contracts.py + plugin_contracts.json); the overhead harness (tests/test_plugin_overhead.py) — the commit series already cuts along these lines, and ghstack makes the stack cheap
Human: recommend Felix Li review whether PR #7465's enablement model — configure(*, source, enable) as the only way to enable a provider, with AITER_PLUGINS=0 as the only environment control and RFC #7240's AITER_PLUGIN_ENABLE/FORCE/DISABLE dropped — is the right contract for the frameworks that will call configure()

📝 [verified] tests/test_plugin_overhead.py asserts an absolute CEILING_US = 4.0 while its own docstring concedes CI runner hardware is uncharacterized (the reason the 1µs BUDGET_US is report-only) — this box measures 2.66µs serving overhead (66% of the ceiling), so a runner ~1.5× slower turns the gate red with no regression present. Author must characterize the CI runner before #7466 wires this in, or gate the ceiling the way the budget is gated.

3 finding(s) posted inline, on the lines they are about:

  • aiter/plugin/__init__.py:196 — gives _RoutedOp a dataclass field default of MappingProxyType({})
  • tests/test_plugin_discovery.py:170 — The PR body claims "multi-process and multi-threaded dispatch under concurrent configure() calls is covered…
  • tests/test_plugin_contracts.py:77-84 — fingerprints a default it cannot literal_eval by its source name (ast.unparse), so a routed op defaulting to…

Comment thread aiter/plugin/__init__.py Resolved
Comment thread tests/test_plugin_discovery.py Resolved
Comment thread tests/test_plugin_contracts.py Resolved
demonsan added a commit that referenced this pull request Nov 9, 2026
…ests

P0/P1 of the provider-architecture refactor: extract the semantic contract of the
gemm_fusion/sp_qkv framework into a flat, backend-free public op and hand the native
implementation to the runtime module, without importing the provider interface on main.

- aiter/ops/gemm_fusion/sp_qkv/CONTRACT.md: op name/version, exact signature,
  dtypes/shapes/layouts, outputs/mutation, tolerance/determinism, workspace/lifetime
  (prepare outside capture), error behaviour, coverage matrix and non-goals. States
  explicitly that native is coverage-limited today (skill §5 option B) and that
  option A (unfused fallback owned by native) is the named follow-up.
- aiter/ops/gemm_fusion/sp_qkv/op.py: sp_qkv_fused v1 with the flat signature
  (15 positional-or-keyword tensors + keyword-only mode/outputs/eps/group/stream);
  mode and mode-specific tensor validation; an explicit payload dict whose keys are
  the contract names in signature order; lazy native delegation to
  runtime.sp_qkv_native(payload). The aiter.plugin route is guarded (try/except
  ImportError -> identity shim) because the #7465/#7466/#7484 interface is not on
  main; __aiter_plugin_op__ is set when the real plugin is present.
- aiter/__init__.py: lazy sp_qkv_fused export via __getattr__ (no eager framework/
  torch-heavy import at aiter import time).
- op_tests/test_gemm_fusion_sp_qkv_op.py: CPU-only tests for the real signature,
  guarded-route registration/inertness, native payload delegation, defaults,
  mode validation and the fake-provider serve/decline dispatch path.

Gate: op tests 14 passed; op_tests/test_gemm_fusion_profile_rules.py 52 passed;
Black/Ruff clean; python -c 'import aiter; print(aiter.sp_qkv_fused.__name__)' works
CPU-only. runtime.py is owned by the runtime implementor and is not part of this
commit.
`_RoutedOp.superseded` defaulted to `MappingProxyType({})` written as a plain
dataclass default. That makes `import aiter` raise

    ValueError: mutable default <class 'mappingproxy'> for field superseded

on every Python 3.11 install, at class creation, before anything of this
interface runs. setup.py declares python_requires=">=3.10", so pip installs
there.

Every gate was green, and the reason is worth stating because it generalises:

- 3.10 rejects only list, dict and set, by type. A mappingproxy passes.
- 3.11 rejects any default whose type declares no __hash__. A mappingproxy
  declares none, so the class is refused.
- 3.12 applies 3.11's rule, but CPython gave mappingproxy a __hash__, so it
  passes again.

CI runs 3.10 and 3.12 — exactly the two versions that accept what 3.11
refuses. No amount of green says anything about the version in between.

`field(default_factory=...)` fixes it: the check reads `f.default`, and with a
factory there is no default to read. Verified on 3.10 and 3.12 here; the
reporting review verified the failure and the fix on 3.11.2.

A test now holds it, and it asks the right question. The obvious spelling —
mirror 3.11 and check whether the type declares __hash__ — passes on 3.12 for
this exact value, so it would have run in CI and caught nothing. It asks
instead whether the default can be hashed, which reads the same on every
version: a mappingproxy declares __hash__ on 3.12 and still raises when hashed.
Mutation-checked by restoring the plain default, which turns it red naming
`_RoutedOp.superseded`.

Two other things the same review raised:

- `_literal()` in the contract gate renders a non-literal default by the source
  that spells it, because the gate reads the tree and never imports it. A
  routed op defaulting to a module constant therefore keeps its fingerprint
  when the constant's value moves — the silent change the gate exists to
  catch. No routed op has such a default today; the gap is now written down
  rather than left for a reader to assume away.
- the testing line said 294; the suite had reached 297 through rebases without
  anyone moving the number. It says 298 now, which is 297 plus the test above.

pytest -q tests/ — 298 passed, 1 skipped, 463 subtests.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu merged commit 5f2d2c7 into ROCm:main Nov 9, 2026
ruanjm pushed a commit that referenced this pull request Nov 10, 2026
…y, provenance, observability (#7465)

* Prototype kernel provider interface

* Gate provider dispatch on explicit enablement

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]>

* Snapshot plugin configuration and honour the enable list order

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]>

* Generate a per-op argument binder and measure dispatch end to end

inspect.Signature.bind is generic: it re-derives the parameter mapping on every
call. Measured against the two signatures #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 #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]>

* Isolate misbehaving providers, free the kill switch, record the config 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]>

* Add the op registry and the four observability reads

RFC #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]>

* Say that decision_counts() counts decisions, not launches

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]>

* Give the version handshakes a window that names its removal release

RFC #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]>

* Cover provider discovery through real packaging metadata

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]>

* Close three conformance gaps against RFC #7240

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 #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]>

* Fix four defects found reviewing the series with fresh eyes

**A provider that touches aiter while importing deadlocked the process.**
_provider_lock was a plain Lock and entry_point.load() -- third-party import
code -- ran while holding it, so a provider that called back into dispatch
re-entered and hung the thread. No traceback, no log, stuck inside a kernel
call. Discovery now runs outside the lock, which is taken only to publish the
result, and the lock is reentrant as well. A race only means the same set is
discovered twice; the first to publish wins. A regression test loads a provider
that calls plugin.status() at module scope and fails on a timeout rather than
hanging the suite: it is skipped with a circular-import reason, which is the
right answer where a deadlock is neither visible nor recoverable.

**A malformed wheel belonging to somebody else raised into kernel calls.**
Every entry point's load() was isolated, but the enumeration around them was
not, and metadata.entry_points() reads every installed distribution. One broken
entry_points.txt propagated out of dispatch -- and left _provider_records as
None, so the next call raised again, forever. It is now isolated like the rest,
publishes an empty set, and reports itself in status().

**A superseded op version matched the oldest acceptable one**, because the
supersedes= mapping was walked in literal order. A contract superseding both 1
and 2 told a provider already on 2 that it was on 1, naming a removal release a
cycle too early and asking for a re-validation it had already done. It now takes
the newest acceptable version, the rule discovery already used for API versions.

**explain() diverged from dispatch**, while documenting itself as the Decision
the call would produce: it never named the provider it blamed, and it returned
a "plugins-disabled" reason that dispatch cannot produce. It now names the
provider, and reports no Decision at all under the kill switch -- which is what
dispatch does there. Explanation.decision is therefore Optional.

Also from the same review:

- The contract gate accepted any version difference, so one bump without
  rewriting the baseline licensed every later signature change for that op.
  It now requires the version to move forward *and* the baseline to be
  rewritten with it. Type annotations and the return annotation join the
  fingerprint: a provider implements against those too. Route decorators are
  resolved from the file's imports instead of matched by name suffix, so an
  alias is found and a same-named unrelated decorator is not.
- qualification is optional. The interface says AITER *may* record a
  provider-supplied evidence reference, not that a provider must have one;
  requiring it only produced placeholder strings.
- Provider attribute reads are isolated. The name is read once at discovery and
  cached on the record, so logging inside an except block cannot throw again
  and escape the boundary, and status() reports an unreachable provider instead
  of being the one call that fails when routing has already degraded.
- A dry run no longer spends the one-shot deprecation warning, and -- found by
  the test for it -- no longer caches the quiet result, which would have
  swallowed the warning for every later call.
- AITER_PLUGIN_FORCE is stripped like every other control; ENTRY_POINT_GROUP is
  exported, since a provider author has to know it; two unread fields and a
  redundant sort are gone.

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

* See the routes that rely on the version default

The gate's decorator detection required both op= and version= keywords, so a
route written as @route(op="rmsnorm") was invisible to it. Since version
defaults to 1 and is written only once it has moved, that left the recommended
spelling -- the common one -- entirely unprotected: its signature could change
without the gate noticing.

Detection now keys on op= alone and reads version as 1 when the keyword is
absent, which is what the decorator itself does. The regression test writes a
route without a version and asserts the scan still finds it.

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

* Give enablement one owner, and the environment one switch

Four environment variables had accreted around enablement: AITER_PLUGINS,
AITER_PLUGIN_ENABLE, AITER_PLUGIN_FORCE and AITER_PLUGIN_DISABLE. Each was
defensible alone and the set was never re-examined. Reviewing them together:

- FORCE was redundant. _build_eligible filtered providers by one name with
  _supports(); ENABLE walked a list of names with _supports(). With a
  single-name list the two paths computed the same thing, differing only in
  the reason string reported when nothing matched.
- ENABLE duplicated configure() while losing what makes configure() worth
  having. Enablement is a policy decision, and a decision should name its
  owner; an environment variable cannot say who set it, so a route enabled
  that way reported config_source="env" and nothing more.
- DISABLE named ops while ENABLE and FORCE named providers. Nothing in the
  shared prefix said which, so the obvious gesture for shutting a provider
  off -- AITER_PLUGIN_DISABLE=<provider> -- was accepted and did nothing. A
  control that looks like it worked is worse than no control.

Enablement now has one owner, configure(*, source, enable), so every route
names the framework that asked for it. The environment keeps AITER_PLUGINS=0
alone: it can only take routing away, never grant it. That asymmetry is the
point. Installing a provider makes it available; a wheel arriving as
somebody's transitive dependency must not be able to change which kernels run,
while an operator must be able to stop routing without editing framework code.

ATOM is the precedent: 291 environment variables, none of which activate its
plugin -- activation is _set_framework_backbone(), called by the integration --
and the only plugin-related ones, ATOM_DISABLE_VLLM_PLUGIN*, subtract.

Per-op opt-out goes with DISABLE. If it is wanted again it belongs in the
enable list as a provider:op entry rather than as a second namespace.

Hot path: 2.42us serving (six runs, 2.36-2.51) against 2.50us (2.44-2.54)
before. The ranges overlap, so this is no worse rather than a measured win.

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

* Say why an enabled provider cannot serve, instead of discarding it

A provider that is installed, enabled, and simply declares the wrong op
version was indistinguishable from nothing being installed at all. Both
answered reason="no-provider", and explain() -- the read whose entire job is
saying why a call went native -- returned no declines, because the
eligibility filter dropped the excluded providers without keeping why.

That is the commonest misconfiguration there is: a provider wheel built
against another contract version. The information was in hand and thrown
away, so finding it meant reading op_versions against the contract by eye.

The eligibility build now keeps the exclusions and the reason a native route
should record, in one cached _Eligibility per (op, generation):

- "provider-op-unsupported" when enabled providers are installed but none
  serves this op version, with per-provider detail naming the versions it does
  serve;
- "no-provider" when an enabled name has no installed provider, with
  "enabled but not installed" against that name;
- "provider-not-enabled" unchanged.

status() reports the same detail per routed op, next to the eligible list.

The hot path does not pay for it: eligibility is already cached per (op,
config generation), so the reasons are computed once per generation, and the
native branch now reads one precomputed string instead of re-deriving the
reason from three conditions. Dispatch overhead is unchanged (2.55-2.67us
over four runs, against 2.58-2.68 before).

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

* Pin the asymmetry the environment controls rest on

Removing three environment variables rested on one claim: the environment can
take routing away but never grant it. Nothing tested that claim. Every test
touching enablement was a conversion of an existing one, so reading
AITER_PLUGIN_ENABLE back into _build_config would have left the suite green.

Two tests, one per half:

- setting AITER_PLUGIN_ENABLE, _FORCE and _DISABLE against an installed
  provider leaves the call native with config_source="default-deny", and the
  provider is never asked;
- what configure() turned on, AITER_PLUGINS=0 plus reload_config() turns off,
  asserted by the call going native rather than only by what was recorded.

The second half had no coverage at all: the kill-switch test that existed
never enabled anybody, so it proved "off when never on".

Found by review rather than by writing them alongside the removal, which is
where they belonged.

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

* Name the entry point group for what registers in it

The group was aiter.kernel_providers, the only place a user-facing name said
"provider" rather than "plugin" -- and it is the one line a plugin author
writes, in their pyproject.toml.

Two words were doing one job. They are better as two layers: a kernel plugin
is the unit that ships and registers, KernelProvider is the interface it
implements. That is the pytest relationship, where a plugin implements hooks
the host calls, rather than the vLLM one, where a plugin is loaded and called
for its side effects on the host. Ours is asked and may decline; it patches
nothing. The type names stay as they are, because they name the interface.

The group is aiter.plugins, unqualified. AITER is a kernel library, so a
plugin to it is a kernel plugin; qualifying the group by a kind with no second
member would spend a longer name every time on a distinction that does not
exist. vLLM qualifies its four groups because platforms, model registries, io
processors and stat loggers are genuinely different subsystems. If a second
kind ever appears here it gets its own group, which is additive; renaming this
one would not be.

Many plugins in one group is the expected shape, and already works: several
may be installed and several enabled at once, asked in the order the framework
listed.

Now is the only free moment to settle this. The group name appears in exactly
one place in this tree, and in one line of any plugin's packaging metadata; no
such line has shipped yet.

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

* Test the judgment the rmsnorm bump rests on, instead of arguing it

rmsnorm's contract went to version 2 and deliberately did not list version 1
in supersedes=, because a kernel written for the v1 write-out contract, handed
a v2 call, treats the caller's input tensor as its output buffer. Nothing
catches that: the argument counts line up, both arguments are tensors, and the
signature check only asks whether the call binds, which it does.

That reasoning lived in a commit message. It was the one judgment in this
design supported by argument rather than by a test.

Three tests now hold it:

- a provider declaring only the superseded version is never asked for a
  version-2 call, and the caller's input comes back untouched;
- the counterfactual, where the only change is adding v1 back to supersedes=:
  the same provider is asked, serves, and writes the caller's input. The test
  asserts the corruption rather than describing it, so what the omission buys
  is visible;
- the contract gate now records which versions a contract still accepts and
  fails when that set changes without the baseline being rewritten. Adding a
  version back moves no signature and no fingerprint, so nothing in the gate
  would otherwise have noticed.

The first two model the shape faithfully: both contracts take a mutable
sequence first, which is what makes confusing them silent rather than a
TypeError. An earlier draft used mismatched types and "passed" by raising,
which would have tested nothing.

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

* Write the selection rules once, and test the one nothing covered

explain() exists to say what dispatch would do, and the two were saying it
separately: a Decision built field by field in both places, and one precedence
rule expressed twice -- in dispatch as a first-error tuple, in explain as a
scan back out of the declines dictionary. A comment stood where the shared
function belonged: "Same precedence as dispatch, and the same provider named
with it." Changing one side and forgetting the other makes explain lie, which
is the only thing it is for.

Both now call _selected() for the candidate's Decision and _native_outcome()
for why a native route happened. explain keeps dispatch's bookkeeping rather
than deriving it, so the rule is one object rather than two agreeing ones.
Dispatch allocates nothing new: the declines dictionary stays in explain.
Overhead is unchanged at 2.44us (2.41-2.50 over four runs).

Mutation-checking the result found the rule nobody had tested: keeping the
last error rather than the first left the whole suite green. A test now pins
it on both paths -- a broken provider does not deny the next one its turn, the
first failure is the one reported, and explain names the provider dispatch
named. Breaking either call site turns it red.

Two leftovers from removing the environment controls, both dead:

- test_enable_list_order_is_honoured_through_configure duplicated
  test_enable_list_order_is_the_preference_order once there was no environment
  ordering left to contrast with, and asserted strictly less;
- a reload_config() that reloaded nothing, under a comment explaining that a
  mid-process environment change needs it. configure() swaps the snapshot
  itself, and no environment variable can enable anything now.

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

* Keep the module importable on the Python in between

`_RoutedOp.superseded` defaulted to `MappingProxyType({})` written as a plain
dataclass default. That makes `import aiter` raise

    ValueError: mutable default <class 'mappingproxy'> for field superseded

on every Python 3.11 install, at class creation, before anything of this
interface runs. setup.py declares python_requires=">=3.10", so pip installs
there.

Every gate was green, and the reason is worth stating because it generalises:

- 3.10 rejects only list, dict and set, by type. A mappingproxy passes.
- 3.11 rejects any default whose type declares no __hash__. A mappingproxy
  declares none, so the class is refused.
- 3.12 applies 3.11's rule, but CPython gave mappingproxy a __hash__, so it
  passes again.

CI runs 3.10 and 3.12 — exactly the two versions that accept what 3.11
refuses. No amount of green says anything about the version in between.

`field(default_factory=...)` fixes it: the check reads `f.default`, and with a
factory there is no default to read. Verified on 3.10 and 3.12 here; the
reporting review verified the failure and the fix on 3.11.2.

A test now holds it, and it asks the right question. The obvious spelling —
mirror 3.11 and check whether the type declares __hash__ — passes on 3.12 for
this exact value, so it would have run in CI and caught nothing. It asks
instead whether the default can be hashed, which reads the same on every
version: a mappingproxy declares __hash__ on 3.12 and still raises when hashed.
Mutation-checked by restoring the plain default, which turns it red naming
`_RoutedOp.superseded`.

Two other things the same review raised:

- `_literal()` in the contract gate renders a non-literal default by the source
  that spells it, because the gate reads the tree and never imports it. A
  routed op defaulting to a module constant therefore keeps its fingerprint
  when the constant's value moves — the silent change the gate exists to
  catch. No routed op has such a default today; the gap is now written down
  rather than left for a reader to assume away.
- the testing line said 294; the suite had reached 297 through rebases without
  anyone moving the number. It says 298 now, which is 297 plus the test above.

pytest -q tests/ — 298 passed, 1 skipped, 463 subtests.

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

---------

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Code <[email protected]>
zufayu added a commit that referenced this pull request Nov 12, 2026
…ch (#7848)

A routed op's first call in a process acquired a lock and read an
environment variable, because the config snapshot was built lazily. Dynamo
can trace neither, so that call graph-breaks: the region compiles as two
graphs instead of one, and a framework that permits a single backend
invocation per compilation is handed a second and asserts.

Measured with a counting backend, each case in its own process:

    plain function                      1 graph
    routed op, snapshot unbuilt         2 graphs   <- the break
    routed op, snapshot built           1 graph

Nothing else on the dispatch path breaks, so building the snapshot at
import is the whole fix. The hot path was already a plain global read for
every call after the first; this makes the first one no different.

The lazy branch in _config() stays, because _reset_for_testing clears the
snapshot and a test that clears it must not become the call that rebuilds
it inside somebody's graph.

tests/test_plugin_compile.py pins both halves -- one graph per compiled
region, and nothing left to build when dispatch starts -- in subprocesses,
since the breakage is first-call-only and torch._dynamo state is global.
Removing the fix fails both.

This is the coverage #7465 and #7728 lacked: every test of the interface
so far has been eager, and an eager test cannot see a graph boundary.

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…ch (#7848)

A routed op's first call in a process acquired a lock and read an
environment variable, because the config snapshot was built lazily. Dynamo
can trace neither, so that call graph-breaks: the region compiles as two
graphs instead of one, and a framework that permits a single backend
invocation per compilation is handed a second and asserts.

Measured with a counting backend, each case in its own process:

    plain function                      1 graph
    routed op, snapshot unbuilt         2 graphs   <- the break
    routed op, snapshot built           1 graph

Nothing else on the dispatch path breaks, so building the snapshot at
import is the whole fix. The hot path was already a plain global read for
every call after the first; this makes the first one no different.

The lazy branch in _config() stays, because _reset_for_testing clears the
snapshot and a test that clears it must not become the call that rebuilds
it inside somebody's graph.

tests/test_plugin_compile.py pins both halves -- one graph per compiled
region, and nothing left to build when dispatch starts -- in subprocesses,
since the breakage is first-call-only and torch._dynamo state is global.
Removing the fix fails both.

This is the coverage #7465 and #7728 lacked: every test of the interface
so far has been eager, and an eager test cannot see a graph boundary.

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants