Skip to content

lab: DT64-shaped 64×64 and 256×256 BF16 objects over source-owned lanes (D-DT64-GEMM-SHAPE-1/2) - #1987

Merged
AdaWorldAPI merged 4 commits into
mainfrom
ccr-8062bcc7-l7lkz9-dt64-gemm-shape
Nov 10, 2026
Merged

AdaWorldAPI merged 4 commits into
mainfrom
ccr-8062bcc7-l7lkz9-dt64-gemm-shape

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Lab-only follow-up to #1983 and #1984, in crates/dr-isa-stream-lab. It does not change DT64, DR, the canonical SoA, or any production API.

What this tests

universe (65,536 identities × F lanes, source-owned) → WHERE (region | mask)
  → VirtualObject = LaneBinding(F fields) + selection + N columns   (addresses only)
  → BF16 tiles: rows = fields, K = selected identities, cols = B columns
  → GEMM → C[F × N] FP32
64×64 256×256
Output tiles 16×16 16 256
K=32 dot-product steps (logical) 32 2,048
One BF16 operand 8 KiB 128 KiB

The 256 fields bind directly under Extent::DR256_SQ_X64 (DT64 MAX_FIELDS = 256). No composed bindings and no lane-budget change were needed. "256×256" here means fields × columns over 256 selected identities. It is not an adjacency matrix.

Four arms, each checked against the oracle before and after timing:

  • direct: strided AMX, with A read in place from the slab;
  • staged: dense 16×K A tiles, with every copied byte counted;
  • ndarray CBLAS BF16: cblas_gemm_bf16bf16f32;
  • oracle: scalar f64 from value functions.

B is prepared once as VNNI panels and reused. The reuse key is the selection, the frame issue, the B revision and the width.

Results

Host: Xeon VM with AMX-BF16, 4 vCPU, L2 2 MiB. Tier AMX TDPBF16PS, single-threaded. Timings moved by up to 35% between runs. Full table and three raw runs: crates/dr-isa-stream-lab/BENCH-SHAPE.md and results/.

Metric 64×64 256×256
DT64 bind (cold) 3.4 µs 8.9 µs
Resolve: one check + borrows (warm) 1.8 µs · 0 allocs 13.9 µs · 0 allocs
Direct AMX 4.0–5.9 µs · 0 B copied · 0 allocs 146–178 µs · 0 B · 0 allocs
Staged AMX 4.1–4.9 µs · 8 KiB copied 140–155 µs · 128 KiB copied
ndarray CBLAS BF16 ~38 µs · 23 allocs 1.06–1.63 ms · 263 allocs · 785 KiB tmp
B preparation 8.9–13.2 µs · 8 KiB 149–181 µs · 128 KiB
FP32 C 16 KiB 256 KiB
Warm end-to-end (B reused) 6.7–7.2 µs 170–197 µs
Cold end-to-end 25.9 µs 368 µs

Decision: MIXED.

  • Use direct for region-shaped WHERE results over a block-padded slab. It copies nothing and allocates nothing, but on this host it is not measurably faster than staged.
  • Use staged for scattered masks, interior tails, and permuted or scattered lanes.
  • Always prepare B once and reuse it. At 256, preparing B costs about as much as the GEMM, and reuse halves the end-to-end time.
  • ndarray CBLAS BF16 is 7–11× slower and is not a consumer for this shape.

Scaling 16 → 256 tiles:

  • MACs grow 64×; direct time grows 25–44×, so throughput goes up.
  • At 256, arithmetic and B preparation are about equal.
  • The single binding check is third, at about 8%.

Sparse demand. A mask of 40 scattered identities compacts K to 64 (padded), so the arithmetic stays dense. Only the 20 KiB of selected values is copied, but the gather makes it slower (392–557 µs) than the dense 256-identity region.

Falsifiers (14 tests, all green)

Each refusal is tested two-sided where a bypass is constructible.

  • Exactness: all four arms agree exactly at both sizes.
  • Tile order: every tile is distinct, and swapping two tiles is caught.
  • K accumulation: K = 32, 64 and 256.
  • Tails 63/64/65:
    • At the end of the universe the read hits the slab's zeroed padding, and direct is exact.
    • In the middle it is refused with OverRead.
    • Without that refusal, a NaN in the next identity poisons the tile even though B's padding row is zero.
  • Direct refusals: scattered lanes, permuted rows, short pitch, scattered mask.
  • Orientation: a square transposed slab reads wrong if declared in the identity order, and is refused at bind if declared in its true order.
  • Binding: cross-space selection, stale frame, foreign frame, wrong reader scope, changed field mapping, different schema basis. All are refused before any borrow.
  • Prepared B: refused after a selection, frame, revision or width change. Using a stale B gives the wrong answer.
  • Rounding: inexact values are refused at ingest. Inputs rounded on purpose meet the documented bound: 2·K·2^-24·Σ|ab| between arms, plus 2^-8·Σ|ab| against the unrounded answer.
  • No global G2L: resolve borrows exactly one lane per field, at a universe of 256 or 65,536 identities.

