Skip to content

simd: PowerSums::checked_merge + CrossPowerSums fold; CovHighD::from_symmetric_fn - #338

Merged
AdaWorldAPI merged 3 commits into
masterfrom
ccr-1d39fce9-gdgy6k
Oct 4, 2026
Merged

AdaWorldAPI merged 3 commits into
masterfrom
ccr-1d39fce9-gdgy6k

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • PowerSums::checked_merge: combine per-chunk power sums exactly; refuses (returns None) instead of wrapping.
  • CrossPowerSums { n, Σx, Σy, Σx², Σy², Σxy } and masked_group_cross_power_sums_i32{,_via,_pair} on the existing visitor walker, re-exported from simd.
  • pillar::cov_high_d: CovHighD::from_symmetric_fn, public get, and a sandwich test with a non-identity M.

Consumed by lance-graph branch ccr-1d39fce9-gdgy6k (mask-risc grouped moments / cross moments terminals, jc ANOVA / Pearson / OLS from moments, perturbation-sim angle covariance). That PR depends on this one.

Tests

  • Chunked merge equals the one-pass result; a merge past the width bound refuses.
  • Cross moments across key forms (lane / via / pair) agree with a reference fold.
  • Sandwich test against a non-identity matrix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X1YcYMRSFvfczXoP748wtB


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added tools for constructing and reading symmetric covariance matrices.
    • Added grouped analysis of paired values, including counts, individual totals, squared totals, and cross-products. Results can be combined safely, with overflow reported rather than silently accepted.
    • Added access to these paired-value calculations through the SIMD masking interface.
  • Bug Fixes
    • Improved validation coverage for covariance calculations and grouped statistics, including overflow handling and mismatched input lanes.

… wrapping

The keyed fold wraps, as the whole family does. A caller that tiles a
population and combines the per-tile results needs the opposite: exact
addition that refuses past the documented 2^32-rows-per-group bound.
Each field is checked independently.

Tests: two-chunk merge equals the one-pass fold at word, mid-word and
end splits in both orders; three-way associativity; per-field refusal.

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

CrossPowerSums is the bivariate sibling of PowerSums: same widths for the
marginals (u128 square sums), plus a signed i128 Σxy. x()/y() return the
marginals exactly as the univariate fold produces them; checked_merge
combines chunks without wrapping. masked_group_cross_power_sums_i32 with
_via / _pair share one fold, as the power-sum family does.

Tests: i128/u128 longhand oracle on resident and VIA keys at three mask
densities, marginals equal the univariate fold (resident and pair),
chunk merges in both orders, exactness at the i32 extremes, per-field
merge refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1YcYMRSFvfczXoP748wtB
…n-identity M

CovHighD had no public way to be built from data (only identity() and
the private zero()), so a consumer could not push a real covariance
through sandwich without re-spelling the packed lower-triangle index.
from_symmetric_fn reads the lower triangle once; get is made public.

Every existing sandwich test used M = I, where a transposed or
mis-indexed product is invisible. Adds a dense M·Σ·M triple-product
check for a non-identity symmetric M.

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

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
CLAUDE.md — auto-discovered

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: 28c60a37-484d-45f2-837e-63f4013d02b9
📥 Commits

Reviewing files that changed from the base of the PR and between 9e4249d and a62add4.

📒 Files selected for processing (3)
  • src/hpc/pillar/cov_high_d.rs
  • src/simd.rs
  • src/simd_masking_ops.rs

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

The changes add symmetric covariance construction and public lookup, checked merging for power statistics, and masked grouped cross-power-sum operations for three key formats.

Changes

Symmetric covariance

Layer / File(s) Summary
Symmetric access and construction
src/hpc/pillar/cov_high_d.rs
CovHighD::get is public. from_symmetric_fn fills the lower triangle and uses symmetry for other reads. Tests cover the constructor and a dense reference for sandwich.

Masked grouped cross-power sums

Layer / File(s) Summary
Statistic types and checked merging
src/simd_masking_ops.rs
PowerSums and CrossPowerSums gain checked merging. CrossPowerSums exposes its x and y marginals as PowerSums. Tests cover chunk merging and overflow handling.
Joint folds and validation
src/simd_masking_ops.rs, src/simd.rs
Resident-key, indirect-key, and composite-key folds accumulate joint statistics. The SIMD facade exports the new operations and type. Tests compare results with wide references and univariate folds, and cover merging, extreme values, and mismatched lane lengths.

Priority: ⬇️ Low

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

Change: Feature

Suggested reviewers: claude

Merge Risk: ⚪ Minimal · up to a62ad

No identified issue blocks merging after normal checks.

🚥 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 names the checked merge, cross-power-sum fold, and symmetric covariance constructor added by the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 96.55% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 3 files.
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
  • 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.


A rabbit checks the sums at dawn
Two lanes hop where masks are drawn
The lower cells reflect their twin
Checked merges keep overflow out
Three key paths bring the tallies home
The rabbit thumps: the tests all roam

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

@cursor

cursor Bot commented Oct 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: 980b58a8-09c4-4835-ab8e-5eeed85564f4)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 4, 2026 17:56
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Autopilot could not be updated. Open Coding to check access and billing.

@AdaWorldAPI
AdaWorldAPI merged commit b574841 into master Oct 4, 2026
27 checks passed
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