Repository navigation
foundry-parity-lab: per-store cost via INT8 packed GEMM (D-FOUNDRY-PARITY-1, G1 partial) - #1995
Conversation
…rtial) Per-store ingredient cost for every item is one u8 x i8 -> i32 GEMM, C[store][item] = sum_k cost[store][k] * demand[k][item], through ndarray::simd::int8_gemm_packed_strided (ndarray#418; AMX TDPBUSD on the lab host). Only the 23 demanded cost lanes are bound. A is staged once per binding (the source owns A's transpose as i32 lanes; 4096 B, counted); a cost that does not fit u8 is refused. The demand band is packed once and reused only under the same menu revision, the identity-and-revision rule #1992's ReuseKey applies. Tests: oracle and null-model parity over 64 x 8 x q in {1,3,128}; the sum over arm B's CanCook mask equals arm B's network_cost; u8 overflow refused, 255 admitted; stale binding, foreign menu revision and out-of-range q refused; reversed order answers by identity. Five disable runs turn the suite red. The limiting resource (argmin) stays blocked. Plan G1/row 14/H2/roadmap updated; the first arm A comparator allocated per call and is replaced by a fair one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPJjVvasjwqhjJ6c9p
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 611b25227a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
borrow_all validates only the fields a binding carries, so a binding that omitted a demanded cost lane opened and left that column of A zero, understating every cost (all zero for an identity-only binding). open now tracks which demanded categories were bound and refuses with NotBound, matching arm B. The test drops one lane and binds identity only (both refused) and keeps the full binding as the silent half. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPJjVvasjwqhjJ6c9p
… transfer PR_ARC_INVENTORY gets arc entries for #1991 and #1995; LATEST_STATE a row for main after both; STATUS_BOARD marks D-FOUNDRY-PARITY-1 shipped and G1 partial (per-store cost done, limiting resource open as P1b); INTEGRATION_PLANS points at the new entry and EXO-223. New entry D-FOUNDRY-PARITY-1-P1A records arm C and the read-only LGJ crosswalk (the R11 layout-witness gap is D-DRISA-M1). Entries index regenerated; supersession index unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPJjVvasjwqhjJ6c9p
This PR adds arm C to the Foundry parity lab merged in #1991. Arm C closes half of gap G1: per-store ingredient cost, which mask-RISC cannot express. The change is lab-only and no production contract changes.
What
For every store and every item,
C[store][item] = Σ_k cost[store][k] · demand[k][item]. This is oneu8 × i8 → i32GEMM throughndarray::simd::int8_gemm_packed_strided(ndarray#418, now merged). The lab host runs the AMXTDPBUSDtier.storeId. If a binding is missing any of these lanes, arm C refuses it withNotBound, as arm B does; it never treats a missing lane as zero cost.i32lane per category, which is A's transpose, and the kernel readsu8rows. So the bound lanes are copied once per binding into a 64 × 64u8buffer (4 096 B, counted). A cost that doesn't fitu8is refused, never truncated.ReuseKeyapplies to its operands; a digest never decides reuse.Evidence
The lab now has 24 integration tests, 8 of them new:
CanCookmask equals arm B'snetwork_cost. These are two independent arms.u8overflow (300) is refused, and 255 is admitted with an exact result.1..=128.Disable runs, each turned the suite red and was restored: truncate instead of refuse; ignore the denied mask; demand in the wrong column; admit any menu; stage only the first cost lane. The missing-lane test failed before its fix (Codex review) and passes after it.
Gates:
cargo test --release,cargo clippy --all-targets -- -D warnings,cargo fmt --check.Measured
cargo run --release --manifest-path crates/foundry-parity-lab/Cargo.toml --bin bench. One AMX VM, single thread, median of 41 runs, three runs:storeId(cold)borrow_all+ stage A (cold)The first arm A comparator called
fx::recipeonce per (store, item) and measured 7.7–15 µs. That was 512 allocations, not object access, so it was replaced; the fair ratio is about 1.5–1.8×. At this size the GEMM's fixed per-call cost likely dominates. Scaling was not measured.Not done
Locality contract questions
LaneBinding::check), and the menu revision for B (tested).u8row layout requires. Nothing else.🤖 Generated with Claude Code
https://claude.ai/code/session_01XAqKMPJjVvasjwqhjJ6c9p