Skip to content

simd: chained gather — a chain of key reads folded into one pass - #358

Merged
AdaWorldAPI merged 2 commits into
masterfrom
ccr-9f3b8075-74u47l-chain
Oct 12, 2026
Merged

AdaWorldAPI merged 2 commits into
masterfrom
ccr-9f3b8075-74u47l-chain

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

Adds mask_gather_chain_u32 and mask_gather_chain_u32_under, plus ChainHop and ChainTest. They are re-exported from ndarray::simd.

Bit i is set when the key index[i] leads through every hop. At each hop, the row it reaches must be in range, live in that hop's plane, and pass that hop's equality tests (optionally negated). That hop's next lane then gives the key into the following hop.

The targets' predicates are evaluated at the row each key reaches, so no mask over any hop's table is built. This is lance-graph's chained-hop option (a), start[fk^k(i)]: chained hops fold into one pass with one terminal, and nothing is materialized between hops.

  • The gated form reads index only at rows where the gate bit is set. Gate tail bits past n are ignored.
  • out is fully overwritten.
  • The loop is scalar for the same reason as mask_gather_u32: each address is a value the previous hop read.
  • One hop with no tests is exactly mask_gather_u32_under (pinned by a test).

The shape is validated at entry and panics on:

  • an empty chain;
  • a missing next on a non-last hop;
  • a next on the last hop;
  • a lane shorter than rows.

Tests

  • Unit tests:
    • a row-loop oracle over n ∈ {0, 1, 63, 64, 65, 130, 1000}, with dirty gate tails and an anti-vacuity check;
    • the one-hop identity;
    • four should_panic shape guards.
  • Parity crate: cases 0xD02 and 0xD03 (two hops, out-of-range keys at both depths, a negated test, a dirty gate). Green on v4 and on v3.
  • Disable runs, all red then green after git checkout. Each patch anchor was asserted.
    • Dropping the liveness check fails 2 tests.
    • Ignoring negate fails the row-loop test, and parity reports 0xD02.
    • Not following next fails the row-loop test.
    • Removing the gate-tail clamp fails 2 tests.
  • cargo clippy --lib --tests -D warnings and cargo fmt --check are clean.

Next

Consumers, in this order:

  1. a mask-risc chained Gather op with a predicate at each depth;
  2. Quack lowering;
  3. the glove/composer multi-hop out() as one program.

🤖 Generated with Claude Code

https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh


Generated by Claude Code

mask_gather_chain_u32[_under](index, [under], hops, out): bit i is set
when the key index[i] leads through every hop, each row reached in
range, live in the hop's resident plane, passing that hop's equality
tests, and each hop's next key naming the following hop's row. The
targets' predicates are evaluated at the row each key reaches, so no mask
over any hop's table is built (lance-graph's chained-hop option (a),
start[fk^k(i)]). The gated form reads index only at rows the gate holds.

Scalar by necessity, like mask_gather_u32: each address is a value read by
the previous hop. One hop with no tests is mask_gather_u32_under.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
Two hops, out-of-range keys at both depths, a negated test at the second
hop, a dirty gate tail; references walk the chain row by row.

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

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 12, 2026 21:25
@AdaWorldAPI
AdaWorldAPI merged commit e726f98 into master Oct 12, 2026
29 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T21:26:50.025752Z ef36b96 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.

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