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.

Download files

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

Source Distribution

ffsim-0.0.81.tar.gz (1.6 MB view details)

Uploaded Source

Built Distributions

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

ffsim-0.0.81-cp311-abi3-manylinux_2_28_x86_64.whl (713.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

ffsim-0.0.81-cp311-abi3-manylinux_2_28_aarch64.whl (714.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

ffsim-0.0.81-cp311-abi3-macosx_11_0_arm64.whl (666.0 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file ffsim-0.0.81.tar.gz.

File metadata

  • Download URL: ffsim-0.0.81.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ffsim-0.0.81.tar.gz
Algorithm Hash digest
SHA256 b7300a586d39a15b5ef611e9cc87494ab5ffc8c2a9081f23c7f26647398f12a4
MD5 edfaa52e65108d48ba6059bb4fd8b85c
BLAKE2b-256 3b6e3375ff23b39a3b074bc3c18f44e952ddfaa69cd48e467e902bfc254501d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.81.tar.gz:

Publisher: build-and-release.yml on qiskit-community/ffsim

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

File details

Details for the file ffsim-0.0.81-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.81-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a68add50b15a6c005ad6b15f4004a9baa476873ad0b2db06f3133f9abe0925f
MD5 1ca0ab778e04dc017e810fe09b77abb9
BLAKE2b-256 935ced6afa66dddef83fbc304a854f2fac720c6155f6f0e56e830bba69850cc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.81-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: build-and-release.yml on qiskit-community/ffsim

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

File details

Details for the file ffsim-0.0.81-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.81-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4e69c8b09333c35af7b344cc1d35b5b9b42969817fd2f4333ab6f6e29b09ab00
MD5 90010d7be44eb22d7876a4eb36f753fc
BLAKE2b-256 c5c31b32ae751cff37118b0249558114e3209c32df8b449e04ada81e9cf807f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.81-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: build-and-release.yml on qiskit-community/ffsim

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

File details

Details for the file ffsim-0.0.81-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.81-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 824fb780d173d2484a76a252f9147cb581c83bc57afa50e40c503f618e7f0a66
MD5 c5b817f1a12f4c93689860bb71bf9c0b
BLAKE2b-256 8ea3f42c4ada9b6d0fa9d87640b6a04d7e39e6721a4e835e5421c0f057722228

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.81-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: build-and-release.yml on qiskit-community/ffsim

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

Release history Release notifications | RSS feed

Supported by

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