Repository navigation
ENH Ridge: support solver="cholesky" for array API inputs - #35418
Merged
OmarManzoor merged 13 commits intoNov 20, 2026
Merged
Conversation
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
cakedev0
commented
Nov 16, 2026
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Member
|
I launched the Intel GPU workflow here: EDIT: it's green \o/ |
solver="cholesky" for array API inputs
ogrisel
reviewed
Nov 16, 2026
This was referenced Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he solver Co-Authored-By: Claude Opus 5.5 <[email protected]>
ogrisel
approved these changes
Nov 19, 2026
Member
There was a problem hiding this comment.
LGTM.
@lorentzenchr I think _solve_spd might be helpful to add array API support to newton-cholesky on GLMs in a follow-up.
Member
|
BTW, I tried on Apple M4 with PyTorch:
|
OmarManzoor
approved these changes
Nov 20, 2026
Member
Author
|
Cool to have it for the release!! 🎉 |
Member
|
@cakedev0 looking forward to see the updated benchmark dashboards. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Implements option B of #35060
What does this implement/fix? Explain your changes.
Ridge(solver="cholesky")now works with array API inputs, andsolver="auto"resolves to"cholesky"for them, like for NumPy inputs (the warning about"svd"is gone).X.T @ X, orX @ X.Twhenn_features > n_samples) and the solve both stay on the device. The solve usesxp.linalg.solve, so a LU decomposition.alphais added to the diagonal in place withA[idx, idx] += alphawhen the namespace supports it (torch, cupy, dpnp). This is not in the array API. The alternative (and fallback) isA += alpha * xp.eye(n)and I don't like making memory allocation, so I made this fast-path to avoid it. WDYT?Ridgefalls back to the SVD solver. Namespaces signal a singular matrix differently (torch and dpnp raise their ownLinAlgError, cupy returns non-finite values), so_solve_spdturns the three cases into a private exception caught in_ridge_regression.AI usage disclosure
Code and tests generated by Claude Code, reviewed by me (not for the tests yet).
Benchmarks
In float32 the speed-up compared to CPU is really nice (except on MPS): NVIDIA L4 & Intel Arc B580: 3.5x to 15x faster (and tremendously faster than the SVD solver).
On a MacBook M2 (MPS) it is also faster than the SVD solver but not faster than NumPy Cholesky (the 10 s for 5,000 x 40,000 comes from a known torch slowdown on M1/M2: since torch 2.14, MPS matmuls with an inner dimension above 32,768 use a slower kernel for correctness, see pytorch/pytorch#198182).
In float64, it's not much faster than CPU.
Full tables:
Fit times in seconds,
Ridge(alpha=1.0), one target, standard normal data, best of 3 after a warmup. "xp svd" is what array API inputs get on main. The NumPy column runs on the CPU of the same machine.float32
float64 (not run on the M2: MPS has no float64)