Linear solvers and eigendecomposition for AWS Trainium via NKI
Project description
trnsolver
Linear solvers and eigendecomposition for AWS Trainium via NKI.
Eigenvalue problems, matrix factorizations, and iterative solvers for scientific computing on Trainium. The Jacobi eigensolver is the primary NKI acceleration target — each Givens rotation maps to a 2-row matmul on the Tensor Engine.
Part of the trnsci scientific computing suite (github.com/trnsci).
Install
pip install trnsolver
# With Neuron hardware support
pip install trnsolver[neuron]
Usage
import torch
import trnsolver
# Symmetric eigenvalue decomposition (Jacobi on NKI)
eigenvalues, eigenvectors = trnsolver.eigh(A)
# Generalized eigenproblem: A x = λ B x (the SCF problem)
eigenvalues, eigenvectors = trnsolver.eigh_generalized(F, S)
# Factorizations
L = trnsolver.cholesky(A)
P, L, U = trnsolver.lu(A)
Q, R = trnsolver.qr(A)
# Direct solvers
x = trnsolver.solve(A, b)
x = trnsolver.solve_spd(A, b) # Cholesky-based (faster for SPD)
A_inv_sqrt = trnsolver.inv_sqrt_spd(A) # A^{-1/2} for density fitting
# Iterative solvers
x, iters, residual = trnsolver.cg(A, b, tol=1e-8)
x, iters, residual = trnsolver.gmres(A, b, tol=1e-6)
SCF Example
python examples/scf_eigen.py --demo
python examples/scf_eigen.py --nbasis 50 --nocc 10
Demonstrates the self-consistent field iteration: build Fock matrix → solve generalized eigenproblem FC = SCε → build density → check convergence.
Operations
| Category | Operation | Description |
|---|---|---|
| Eigen | eigh |
Symmetric eigendecomposition (Jacobi / torch) |
| Eigen | eigh_generalized |
Generalized: Ax = λBx via Cholesky reduction |
| Factor | cholesky |
A = LL^T |
| Factor | lu |
PA = LU |
| Factor | qr |
A = QR |
| Solve | solve |
Ax = b (LU-based) |
| Solve | solve_spd |
Ax = b (Cholesky, A is SPD) |
| Solve | inv_spd |
A^{-1} for SPD A |
| Solve | inv_sqrt_spd |
A^{-1/2} for density fitting metric |
| Iterative | cg |
Conjugate Gradient (SPD systems) |
| Iterative | gmres |
GMRES (general systems) |
Status
- Jacobi eigensolver with PyTorch backend
- Generalized eigenvalue problem (Cholesky reduction)
- Cholesky, LU, QR factorizations
- Direct and SPD solvers
- CG and GMRES iterative solvers
- SCF example (quantum chemistry use case)
- NKI Jacobi rotation kernel validation
- Newton-Schulz A^{-1/2} via trnblas GEMM
- Benchmarks vs LAPACK/cuSOLVER
Related Projects
| Project | What |
|---|---|
| trnfft | FFT + complex ops |
| trnblas | BLAS operations |
| trnsolver | This repo |
License
Apache 2.0 — Copyright 2026 Scott Friedman
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trnsolver-0.3.0.tar.gz.
File metadata
- Download URL: trnsolver-0.3.0.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c641c3e6458d0175f179f9a1a63da8f5a03d49772f6444f786a89cec08b9ba1c
|
|
| MD5 |
cbc10fcef4c86cd6cc242096c08d3d71
|
|
| BLAKE2b-256 |
67bbc812189c675add3148b6ed14cd1af016d1b1af528cedaf476a370e7408b9
|
Provenance
The following attestation bundles were made for trnsolver-0.3.0.tar.gz:
Publisher:
publish.yml on trnsci/trnsolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trnsolver-0.3.0.tar.gz -
Subject digest:
c641c3e6458d0175f179f9a1a63da8f5a03d49772f6444f786a89cec08b9ba1c - Sigstore transparency entry: 1282495358
- Sigstore integration time:
-
Permalink:
trnsci/trnsolver@0480753af67ebe163eaac08a13a14235f8b9abc3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/trnsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0480753af67ebe163eaac08a13a14235f8b9abc3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file trnsolver-0.3.0-py3-none-any.whl.
File metadata
- Download URL: trnsolver-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc9e6ccf823552cc6095a0e56e7cbed6862667938e41e63aad273c2f45d12750
|
|
| MD5 |
4883c797f14119c8d844bbc6cd538c71
|
|
| BLAKE2b-256 |
716a794a0031606be0c9f1d76de8aa5f30908d208e9d67e051a1a18e823f5b26
|
Provenance
The following attestation bundles were made for trnsolver-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on trnsci/trnsolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trnsolver-0.3.0-py3-none-any.whl -
Subject digest:
dc9e6ccf823552cc6095a0e56e7cbed6862667938e41e63aad273c2f45d12750 - Sigstore transparency entry: 1282495398
- Sigstore integration time:
-
Permalink:
trnsci/trnsolver@0480753af67ebe163eaac08a13a14235f8b9abc3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/trnsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0480753af67ebe163eaac08a13a14235f8b9abc3 -
Trigger Event:
release
-
Statement type: