Skip to main content

PyTC logo

PyTC

CI Documentation Python 3.10+

Python TransCorrelation package

Documentation: https://nickirk.github.io/pytc-docs/

Development provenance

PyTC was initiated in Prof. Ali Alavi's group at the Max Planck Institute for Solid State Research, where the early-stage development of the transcorrelated-method infrastructure took place. Its current development is based in Prof. Tianyu Zhu's group at Yale University.

Features

  • Modular Jastrow factors: Boys-Handy, Nuclear Cusp, Neural Network (EE/EN/EEN), REXP, Polynomial, and Composite
  • JAX-based automatic differentiation for Jastrow gradients and Laplacians via folx
  • VMC-based Jastrow optimization with second-order Newton and first-order machine learning optimizers, e.g. Adam
  • GPU acceleration via JAX for both VMC sampling and integral calculations using multiple GPUs
  • Transcorrelated integrals: K1, K2, K3 two-body and xTC approximated three-body integrals
  • Interpolative Separable Density Fitting (ISDF) for efficient integral calculations — empirical T ∝ n_orb^1.76 scaling, demonstrated past 1200 orbitals on a single B200 GPU
  • PySCF interoperability with JAX-native CCSD: Builds on PySCF mean-field objects and molecular data, then runs xTC-CCSD with PyTC's in-house JAX solver

Dependencies

  • Python >= 3.10
  • numpy
  • scipy
  • jax (autodiff and GPU acceleration)

    Note: To run on GPUs, you must install the correct version of JAX. See the JAX installation guide. For example, for CUDA 12:

    pip install -U "jax[cuda12]"
    
  • flax (neural network)
  • folx (≥0.2.22, installed automatically as a dependency)
  • optax (machine learning optimizers)
  • pyscf

Installation

Requirements: Python >= 3.10

Install from PyPI:

python -m pip install pytc-qc

The PyPI distribution is named pytc-qc; the Python import package remains pytc.

For GPU support (CUDA 12):

python -m pip install pytc-qc
python -m pip install -U "jax[cuda12]"

For source checkout / development install, see the installation guide.

Quick Start

import jax
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from pyscf import gto, scf

from pytc import xtc
from pytc.jastrow import rexp
from pytc.solver import jax_xtc_ccsd

# Set up molecule
mol = gto.M(atom='O 0 0 0; H 0 1 0; H 0 0 1', basis='ccpvdz')
mf = scf.RHF(mol)
mf.kernel()

# Create Jastrow factor
my_jastrow = rexp.REXP()
jastrow_params = {'alpha': jnp.array([1.0])}

# Exact XTC (for small systems)
my_xtc = xtc.XTC.from_pyscf(mf, my_jastrow, grid_lvl=2)
eris_exact = my_xtc.make_eris(mf, jastrow_params)

# ISDF-accelerated XTC (scales to large systems)
n_rank = 10 * my_xtc.n_orb  # ISDF rank
my_isdf_xtc = xtc.ISDFXTC.from_xtc(my_xtc, n_rank=n_rank)
my_isdf_xtc = my_isdf_xtc.isdf(jastrow_params)
eris_isdf = my_isdf_xtc.make_eris(mf, jastrow_params)

# Run xTC-CCSD with pytc's own JAX-native solver
mycc = jax_xtc_ccsd.RCCSD(mf, my_isdf_xtc, jastrow_params)
e_corr, t1, t2 = mycc.kernel(eris=eris_isdf)

See the quickstart guide for additional examples and explanations.

Code Overview

flowchart TD
    PySCF["🔬 PySCF — gto.Mole · scf.RHF"]

    subgraph jastrow["pytc.jastrow"]
        J["BoysHandy · NuclearCusp · NeuralNet · REXP"]
    end

    subgraph ansatz["pytc.ansatz"]
        SJ["SlaterJastrow = SlaterDet + Jastrow"]
    end

    subgraph vmc["pytc.vmc"]
        V["Metropolis sampler — SR / Adam optimizer"]
    end

    subgraph xtc["pytc.xtc · kmat · df"]
        X["XTC exact / ISDFXTC D & X kernels / K1 · K3"]
    end

    subgraph solver["pytc.solver"]
        S["RCCSD — non-Hermitian CCSD"]
    end

    PySCF --> jastrow
    PySCF --> ansatz
    jastrow --> ansatz
    ansatz -->|VMC optimize| vmc
    vmc -->|optimized params| xtc
    jastrow -->|Jastrow factor| xtc
    xtc -->|ERIs| solver
    PySCF -->|mf| solver

Usage

See the pytc/examples/ directory for a numbered walkthrough of the full methodology on H₂O (Jastrow VMC optimization → averaging → dense → ISDF → FNO xTC-CCSD):

  • 01_vmc_optimize_jastrow.py — reference-variance VMC Jastrow optimization
  • 02_load_and_average_jastrow_params.py — Polyak–Ruppert parameter averaging
  • 03_dense_xtc_ccsd.py — dense (non-ISDF) xTC-CCSD
  • 04_isdf_xtc_ccsd.py — ISDF xTC-CCSD (vs. 03's dense reference)
  • 05_make_fno_xtc_ccsd.py — FNO (MP2 natural-orbital) truncation scan

To run the tests:

python -m unittest discover -v

Publications

  • Interpolative Separable Density-Fitting for Transcorrelated Hamiltonians — Ke Liao, Yifan Cheng, Werner Dobrautz, Tianyu Zhu, and Ali Alavi. arXiv:2607.17314 (2026)

Contributing

Contributions are welcome! Here's how you can help:

Reporting Issues

  • Use the GitHub Issues page to report bugs or request features
  • Include a minimal reproducible example when reporting bugs
  • Describe the expected vs. actual behavior

Submitting Pull Requests

  1. Fork the repository and create a feature branch
  2. Make your changes, following the existing code style
  3. Run the tests before submitting:
    python -m unittest discover -v
    
  4. Submit a pull request with a clear description of your changes

Code Style

  • Follow the existing code conventions in the repository
  • Use type hints where appropriate
  • Add docstrings to new functions and classes

For AI Agents

If you are an AI coding assistant working on this repository, please read the documentation in the .agents/ directory before proceeding. This directory contains important rules, architecture details, and step-by-step workflows.

  • .agents/rules.md: Core conventions and constraints for pytc.
  • .agents/ARCHITECTURE.md: High-level explanation of the codebase structure.
  • .agents/workflows/: Checklists and standardized processes for adding code (e.g., adding a new Jastrow factor, creating PRs).

Metadata

Release files for pytc-qc 0.2.1

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

Source distribution (sdist)

Source distribution for pytc-qc 0.2.1
File Size Uploaded
pytc_qc-0.2.1.tar.gz 412.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytc-qc 0.2.1
File Interpreter ABI Platform
pytc_qc-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 887.9 kB

Release files / pytc_qc-0.2.1.tar.gz

Download URL pytc_qc-0.2.1.tar.gz
Size 412.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74f9a6be9ec0e05977d67a620b94f036cb61bb34dfc96fb425529fb5086984e5
BLAKE2b-256 checksum
How to use checksums
f1d877438f10d241a86f14201257a2b14993d6d4f754f32ebfbade4f52ec2475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 23, 2026.

Transparency log

Release files / pytc_qc-0.2.1-py3-none-any.whl

Download URL pytc_qc-0.2.1-py3-none-any.whl
Size 475.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9439f57a052ae4015eb486a1ab8963580b7d74c00f0ea8712933c14d8bfa642f
BLAKE2b-256 checksum
How to use checksums
19cacdd01db571eb12b54cc9676349b0785540b89247fca591b2a3e28e68b838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

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