Skip to content

dr-isa-stream-lab: INT8 direct arm on prepacked INT8 B - #1992

Merged
AdaWorldAPI merged 4 commits into
mainfrom
ccr-8062bcc7-l7lkz9-int8-direct
Nov 10, 2026
Merged

AdaWorldAPI merged 4 commits into
mainfrom
ccr-8062bcc7-l7lkz9-int8-direct

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

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 as cols/16 PackedI8B bands.
  • int8::direct: reads A in place at the u8 lanes' pitch and calls ndarray::simd::int8_gemm_packed_strided.
    • When every lane sits in one strided slab, this is one call.
    • Otherwise it makes one call per 16-field group, and each call writes its own rows of C. No scratch buffer is used and nothing is allocated.
    • Lanes that are not in one slab, not at one pitch or not consecutive are refused, never copied. So is a mask selection, and so is a region whose padded read would leave the lane's row.
  • shape::ReuseKey: the prepared-B reuse rule is now one type, shared by the BF16 PreparedB and the INT8 PreparedI8B. 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.

Row 64 fields 256 fields
backend::gemm_i8, which packs B on every call 3.4–3.6 µs 78.3–78.8 µs
… of which band gather + VNNI pack 1.9–2.1 µs 28.6–29.4 µs
Direct GEMM: A in place, B prepared once 0.98–1.01 µs 45.5–48.1 µs
Prepare B once 6.4–6.7 µs ~105 µs
Warm end to end, staged arm 5.7–5.9 µs 88.9–92.2 µs
Warm end to end, direct arm 2.9–3.0 µs 47.5–57.9 µs

The 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_strided once per tile measured 99–108 µs, which is slower than gemm_i8 even 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 includes int8_gemm_packed_strided.

Gates

  • cargo fmt and cargo 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.
  • Disable runs live in ndarray#418, against the kernels themselves.
  • Board entry: .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

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
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ead0cfcc-131d-4371-93ab-e6ff6ca4eb5e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 10, 2026 17:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T18:01:07.101050Z d024630 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Owner Author

The red check, excluded-crate fmt, clippy and tests, is the dependency on AdaWorldAPI/ndarray#418 described in this PR, not a defect in this change.

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:

error[E0432]: unresolved imports `ndarray::simd::int8_gemm_packed_strided`, `ndarray::simd::PackedI8B`

Built against ndarray#418's branch, the lab is green locally: 47 tests pass, and cargo clippy --all-targets -D warnings is clean. Nothing can be ported into this PR to fix it, because the missing entries are what #418 adds.

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
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Add Carrot credits or activate Agent usage billing to use Autofix

@AdaWorldAPI AdaWorldAPI changed the title dr-isa-stream-lab: INT8 direct arm on prepacked INT8 B (needs ndarray#418) dr-isa-stream-lab: INT8 direct arm on prepacked INT8 B Nov 10, 2026
@AdaWorldAPI
AdaWorldAPI merged commit 6d2f51e into main Nov 10, 2026
13 of 14 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Nov 10, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk
AdaWorldAPI pushed a commit that referenced this pull request Nov 10, 2026
…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
AdaWorldAPI added a commit that referenced this pull request Nov 10, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants