Faster simulations 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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ffsim-0.0.65.tar.gz.
File metadata
- Download URL: ffsim-0.0.65.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b86f5df14b9b3b2d5b66baeef2f8b0827a1c5c49f972a962d277d405a52a939
|
|
| MD5 |
53c7ec763175875a0745d8f2f034d9dc
|
|
| BLAKE2b-256 |
86cf11c98280cb2edd073a91da0b0e98c85df18bc93bb65bf3059d339a9b85ab
|
Provenance
The following attestation bundles were made for ffsim-0.0.65.tar.gz:
Publisher:
build-and-release.yml on qiskit-community/ffsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffsim-0.0.65.tar.gz -
Subject digest:
8b86f5df14b9b3b2d5b66baeef2f8b0827a1c5c49f972a962d277d405a52a939 - Sigstore transparency entry: 863931824
- Sigstore integration time:
-
Permalink:
qiskit-community/ffsim@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Branch / Tag:
refs/tags/v0.0.65 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-release.yml@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffsim-0.0.65-cp310-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ffsim-0.0.65-cp310-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c2a6bbeca09f737e5d6c48e2f2d69a0cf38a330271ccdf9922b7e8230a241b
|
|
| MD5 |
6c28cd61ec46735b087e3cd7654d827b
|
|
| BLAKE2b-256 |
24c903dcb2f7346ad3dd82690b9730c022e7d41c8dd59cd61f7eb6fb95ae2d4f
|
Provenance
The following attestation bundles were made for ffsim-0.0.65-cp310-abi3-manylinux_2_28_x86_64.whl:
Publisher:
build-and-release.yml on qiskit-community/ffsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffsim-0.0.65-cp310-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
c8c2a6bbeca09f737e5d6c48e2f2d69a0cf38a330271ccdf9922b7e8230a241b - Sigstore transparency entry: 863931835
- Sigstore integration time:
-
Permalink:
qiskit-community/ffsim@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Branch / Tag:
refs/tags/v0.0.65 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-release.yml@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffsim-0.0.65-cp310-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ffsim-0.0.65-cp310-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e37d73649b2f524385aaff92966b24ebe6fc9214a0741f3f3f39f5f90cfeebd
|
|
| MD5 |
2056d411b3866d66075e8c4afd3373ff
|
|
| BLAKE2b-256 |
8b2a4b2bcd66f077ceffaa068c1931a24710c73b9250b6a93afe663fcccedfe8
|
Provenance
The following attestation bundles were made for ffsim-0.0.65-cp310-abi3-manylinux_2_28_aarch64.whl:
Publisher:
build-and-release.yml on qiskit-community/ffsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffsim-0.0.65-cp310-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
5e37d73649b2f524385aaff92966b24ebe6fc9214a0741f3f3f39f5f90cfeebd - Sigstore transparency entry: 863931827
- Sigstore integration time:
-
Permalink:
qiskit-community/ffsim@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Branch / Tag:
refs/tags/v0.0.65 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-release.yml@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffsim-0.0.65-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ffsim-0.0.65-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 645.1 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8e2b7506ea2833567e10c919364d07eacb11c04fb10451abd983491b18c0875
|
|
| MD5 |
5b267add9faf1b9629a3b5c719ce5cb7
|
|
| BLAKE2b-256 |
0d82e84dd7b09a17de6fbab69a3bf30fe33317045ed51189ae55a386d33abda8
|
Provenance
The following attestation bundles were made for ffsim-0.0.65-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
build-and-release.yml on qiskit-community/ffsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffsim-0.0.65-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
a8e2b7506ea2833567e10c919364d07eacb11c04fb10451abd983491b18c0875 - Sigstore transparency entry: 863931832
- Sigstore integration time:
-
Permalink:
qiskit-community/ffsim@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Branch / Tag:
refs/tags/v0.0.65 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-release.yml@4e248554ee90979adb6f5afdc4cbb14e22487ab0 -
Trigger Event:
release
-
Statement type: