Skip to content

Add hash-free seqno index tables to the Milnor algebra#270

Open
JoeyBF wants to merge 2 commits into
SpectralSequences:masterfrom
JoeyBF:claude/milnor-seqno-index
Open

Add hash-free seqno index tables to the Milnor algebra#270
JoeyBF wants to merge 2 commits into
SpectralSequences:masterfrom
JoeyBF:claude/milnor-seqno-index

Conversation

@JoeyBF

@JoeyBF JoeyBF commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Splits the GPU-agnostic seqno index out of the Nassau GPU work (#264) so it can land on its own. Second of three; follows the benchmark split (#269).

What

A flat, arc-swapped hash-free index for the Milnor basis: an O(number of p-part entries) rank computed from a precomputed g table, with no hash lookup.

  • SeqnoTables + compute_seqno_tables (idempotent, concurrency-safe via ArcSwapOption::rcu) + seqno, applicable at p = 2 with a trivial profile and stable ordering.
  • benches/seqno.rs: an A/B of the table index against the basis hashmap (needs the criterion harness from Migrate the algebra benchmark suite to criterion #269).

Notes

This is general infrastructure, independent of the GPU backend — it's the uploadable/on-device index primitive and an independently benchmarkable alternative to the basis hashmap. The CPU basis index deliberately still uses the hashmap (the tables lose to it on the CPU), and compute_basis does not build them; this is documented at try_basis_element_to_index.

Test plan

  • cargo test -p algebraseqno_matches_enumeration_order passes
  • cargo bench --no-run -p algebra — the seqno bench compiles
  • just lint (nightly fmt + clippy, -D warnings)

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added faster sequence-number lookups for supported Milnor algebra cases.
    • Added on-demand table generation for sequence-number calculations.
  • Performance

    • Improved basis index calculation by enabling hash-free lookup paths.
    • Added benchmarks comparing sequence-number and hashmap-based lookups.
  • Bug Fixes

    • Added validation that sequence-number results match basis enumeration order.

Add a flat, arc-swapped `seqno` index for the Milnor basis: an
O(#p-part-entries) rank computed from a precomputed `g` table, with no
hash lookup. This is a general (GPU-agnostic) data structure — it is the
uploadable/on-device index primitive, and an independently benchmarkable
alternative to the basis hashmap.

- `SeqnoTables` + `compute_seqno_tables` (idempotent, concurrency-safe
  via `ArcSwapOption::rcu`) + `seqno` in `milnor_algebra.rs`, applicable
  at p = 2 with a trivial profile and stable ordering.
- The CPU basis index deliberately still uses the hashmap (the tables lose
  to it on the CPU); `compute_basis` does not build them. Documented at
  `try_basis_element_to_index`.
- `benches/seqno.rs`: A/B of the table index against the hashmap.
- Covered by the `seqno_matches_enumeration_order` test.

Split out of the Nassau GPU work as standalone infrastructure.

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

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@JoeyBF, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bc53080d-8868-4e3d-a157-28cfc1cfd9e3

📥 Commits

Reviewing files that changed from the base of the PR and between e41c769 and 5c4f429.

📒 Files selected for processing (1)
  • ext/crates/algebra/src/algebra/milnor_algebra.rs
📝 Walkthrough

Walkthrough

The algebra crate adds cached, hash-free sequence-number ranking for applicable Milnor algebras, validates it against enumeration order, and introduces a Criterion benchmark comparing it with hashmap-based lookup.

Changes

Sequence-number lookup

Layer / File(s) Summary
Sequence-number table storage and eligibility
ext/crates/algebra/src/algebra/milnor_algebra.rs
MilnorAlgebra stores optional ArcSwap-backed tables, initializes them, documents lookup behavior, and defines applicability conditions.
Table construction and ranking
ext/crates/algebra/src/algebra/milnor_algebra.rs
Tables are computed and atomically extended, seqno ranks basis elements from p_part, and a unit test compares results with enumeration order.
Lookup benchmark integration
ext/crates/algebra/Cargo.toml, ext/crates/algebra/benches/seqno.rs
A Criterion benchmark target compares hashmap and table lookups across configured degrees.

|

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Benchmark
  participant MilnorAlgebra
  participant SeqnoTables
  Benchmark->>MilnorAlgebra: compute_basis()
  Benchmark->>MilnorAlgebra: compute_seqno_tables(max_degree)
  MilnorAlgebra->>SeqnoTables: publish cached table
  Benchmark->>MilnorAlgebra: basis_element_to_index(element)
  Benchmark->>MilnorAlgebra: seqno(element.p_part)
  MilnorAlgebra-->>Benchmark: return lookup index
Loading

Possibly related PRs

Poem

I’m a rabbit with ranks in a table so neat,
Hashes hop aside for a lookup fleet.
The degrees all sparkle, the benchmarks run,
While seqno counts softly beneath the sun.
Squeak—cached indices, a burrow well done!

🚥 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 summarizes the main change: adding hash-free seqno index tables to the Milnor algebra.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests

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

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

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ext/crates/algebra/src/algebra/milnor_algebra.rs`:
- Around line 1941-1958: The test seqno_matches_enumeration_order only validates
a single compute_seqno_tables call. Extend coverage by invoking
compute_seqno_tables again with a larger max_degree and rechecking seqno
correctness, and add concurrent callers if practical to exercise the monotonic,
non-shrinking publication behavior documented for compute_seqno_tables.
- Around line 1006-1026: Update seqno to add a debug_assert before indexing t.g,
validating that cur_d is within the loaded table’s max_degree (and preserving
the existing table-not-built diagnostic). Ensure the assertion identifies the
requested degree and table capacity so stale or partially built seqno tables
fail with a clear diagnostic rather than a raw Vec bounds panic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 61e89921-4801-4d53-b8e0-c3229727be50

📥 Commits

Reviewing files that changed from the base of the PR and between 4867b30 and e41c769.

📒 Files selected for processing (3)
  • ext/crates/algebra/Cargo.toml
  • ext/crates/algebra/benches/seqno.rs
  • ext/crates/algebra/src/algebra/milnor_algebra.rs

Comment thread ext/crates/algebra/src/algebra/milnor_algebra.rs
Comment thread ext/crates/algebra/src/algebra/milnor_algebra.rs
- `seqno`: add a `debug_assert` that the element's degree is within the loaded
  table's `max_degree`, so a not-built-far-enough call fails with a clear
  diagnostic instead of a raw slice out-of-bounds panic.
- `seqno_matches_enumeration_order`: build the tables partially, rebuild
  identically (no-op), grow, then request a smaller degree — exercising the
  idempotent, monotonic (non-shrinking) publish documented on
  `compute_seqno_tables`, not just a single build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UPYvsLdEfitgCbAiPxxx3U
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