Repository navigation
dr-isa-stream-lab: INT8 direct arm on prepacked INT8 B - #1992
Conversation
Adds int8::direct and int8::PreparedI8B. A is read in place at the u8 lanes' pitch and B is prepared once as PackedI8B bands, through ndarray::simd::int8_gemm_packed_strided (AdaWorldAPI/ndarray#418). The prepared-B reuse rule moves into shape::ReuseKey, shared by the BF16 and INT8 prepared operands so the two cannot drift. Measured on one AMX VM (median of 41 warm runs, three runs), 256 fields x 256 columns: the direct GEMM takes 45.5-48.1 us against 78.3-78.8 us for backend::gemm_i8, end to end 47.5-57.9 us against 88.9-92.2 us; at 64 fields 0.98-1.01 us against 3.4-3.6 us. No A copied, no allocation. Needs ndarray#418. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
|
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. |
|
The red check, The job checks out ndarray's default branch. Neither of the two entries this lab now calls is on that branch yet, so the build fails here: Built against ndarray#418's branch, the lab is green locally: 47 tests pass, and Merge #418 first, then re-run this check. It should go green with no change here. Generated by Claude Code |
The benchmark's pack-timing row called ndarray::hpc::amx_matmul::vnni_pack_i8 directly. hpc is reached only through the ndarray::simd polyfill, so the row now times PackedI8B::pack_from, which packs into the same VNNI layout. The measured share is unchanged (23.1 us, 39% of the gemm_i8 row at 256 fields). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
|
Add Carrot credits or activate Agent usage billing to use Autofix |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
…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
…RITY-1, G1 partial) (#1995) * foundry-parity-lab: arm C per-store cost via INT8 packed GEMM (WIP) * foundry-parity-lab: arm C per-store cost via INT8 packed GEMM (G1, partial) 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 * foundry-parity-lab: arm C refuses a binding missing a demanded cost lane 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 --------- Co-authored-by: Claude <noreply@anthropic.com>
Depends on AdaWorldAPI/ndarray#418, now merged (79ed32c). The lab path-depends on ndarray's default branch, and every check here is green against it.
It builds the OPTIMIZATION FOUND item from #1990. The question it answers is the contract's governing question (
.claude/knowledge/dr-dt64-locality-execution-contract.md, EXO-220): the VNNI pack of B was recomputed on every operation; is it now done once per binding?Change
int8::PreparedI8B: B is packed once ascols/16PackedI8Bbands.int8::direct: reads A in place at the u8 lanes' pitch and callsndarray::simd::int8_gemm_packed_strided.shape::ReuseKey: the prepared-B reuse rule is now one type, shared by the BF16PreparedBand the INT8PreparedI8B. Reuse needs a matching operand identity and revision, plus either the same object or a full match on selection, frame issue and width. A digest never decides reuse.Results
One AMX VM, median of 41 warm runs. Each range covers three runs; run-to-run variation on this VM is up to about 35%. Every row is checked against the i64 oracle.
backend::gemm_i8, which packs B on every callThe direct arm copies no A and allocates nothing. Preparing B once costs about as much as three per-call packs, so it pays off from the third reuse.
Negative result, kept on record. Calling
int8_tile_gemm_16x16_packed_stridedonce per tile measured 99–108 µs, which is slower thangemm_i8even with its per-call pack. Each call configures the tiles again (~105 ns), and per-tile calls lose the 2×2 register blocking. Hoisting the pack only pays off once the whole-matrix kernel takes the prepacked bands. That finding is why ndarray#418 includesint8_gemm_packed_strided.Gates
cargo fmtandcargo clippy --release --all-targets -D warnings: clean.cargo test --release: 47 tests pass. New tests:int8_direct_is_exact_and_reuses_its_prepared_b: 64 and 256 fields; regions with K tails 63, 65, 128 and 512; two runs per prepared B; equal to the oracle and to the staged arm.int8_direct_refuses_what_it_cannot_read_in_place: permuted rows, a mask selection, an over-reading region, and another operand..claude/board/entries/2026-11-10-int8-direct-packed-b.md. BENCH-SHAPE.md has the new section.🤖 Generated with Claude Code
https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk