Skip to content

D-MHB-1: Mexican-hat response without a raster (probe + board) - #1415

Merged
AdaWorldAPI merged 1 commit into
mainfrom
ccr-b2e415d9-4jfvyk-mexhat
Oct 8, 2026
Merged

AdaWorldAPI merged 1 commit into
mainfrom
ccr-b2e415d9-4jfvyk-mexhat

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

This PR adds a probe and a board entry. No production primitive and no ndarray change.

The question: can popcount stacking, a quantised Mexican hat and an exact early exit answer a centre-surround query without per-point geometry and without a materialised raster? And is a Rolling-Floor controller worth adding on top?

The query: S(c) = Σ_{p ∈ P, |p − c|² ≤ R²} w(|p − c|²).

  • P is a presence bitmap.
  • w is a normalised DoG, quantised to integers.
  • σc 3, σs 6, R 18: a 37 × 37 window.

Files:

  • Probe: crates/lance-graph-mask-risc/examples/mexhat_bucket_probe.rs
  • Board: entries/2026-10-08-mexhat-bucket-cascade-probe.md, plus a STATUS_BOARD row
CARGO_PROFILE_RELEASE_DEBUG=0 cargo run --release -p lance-graph-mask-risc --example mexhat_bucket_probe

Inventory (read in code)

ndarray:

  • RollingFloor: exact moments, a quarter-σ lattice, thresholds derived on demand. Not re-exported from ndarray::simd.
  • hamming_distance_within: an exact early exit.
  • Cascade:
    • Stroke 2 has an exact budget exit.
    • Stroke 1 is a statistical prune with no exact fallback. A candidate it cannot resolve is dropped. Reported here, not changed.
  • The Mexican hat:
    • lsi.rs mexican_hat is a five-step percentile function, not a DoG.
    • Pillar-15 is DEFERRED, and its stub reports passed: true.

The drift observation reproduces: FIXED and SHIPPED reject 97.55 % in phase 2. That probe tests Cascade, not RollingFloor.

Measured

Medians of 10 runs, ns per query, 1M grid:

density D window + LUT F bit-sliced E rings K=8 B mask-risc
0.01 246 624 489 61.7 k
0.1 619 592 464 62.4 k
0.5 1166 624 489 80.4 k
0.9 1516 604 473 88.9 k
  • F is exact. Σ_b 2^b (popcount(P ∧ Pos_b) − popcount(P ∧ Neg_b)) equals direct geometry on every checked centre (asserted), at constant cost, with no value lane, no square root and no exp.
  • E is fast but wrong: off by 950–5,600 at K = 8 and 255–1,830 at K = 32, and K = 32 is slower than F.
  • B materialises a weight lane per query (38–152 KB), because mask-risc has no 2-D window operand.
  • Early exit (H) for S ≥ T with exact [L, U] row bounds:
    • equals the full decision on every query;
    • about −20 % against F at the median threshold;
    • down to ~10 of 37 rows at the 99 % quantile on sparse input.

Counterexamples and falsifiers

  • Kernel: one sign change at the analytic zero crossing, one annular minimum, the 8 square symmetries, a disk partition, no overflow.
  • A partial sum that rises above T and ends below it: H rejects correctly after 18 rows.
  • A ring at the zero crossing: 35 of 37 rows needed.
  • Dense input with T at the median: 24 of 37 rows.
  • Geometry buckets cannot see phase: at width λ/2, 738 of 1,003 (r1, r2) buckets hold both a dark and a bright fringe cell; at λ/8, none do.
  • Disable runs, each red then restored:
    • dropping the unvisited-row upper bound decides 52 of 512 queries wrongly;
    • shifting F's negative planes fails F differs from D.

Verdicts

  • ADOPT, each in its own PR:
    • F for dense windows, routed through ndarray::simd;
    • D for sparse windows.
  • PROBE: a per-query D/F choice from the window popcount. The per-row choice (G) loses up to 43 % at mid density.
  • PROBE: an early exit on the D path.
  • REJECT:
    • the ring-bucket Mexican hat;
    • B for this query;
    • treating lsi.rs as a DoG.
  • PARK:
    • a Rolling-Floor controller (the deciding quantity is an exact popcount);
    • statistical early exit (the exact bound already decides without error);
    • Pillar-15.

Proposed, not implemented — R-MHB-1: rewrite a masked sum over a static, narrow integer weight template into bit-sliced fused Counts over resident planes.

Checks

  • cargo clippy -p lance-graph-mask-risc --examples -D warnings: clean.
  • fmt: clean.
  • The entries index is regenerated; the supersession index is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFw2WdKr1oxvaKCJC2ua2R


Generated by Claude Code

Measures whether popcount stacking, a quantised DoG and an exact early
exit can answer a centre-surround query without per-point geometry or a
materialised raster. Probe only; no production primitive.

- Bit-sliced weight planes (F) are exact (asserted equal to direct
  geometry on every centre) at a constant ~600 ns per query.
- Direct window geometry (D) wins below a density of about 0.1.
- Equal-q ring buckets (E) are fast but wrong at every K tried.
- The shipped mask-risc path (B) materialises a weight lane per query
  and is 26-150x slower.
- The exact-bound early exit (H) saves about 20 % at the median
  threshold and equals the full decision on every query.
- Rolling-Floor control and statistical early exit are parked: the
  deciding quantity is an exact popcount.

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

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 9a716614-41b2-4d62-929d-1f4b514eccc3
📥 Commits

Reviewing files that changed from the base of the PR and between d127f7d and 3f84990.

📒 Files selected for processing (4)
  • .claude/board/STATUS_BOARD.md
  • .claude/board/entries/2026-10-08-mexhat-bucket-cascade-probe.md
  • .claude/board/entries/README.md
  • crates/lance-graph-mask-risc/examples/mexhat_bucket_probe.rs
 _____________________________________________________________________________
< Butterfly effect: one bug in your code can cause a hurricane in production. >
 -----------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Add Carrot credits or activate Agent usage billing to use Autopilot

@AdaWorldAPI
AdaWorldAPI merged commit 873f45c into main Oct 8, 2026
10 of 11 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Oct 8, 2026
Keeps both STATUS_BOARD sections (D-PHT and D-MHB from #1415) and
regenerates the entries index.

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

@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: 3f84990c7f

ℹ️ 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 on lines +848 to +852
let (_, ns_h) = time(5, || {
qs.iter()
.map(|&(x, y)| arm_h(g, k, &order, &up, &lo, x, y, t, &mut Work::default()).1)
.sum::<usize>()
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve timed sums against dead-code elimination

In optimized release builds, the value returned by time is bound to _, and this closure never passes its sum to std::hint::black_box as the main bench harness does. After inlining, LLVM may remove the unused row/popcount work or retain only panic-relevant checks, so the reported H latency and the documented ~20% advantage over F are not reliable; consume each timed sum with black_box before comparing the timings.

Useful? React with 👍 / 👎.

}
}
// The full scan is O(grid) per query; check it on a few centres.
for &(cx, cy) in qs.iter().take(8) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report the actual full-scan coverage

The new status-board gate says the full scan agrees on every centre, and the entry associates the exact-equality check with 1,024 centres per fixture, but arm_scan is evaluated for only the first eight centres while D/F/G use the full query set. Anyone relying on the board therefore sees the full-scan oracle coverage overstated by 128×; either run this oracle over all centres or qualify the board and printed claim as eight centres per fixture.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

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-08T19:16:29.405241Z 3f84990 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