Skip to main content

Differentiable eigenvalue decomposition with JAX (CPU/GPU)

Project description

Differentiable Generalized Eigenvalue Decomposition

Eigh Logo

Standalone implementation of differentiable eigenvalue decomposition with CPU (LAPACK) and GPU (cuSOLVER) backends. Extracted from pyscfad.

Features

  • Generalized Problems: A @ V = B @ V @ diag(W), etc.
  • JAX Integrated: Full support for jit, vmap, grad, and jvp.
  • High Performance: Optimized LAPACK (CPU) and cuSOLVER (GPU) kernels.
  • Precision: float32/64 and complex64/128.
  • Degeneracy Handling: Configurable deg_thresh for stable gradients.

Installation & Quick Start

# Install from source
pip install .

# For GPU support in this environment
pip install .[cuda-local]

Usage Example

import jax
import jax.numpy as jnp
from eigh import eigh

jax.config.update("jax_enable_x64", True)
A = jnp.array([[2., 1.], [1., 2.]])
w, v = eigh(A) # Standard
grad = jax.grad(lambda A: eigh(A)[0].sum())(A) # Differentiable

API Reference

  • eigh(a, b=None, *, lower=True, eigvals_only=False, type=1, deg_thresh=1e-9) Scipy-compatible interface. type supports 1: A@v=B@v@λ, 2: A@B@v=v@λ, 3: B@A@v=v@λ.
  • eigh_gen(a, b, *, lower=True, itype=1, deg_thresh=1e-9) Lower-level generalized solver.

Degenerate Eigenvalues & Gradients

Individual eigenvalue gradients are ill-defined for degenerate (repeated) eigenvalues. However, symmetric functions (like sum, var, trace) have stable gradients. The deg_thresh parameter (default 1e-9) masks divisions by near-zero gaps to maintain stability.

Development & Testing

  • Requirements: CMake 3.18+, C++17, JAX, NumPy, LAPACK/CUDA.
  • Tests:
    pytest tests/test_eigh.py     # Core functionality
    pytest tests/test_eigh_gen.py # Generalized itypes
    pytest tests/test_eigh_jit.py # JIT & vmap
    
  • GPU Setup:
    source setup_gpu_env_clean.sh
    ./run_gpu.sh python example_simple.py
    

License & Citation

Apache License 2.0. If used in research, please cite:

