Skip to main content

Faster simulation of fermionic quantum circuits.

Project description

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.

Installation

We recommend installing ffsim using pip when possible:

pip install ffsim

This method won't work natively on Windows, however. Refer to the installation instructions for information about using ffsim on Windows, as well as instructions for installing from source and running ffsim in a container.

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

Multithreading

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

Citing ffsim

You can cite ffsim using the following BibTeX:

@misc{ffsim,
  author = {{The ffsim developers}},
  title = {ffsim: Faster simulations of fermionic quantum circuits},
  howpublished = {\url{https://github.com/qiskit-community/ffsim}},
}

Developer guide

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

Project details


Release history Release notifications | RSS feed

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.74.tar.gz (1.7 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.74-cp310-abi3-manylinux_2_28_x86_64.whl (12.7 MB view details)

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

ffsim-0.0.74-cp310-abi3-manylinux_2_28_aarch64.whl (5.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

ffsim-0.0.74-cp310-abi3-macosx_11_0_arm64.whl (674.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for ffsim-0.0.74.tar.gz
Algorithm Hash digest
SHA256 5c6b3688537c1ca5f8600420c9a3a79006c26034f6ade768c381b6208095b0f9
MD5 c7435ea1a7957cbc2ba7e0128a0ef2bf
BLAKE2b-256 3f865aa5b91dd183a3b10c6c8899d84d528e6d9155a29b3feb9e497bfb88272b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.74.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.74-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.74-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c11389a9dd0e6b65856d18e53a7e28a65d35ac9002922a9d1e6026b57df995bf
MD5 26eaecd624f93fc584db609d8445492b
BLAKE2b-256 9108ddd58656ec43e1625ce1e52279b25461f8e4d2f31856990431c086530af8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.74-cp310-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.74-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.74-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1ad0139be035f5346cb24f1e2e45a59cef96758bdbde4d98f4802999731fc81c
MD5 849ef5406d865d821493fdd80e27a58a
BLAKE2b-256 8cc106255ebcb8880ad425b488030e625db47e54b4eead78dd79df745a347b95

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.74-cp310-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.74-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.74-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5505c70f25ab68a9b24407ec11f73d79bd0dd82565283abf7f6f380327332be
MD5 64a3bd43abf4a8253839d92530626fa3
BLAKE2b-256 7ea51c0affa98492934998f6959d007634fe7447d1875539e4e5263e42f78870

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffsim-0.0.74-cp310-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.

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