Skip to content

Implement dual ridge regression for Allen2022#2383

Merged
KartikP merged 4 commits into
masterfrom
kp/dual-ridge-minimal
May 26, 2026
Merged

Implement dual ridge regression for Allen2022#2383
KartikP merged 4 commits into
masterfrom
kp/dual-ridge-minimal

Conversation

@KartikP
Copy link
Copy Markdown
Collaborator

@KartikP KartikP commented May 8, 2026

Minimal version of #2364

Near identical scores for Allen2022 from V1 --> V4 (tolerance of 0.005). Had to bump tolerance for IT (tolerance of 0.01).

Ridge and RidgeCV regression now use the dual kernel form when n_samples < n_features. This is common in Brain-Score which there are only hundreds of stimuli but thousands to hundreds of thousands of model features. This avoids materializing the coefficient matrix (n_features, n_targets) which can produce OOM for large models on fMRI benchmarks.

This PR adds DualRidgeRegression and DualRidgeCVRegression in the metrics/regression_correlation/metric.py.

Instead of solving for the full weight matrix, we precompute a small project matrix and apply it to the neural target in chunks.

This PR effectively reduces a coefficient matrix for ViT-L at 148k features on Allen2022 at 52k neuroids stored at 8 bytes from 62GB down to ~1MB.

@KartikP KartikP merged commit da14952 into master May 26, 2026
11 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.

1 participant