Skip to main content

Logo Linear Operators for Curvature Matrices in PyTorch

Python 3.10+ tests Coveralls

This library provides linear operators---a unified interface for matrix-free computation---for deep learning curvature matrices in PyTorch. curvlinops is inspired by SciPy's sparse.linalg.LinearOperator interface and implements a PyTorch version.

You can read our position paper to know more about why combining linear operators with curvature matrices might be a good idea.

Main features:

  • Broad support of curvature matrices. curvlinops supports many common curvature matrices and approximations thereof, such as the Hessian, Fisher, generalized Gauss-Newton, and K-FAC (overview, visual tour).

  • Unified interface. All linear operators share the same interface, making it easy to switch between curvature matrices.

  • Purely PyTorch. All computations can run on a GPU.

  • SciPy export. You can export a curvlinops linear operator to a SciPy LinearOperator with .to_scipy(). This allows plugging it into scipy, while carrying out the heavy lifting (matrix-vector multiplies) in PyTorch on GPU. My favorite example is scipy.sparse.linalg.eigsh that lets you compute a subset of eigen-pairs (example).

  • Randomized estimation algorithms. curvlinops offers functionality to estimate properties the matrix represented by a linear operators, like its spectral density (example), inverse (example), trace & diagonal (example).

Installation

pip install curvlinops-for-pytorch

Useful Links

Citation

If you find curvlinops useful for your work, consider citing our position paper

@article{dangel2025position,
  title =        {Position: Curvature Matrices Should Be Democratized via Linear
                  Operators},
  author =       {Dangel, Felix and Eschenhagen, Runa and Ormaniec, Weronika and
                  Fernandez, Andres and Tatzel, Lukas and Kristiadi, Agustinus},
  journal =      {arXiv 2501.19183},
  year =         2025,
}

Future ideas

  • Refactor the back-end for curvature-matrix multiplication into pure functions to improve recycle-ability and ease the use of torch.compile.

  • Multi-GPU support.

  • Include more curvature matrices

Logo mage credits

Metadata

Release files for curvlinops-for-pytorch 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for curvlinops-for-pytorch 3.0.1
File Size Uploaded Provenance Actions
curvlinops_for_pytorch-3.0.1.tar.gz 2.0 MB Without provenance Details for curvlinops_for_pytorch-3.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for curvlinops-for-pytorch 3.0.1
File Interpreter ABI Platform Actions
curvlinops_for_pytorch-3.0.1-py3-none-any.whl Python 3 none any Details for curvlinops_for_pytorch-3.0.1-py3-none-any.whl

Total release size: 2.1 MB

Release files / curvlinops_for_pytorch-3.0.1.tar.gz

Download URL curvlinops_for_pytorch-3.0.1.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
916dd1f1a145d2fed062fcbbcc860561164bbe28b3e02174f8c7d78a006f54a7
BLAKE2b-256 checksum
How to use checksums
89bfd6af0f519f0918c3b8b3558a1987bc401a02fcfc2599a1b2b602f89c8b90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / curvlinops_for_pytorch-3.0.1-py3-none-any.whl

Download URL curvlinops_for_pytorch-3.0.1-py3-none-any.whl
Size 89.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b9adcc31fb65614bf3ba95afdf353a18fa14e150927721b9526a4f626d87d8e
BLAKE2b-256 checksum
How to use checksums
e46a53874c03fd9a5aa2aa2b73d9f67aaa17e3571f62bddc26565d8b6c89d2ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for curvlinops-for-pytorch 3.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page