Skip to content

Feat: added CuPy support to LinearOperator.eigs and LinearOperator.cond - #816

Open
mrava87 wants to merge 20 commits into
PyLops:devfrom
mrava87:feat-eigs_cupy
Open

mrava87 wants to merge 20 commits into
PyLops:devfrom
mrava87:feat-eigs_cupy

Conversation

@mrava87

@mrava87 mrava87 commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds support for CuPy in LinearOperator.eigs and LinearOperator.cond.

However, since not all methods in scipy are not available in cupy (eg scipy.sparse.linalg.eigs), and some input parameters are missing or have missing options (eg SM in cupyx.scipy.sparse.linalg.eigsh), a number of checks and error raises are required.

Moreover, some cupyx eigenvalue solvers seem to require self.ndim that scipy/cupy.LinearOperator define as self.ndim = len(self.shape) (not that the equivalent scipy eigenvalue solvers don't... to accommodate for it, every operator that used self.ndim internally (eg FFT) is now modified to use self.ndims so self.ndim can be defined for the base class and made available to all operators.

@mrava87 mrava87 self-assigned this Oct 9, 2026
@codacy-production

codacy-production Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@mrava87 mrava87 changed the title Feat: added CuPy support to LinearOperator.eigs Feat: added CuPy support to LinearOperator.eigs and LinearOperator.cond Oct 11, 2026
@mrava87
mrava87 marked this pull request as ready for review October 11, 2026 17:44
Comment thread pylops/linearoperator.py
Comment on lines +1073 to +1077
If ``backend="cupy"``, the eigenvalues of a square operator
can be computed only when in symmetric (``symmetric=True``),
since CuPy does not provide an equivalent
of :func:`scipy.sparse.linalg.eigs`. A
:obj:`NotImplementedError` is raised.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a cool paper to implement to get this to work without quadratic memory required by Arnoldi: https://arxiv.org/abs/2407.03208

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