Disable runs (each turns tests red; the tree was restored from the committed state):

  • Over-read guard off: tails_* and without_the_over_read_refusal_* fail.
  • Selection witness off: prepared_b_is_reused_and_invalidated fails.
  • Binding check in resolve off: frame_scope_mapping_and_basis_refusals fails.

#1984 ancestry

#1984 merged into #1983's branch 13 s after #1983 itself merged, so 1f47c03e9, edbf2fa44 and d563af107 are not on main. They survive on ccr-8062bcc7-l7lkz9-vcsr. This PR does not cherry-pick them; their BENCH.md is preserved there. Re-landing them is a separate decision.

#1984's reference numbers (different workloads; no speed-up is claimed across them):

Workload Result
WHERE 16×16 over 65,536 identities direct AMX 172.5 µs vs ndarray CBLAS 3,397.3 µs
Degree-8 graph CSR 11.6 ms vs AMX 32.3 ms
Degree-64 local graph staged AMX 12.5 ms vs CSR 75 ms

The graph conclusions stay separate from these matrix-shaping conclusions.

Recommendation on promotion

Do not promote the GEMM into Quack / mask-RISC. It is an optional arithmetic consumer, and mask-RISC terminals are untouched. Two pieces are worth their own PRs:

  1. A LaneBinding::borrow_all (one check, N borrows) in lance-graph-dt64. LaneBinding::lane per field is quadratic: 155 µs against 14 µs at 256 fields.
  2. The prepared-operand reuse key (selection witness + frame issue + revision + width), for any consumer that caches a derived operand.

Gaps

Gates: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and cargo test --release (32 tests) are green. CI now also runs --bin shape.


Generated by Claude Code

…SHAPE-1/2)

A WHERE-selected population is routed through one DT64 lane binding into a
virtual object (fields x columns, reduction over selected identities) and
consumed as 16 or 256 output tiles by four arms: direct strided AMX, staged
dense A tiles, ndarray CBLAS BF16, and a scalar f64 oracle.

The object holds addresses and the selection only. B is prepared once as
VNNI column panels, keyed to the selection, the frame issue, the B revision
and the width, and refused when any of them changes. Direct reads refuse
scattered masks, non-slab or permuted lanes, short pitches, and any K
padding that would read live neighbouring identities (a NaN there poisons
the tile even though B's padding row is zero).

256 demanded fields bind directly under Extent::DR256_SQ_X64 (MAX_FIELDS is
256); no production lane budget changes.

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: 3f38f8fe-35a0-42d3-b2de-1361a5f00773
  • 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 16:24
@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-10T16:34:08.064922Z afe8d15 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 719d057974

ℹ️ 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".

Comment thread crates/dr-isa-stream-lab/src/shape.rs Resolved
Lanes now carry the frame issue and per-row lane addresses of the object
that resolved them. direct, staged and cblas refuse lanes from another
source or frame, with another field count, or under another mapping
(ShapeRefusal::ForeignLanes), before any arithmetic. Before this, lanes
from a foreign source passed whenever the geometry fit, and 64-field lanes
on a 256-field object silently computed 64 rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk

Copy link
Copy Markdown
Owner Author

@codex review

The lane-provenance finding is fixed in fe3491a. The direct, staged and CBLAS arms now refuse lanes that another object resolved, and there is a new test with a disable run for each of its checks.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe3491a82d

ℹ️ 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".

Comment thread crates/dr-isa-stream-lab/src/shape.rs Resolved
A region past the source's logical length that still fit the padded
pitch passed every guard: direct read the slab's zero padding as selected
values and returned Ok, while staged and cblas panicked. admit_lanes, which
all three arms call, now refuses any selected identity at or past the
shortest lane's length (ShapeRefusal::OutOfRange). Padding stays allowed as
K padding only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMMWgnUU9g7Ldyn6sbk

Copy link
Copy Markdown
Owner Author

@codex review

The bounds finding is fixed in afe8d15: every arm now refuses selections past the end of the lanes.


Generated by Claude Code

@AdaWorldAPI
AdaWorldAPI merged commit a427c07 into main Nov 10, 2026
11 of 12 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: afe8d156d9

ℹ️ 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".

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