pgw#1143 steps 1-3 (§1.33): a slot DECLARES the tensor layouts its code can execute - #663
Merged
Conversation
…de can execute
The code side of the layout contract had no declaration surface at all —
`api/slot.py` carried `pipeline_cls, selected_by, family, default_checkpoint,
root, optional` and nothing else, so the hub's th#1803 rebind gate was keyed
off the wheel's decoder census (2 distinct signatures across 64 releases)
rather than off what the author says the slot needs.
`Slot(layouts={component_path: (handle, ...)})` is that declaration: an
ordered tuple per component path, `"*"` for the whole tree, order IS
preference (§1.33 pt 2). It is published into the release manifest as
`functions[].slots[].layouts` for the hub to gate against (th#1809 T1-T2).
- **Absent is UNDECLARED**, a tri-state — never "accepts everything" and
never "accepts nothing". An empty mapping and an empty tuple are both
decoration-time errors; collapsing the tri-state is th#1580's fail-open
defect wearing a new name.
- **On `Slot`, not `Compile`.** `Compile`'s fields feed `contract_axes()`,
a cell-key input, and §1.33 pt 5 is that conversion is upstream of compute
and invisible to cell identity. A layout declaration there would re-key
every cell in the fleet for the one fact that must never enter the key.
- **Handles at the constructor, KEYS at decoration.** The handle vocabulary
is `KNOWN_CONTRACTS` (refusal text reused verbatim from
`tensor_layout_contract._validate`); the component keys are checked
against the DERIVED component tree in `_spec_for_handler`, because a key
that matches nothing reads as a declaration and gates nothing.
- **The SDK emits HANDLES, never digests** (th#1580 A2: descriptors are Go).
The hub resolves handle -> `Contract.Digest()` at manifest ingest against
its own registry — the only moment one wheel and one hub are both pinned —
so `KNOWN_CONTRACTS` is honestly a transcription that may be stale and is
CHECKED. `hf.fp8-blockwise@1` joins it: registered hub-side since th#1803
(`226070fd`), and its absence made §1.33's own worked example (an fp8
text_encoder against a bf16 DiT) undeclarable.
- **A composite `<topology>+<quant>` handle is refused, naming th#1809 T3.**
The topology axis has no registry to compare against yet; storing half a
pair is not exact.
- **The census stays a LOWER bound.** A declared handle no
`@implements_contract` decoder backs lands on the manifest as
`layouts_census_unbacked` and does NOT refuse — the blockwise conditioner
is decoded natively by `transformers` through `quantization_config` with
zero cozy markers, and refusing would make the motivating case illegal.
- **`scripts/lint_layout_declarations.py`** (new `fast gates` step) refuses a
declaration the AST sweep cannot read. Discovery imports endpoint modules
torch-stubbed, and pgw#1107's sweep reads them without importing at all; a
computed declaration is legible to neither, which would make the published
manifest the only place the demand can be read.
RED on master, measured: `Slot(P, layouts=...)` -> `TypeError: unexpected
keyword argument 'layouts'`; `_slot_to_manifest` emits
`['components', 'name', 'pipeline_class']`; `KNOWN_CONTRACTS` holds 5 of the
hub's 6 handles.
The fence's subject is a declaration that gets PUBLISHED. tests/ holds the opposite by construction — a test proving the constructor refuses a computed declaration has to write one — so sweeping it made this fence and its own negative test mutually exclusive (CI, run 31534100939). Endpoint repos point the script at their own tree, where every declaration is a real one.
The declaration crosses TWO encoders before any gate sees it — msgspec TOML into endpoint.lock, then JSON into tensorhub's `manifestSlotLayoutDoc` (`map[string][]string`). A nested table inside an array-of-tables is exactly where a TOML encoder's key ordering bites, and the failure would be silent: the hub would read the slot as UNDECLARED and the gate would fall back to the census with nothing to say about it.
th#1803 PR #662 landed `hf.fp8-blockwise@1` in the transcription WITH a real decoder behind it while this branch was open. Rebased onto it; the changelog no longer claims a transcription this issue did not make.
PaulFidika
force-pushed
the
1143-slot-layouts
branch
from
August 11, 2026 21:05
231ad11 to
eaf4914
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code side of the layout contract had no declaration surface at all —
api/slot.pycarriedpipeline_cls, selected_by, family, default_checkpoint, root, optionaland nothing else, so the hub's th#1803 rebind gate was keyedoff the wheel's decoder census (2 distinct signatures across 64 releases)
rather than off what the author says the slot needs.
Slot(layouts={component_path: (handle, ...)})is that declaration: anordered tuple per component path,
"*"for the whole tree, order ISpreference (§1.33 pt 2). It is published into the release manifest as
functions[].slots[].layoutsfor the hub to gate against (th#1809 T1-T2).never "accepts nothing". An empty mapping and an empty tuple are both
decoration-time errors; collapsing the tri-state is th#1580's fail-open
defect wearing a new name.
Slot, notCompile.Compile's fields feedcontract_axes(),a cell-key input, and §1.33 pt 5 is that conversion is upstream of compute
and invisible to cell identity. A layout declaration there would re-key
every cell in the fleet for the one fact that must never enter the key.
is
KNOWN_CONTRACTS(refusal text reused verbatim fromtensor_layout_contract._validate); the component keys are checkedagainst the DERIVED component tree in
_spec_for_handler, because a keythat matches nothing reads as a declaration and gates nothing.
The hub resolves handle ->
Contract.Digest()at manifest ingest againstits own registry — the only moment one wheel and one hub are both pinned —
so
KNOWN_CONTRACTSis honestly a transcription that may be stale and isCHECKED.
hf.fp8-blockwise@1joins it: registered hub-side since th#1803(
226070fd), and its absence made §1.33's own worked example (an fp8text_encoder against a bf16 DiT) undeclarable.
<topology>+<quant>handle is refused, naming th#1809 T3.The topology axis has no registry to compare against yet; storing half a
pair is not exact.
@implements_contractdecoder backs lands on the manifest aslayouts_census_unbackedand does NOT refuse — the blockwise conditioneris decoded natively by
transformersthroughquantization_configwithzero cozy markers, and refusing would make the motivating case illegal.
scripts/lint_layout_declarations.py(newfast gatesstep) refuses adeclaration the AST sweep cannot read. Discovery imports endpoint modules
torch-stubbed, and pgw#1107's sweep reads them without importing at all; a
computed declaration is legible to neither, which would make the published
manifest the only place the demand can be read.
RED on master, measured:
Slot(P, layouts=...)->TypeError: unexpected keyword argument 'layouts';_slot_to_manifestemits['components', 'name', 'pipeline_class'];KNOWN_CONTRACTSholds 5 of thehub's 6 handles.
Pairs with tensorhub th#1809 T1-T2 (the hub-side gate that reads this). Steps 1-3 are additive: no endpoint declares
layouts=yet, so every existing manifest is byte-identical and every slot stays UNDECLARED until an author opts in. No release cut — this joins the next batch.🤖 Generated with Claude Code