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.2.tar.gz (286.5 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.2-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.2-cp313-cp313-macosx_11_0_arm64.whl (58.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.15+ x86-64

eigh-0.1.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (58.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.15+ x86-64

eigh-0.1.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (58.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.15+ x86-64

eigh-0.1.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (58.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

eigh-0.1.2-cp310-cp310-macosx_10_15_x86_64.whl (61.9 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: eigh-0.1.2.tar.gz
  • Upload date:
  • Size: 286.5 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.2.tar.gz
Algorithm Hash digest
SHA256 a7aee4da2e700f9252a9ba5fb15fd619a68be6281f324863b6ddf6ae780ee9c3
MD5 42da25827d8b33fe376f03e3e481b0ef
BLAKE2b-256 e668a78687906fc65200e6920764118ca36fa3e71d7cc026ccb5d8e943579dda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ecb4bd5a512558b34157ae9fef2813d43a540e706ccbb477ce5b54f5aefa63f7
MD5 baff752e10c4857719197110c7b0c41c
BLAKE2b-256 071be6fbe3d73bef2d98575af00bc63e9a5689139648507b6e6b8cd626a8aa6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 91e1ea55202510793587de47b458a2cc7399854c327b9c121aa233738495c23d
MD5 6caae10c01b77028071fb0e1e2552554
BLAKE2b-256 98057c585c26edfd7c76ab99f6bd2e14237de2132c12a5f03f7280bc87f87e22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1cc75e1159363cdf2bc134fbe6c763ada72c1208c9952ba4636fb44e824a3c74
MD5 aae37d703cccea342b1249d0e126e358
BLAKE2b-256 249eee18f565fa4d75a8824a4b9cee4422b072246eade0b0cc64ddf294faf08c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b99198d1301d823be386a86a91764712beae76b91b1382f27a90b93074b46d12
MD5 8f7b85567e61fd9126aa2df6640cc15e
BLAKE2b-256 47a19a36379e1968360e0af271772310fcc73e4f5a7df157c358aee261761627

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8edac4534accc1d289b2069f03a88442b4fc7c820a2f8267eb9f768ce3656864
MD5 6a0966fdc6b245e6e127258fd0cd331f
BLAKE2b-256 c00b3ad576eeeb39e5dabbab0f10b7f3fb7247f136c4b5b0a8baa944a6ff8a04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 041abfc60834d39f1757748a537d55ddc0ba12bc19d947d93b49d170361a8a51
MD5 714f9bfa52f2faf3ba8d6b33336097c6
BLAKE2b-256 7756c3be5fe20fecd0fec03bf683077e23e90fc5694c9ae2f1a82661d9b56290

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 01d012b3b7434c08bd1a874635f77439dc9d93c6ea2b416a04ea4906d3458cd5
MD5 e9856ca71695460dd371681bfa52c654
BLAKE2b-256 8fe0cbe299f65d2ba361f75502991924a4e243b61fd6fadc834b3e766b9ae63f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16bdfc372ff4c473cb6761cbcb5eb4670a5b80848d2bdbb797cf64d29577a3e6
MD5 a4b80fc25f1edf2a8da478a856c60405
BLAKE2b-256 bb7f6c673e03c9544b158a7efdf4b2a026870c78530a92899a79f082108210f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 37542339bc3b6e6742c16e9f81c124537dd9c39ca16ef130376b8dc942c3ce69
MD5 22a0a2312096d8e102a45ba5ef5e5e27
BLAKE2b-256 4a147c337035858d7aac00512bbe77eb36313ccdb4e1f4fd28484988febeff21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 892f8c02eb7aee45617b1c25de01161f82db7b763b6bc641bb3a709b0eb58ed9
MD5 315530d899583d97ea2f72bc5551dc85
BLAKE2b-256 56d46e60bfcdc017a4a7395d215aa5f7514af3715ba19de215d4618dbe916012

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 285d4883d1013c1506c6cf9b4185c723f241296436cfb78626f4b08c92dd8462
MD5 9722a0e005378a076a804513dfbad24c
BLAKE2b-256 cb833368bddc0706686a0a104853f90777431b8956955a554c841c4f242c63fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eigh-0.1.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 472f94901fefd6be61e0c3b9181006a4bb7c19ad0124c5e8ac34e23fc223eaa9
MD5 2dc2f201abae82e27400ff1b0ba57d0c
BLAKE2b-256 2f3d59422a1b370f2185c6aa96093099a5c93f7c747e063b1b9bc709d176c205

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