Skip to main content

Fermionic Hamiltonian downfolding (CFU/DUCC/PUCC/CCSD) and projective quantum eigensolvers (PQE), input-file driven.

Project description

qufold

Fermionic Hamiltonian downfolding + projective quantum eigensolvers, driven by a single Q-Chem-style input file.

qufold builds compact, accurate effective active-space Hamiltonians from a full electronic-structure problem, so that the expensive part of a quantum simulation (qubitized QPE, FCI, a projective eigensolver) runs on a small, strongly-correlated active space instead of the full orbital set. Its flagship method is CFUClosed-Form Unitary downfolding — which applies a sequence of exact single-generator unitary similarity transforms to the Hamiltonian before projecting the external orbitals onto Hartree–Fock. "Closed-form" means each rotation e^{-θA} H e^{θA} is evaluated exactly (no Baker–Campbell–Hausdorff truncation), so every step is rigorously unitary and norm-preserving.

You write one text file and run one command:

qufold examples/cfu/h4_cfu.in

The architecture is deliberately layered so the physics is auditable and the performance is swappable: every method is written once against a small operator-algebra interface (commutator, multiply, similarity_transform, rotate_single, hf_expectation, gradient, optimal_theta) and then runs unchanged on three interchangeable backends — a transparent reference implementation, a fast compiled C++ kernel, and a GPU Majorana kernel.


Status

qufold is research software under active development (alpha). The CFU pipeline is implemented end-to-end and validated; the remaining methods and the fast backends are scaffolded behind the same fixed contracts and land incrementally. The table below is an honest map of what runs today.

Methods × backends

Method openfermion (reference) cpu (C++ kernel) gpu (Majorana)
cfu — Closed-Form Unitary ✅ implemented 🚧 scaffolded 🚧 scaffolded
ducc — Double Unitary CC 🚧 scaffolded 🚧 scaffolded 🚧 scaffolded
pucc — Projective UCC 🚧 scaffolded 🚧 scaffolded 🚧 scaffolded
ccsd_downfold — non-unitary CCSD 🚧 scaffolded 🚧 scaffolded 🚧 scaffolded
pqe — Projective Quantum Eigensolver 🚧 scaffolded 🚧 scaffolded 🚧 scaffolded

Legend: ✅ implemented = runs and is validated; 🚧 scaffolded = the contract, registry entry, and keywords exist, but the implementation is not yet wired in. Requesting a scaffolded backend fails over gracefully to the openfermion reference backend (with a warning) rather than crashing; requesting a scaffolded method raises a clear "not yet implemented" error.

Why is the reference backend the one that is "done"? It is the auditable truth: each primitive maps one-to-one to the math via OpenFermion/NumPy. The cpu (pybind11 fermionic kernel, ~7–10× faster on normal-ordered commutators/products) and gpu (CuPy bit-packed Majorana kernel — operators stored as 128-bit bitmasks, products are XOR + popcount) backends are validated against it before they are marked implemented.

Validation snapshot

  • CFU on H4 recovers ~87 % of the CASSCF→FCI correlation gap on the reference backend, with downfold → FCI reproducing PySCF CASCI to ~2e-8 Ha on the K=0 (no-transform) checkpoint — i.e. the downfold itself is exact and the recovery comes from the unitary transforms.

Install

qufold works out of the box with only the reference backend's dependencies (NumPy, SciPy, OpenFermion, PySCF):

pip install qufold                 # reference (openfermion) backend
pip install "qufold[cpu]"          # + compile the bundled C++ fermionic kernel
pip install "qufold[gpu]"          # + GPU Majorana backend (needs CuPy/CUDA)
pip install "qufold[pqe]"          # + QForte bridge for the PQE methods
pip install "qufold[dev]"          # + tests / docs / build tooling

From source (development):

git clone https://github.com/mjangrou/qufold
cd qufold
pip install -e ".[dev]"

