Repository navigation
dr-isa-stream-lab: INT8 u8×i8 arm and FACET STRIDE audit (D-DT64-GEMM-SHAPE-3) - #1990
Conversation
…MM-SHAPE-3) Adds a u8 x i8 -> i32 arm over the same DT64 virtual object and fixture as the BF16 arms, run through ndarray::backend::gemm_i8 (AMX TDPBUSD). A is unsigned (value + 8) and B signed, so the instruction's operand contract holds with no reinterpretation. C_int8 = C_bf16 + 8 * colsum(B) is checked on the same fixture. A is staged with one region copy per lane (5-7 us at 256 fields, against 34-43 us for the per-value walk). B is borrowed in place from its table when the selection is a region of the right length (about 30 ns, against 46-59 us to materialize). The band gather and VNNI pack that gemm_i8 does on every call are timed apart with ndarray's own vnni_pack_i8: 23-29 us, 36-38% of the INT8 GEMM at 256 fields. Prepared-B reuse is keyed on authoritative identity instead of a digest: the object it was packed for, otherwise the full selection, frame issue and width, and always the operand's identity (function seed or table instance, plus revision). The FNV selection key is removed. Corrects #1987's "B preparation ~ GEMM": that timer included the synthetic operand's hash. From a table built once, B preparation is about a third of the BF16 GEMM. ndarray is unchanged; the facet-stride guard reports no hits. 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa7e4de5cc
ℹ️ 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".
A BTable indexes row-major, so a column past its width read the next row: a 64-column table under a 256-column object returned B[1][0] for B[0][64] and the GEMM completed with wrong values. Each arm that reads B (prepare, cblas, the INT8 arm) now checks the table's rows and columns against the object first and returns ShapeRefusal::OperandShape. The table accessors also assert the column, so any other caller panics instead of misreading. PreparedB::prepare returns a Result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
TranslatedB::extent() reported the source's position range, so an identity past the inner table passed admit_operand and packing indexed past the table. extent() now reports the inner operand's own extent, and BValues gains highest_row(selection), which TranslatedB overrides to resolve each selected position to the identity it reads. admit_operand then refuses with ShapeRefusal::OperandShape before any packing (#1990's contract). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
…cross GEMMs (D-DT64-G2L-1) (#1994) * dr-isa-stream-lab: INT8 direct arm on ndarray's prepacked INT8 entries 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 * dr-isa-stream-lab: record the INT8 direct arm results Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * wip: G2L lab, one witnessed translation reused across GEMMs (untested) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * dr-isa-stream-lab: time the B pack through ndarray::simd, not hpc 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 * feat(dr-isa-stream-lab): G2L lab falsifier — one witnessed translation reused across GEMMs D-DT64-G2L-1. A selection named in global ids is translated once under one frame of the source's DR MapTable into the source's own row order (counted lookups). The object is bound in the source's space, B is prepared once through the translation (one map read per row), and every run reads the source's lanes in place with zero lookups. Cross-space reads without a translation stay refused (ADMISSION B, #1640). One AMX VM, three runs: translate once 68-85 us (3200 lookups), prepare B 37-47 us, warm run 16-22 us with 0 lookups; re-translating per operation 128-166 us (about 8x). Six falsifiers in tests/integration/g2l.rs, four disable runs red. Contract doc G2L row moves from OPEN to measured (lab). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * dr-isa-stream-lab: refuse a translated identity past the inner B table TranslatedB::extent() reported the source's position range, so an identity past the inner table passed admit_operand and packing indexed past the table. extent() now reports the inner operand's own extent, and BValues gains highest_row(selection), which TranslatedB overrides to resolve each selected position to the identity it reads. admit_operand then refuses with ShapeRefusal::OperandShape before any packing (#1990's contract). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * dr-isa-stream-lab: report G2L costs one by one The G2L bench now reports separately: G2L lookups and translation time; admission and packing map reads during B preparation; B bytes packed and preparation time; A staging bytes and time per warm run; GEMM-only time; and the complete warm run. GEMM alone is 0.71-0.86 us; staging the sparse selection into a padded A is 11-14 us of a 20-24 us warm run, so zero lookups is not zero data movement. BENCH-SHAPE, the board entry and the contract doc record that K order changes under translation and is validated only for exact integer GEMM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * board: regenerate entries index after merging main Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk * dr-isa-stream-lab: refuse a translation made on another source Two sources built in the same order have equal coordinate digests, so Translation::check admitted a translation from the other one and packing then panicked reading a table with a frame it never issued (Codex, #1994). check now asks the source's own map table whether it issued the translation's frame, and refuses with G2lRefusal::Foreign before packing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk --------- Co-authored-by: Claude <noreply@anthropic.com>
Follow-up to #1988 and #1989, both merged; this PR now targets
main. Not for automatic merge.Contract:
.claude/knowledge/dr-dt64-locality-execution-contract.md(EXO-220).Central question
Answer: DT64 routes the positions. The BF16 arm reads A in place. The data movement that remains is the hardware's own requirement (VNNI packing of B) plus one INT8 staging copy of A. That copy exists because ndarray has no strided-A INT8 entry.
What this adds
A
u8 × i8 → i32arm over the same virtual object, fixture and B table as the BF16 arms. It callsndarray::backend::gemm_i8, which runs AMXTDPBUSD.The TDPBUSD operand contract is kept. A is unsigned (
value + 8) and B is signed, with no reinterpretation.a_is_never_reinterpreted_as_signed(200 × −1 = −200·K).Cross-check against BF16 on the same fixture:
C_int8 = C_bf16 + 8·colsum(B).int8_and_bf16_agree_on_the_same_fixture.Prepared-B reuse is keyed on authoritative identity, not a digest. The FNV selection key is removed. B is reused only if all of these match:
Two tables with equal values and the same revision count as different operands.
prepared_b_reuse_is_keyed_by_identity_not_a_digest.Correction to #1987
#1987 said B preparation costs about as much as the GEMM. That was wrong. Its timer included the hash of the synthetic operand. With a B table built once, preparing B costs about 45 µs, roughly a third of the BF16 GEMM.
Results at 256 fields
All measurements: one AMX VM, same fixture, six runs. The raw output of the last three runs is in
results/shape-2026-11-10-int8-run*.txt. Run-to-run variation is up to about 35%.vnni_pack_i8The pack row is measured separately from the cost of reading the B table.
Audit verdicts
borrow_all, lanes in view orderTDPBF16PS/TDPBUSDthrough ndarraylut_u8,lut9)INT8 A staging and B re-pack. In this lab, A is now a region copy and B is borrowed in place. At the ndarray layer,
gemm_i8re-packs B on every call, which costs 36–38% of its GEMM. That justifies a separate ndarray PR addingPackedI8Band a strided-A INT8 entry, the INT8 counterparts ofPackedBf16Band #414. That ndarray PR is proposed, not part of this one. ndarray is unchanged here, andfacet-stride-guard --diff origin/mainreports 0 hits.Governing question
INT8 B is gathered and VNNI-packed again on every call. A prepacked INT8 B, keyed on operand identity and revision, would do that once per binding. That is the ndarray follow-up.
Gates
cargo fmt --checkis clean.cargo clippy --release --all-targets -D warningsis clean.cargo test --release: 43 passed.facet-stride-guard: 0 hits..claude/board/entries/2026-11-10-dt64-int8-facet-stride.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk