Skip to main content

ffsim

ffsim is a software library for simulating fermionic quantum circuits that conserve particle number and the z component of spin. This category includes many quantum circuits used for quantum chemistry simulations. By exploiting the symmetries and using specialized algorithms, ffsim can simulate these circuits much faster than a generic quantum circuit simulator.

Documentation

Documentation is located at the project website. You might also be interested in the paper about ffsim.

Installation

On Linux and macOS, you can install ffsim using pip:

pip install ffsim

See the installation instructions for information about using ffsim on Windows, as well as instructions for installing from source and running ffsim in a container.

Get started

Visit State vectors and gates to start learning ffsim's core concepts, or jump straight into a tutorial. Check out the guides for help with specific tasks, or visit the API reference for detailed documentation of all function and classes available in the library.

Multithreading

Some ffsim functions implemented in Rust use multithreading. The number of threads can be controlled using the environment variable RAYON_NUM_THREADS. For example, to disable multithreading, set this variable as RAYON_NUM_THREADS=1.

Code example

import numpy as np
import pyscf

import ffsim

# Generate the Hamiltonian for an N2 molecule using PySCF and ffsim's wrapper for it
mol = pyscf.gto.Mole()
mol.build(atom=[["N", (0, 0, 0)], ["N", (1.0, 0, 0)]], basis="6-31g", symmetry="Dooh")
scf = pyscf.scf.RHF(mol).run()
mol_data = ffsim.MolecularData.from_scf(scf, active_space=range(4, mol.nao_nr()))
norb, nelec = mol_data.norb, mol_data.nelec
hamiltonian = mol_data.hamiltonian

# Convert the Hamiltonian to a SciPy LinearOperator
linop = ffsim.linear_operator(hamiltonian, norb=norb, nelec=nelec)

# Generate a random orbital rotation
orbital_rotation = ffsim.random.random_unitary(norb, seed=1234)

# Create the Hartree-Fock state and apply the orbital rotation to it
vec = ffsim.hartree_fock_state(norb, nelec)
vec = ffsim.apply_orbital_rotation(vec, orbital_rotation, norb=norb, nelec=nelec)

# Compute the energy of the state
energy = np.vdot(vec, linop @ vec).real
print(energy)  # prints -104.17181289596

Citing ffsim

You can cite ffsim using the following BibTeX:

@misc{sung2026ffsim,
      title={ffsim: Faster simulation of fermionic quantum circuits},
      author={Kevin J. Sung and Inho Choi and Mirko Amico and Bartholomew Andrews and Esra Ayantuna and Yukio Kawashima and Wan-Hsuan Lin and David Omanovic and Samuele Piccinelli and Javier Robledo Moreno and Abdullah Ash Saki and James Shee and Soyoung Shin and Minh C. Tran and Kento Ueda and Haimeng Zhang and Mario Motta},
      year={2026},
      eprint={2605.03123},
      archivePrefix={arXiv},
      primaryClass={quant-ph},
      url={https://arxiv.org/abs/2605.03123},
}

Developer guide

See the developer guide for instructions on contributing code to ffsim.

Metadata

Release files for ffsim 0.0.84

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

Source distribution (sdist)

Source distribution for ffsim 0.0.84
File Size Uploaded
ffsim-0.0.84.tar.gz 1.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for ffsim 0.0.84
File Interpreter ABI Platform
ffsim-0.0.84-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
ffsim-0.0.84-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
ffsim-0.0.84-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 4.0 MB

Release files / ffsim-0.0.84.tar.gz

Download URL ffsim-0.0.84.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
bc7a322dc2e5ae0ee76a2d4789899ba5c45773631afdb452bdb6ee92b29a1ae5
BLAKE2b-256 checksum
How to use checksums
38449a4aa7f1a49006f21be9c93ee302ea28c681d61ed3a5dc1e642b706fc15c
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 19, 2026.

Transparency log

Release files / ffsim-0.0.84-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL ffsim-0.0.84-cp311-abi3-manylinux_2_28_x86_64.whl
Size 749.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
589b518aa3751b623e31ebfb1ee526be0c0583290e8b5b6239002278210ce24b
BLAKE2b-256 checksum
How to use checksums
a9046df74a2b9c1c7bb4de4dbb3537b4514f883bd6c31e04fea41b554e10a693
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 19, 2026.

Transparency log

Release files / ffsim-0.0.84-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL ffsim-0.0.84-cp311-abi3-manylinux_2_28_aarch64.whl
Size 742.6 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
13874e502355b9779413937025e9b796aa04234d73e4e6885ac2c525fb7c983a
BLAKE2b-256 checksum
How to use checksums
c0c73f47c9a475366d4ba6295768d410ebbc2de4adebbb20c0db81005a0abaf2
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 19, 2026.

Transparency log

Release files / ffsim-0.0.84-cp311-abi3-macosx_11_0_arm64.whl

Download URL ffsim-0.0.84-cp311-abi3-macosx_11_0_arm64.whl
Size 684.8 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c90b9ead790b597d1e1d86ec8df7d30a3cd28434864ae42d5538a3a8a452bf74
BLAKE2b-256 checksum
How to use checksums
19159862a52b78f62098eabbda10f36b8fbd8864ba3e7fd97c387efb19e91389
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 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.84 This release

4 release files

0.0.83

4 release files

0.0.82

4 release files

0.0.81

4 release files

0.0.79

4 release files

0.0.78

4 release files

0.0.77

4 release files

0.0.74

4 release files

0.0.73

4 release files

0.0.72

4 release files

0.0.71

4 release files

0.0.69

4 release files

0.0.68

4 release files

0.0.67

4 release files

0.0.66

4 release files

0.0.65

4 release files

0.0.64

4 release files

0.0.63

4 release files

0.0.62

4 release files

0.0.61

4 release files

0.0.60

4 release files

0.0.59

4 release files

0.0.56

4 release files

0.0.55

4 release files

0.0.54

4 release files

0.0.53

4 release files

0.0.52

4 release files

0.0.49

4 release files

0.0.48

4 release files

0.0.47

4 release files

0.0.45

4 release files

0.0.43

4 release files

0.0.42

4 release files

0.0.41

4 release files

0.0.39

4 release files

0.0.38

4 release files

0.0.37

4 release files

0.0.35

4 release files

0.0.34

4 release files

0.0.33

4 release files

0.0.32

4 release files

0.0.31

4 release files

0.0.28

3 release files

0.0.25

3 release files

0.0.24

3 release files

0.0.23

3 release files

0.0.22

3 release files

0.0.21

3 release files

0.0.20

3 release files

0.0.19

3 release files

0.0.17

3 release files

0.0.15

3 release files

0.0.9

3 release files

0.0.8

3 release files

0.0.7

3 release files

0.0.6

3 release files

0.0.5

3 release files

0.0.4

3 release files

0.0.3

3 release files

0.0.2

3 release files

0.0.0

3 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