# Scoped cast-storage decisions

Cast storage is a typed mid policy: an effective initial default, per-operator defaults and per-site overrides. ReuseIfSmaller retains the existing alias-safety and per-shard storage-saving requirements. The realized result remains ordinary mid allocation aliases. Recipe::in_place_casts and the proposal-wide global toggle are removed. Version-one/two booleans migrate to version-three policy defaults at checkpoint loading; new checkpoints contain no legacy storage field.

Search retains a joint donation proposal for existing cast families, adds individual cast proposals, and pairs layout changes with the affected operator and its direct consumers. Newly introduced casts observe their operator's selected default. Unrelated operators stay fixed. Source validation walks semantic operations, including Repeat, without unrolling bodies. Missing site requests, unknown source operations and explicit overrides blocked by diagnostic checkpoints produce errors.

Validation:

- Workspace release suite: 432 passed, 0 failed, 8 ignored. Log: /tmp/ipu-scoped-cast-workspace-tests2.log.
- Scoped donation test binds three independent casts (two in one family), checks per-site and operator-default isolation, validates allocation aliases and low kernel calls, round-trips policy serialization and rejects duplicate site requests.
- Proposal test verifies joint layout/donation alternatives leave an unrelated family and the global default fixed. Named-site regression also checks rejection of stale cast-storage requests.
- Legacy storage defaults preserve incumbent and visited choices; ordinal cast checkpoint migration rebuilds identical executable mid and saves the current schema.
- SDK-enabled saved_search_preserves_budget_aliases_and_order passes with actual package construction. Log: /tmp/ipu-scoped-cast-replay-test.log.
- Default FP16 MLP Repeat 3, FP8 ViT Repeat 3, and saved real-weight SigLIP So400m 27-layer BS1 packages are byte-identical to named-sites, and therefore to the hardware-validated exchange-relocation packages. No repeat device execution for identical packages.
- Full-model build-only time 96.280 s, peak host RSS 4,342,420 KiB. This is a validation sample with concurrent host jobs, not a controlled timing comparison.
- A four-step FP8 ViT search with three repeated layers passes on hardware: minimum cosine 0.997459656 and maximum absolute error 0.189453. Saved state records four attempts, ten visited recipes, five containing scoped storage overrides. Final incumbent retains separate cast storage; the test demonstrates search/replay correctness, not a claimed donation speedup.
- Workspace all-target check, formatting and whitespace checks pass. Logs: /tmp/ipu-scoped-cast-check-final.log and /tmp/ipu-scoped-cast-format.log.

Commands, saved states, generated packages, the short-search device profile, comparison JSON and runtime logs are adjacent. Ownership mappings, packing/grouping scope and the remaining storage/copy/cache contracts in docs/COMPILER_STRUCTURE_PROPOSAL.md are still open. Overall code-size reduction remains unproven.
