Repository navigation
Conversation
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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Part 2 of the series implementing the dispatch design behind RFC #7240.
Together these close the RFC's first milestone, whose bar is that hot-path cost
is measured, not designed. This is the part that produces the measurement.
configure()Decision.config_sourceStacks on #7437 — earlier commits appear in this diff because those branches are
not in this repository. Review the last commit only. #7086 and #7123 are
untouched.
The generated binder
inspect.Signature.bindis generic: it re-derives the parameter mapping onevery call. Measured against the two signatures #7123 routes, that is 4.57us
for
rmsnormand 6.05us forpertoken_quant— on its own more than anyplausible dispatch budget, and the step that dominated the hot path.
The signature is already known when
route()decorates the op, so the binder isgenerated once, at decoration:
It produces exactly what
bind()+apply_defaults()produce, raises the sameTypeErroron a malformed call, and costs 0.076us / 0.083us. Defaults travelthrough the generated function's namespace rather than through source text,
because a default such as
dtypes.fp32has no parseable repr. Signatures with*args/**kwargs, or with a parameter that would collide with an injecteddefault, fall back to
Signature.bind.This sits below the API boundary: providers receive the same canonical
arguments, callers call the same way,
api_versiondoes not move. It can bereplaced at any time — which is the point. An earlier draft of the design
proposed a public
select = Noneauto-accept state so dispatch could skipcanonicalization; that would have put a provider-visible fast path, a
"
run()must mirror the contract including defaults" conformance rule, and theloss of per-call coverage checking into permanent public contract, to solve a
problem an internal change solves. The measurements below also show it would no
longer buy what it was meant to buy.
Equivalence is tested against
Signature.binditself, parametrised overpositional-only, keyword-only, defaulted, empty and var-argument signatures, for
both accepted and rejected calls.
Measurements
tests/test_plugin_overhead.pyprints the numbers as well as asserting on them.Xeon Platinum 8480C, Python 3.12.12, CPU-only, min of 5 x 20k. Overhead over a
direct native call:
AITER_PLUGINS=0Signature.bind, for scaleTwo things worth stating plainly:
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. That is
the same class of error as the 1.5–3us estimate this PR replaces; per-step
projections underestimate systematically.
Decisionconstruction plus theContextVarset is 0.787us of what remains— 44%, and now the largest single item. Canonicalization is 4%. Part 3's free
kill-switch path removes it from the disabled path; whether it can be reduced on
the serving path is a design question, since it is the foundation the
observability APIs are built on.
The gate
The benchmark asserts what can be defended on unknown hardware: the whole
aiter-side overhead must cost less than one
Signature.bindof the samesignature, measured in the same process. That fails the moment generic
canonicalization, a per-call
getenv, or a rebuilt provider list returns, on anyrunner — and it is machine-independent, unlike an absolute threshold. A 4us
absolute ceiling catches a gross regression that somehow keeps the ratio.
The 1us budget is reported, not asserted, until CI runner hardware is
characterised. A gate that goes red on a slow runner teaches people to ignore
the gate.
Testing
pytest -q tests/test_plugin.py tests/test_plugin_overhead.py— 42 passed.CPU-only, no GPU required.
black --checkandruff checkclean.🤖 Generated with Claude Code