@software{pyscfad,
  author = {Zhang, Xing},
  title = {PySCFad: Automatic Differentiation for PySCF},
  url = {https://github.com/fishjojo/pyscfad},
  year = {2021-2025}
}

@software{sokolov2026eigh,
  title={Eigh: Differentiable eigenvalue decomposition with jax (cpu/gpu)},
  author={Sokolov, Igor},
  url={https://github.com/Brogis1/eigh},
  year={2026}
}

@article{sokolov2026xc,
  title = {Quantum-enhanced neural exchange-correlation functionals},
  author = {Sokolov, Igor O. and Both, Gert-Jan and Bochevarov, Art D. and Dub, Pavel A. and Levine, Daniel S. and Brown, Christopher T. and Acheche, Shaheen and Barkoutsos, Panagiotis Kl. and Elfving, Vincent E.},
  journal = {Phys. Rev. A},
  volume = {113},
  issue = {1},
  pages = {012427},
  numpages = {24},
  year = {2026},
  month = {Jan},
  publisher = {American Physical Society},
  doi = {10.1103/m51l-fys2},
  url = {https://link.aps.org/doi/10.1103/m51l-fys2}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eigh-0.1.1.tar.gz (286.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

eigh-0.1.1-cp313-cp313-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

eigh-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (58.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

eigh-0.1.1-cp313-cp313-macosx_10_15_x86_64.whl (61.8 kB view details)

Uploaded CPython 3.13macOS 10.15+ x86-64

eigh-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

eigh-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (58.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

eigh-0.1.1-cp312-cp312-macosx_10_15_x86_64.whl (61.8 kB view details)

Uploaded CPython 3.12macOS 10.15+ x86-64

eigh-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

eigh-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (58.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

eigh-0.1.1-cp311-cp311-macosx_10_15_x86_64.whl (62.2 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

eigh-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

eigh-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (58.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

eigh-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl (61.8 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

File details

Details for the file eigh-0.1.1.tar.gz.

File metadata

  • Download URL: eigh-0.1.1.tar.gz
  • Upload date:
  • Size: 286.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eigh-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ed4051538b72e6740dd7e6acb102e25af42768a50721ea405f5af17ac921efe5
MD5 97af5570535dfc3d0996b6477346feb2
BLAKE2b-256 8465a0dc5715712892b742526ff3ee660429ff896182c46548d8b3b22e2375dc

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91fd2b5234fb743245131cdb1bd18a97bee7ea336fe210121123aeb95162948b
MD5 df79ea5cb71e2b87c5cd77e88704a9d5
BLAKE2b-256 6954b3765db1ec2d6caae6ecee566b68eeb51bbb1742289a813abf7073fb1108

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48a0534cf8ef9dc11c61e2467e0b9e9606d516b9153820490b98720a2933fd76
MD5 62814e88dd8f57abbbae93b1106f7201
BLAKE2b-256 bd0a67f03a7047d3179d7bac9e6f486d025f1333771cb9fae2de804f402649a3

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp313-cp313-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 426c25138a64b3e9c996e6c74d143c175477216d383ed95c49e3d30194dd8473
MD5 601ec5e30c8d05528bd52cb27b7c2652
BLAKE2b-256 bf6dddec1df67095050c6106f33ac6eddafa40d8ea32317bd832e4f85db3e47f

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76fcab3f57cd83a23deb369bcea3019ba48d8902c51aa0d7573c07d95bccf586
MD5 9f269895afc9fea0e6e388ead309fa36
BLAKE2b-256 253e175acbc982fd159884f51f6207cb7ab238a9aa12b7fc77f4c517510248fd

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8162e05a20824f2d883ee90f6ad14c7730158af143692a6f380ae57f19455fd7
MD5 bfda2441722dcd5e54f8a1970eb90d8d
BLAKE2b-256 cf2798a4d0a8db15ead767c96fb5ce22cfdc3beddd2586fdc39e45a5a9e53514

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 88083d12ac4f052ac53113fcc5c151d7cb252573e02422cf143115c6bd2a1688
MD5 5d5830a29d695bec001ade2933d5dd99
BLAKE2b-256 1358a863a8e2cb49f6c0c5cd0b3e78a5ba7bd318050782b9cf4d7c8786a780d1

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a53c681d390fc984d6f98e69cc86ce86bbaf9cda23981882faf0447e129cc36
MD5 4ccd5fa42582fb1ffa8c7764d6072e2a
BLAKE2b-256 2ebdd20ea2cdafc725294e30436f3a919221892183f4aa5fe737e1e6cd93af54

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bab5668896648d38a4c477186b45c7b217463603000955ddd82c146d73d49c73
MD5 4bb23b73c76a93a5169bec911e53b363
BLAKE2b-256 c9435ca8002fcfb06c0152fa0b5cc8504a1f0e9ec33d77fd7c2e3189c085e92e

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9d818722ff2ea6276e908e02e2462ea8ea11bfefa48e1025f5a9bb03be63cc95
MD5 0cac3555e96568a0b7db98290b1b6b89
BLAKE2b-256 881651b6e486908de31ebb814a09ac1f2e1166dc3c966430e1ca52ffe39350f3

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 065919f050ab77a8bc5659efd72f8da43f9b4a1c97f0d68bfc10b992939d6c46
MD5 938d74a25f624538be21f6b4c935139d
BLAKE2b-256 e735575b883b1ac98780722ca2d789299e9b68ca43cccd3d049aeb503988e019

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7a3665aa75a835dd7fed1a6a915f4688843b915d6a39894c0e4fba5e1ce58f0
MD5 5c92c45989c0fb0440572b4b9e3a2542
BLAKE2b-256 3fd18100482312e999cc5490007c5d1fb2c9afb2a3ba0214dfc6901175b6c12c

See more details on using hashes here.

File details

Details for the file eigh-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for eigh-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9d65d1b2771cab724f65b80d05cff4e4641307b0518931c41a05bfb3ec73a233
MD5 2935dc44eea56b68509bc41831cb141b
BLAKE2b-256 c3fface872b3cc4ef5ef930615c4549d6b1437bb8a8600a2d74bd4026737f926

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page