D0.3 WireSweep DTOs + grid enumerator (Phase 0 surface complete, 71/71 tests)#232
Merged
Merged
Conversation
Last Phase 0 Wire-surface deliverable from codec-sweep-via-lab-infra-v1.
71/71 cognitive-shader-driver tests pass under --features serve
(+5 new D0.3 tests).
DTOs (~250 LOC in wire.rs):
WireMeasure enum:
ReconstructionErrorHeldOut / ReconstructionIccHeldOut /
TokenAgreementTop1 / TokenAgreementTop5 / PerLayerMse
(serde: lowercase snake_case)
WireSweepGrid:
subspaces / centroids / residual_depths / rotations /
distances / lane_widths — each a Vec<T> with sensible defaults
(defaults produce cardinality 1 for minimal payloads)
+ residual_centroids / calibration_rows / measurement_rows / seed
Methods:
- cardinality() -> usize — product of axis lengths
- enumerate() -> Vec<WireCodecParams> — full Cartesian product
WireSweepRequest:
tensor_path / grid / measure (default: ICC + top-1) /
log_to_lance (optional Lance fragment path) / label
WireSweepResult (one per grid point):
grid_index / candidate / kernel_hash (CodecParams::kernel_signature) /
calibrate (Option<WireCalibrateResponse>) /
token_agreement (Option<WireTokenAgreementResult>) /
stub flag (mirrors WireTokenAgreementResult.stub)
WireSweepResponse (for non-streaming batch clients):
label / cardinality / results / elapsed_ms / lance_fragment_path
Streaming handler (SSE) + Lance writer deferred to Phase 3 D3.1.
Phase 0 ships the SURFACE; Phase 3 lands the execution.
Tests (5 new):
- sweep_grid_cardinality_is_product_of_axes (1×3×3×2×1×2 = 36)
- sweep_grid_enumerate_produces_all_unique_signatures
(4 distinct kernel signatures from 4 distinct IR-shaping tuples)
- sweep_grid_defaults_produce_single_candidate
(empty JSON {} → cardinality 1, single default WireCodecParams)
- sweep_request_round_trips_json (full payload with all fields)
- sweep_measure_serializes_snake_case (serde enum format)
Board hygiene (CLAUDE.md Mandatory rule):
STATUS_BOARD.md:
D0.3 Queued → In PR
D0.4 Queued → Ready (surface freeze fires on merge)
EPIPHANIES.md PREPEND:
"D0.3 sweep grid IS the JIT cache warmer" —
the grid and the cache signature are the same object viewed
from two sides. Each unique (subspaces, centroids,
residual_depth, rotation_kind, distance, lane_width) tuple maps
to exactly one kernel_signature(). First traversal compiles N
kernels; every subsequent sweep with overlapping tuples hits
cache at ~0 ms. 54-candidate Appendix A §30 sweep: ~800 ms
one-time compile, free after.
Phase 0 state after this PR (all 7 D0.x deliverables):
✅ D0.1 WireCalibrate + WireTensorView (PR #227)
✅ D0.2 WireTokenAgreement stub (PR #231)
✅ D0.3 WireSweep DTOs + grid (this PR)
⏳ D0.4 surface freeze (fires on merge)
✅ D0.5 auto_detect (PR #231)
✅ D0.6 CodecParamsBuilder (PR #225)
✅ D0.7 precision-ladder validation (PR #225)
Rules honored (every Wire DTO in this PR):
Rule D — JSON/YAML/REST only, never in-Rust construction at ingress
Rule E — Wire surface IS SIMD surface (lane_widths axis explicit,
kernel_hash returned per result)
Rule F — serde mirrors at ingress only; enumerate() returns plain
Rust objects that never re-serialize until egress
After this PR merges: D0.4 surface freeze → Phase 1 (JIT kernels) begins.
https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
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.
Summary
Last Phase 0 Wire-surface deliverable from
codec-sweep-via-lab-infra-v1. Ships the DTOs + the grid enumerator; streaming handler + Lance writer defer to Phase 3 D3.1.71/71
cognitive-shader-driver --features servetests pass (+5 new).What landed
WireMeasureenum (5 variants, snake_case serde)reconstruction_error_held_out/reconstruction_icc_held_out/token_agreement_top1/token_agreement_top5/per_layer_mse.WireSweepGrid— the Cartesian-product input surfaceEvery axis is a
Vec<T>with sensible default (one element → cardinality 1). Axes:Example:
1 × 3 × 3 × 2 × 1 × 2 = 36candidates for the plan's Appendix A §30 sweep.WireSweepRequest+WireSweepResult+WireSweepResponseRequest carries
tensor_path+grid+measureset + optionallog_to_lanceLance fragment path +label. Each result carries the candidate +kernel_hash(theCodecParams::kernel_signature()of the executed kernel) + optionalcalibrate/token_agreementpayloads +stubflag (D0.2 pattern — machine-checkable Phase-0-honesty).The key insight (landed as epiphany)
The sweep grid IS the JIT cache warmer. Each unique tuple
(subspaces, centroids, residual_depth, rotation_kind, distance, lane_width)maps to exactly onekernel_signature(). First traversal compiles N kernels; every subsequent sweep with overlapping tuples hits cache at ~0 ms compile cost. The grid axis and the cache signature are the same object viewed from two sides.The 54-candidate Appendix A §30 sweep: ~800 ms one-time compile, free after. That's the operational loop D0.1–D0.7 buys.
Phase 0 state after merge
WireCalibrate+WireTensorViewWireTokenAgreementstubWireSweepDTOs + gridauto_detectCodecParamsBuilderAfter this PR merges, Phase 0 closes. Phase 1 (JIT kernels) begins next — D1.1
CodecKernelCacheviaJitCompilercompiles kernels perkernel_signature(); D1.2 rotation primitives; D1.3 residual PQ via JIT composition.Board hygiene (same commit per Mandatory rule)
Test Plan
cargo test --manifest-path crates/cognitive-shader-driver/Cargo.toml --features serve— 71/71 pass (+5 new)cargo test -p lance-graph-contract --lib— 147/147 pass (unchanged)cargo test --manifest-path crates/jc/Cargo.toml— 6/6 pass (JC substrate proof unchanged)https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh