Skip to content

pgw#1143 steps 1-3 (§1.33): a slot DECLARES the tensor layouts its code can execute - #663

Merged
PaulFidika merged 4 commits into
masterfrom
1143-slot-layouts
Aug 11, 2026
Merged

pgw#1143 steps 1-3 (§1.33): a slot DECLARES the tensor layouts its code can execute#663
PaulFidika merged 4 commits into
masterfrom
1143-slot-layouts

Conversation

@PaulFidika

Copy link
Copy Markdown
Contributor

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.

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

…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
PaulFidika merged commit b841735 into master Aug 11, 2026
2 checks passed
@PaulFidika
PaulFidika deleted the 1143-slot-layouts branch August 11, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant