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.

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{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.76.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.76-cp310-abi3-manylinux_2_28_x86_64.whl (729.3 kB view details)

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

ffsim-0.0.76-cp310-abi3-manylinux_2_28_aarch64.whl (712.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

ffsim-0.0.76-cp310-abi3-macosx_11_0_arm64.whl (669.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: ffsim-0.0.76.tar.gz
  • Upload date:
  • Size: 1.7 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.76.tar.gz
Algorithm Hash digest
SHA256 856a9b87cb2f54692469654e6b3d07c11f30f445fa9d7e42a6ea1be6fa3559ca
MD5 ec922e5c7cd073e4d6a29c8897fcca73
BLAKE2b-256 cf331c82d128b365e38c49103addce7aa1479ca883332911d268b1de3a5aa249

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ffsim-0.0.76-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a4091d43733c224d0fa9c7f879c5516ec86dbc3e0296aaf5eeadec90570c0b2
MD5 d8b95d54d07f4706e2f1dd5c7b7ccf38
BLAKE2b-256 5df5da0e0ffad4cbe922a758dbdf4ecec0440b60bd13fb9fec66eedd87b8e891

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ffsim-0.0.76-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0e79bc44e5852d4379d90ce2f066b2c50a27feba399bb4fac14b261da4d0d67c
MD5 f303dbad07d588766af3aa0a9431887c
BLAKE2b-256 c3ae2b25715944aa3377392f45ad9001fc19b0a99ac0eb22f1d3c0db9fb81e33

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ffsim-0.0.76-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 156a848d010c23f55767f445e8c136994968d243d39a36bc89a6e61d20e74e3a
MD5 b3246ff887cc08309fbe9b6c64993b98
BLAKE2b-256 b6493b55830821e41c4b457697ffef54783853234c74716c17e96567d337c21b

See more details on using hashes here.

Provenance

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