Skip to content

lgj-abi: lgj_hop conjunction as one ternlog pass; lane read as a lane (5×) - #73

Open
AdaWorldAPI wants to merge 2 commits into
mainfrom
claude/pr-294-ragged-path-validation-170zcy
Open

lgj-abi: lgj_hop conjunction as one ternlog pass; lane read as a lane (5×)#73
AdaWorldAPI wants to merge 2 commits into
mainfrom
claude/pr-294-ragged-path-validation-170zcy

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Sep 4, 2026

Copy link
Copy Markdown
Owner

What

lgj_hop's selection selected = class_f ∧ src ∧ struct_f was spelled as two mask_and_assign passes through a scratch write. AND is the rank-1 spelling of a 3-input mask op; the conjunction is now one mask_ternlog_assign::<AND3> pass (one VPTERNLOGQ per 512 bits) via a new kernels::simd_mask_ternlog_assign wrapper + kernels::ternlog re-export — exports names kernels::ternlog::AND3, never ndarray::simd directly (abi.md §8).

The lgj_hop doc block still described the PR #39 gather that R1 (0385269) reversed; rewritten to the shipped mask-algebra shape with the arc named and the next rung (dst = src ⊗ A over the V3 EdgeBlock, decode modes 1..=3) stated.

No ABI symbol, no minor bump, no Java change. LATEST_STATE entry in the same commit.

Depends on AdaWorldAPI/ndarray#301 (same branch name) — mask_ternlog + the contiguous fast path. Path dep, so this builds once that lands or against that branch checked out at ../../../ndarray.

Measured

columnar_hop_bench, 65 536 rows × 32 facets, equivalence asserted before timing:

frontier before after
classid (3 933) 6 342 µs 1 203 µs
hop2 (6 943) 6 408 µs 1 101 µs
all (65 536) 7 547 µs 1 851 µs

The ternlog wire is one of three mask passes and cannot account for 5×. The bulk is what it exposed on the ndarray side: eq_u32_strided_to_mask at stride_bytes == 4 — every lane of the minor-10 facet-major store — gathered 16 bounds-checked scalar reads into a temporary before the vector compare. The store was contiguous; the kernel read it as strided. 2.1 GB/s → ~13 GB/s, fixed in the primitive, so lgj_op_eq_classid and every other stride-4 caller gets it with no change here.

Gates

lgj-abi: cargo fmt --check clean · cargo test 138/138 + 3/3 (incl. the pinned 10 → 19 → 29 hop regression on both layouts, aliasing + reserved-mode falsifiers) · cargo clippy --all-targets -- -D warnings clean. Java suite not re-run: no Java source or ABI surface changed; rebuild the .so before the next Java run.

Not here (own PR)

The BBB fence: no byte offset, stride, slot index, or carving width in any public Java signature (WideFieldMask.ofFacets(int…), the 97 LgjLaneDesc lanes, the *At accessors). The wall passes handles, classids, names, counts, statuses.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WkNBjHc2e3zuyz9i8qJEv


Generated by Claude Code

Summary by CodeRabbit

  • Performance

    • Improved lgj_hop selection performance by streamlining mask processing and reducing intermediate work.
    • Optimized contiguous data access to improve throughput, particularly for larger datasets.
  • Behavior

    • Hop selection continues to combine class, edge, and source-mask criteria while preserving existing payload decoding behavior.
  • Validation

    • Updated performance benchmarks and validation records for the optimized selection path.

selected = class_f AND src AND struct_f was two mask_and_assign passes
through a scratch write. AND is the rank-1 spelling of a 3-input mask op;
the conjunction is now one mask_ternlog_assign::<AND3> pass (one VPTERNLOGQ
per 512 bits) through a new kernels::simd_mask_ternlog_assign wrapper and a
kernels::ternlog re-export, so exports names kernels::ternlog::AND3 and
never reaches past kernels for SIMD vocabulary (abi.md §8).

The lgj_hop doc block still described the PR #39 gather that R1 (0385269)
reversed; rewritten to the shipped mask-algebra shape with the arc named
and the next rung (dst = src ⊗ A over the V3 EdgeBlock, decode modes 1..=3)
stated.

columnar_hop_bench, 65 536 rows, 32 facets, equivalence asserted before
timing: 6 342 / 6 408 / 7 547 us -> 1 203 / 1 101 / 1 851 us (classid /
hop2 / all). Most of that is the ndarray-side finding this exposed:
eq_u32_strided_to_mask at stride 4 — every lane of the facet-major store —
gathered 16 scalar reads into a temporary before the vector compare. Fixed
in the primitive (ndarray, same branch name); no change needed here.

No ABI symbol, no minor bump, no Java change. Gates: fmt clean, 138/138 +
3/3 tests incl. the pinned 10 -> 19 -> 29 hop regression on both layouts,
clippy --all-targets -D warnings clean. LATEST_STATE entry in this commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WkNBjHc2e3zuyz9i8qJEv
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 71 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 0a57d860-7bf0-4b61-8ca9-a6636bb78d42

📥 Commits

Reviewing files that changed from the base of the PR and between 8615f13 and e86e8f5.

📒 Files selected for processing (1)
  • .claude/board/LATEST_STATE.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: a6fb4d08-b939-461d-b31d-97c585a7aef1

📥 Commits

Reviewing files that changed from the base of the PR and between e8388e9 and 8615f13.

📒 Files selected for processing (3)
  • .claude/board/LATEST_STATE.md
  • native/lgj-abi/src/exports.rs
  • native/lgj-abi/src/kernels.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The change adds a ternary SIMD mask wrapper and updates lgj_hop to combine class, source, and structured-edge masks in one AND3 pass. Documentation records the implementation, benchmarks, validation gates, and scope boundaries.

Changes

lgj_hop ternary-mask optimization

Layer / File(s) Summary
Ternary mask kernel wrapper
native/lgj-abi/src/kernels.rs
Adds simd_mask_ternlog_assign and re-exports ternlog for named truth-table operations.
lgj_hop selection update
native/lgj-abi/src/exports.rs, .claude/board/LATEST_STATE.md
Updates lgj_hop to combine three selection masks with one AND3 operation. Documents benchmarks, validation, and the separate Java ABI scope.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 8615f

This updates lgj_hop to combine its selection masks in one SIMD AND3 pass while retaining the existing scatter behavior. No current merge-blocking risk remains.

Suggested reviewers: claude

Poem

A rabbit hops through masks of three
One ternary pass runs swift and free
The kernels hum, the bits align
The scatter path keeps payloads fine
Benchmarks bloom beneath moonlight
And board notes mark the trail just right

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main lgj_hop change: one ternary-mask pass. It also accurately references the lane-read optimization discussed in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@cursor

cursor Bot commented Sep 4, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_52c2f617-eacb-4131-ad30-4d2f54aa3f31)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review September 4, 2026 21:34
…path-validation-170zcy

# Conflicts:
#	.claude/board/LATEST_STATE.md
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