dftax writes Kohn-Sham DFT (integrals, quadrature grid, exchange-correlation,
the SCF loop) as a single differentiable JAX program. Once the energy is one
autodiff-traceable function, the derivatives quantum chemistry cares about are
just calls to jax.grad. Forces are −∂E/∂R; the Fock matrix is sym(∂E/∂P),
so no exchange-correlation potential is coded by hand; response properties are
higher derivatives of the same function.
forces(mol, xc, res) # −∂E/∂R nuclear forces
hessian(mol, xc) # ∂²E/∂R² vibrational frequencies
polarizability(mol, xc) # −∂²E/∂F²
alchemical_deriv(mol, xc) # ∂E/∂Z
Converged quantities are differentiated through the SCF fixed point (CPHF), so a gradient of a converged calculation costs one linear solve rather than an unrolled solver. And because it is ordinary JAX, the whole engine jits, vmaps over geometries, and runs on GPU; a DFT calculation drops into a training loop or an end-to-end functional fit like any other differentiable block.
The runtime carries no libcint, libxc, or Maple: basis sets come from the
Basis Set Exchange at setup, the molecular
grid is built natively, and PySCF appears only as a test-time reference.
Installation
pip install dftax # CPU
pip install dftax[cuda12] # + CUDA-12 jaxlib (Linux GPU)
Quick start
import jax
jax.config.update("jax_enable_x64", True) # DFT energies want float64
from dftax import KS, Molecule, scf
from dftax.energy.xc import PBE # also: LDA, PBE0, B3LYP
mol = Molecule.from_xyz("O 0 0 0; H 0.757 0.587 0; H -0.757 0.587 0", "sto-3g")
res = scf(KS(mol, PBE())) # DIIS SCF -> KSResult
print(res.e_tot, res.converged) # total energy (Ha), convergence flag
KS(system, xc, *, grid=, coulomb=, spin=, mesh=) assembles the energy
functional; the verbs scf and minimize solve it, and forces, dipole,
polarizability, and the rest read properties from it. Every choice is a value
passed to the builder, not a global flag. A nonzero spin (given as 2S) runs
the spin-polarized α/β path through the same call.
Scaling up
The exact 4-center ERI is O(N⁴): the small-system reference the rest is checked
against. From there each backend is one more value on the builder. Density
fitting (df(...)) takes the Coulomb cost to O(N³); streaming holds the tensors
at O(N²) memory; Schwarz screening trims the per-iteration work; and
mesh=mesh() shards the grid and the density-fitting tensor across GPUs. Every
collective differentiates, so SCF, minimization, and forces run unchanged.
from dftax import KS, df, mesh, scf
from dftax.energy.xc import PBE0
scf(KS(mol, PBE0(), coulomb=df("def2-universal-jkfit"), mesh=mesh()))
Accuracy
Against PySCF on water / sto-3g (see
scripts/bench/BENCHMARKS.md):
| functional | |ΔE| vs PySCF |
|---|---|
| LDA | 2e-11 (≈ machine) |
| B3LYP | 2e-9 (≈ machine) |
| PBE | 1.5e-5 |
| PBE0 | 1.1e-5 |
LDA and B3LYP reproduce libxc to machine precision. PBE and PBE0 sit near 1e-5 Ha, a gap in the hand-rolled GGA enhancement factors rather than in the SCF or the integrals, and well within chemical accuracy. Analytic forces match finite differences to about 4e-8 Ha/Bohr, the CPHF polarizability matches finite-field to about 1e-4, and vibrational frequencies match PySCF to a few cm⁻¹.
Limitations
- One-electron integrals run up to g (l=4), i.e. cc-pVTZ/QZ.
- The materialized exact-ERI path hits a GPU memory ceiling near nao ≈ 70; use density fitting, streaming, and screening at scale (exact-exchange compute stays O(N⁴) regardless).
- GPU correctness is validated interactively on an A100 rather than in CPU CI, and large-N GPU throughput is not yet benchmarked.
Documentation
Docs, tutorials, and executed example notebooks live at
https://andresguzco.github.io/dftax/; the same examples are runnable scripts
under examples/.
See also
dftax builds on Equinox and Optax, and shares ground with other differentiable electronic-structure codes: MESS and D4FT (in JAX), DQC (PyTorch), and PySCFad. It leans on PySCF as its test-time reference and aims to be a good neighbor to it, not a replacement.
Citation
@software{dftax,
author = {Guzm{\'a}n-Cordero, Andr{\'e}s},
title = {dftax: a differentiable Kohn-Sham DFT engine in JAX},
url = {https://github.com/andresguzco/dftax},
version = {0.2.0},
year = {2026},
}
License
Metadata
Release files for dftax 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dftax-0.4.0.tar.gz | 937.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dftax-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.8 MB
Release files / dftax-0.4.0.tar.gz
| Download URL | dftax-0.4.0.tar.gz |
|---|---|
| Size | 937.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
439e54e68464fa52c80b3316f152be0f275126ca3f30a537328f1805cbd9db4c
|
|
BLAKE2b-256 checksum How to use checksums |
7731b8cb726df2602f506e3316726d0865942db38539471992ce2c7e7c058961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency logRelease files / dftax-0.4.0-py3-none-any.whl
| Download URL | dftax-0.4.0-py3-none-any.whl |
|---|---|
| Size | 865.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3207e361f992916bdaab244fabc73c46a2ff1f5710909c5d439bc8f40c079bfa
|
|
BLAKE2b-256 checksum How to use checksums |
ce9e9587308072f047de5c12dd66dfca2aa0d1ee0f5914833434387aa3f2ed29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency log