Skip to main content

fermix

Fast batched determinants and Pfaffians in JAX

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.

Designed for quantum Monte Carlo in fermionic systems: a large batch of moderate-size matrices (n ~ 32-8192), forward and backward.

Install

Requires jax >= 0.7.1

pip install fermix

Usage

import jax, jax.numpy as jnp
from fermix import slogdet, slogpf, det, pf

A = jax.random.normal(jax.random.key(0), (4096, 128, 128), jnp.float32)
sign, logabs = slogdet(A) # like jnp.linalg.slogdet, but faster
S = A - jnp.swapaxes(A, -1, -2)
sign, logabs = slogpf(S) # Pfaffian of the skew-symmetric batch

Simply replace slogdet / slogpf / det / pf in your program by the functions in fermix.

All functions accept any leading batch dimensions, any matrix size, the four dtypes float32 / float64 / complex64 / complex128 (the 64-bit ones need jax_enable_x64), and are jit/vmap/grad/jvp compatible. Conventions follow jnp.linalg.slogdet.

Performance

Forward time per matrix on one H200 GPU against jnp.linalg.slogdet and a naive batched Parlett–Reid slogpf written in jax.numpy (the generic fallback path). The time costs of det and pf are similar.

slogdet forward time and speedup over jnp.linalg.slogdet, H200

slogpf forward time and speedup over the naive jax.numpy path, H200

Notes and limits

  • Without a CUDA GPU the call emits a FermixFallbackWarning and runs a much slower generic jax.numpy path; dtypes other than the four supported ones raise TypeError.
  • 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.
  • prec selects the block-GEMM algorithm: "tf32x3" (default, tensor cores at fp32-level accuracy) or "ieee" (exact fp32, ~5 % slower); the 64-bit dtypes always run IEEE fp64.
  • Complex matrices are stored as separate real and imaginary arrays (Triton has no complex type), so they move twice the bytes and do four real products per complex one.
  • Memory: two (B, n, n) work buffers for the forward and about five more for the gradient.
  • 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.
  • det and pf overflow the 32-bit dtypes for large or badly scaled matrices, and so do their gradients; use slogdet and slogpf there.
  • Singular inputs are safe: the forward gives (0, −inf) and the gradients stay finite, never NaN.

Citation

@software{fermix,
  author  = {Chen, Ao},
  title   = {{fermix}: Fast batched determinants and Pfaffians in {JAX}},
  year    = {2026},
  version = {0.1.0},
  url     = {https://github.com/ChenAo-Phys/fermix}
}

Release files for fermix 0.1.0

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

Source distribution (sdist)

Source distribution for fermix 0.1.0
File Size Uploaded
fermix-0.1.0.tar.gz 64.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fermix 0.1.0
File Interpreter ABI Platform
fermix-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 125.0 kB

Release files / fermix-0.1.0.tar.gz

Download URL fermix-0.1.0.tar.gz
Size 64.2 kB
Tags Source
SHA-256 checksum
How to use checksums
711ac0acb8cb130deede18adc74ad4a3346d878fe8da03bb6b2b121a1e3d422f
BLAKE2b-256 checksum
How to use checksums
e6d92d06dc745bb2e68f8ad6680ddff508d8fd8886cceef63874be2b4e911af0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / fermix-0.1.0-py3-none-any.whl

Download URL fermix-0.1.0-py3-none-any.whl
Size 60.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad1af84bb6b1d508a1eebca0a73ec7f24193582a15f62dfbb8dc9b2c63da4866
BLAKE2b-256 checksum
How to use checksums
39cc66793728fd151c0ca24b05dba9d216dbe97c377b52032a5f6bdc6274b0e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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