Add hash-free seqno index tables to the Milnor algebra#270
Conversation
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
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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. ChangesSequence-number lookup
| 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
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
ext/crates/algebra/Cargo.tomlext/crates/algebra/benches/seqno.rsext/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
Splits the GPU-agnostic
seqnoindex 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
gtable, with no hash lookup.SeqnoTables+compute_seqno_tables(idempotent, concurrency-safe viaArcSwapOption::rcu) +seqno, applicable atp = 2with a trivial profile and stable ordering.benches/seqno.rs: an A/B of the table index against the basis hashmap (needs thecriterionharness 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_basisdoes not build them; this is documented attry_basis_element_to_index.Test plan
cargo test -p algebra—seqno_matches_enumeration_orderpassescargo bench --no-run -p algebra— theseqnobench compilesjust lint(nightly fmt + clippy,-D warnings)🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
New Features
Performance
Bug Fixes