The fast cpu backend ships its compiled kernel as package data (qufold/_vendor/*.so); public wheels carry a prebuilt kernel so most users never compile anything (see Distribution model below).


Quickstart

# 1. activate an environment with the deps (see Install)
# 2. run the bundled H4 CFU example
qufold examples/cfu/h4_cfu.in
# 3. read the result block printed to stdout (reference energy, downfolded
#    energy, recovery in mHa, generator count, trajectory)
# 4. or drive it programmatically:
python -c "import qufold; print(qufold.run_calculation('examples/cfu/h4_cfu.in').energy)"

The input file ($molecule / $rem)

A calculation is fully specified by one human-friendly, Q-Chem/Psi4-flavoured keyword file: a $molecule block (geometry + charge/multiplicity) and a $rem ("remarks") keyword block. Lines are keyword value; # starts a comment; sections are $section … $end.

$molecule
0 1                          # charge  spin-multiplicity
H   0.0000  0.0000  0.0000
H   0.0000  0.0000  0.7400
H   0.0000  0.0000  2.0000
H   0.0000  0.0000  2.7400
$end

$rem
method        cfu            # cfu | ducc | pucc | ccsd_downfold | pqe
backend       openfermion    # openfermion | cpu | gpu
basis         sto-3g
active_space  full           # avas | manual | full
orbital_opt   true           # CASSCF-optimize before downfolding
n_generators  40             # CFU: number of greedy-ADAPT steps K
generator_pool ccsd_screened # screened doubles (singles excluded by design)
pool_tol      1e-3
solve_fci     true           # exactly diagonalize the downfolded Hamiltonian
$end

Every keyword — its type, default, allowed values, and a one-paragraph help string — lives in qufold/input/keywords.py, the single source of truth from which the keyword reference (docs/keywords.md) is generated, so the manual can never drift from the code.


How it fits together

input file  ─►  Calculation  ─►  Problem (SCF / active space / CASSCF-OO)
            ─►  Method.run(backend)  ─►  Result  ─►  analysis (FCI, λ)  ─►  output
  • qufold/input/ — parser + keyword registry (the manual-in-code).
  • qufold/core/Problem builder (hamiltonian.py), CC amplitudes and the screened-doubles generator pool (amplitudes.py), FCI / LCU-1-norm analysis (analysis.py).
  • qufold/methods/ — thin orchestration over backend primitives. Each method subclasses Method and sets name=<keyword>. CFU is the worked template (cfu.py).
  • qufold/backends/ — the operator algebra. base.py is the contract; openfermion_backend.py is the reference impl; registry.py selects with graceful failover.
  • qufold/downfold/ — the backend-independent Majorana-space projection (projector.downfold_to_active(H, problem)), exact for any body rank.
  • qufold/drivers/driver.py — top-level orchestration (the CLI calls this; also the programmatic qufold.run_calculation).

Operators cross every API boundary as a plain dict FermionOp = { ((p,1),(q,0),…): complex } (OpenFermion term convention, 1 = creation, 0 = annihilation), so methods stay backend-agnostic even when a backend uses a faster internal representation (e.g. Majorana bitmasks).


Documentation

  • docs/keywords.md — the full keyword reference (generated from qufold/input/keywords.py).
  • docs/methods/ — the theory and contract for each method (CFU, DUCC, PUCC, CCSD downfolding, PQE).
  • docs/tutorials/ — worked end-to-end examples.
  • examples/ — ready-to-run input files (examples/cfu/h4_cfu.in, …).
  • CONTRIBUTING.md — how to add a method, a keyword, or a backend.

Distribution model

qufold is developed in a private repository and released publicly as source-hidden binary wheels on PyPI for tagged versions. Every module — including the package __init__ files — is Cython-compiled to a platform .so and the original .py is excluded from the wheel, so the published package contains no readable Python source and no .pyc bytecode, only symbol-stripped machine code plus the compiled C++ kernel. pip install qufold then gives users the full functionality (and the fast cpu backend) without a compiler and without the source.

This is the strongest practical obfuscation for a pip package: recovering the original Python from a Cython .so is impractical (it is compiled C, not bytecode). It is not cryptographic secrecy — any runnable executable can in principle be reverse-engineered — but it defeats casual reading and decompilation.

The .github/workflows/wheels.yml pipeline builds these compiled wheels with cibuildwheel across Linux/macOS/Windows × CPython 3.10–3.13 on every vX.Y.Z tag and publishes them to PyPI via Trusted Publishing (no API token). Wheels only — no source distribution (sdist) is ever published, since an sdist would ship the source. (Trade-off: users on a platform/Python without a matching wheel cannot install; the wheel matrix is kept broad to cover common setups.) See setup.py for the build and .github/workflows/wheels.yml for the one-time PyPI Trusted-Publisher setup.


Citation

If qufold is useful in your work, please cite it (a CITATION.cff will ship with the first tagged release). Authors: Mohammad Reza Jangrouei, Artur F. Izmaylov.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qufold-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

qufold-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

qufold-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

qufold-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

qufold-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qufold-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

qufold-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

qufold-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qufold-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

qufold-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

qufold-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qufold-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file qufold-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1fb9b1f12ca0f512b1e9f4aae87f508ff20dc1578ae61452fdb02d86347a126
MD5 f928fab7e7dfbafc46f3b27e435be423
BLAKE2b-256 5ff065575af12671abf59cac72a94d8ac2966db039feb8bf855597e6f2cf5d6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2426094fc2484c9cca5cce2444a28218683c828e4ddf2237ff6fa70aa72f6ad0
MD5 67d24389a8c826d423ad95ea4c1742a4
BLAKE2b-256 958437b680bc2e031558903d844999473ba8505866393fb7983695c3c61ad7d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 afe2131f929af383ef4bb1232d428387d4c6cef2fef73429d41df503f6b9a824
MD5 062e09eb2ca6b774b1ba7cdb53bbd4d1
BLAKE2b-256 50c11eff3a4a7bb39385a73d24a93b177e5877e94c5b6f9cb212127d5371b299

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 23ce17079b15c1a41411da987a45d9ad322f948ba614a8f557b89fbd51b3631c
MD5 21d31e728e7904f744ca8b5b79e2cc87
BLAKE2b-256 7a18da82af32f6a5cefb852dbd1ef3f55ca06a01a7b5829164389141890fc6ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc10347d6a35dc6b37753da523432c14531dd00aec804b382baf95d26212891d
MD5 a1bcf984b5a7197e0eaf076187ac2296
BLAKE2b-256 fc48eab42612327a9e0ba5e82b01acee81a2ed82db33b72a7e154e77cfd981fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f28555185b2fc7bfe6779c25afd78f6df50b25bd6199e9f0b329872d9b60ac9f
MD5 2fe7d639b8db46aba05eed03381ceeae
BLAKE2b-256 cba8655bfa1725d5b34854348340b66770a1f1eb1ff3d1546a93efe6deb37fd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22650f41c084d63ec2257ff51439d98def2b164804a9f3925d0aa9c9c1504ef9
MD5 3cc60a8a3b3080ee2bafb7931e4481b8
BLAKE2b-256 9ed9ea4ca82a50efa77a43e28628666e9c252ab2fe844fd1a7329d90555f5193

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6170167755c8eec981746f6bbd9e28d1580cffb5861ec7691678888adacf967f
MD5 a5d3f2235afbe024f86312571e9af660
BLAKE2b-256 afd28863d9c59d5fdbb770a5050725338b95298e9e8f91c8d3a47ff3cbbe76c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e38a886dc019bcf3cadbd582f6b5d19e4b04e7a0538984f12198d16c58a1c6e7
MD5 31eba5f1aafe8b2624d837e5d6d07541
BLAKE2b-256 b5722efddaeaef19fe4f0b17ae5cc0d38e8cce478fde493ba78a17e14aeab48d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f133e823656d6560e83e98f1958f65ec9e7e9a35fa7a623e0f725a57c96a4f8f
MD5 df437a0125930b24ec7ff1f1b9d35e67
BLAKE2b-256 cb75055cb933e569dca85702272dc9133a45e8d734e8f3972d6341bc62fd2c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e12491c0b33118a57eef83225904fed1b7f4413e5450c601c6716c093ae5709
MD5 7f120a167a0090c3a064fd9425d778ed
BLAKE2b-256 c556c25c88bb1500a0eb9032d940f301dd4e9513241343a31d63cd09b720f021

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qufold-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qufold-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 587d142179f7521f51b8371fab1e014a3d4499cf9ca0113de52213adb93dc616
MD5 b339b36a9c8fd6e4a039c960eace95b7
BLAKE2b-256 95370662cab51094e07aac7eaa58a3320dc2abb83fd2f8803f456d271b7583a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for qufold-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on mrJangrouei/qufold

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page