fermix 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fermix-0.1.0/LICENSE +21 -0
- fermix-0.1.0/PKG-INFO +99 -0
- fermix-0.1.0/README.md +69 -0
- fermix-0.1.0/pyproject.toml +51 -0
- fermix-0.1.0/setup.cfg +4 -0
- fermix-0.1.0/src/fermix/__init__.py +10 -0
- fermix-0.1.0/src/fermix/_common.py +694 -0
- fermix-0.1.0/src/fermix/_diff.py +333 -0
- fermix-0.1.0/src/fermix/_fallback.py +300 -0
- fermix-0.1.0/src/fermix/_field.py +416 -0
- fermix-0.1.0/src/fermix/_inverse.py +531 -0
- fermix-0.1.0/src/fermix/_lu.py +621 -0
- fermix-0.1.0/src/fermix/_pf.py +570 -0
- fermix-0.1.0/src/fermix/_pfinv.py +269 -0
- fermix-0.1.0/src/fermix/_poly.py +71 -0
- fermix-0.1.0/src/fermix/api.py +230 -0
- fermix-0.1.0/src/fermix.egg-info/PKG-INFO +99 -0
- fermix-0.1.0/src/fermix.egg-info/SOURCES.txt +20 -0
- fermix-0.1.0/src/fermix.egg-info/dependency_links.txt +1 -0
- fermix-0.1.0/src/fermix.egg-info/requires.txt +10 -0
- fermix-0.1.0/src/fermix.egg-info/top_level.txt +1 -0
- fermix-0.1.0/tests/test_fermix.py +762 -0
fermix-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ao Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fermix-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fermix
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast batched real and complex determinants and Pfaffians on GPU with JAX/Pallas kernels, with singular-safe gradients
|
|
5
|
+
Author-email: Ao Chen <aochen@caltech.edu>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ChenAo-Phys/fermix
|
|
8
|
+
Project-URL: Repository, https://github.com/ChenAo-Phys/fermix
|
|
9
|
+
Project-URL: Issues, https://github.com/ChenAo-Phys/fermix/issues
|
|
10
|
+
Keywords: jax,pallas,determinant,pfaffian,gpu,variational monte carlo
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: jax>=0.7.1
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: pytest; extra == "test"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Requires-Dist: black; extra == "dev"
|
|
28
|
+
Requires-Dist: pyright; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
<h1 align='center'>fermix</h1>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<strong>Fast batched determinants and Pfaffians in JAX</strong>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
Fermix supports `slogdet` / `slogpf` / `det` / `pf` for float32, float64, complex64, and complex128 matrices on NVIDIA GPUs, written in JAX with Pallas (Triton) kernels. The codes are generated by Claude Code.
|
|
38
|
+
|
|
39
|
+
Designed for quantum Monte Carlo in fermionic systems: a large batch of moderate-size matrices (n ~ 32-8192), forward and backward.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
Requires jax >= 0.7.1
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install fermix
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import jax, jax.numpy as jnp
|
|
53
|
+
from fermix import slogdet, slogpf, det, pf
|
|
54
|
+
|
|
55
|
+
A = jax.random.normal(jax.random.key(0), (4096, 128, 128), jnp.float32)
|
|
56
|
+
sign, logabs = slogdet(A) # like jnp.linalg.slogdet, but faster
|
|
57
|
+
S = A - jnp.swapaxes(A, -1, -2)
|
|
58
|
+
sign, logabs = slogpf(S) # Pfaffian of the skew-symmetric batch
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Simply replace `slogdet` / `slogpf` / `det` / `pf` in your program by the functions in `fermix`.
|
|
62
|
+
|
|
63
|
+
All functions accept any leading batch dimensions, any matrix size, the four dtypes float32 / float64 / complex64 / complex128
|
|
64
|
+
(the 64-bit ones need `jax_enable_x64`), and are `jit`/`vmap`/`grad`/`jvp` compatible. Conventions follow `jnp.linalg.slogdet`.
|
|
65
|
+
|
|
66
|
+
## Performance
|
|
67
|
+
|
|
68
|
+
Forward time per matrix on one H200 GPU against `jnp.linalg.slogdet` and a naive batched Parlett–Reid `slogpf` written in
|
|
69
|
+
jax.numpy (the generic fallback path). The time costs of `det` and `pf` are similar.
|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
## Notes and limits
|
|
76
|
+
|
|
77
|
+
- Without a CUDA GPU the call emits a `FermixFallbackWarning` and runs a much slower generic jax.numpy path;
|
|
78
|
+
dtypes other than the four supported ones raise `TypeError`.
|
|
79
|
+
- Launch parameters are tuned per GPU architecture and dtype (`fermix._common.TUNES`); only the A100-80GB and the H200 have measured tables, other GPUs use the closest one.
|
|
80
|
+
- `prec` selects the block-GEMM algorithm: `"tf32x3"` (default, tensor cores at fp32-level accuracy) or `"ieee"`
|
|
81
|
+
(exact fp32, ~5 % slower); the 64-bit dtypes always run IEEE fp64.
|
|
82
|
+
- Complex matrices are stored as separate real and imaginary arrays (Triton has no complex type), so they move
|
|
83
|
+
twice the bytes and do four real products per complex one.
|
|
84
|
+
- Memory: two (B, n, n) work buffers for the forward and about five more for the gradient.
|
|
85
|
+
- Compile time is a few seconds per shape and dtype up to n ~ 1024 and tens of seconds to minutes for n in the thousands; JAX's persistent compilation cache (`jax_compilation_cache_dir`) makes it a one-off.
|
|
86
|
+
- `det` and `pf` overflow the 32-bit dtypes for large or badly scaled matrices, and so do their gradients; use `slogdet` and `slogpf` there.
|
|
87
|
+
- Singular inputs are safe: the forward gives (0, −inf) and the gradients stay finite, never NaN.
|
|
88
|
+
|
|
89
|
+
## Citation
|
|
90
|
+
|
|
91
|
+
```bibtex
|
|
92
|
+
@software{fermix,
|
|
93
|
+
author = {Chen, Ao},
|
|
94
|
+
title = {{fermix}: Fast batched determinants and Pfaffians in {JAX}},
|
|
95
|
+
year = {2026},
|
|
96
|
+
version = {0.1.0},
|
|
97
|
+
url = {https://github.com/ChenAo-Phys/fermix}
|
|
98
|
+
}
|
|
99
|
+
```
|
fermix-0.1.0/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<h1 align='center'>fermix</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Fast batched determinants and Pfaffians in JAX</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
Fermix supports `slogdet` / `slogpf` / `det` / `pf` for float32, float64, complex64, and complex128 matrices on NVIDIA GPUs, written in JAX with Pallas (Triton) kernels. The codes are generated by Claude Code.
|
|
8
|
+
|
|
9
|
+
Designed for quantum Monte Carlo in fermionic systems: a large batch of moderate-size matrices (n ~ 32-8192), forward and backward.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Requires jax >= 0.7.1
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install fermix
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import jax, jax.numpy as jnp
|
|
23
|
+
from fermix import slogdet, slogpf, det, pf
|
|
24
|
+
|
|
25
|
+
A = jax.random.normal(jax.random.key(0), (4096, 128, 128), jnp.float32)
|
|
26
|
+
sign, logabs = slogdet(A) # like jnp.linalg.slogdet, but faster
|
|
27
|
+
S = A - jnp.swapaxes(A, -1, -2)
|
|
28
|
+
sign, logabs = slogpf(S) # Pfaffian of the skew-symmetric batch
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Simply replace `slogdet` / `slogpf` / `det` / `pf` in your program by the functions in `fermix`.
|
|
32
|
+
|
|
33
|
+
All functions accept any leading batch dimensions, any matrix size, the four dtypes float32 / float64 / complex64 / complex128
|
|
34
|
+
(the 64-bit ones need `jax_enable_x64`), and are `jit`/`vmap`/`grad`/`jvp` compatible. Conventions follow `jnp.linalg.slogdet`.
|
|
35
|
+
|
|
36
|
+
## Performance
|
|
37
|
+
|
|
38
|
+
Forward time per matrix on one H200 GPU against `jnp.linalg.slogdet` and a naive batched Parlett–Reid `slogpf` written in
|
|
39
|
+
jax.numpy (the generic fallback path). The time costs of `det` and `pf` are similar.
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
## Notes and limits
|
|
46
|
+
|
|
47
|
+
- Without a CUDA GPU the call emits a `FermixFallbackWarning` and runs a much slower generic jax.numpy path;
|
|
48
|
+
dtypes other than the four supported ones raise `TypeError`.
|
|
49
|
+
- Launch parameters are tuned per GPU architecture and dtype (`fermix._common.TUNES`); only the A100-80GB and the H200 have measured tables, other GPUs use the closest one.
|
|
50
|
+
- `prec` selects the block-GEMM algorithm: `"tf32x3"` (default, tensor cores at fp32-level accuracy) or `"ieee"`
|
|
51
|
+
(exact fp32, ~5 % slower); the 64-bit dtypes always run IEEE fp64.
|
|
52
|
+
- Complex matrices are stored as separate real and imaginary arrays (Triton has no complex type), so they move
|
|
53
|
+
twice the bytes and do four real products per complex one.
|
|
54
|
+
- Memory: two (B, n, n) work buffers for the forward and about five more for the gradient.
|
|
55
|
+
- Compile time is a few seconds per shape and dtype up to n ~ 1024 and tens of seconds to minutes for n in the thousands; JAX's persistent compilation cache (`jax_compilation_cache_dir`) makes it a one-off.
|
|
56
|
+
- `det` and `pf` overflow the 32-bit dtypes for large or badly scaled matrices, and so do their gradients; use `slogdet` and `slogpf` there.
|
|
57
|
+
- Singular inputs are safe: the forward gives (0, −inf) and the gradients stay finite, never NaN.
|
|
58
|
+
|
|
59
|
+
## Citation
|
|
60
|
+
|
|
61
|
+
```bibtex
|
|
62
|
+
@software{fermix,
|
|
63
|
+
author = {Chen, Ao},
|
|
64
|
+
title = {{fermix}: Fast batched determinants and Pfaffians in {JAX}},
|
|
65
|
+
year = {2026},
|
|
66
|
+
version = {0.1.0},
|
|
67
|
+
url = {https://github.com/ChenAo-Phys/fermix}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
# setuptools >= 77 for the PEP 639 license expression below
|
|
3
|
+
requires = ["setuptools>=77"]
|
|
4
|
+
build-backend = "setuptools.build_meta"
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "fermix"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
description = "Fast batched real and complex determinants and Pfaffians on GPU with JAX/Pallas kernels, with singular-safe gradients"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
authors = [{ name = "Ao Chen", email = "aochen@caltech.edu" }]
|
|
15
|
+
keywords = ["jax", "pallas", "determinant", "pfaffian", "gpu", "variational monte carlo"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
22
|
+
"Environment :: GPU :: NVIDIA CUDA",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
]
|
|
25
|
+
# jax 0.7.1 is the first release exporting pallas.triton.load / .store, which the
|
|
26
|
+
# kernels use for masked access; older jax cannot run them.
|
|
27
|
+
dependencies = ["jax>=0.7.1", "numpy"]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
test = ["pytest"]
|
|
31
|
+
dev = ["pytest", "black", "pyright"]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/ChenAo-Phys/fermix"
|
|
35
|
+
Repository = "https://github.com/ChenAo-Phys/fermix"
|
|
36
|
+
Issues = "https://github.com/ChenAo-Phys/fermix/issues"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
pythonpath = ["src"]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
|
|
45
|
+
[tool.black]
|
|
46
|
+
target-version = ["py311"]
|
|
47
|
+
|
|
48
|
+
[tool.pyright]
|
|
49
|
+
include = ["src/fermix", "tests"]
|
|
50
|
+
pythonVersion = "3.11"
|
|
51
|
+
typeCheckingMode = "standard"
|
fermix-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""fermix: fast batched determinants and Pfaffians (float32 / float64 / complex64 /
|
|
2
|
+
complex128) on GPU (JAX / Pallas), with singular-safe gradients.
|
|
3
|
+
|
|
4
|
+
Public functions: :func:`slogdet`, :func:`slogpf`, :func:`det`, :func:`pf`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .api import FermixFallbackWarning, det, pf, slogdet, slogpf
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
__all__ = ["slogdet", "slogpf", "det", "pf", "FermixFallbackWarning", "__version__"]
|