Source-linked AI summary
OpenFermion: The Electronic Structure Package for Quantum Computers
Jarrod R. McClean, Kevin J. Sung, Ian D. Kivlichan, Yudong Cao, Chengyu Dai, E. Schuyler Fried, Craig Gidney, Brendan Gimby, Pranav Gokhale, Thomas Häner, Tarini Hardikar, Vojtěch Havlíček, Oscar Higgott, Cupjin Huang, Josh Izaac, Zhang Jiang, Xinle Liu, Sam McArdle, Matthew Neeley, Thomas O'Brien, Bryan O'Gorman, Isil Ozfidan, Maxwell D. Radin, Jhonathan Romero, Nicholas Rubin, Nicolas P. D. Sawaya, Kanav Setia, Sukin Sim, Damian S. Steiger, Mark Steudtner, Qiming Sun, Wei Sun, Daochen Wang, Fang Zhang, Ryan Babbush
TL;DR
Quantum chemistry algorithms require expertise across chemistry and quantum computing, while compiling them for quantum hardware remains difficult. OpenFermion addresses this gap with an open-source, modular library that translates molecular specifications through electronic-structure tools into quantum operators and circuits. Its examples show interoperable workflows for mapping, simulation, and hardware-oriented execution, while supporting robust, framework-agnostic development.
Problem
Developing quantum algorithms for chemistry and materials can require prohibitive expertise across chemistry and quantum computing, while compiling efficient algorithms into hardware-realizable gates remains difficult.
Method
OpenFermion provides an open-source, modular, documented, and tested library that interfaces with electronic-structure packages, manipulates quantum operators, and delegates hardware-specific compilation to plugins.
Results
OpenFermion demonstrates end-to-end workflows from molecular and fermionic models to qubit operators, optimized circuits, numerical simulation, and Quil programs suitable for cloud simulation or hardware execution.
Takeaways & Limitations
The package lowers barriers for quantum algorithm developers and quantum chemists while supporting interoperable development of quantum chemistry and materials-simulation algorithms.
Abstract
from arXiv · showhide
Quantum simulation of chemistry and materials is predicted to be an important application for both near-term and fault-tolerant quantum devices. However, at present, developing and studying algorithms for these problems can be difficult due to the prohibitive amount of domain knowledge required in both the area of chemistry and quantum algorithms. To help bridge this gap and open the field to more researchers, we have developed the OpenFermion software package (www.openfermion.org). OpenFermion is an open-source software library written largely in Python under an Apache 2.0 license, aimed at enabling the simulation of fermionic models and quantum chemistry problems on quantum hardware. Beginning with an interface to common electronic structure packages, it simplifies the translation between a molecular specification and a quantum circuit for solving or studying the electronic structure problem on a quantum computer, minimizing the amount of domain expertise required to enter the field. The package is designed to be extensible and robust, maintaining high software standards in documentation and testing. This release paper outlines the key motivations behind design choices in OpenFermion and discusses some basic OpenFermion functionality which we believe will aid the community in the development of better quantum algorithms and tools for this exciting area of research.
INTRODUCTION
OpenFermion addresses the difficulty of translating quantum chemistry problems into hardware-realizable quantum algorithms by bridging chemistry and quantum-computing expertise. It provides an extensible, framework-agnostic package for specifying molecular systems and supporting this workflow.
- INTRODUCTION: Quantum simulation has promising applications, but compiling efficient algorithms into hardware-realizable gates remains difficult.The paper focuses on quantum simulation as an important application area for quantum devices.
- INTRODUCTION: Developing quantum chemistry algorithms can require prohibitive expertise because chemistry and quantum-information communities use different terminology and approximations.The paper argues that both communities have crucial roles in developing algorithms for emerging quantum devices.
- INTRODUCTION: OpenFermion bridges these domains by minimizing the knowledge required to begin and helping experienced researchers work more quickly.Its purpose is to facilitate explicit quantum simulation algorithms for quantum chemistry.
- A. Molecule specification and input generation: The package represents molecules through geometry, charge, multiplicity, and basis-set specifications before mapping the resulting problem toward qubits.Electronic structure concerns electronic configurations for fixed nuclear positions, while basis sets balance computational cost and accuracy.
- A. Molecule specification and input generation: OpenFermion supports explicit spin labels and molecular input workflows, including an H2 example defined with geometry and multiplicity.Spin symmetry can reduce spaces and expose excited states that are lowest within a spin manifold.
- A. Molecule specification and input generation: At present, basis sets are limited to implementations available through common molecular electronic-structure packages, with parametric or user-defined sets planned for future versions.The chemical problem is well defined after these specifications, but additional qubit-mapping steps remain.
B. Integral generation
OpenFermion generates electronic-structure data through plugins for established chemistry packages and stores molecular results in reusable, framework-agnostic data structures. Its storage design loads large arrays only when accessed.
- B. Integral generation: OpenFermion currently interfaces with Psi4 and PySCF through separately installed plugin libraries.The plugins are intended to hide underlying package details from users and can be expanded to additional packages.
- B. Integral generation: OpenFermion uses default parameters and external electronic-structure packages to supply computationally involved integral data and transformations.Hartree-Fock molecular-orbital transformations can make mean-field states easier to represent on classical and quantum computers, while adding cost and convergence challenges.
- B. Integral generation: These interfaces generate quantities such as two-electron integrals, molecular-orbital coefficients, correlated-method energies, reduced density matrices, and coupled-cluster amplitudes.The package exposes MP2, CISD, CCSD, and FCI energies through the generated molecular data.
- B. Integral generation: The resulting molecular data structure is agnostic to the electronic-structure package that generated it.This design supports analysis and reuse without exposing package-specific details.
- B. Integral generation: Molecular data are stored with HDF5 and loaded on demand, giving loading a minimal memory footprint for large arrays such as integrals and density matrices.Accessing an array-like attribute transparently loads the corresponding property.
C. Mapping to qubits
OpenFermion maps fermionic Hamiltonians to qubit operators and connects those representations to circuit-compilation frameworks. Examples demonstrate Jordan–Wigner transformations, numerical diagonalization, time evolution, and Gaussian-state preparation.
- C. Mapping to qubits: OpenFermion implements common fermion-to-qubit mappings including Jordan–Wigner and Bravyi–Kitaev transformations.These mappings account for the difference between indistinguishable fermions and distinguishable qubits.
- C. Mapping to qubits: The Jordan–Wigner workflow returns a qubit operator that completely specifies the transformed Hamiltonian acting on qubits.The representation can then be converted to a sparse or dense matrix for numerical analysis.
- C. Mapping to qubits: OpenFermion also maps bosonic Hamiltonians to optical propagation modes, or qumodes, through plugins for quantum-optics simulators.Bosonic-to-qubit mappings are described as possible future functionality.
- C. Mapping to qubits: Exact eigenvalues and eigenvectors of the H2 Hamiltonian can be obtained from the dense matrix of its transformed qubit Hamiltonian.The example uses standard linear-algebra routines after converting the operator representation.
- C. Mapping to qubits: Framework-specific plugins compile operator representations into circuits while keeping the core package agnostic to hardware and compilation platforms.Supported frameworks at the time include Cirq, Forest, and Strawberry Fields.
- C. Mapping to qubits: The examples include low-rank Trotter evolution for H2 and preparation of a Fermi–Hubbard tunneling ground state as a fermionic Gaussian state.The H2 example performs one Trotter step and merges single-qubit rotations; the Hubbard tunneling term has a Slater-determinant ground state.
2. Forest-OpenFermion Example
The Forest-OpenFermion example builds a Hubbard model, translates it into pyQuil-compatible PauliSum data, and generates first-order Trotter evolution. The resulting Quil program can be simulated or executed through Forest.
- 2. Forest-OpenFermion Example: The example constructs a four-site single-band periodic-boundary Hubbard model and applies first-order Trotter evolution to two localized electrons of opposite spin.The initial state places the electrons on the first spatial site.
- 2. Forest-OpenFermion Example: Forest-OpenFermion converts between OpenFermion QubitOperator objects and pyQuil PauliSum objects.This provides an interface between OpenFermion operator data and Rigetti’s Forest environment.
- 2. Forest-OpenFermion Example: The FermionOperator lets users translate a mathematical Hubbard Hamiltonian directly into executable code and modify its terms explicitly.The example defines hopping for α and β spin orbitals and includes Hermitian-conjugate terms.
- 2. Forest-OpenFermion Example: Jordan–Wigner transformation produces QubitOperators that are then converted into pyQuil PauliSum objects for circuit generation.The pyQuil exponentiate routine generates the first-order Trotter circuit for t = 0.1.
- 2. Forest-OpenFermion Example: The resulting Quil program initializes two localized electrons and applies the time-propagation circuit.That program can be sent to the Forest cloud API for simulation or execution on hardware.
3. SFOpenBoson Example
OpenFermion interfaces with Strawberry Fields through SFOpenBoson to simulate Bose-Hubbard models using continuous-variable gates and light propagation modes.
- A 2 × 2 Bose-Hubbard Hamiltonian is generated with tunneling 1, interaction 1.5, and chemical potential 0.5.
- SFOpenBoson converts OpenFermion BosonOperator and QuadOperator data into continuous-variable quantum-computation operations and gates.
- The example initializes a two-qumode circuit in Fock state |2, 0, 0, 0⟩ and evolves it to t = 0.1 using a 20-term Lie product formula.
- The simulated circuit applies beamsplitter gates across qumode pairs and a Kerr interaction on one qumode.
- The printed output lists the first applied gates and the qumodes on which they act.
II. DATA STRUCTURES
OpenFermion represents fermionic operators symbolically, enforcing fermionic statistics and supporting arithmetic, normal ordering, and efficient term combination.
- FermionOperator represents arbitrary linear combinations of fermionic creation and annihilation operators.
- Fermionic anti-commutation relations are handled transparently when operators are reordered into a unique normal-ordered form.
- OpenFermion supports addition, multiplication, and integer exponentiation of fermion operators while preserving consistent ladder-operator manipulation.
- Applying normal ordering to the demonstrated fourth power produces zero.
- FermionOperator stores ladder-operator sequences and coefficients in a hash table implemented with a Python dictionary.
- The hash-table design facilitates efficient arithmetic combination and near-automatic duplicate-term merging for modestly sized examples.
B. QubitOperator data structure
QubitOperator expresses quantum-computing operators as weighted products of Pauli operators and the identity, using a dictionary-backed symbolic representation.
- QubitOperator maps intermediate fermionic operators into the language of qubits through Pauli operators and identity.
- Tensor products of Pauli operators form a basis for Hermitian operators, with indexed symbols specifying the qubit acted upon.
- The example constructs O as Z1 Z2 plus X1 plus X2.
- QubitOperator uses a Python-dictionary hash table whose tuple keys encode Pauli types and target qubits.
C. BosonOperator and QuadOperator data structures
OpenFermion extends symbolic operator support to bosonic ladder and quadrature operators, including normal ordering, representation conversion, and Bose-Hubbard models.
- BosonOperator represents bosonic creation and annihilation operators and inherits symbolic-operator functionality from FermionOperator.
- Bosonic operators on different subsystems commute, so terms are stored with indices ordered ascendingly before normal ordering.
- QuadOperator represents Hermitian position and momentum operators in phase space, which satisfy [q_i, p_j] = iℏδ_ij.
- Quadrature normal ordering rearranges terms so position operators q_i appear to the left of momentum operators p_i.
- The ℏ parameter controls the convention used in quadrature commutation relations, defaulting to ℏ = 1 when omitted.
- BosonOperator and QuadOperator support conversion functions, sparse representations, symmetric ordering, Weyl quantization, and Bose-Hubbard models.
D. The MolecularData data structure
MolecularData stores the physical and computed quantities defining a molecular electronic-structure problem, while supporting disk-backed access and active-space reduction.
- MolecularData stores intermediate molecular quantities, including two-electron integrals and basis transformations.
- HDF5-backed getters and setters load only requested properties, reducing memory impact for large molecular objects.Gzip compression also minimizes disk storage requirements.
- Active-space approximations isolate selected orbitals by modifying one- and two-electron integrals and active electron and orbital counts.The procedure assumes a single reference and integrates out occupied orbitals.
- The active-space Hamiltonian can be used to build quantum circuits for the reduced-size problem.
E. The InteractionOperator data structure
InteractionOperator provides compact numerical representations for molecular Hamiltonians and supports efficient transformations, while InteractionRDM represents reduced density matrices used for fermionic energies.
- Hamiltonians with fewer than 100 qubits can contain tens to hundreds of millions of terms requiring roughly ten gigabytes of memory.Gaussian basis functions produce full O(N^4) term scaling.
- InteractionOperator stores a constant, an N by N one-body matrix, and an N by N by N by N two-body tensor.It trades some symmetry-based space efficiency for simplicity and numerical operability.
- QuadraticHamiltonian specializes representation and manipulation for Hamiltonians containing at most quadratic fermionic terms.It stores M, ∆, µ, and the constant term.
- Hash-table storage reduces Trotter-error computation from O(N^14) with linked-list iteration to O(N^10) while retaining average O(N^4) space complexity.For Hamiltonians with O(N^2) terms, the same implementation achieves O(N^4) time instead of O(N^6).
2. FermionOperator example: symbolic Fourier transformation
OpenFermion supports symbolic Fourier transformations and efficient basis operations, enabling verification of transformed Hamiltonians and reducing the cost of orbital integral transformations.
- OpenFermion supports symbolic manipulation of fermionic Hamiltonians to analyze simulation algorithms and Hamiltonian representations.A cited application reduced electronic-structure Trotter-step depth from O(N^4) to O(N).
- The discrete Fourier transform can be applied symbolically to a plane-wave Hamiltonian and simplified automatically through normal ordering.This verifies the compact plane-wave dual Hamiltonian form.
- Rotating molecular orbitals changes the one- and two-electron integrals and can support optimization of measurement-related quantities.The rotation is organized by the κ matrix and implemented through InteractionOperator transformations.
- 65?
4. QuadraticHamiltonian example: preparing fermionic Gaussian states
OpenFermion provides utilities for generating fermionic Hamiltonians, preparing Gaussian and Slater-determinant states, and converting operators into quantum circuits. These tools connect model specification and numerical or circuit-based study across several fermionic systems.
- QuadraticHamiltonian example: preparing fermionic Gaussian states: OpenFermion efficiently computes basis transformations for quadratic Hamiltonians and compiles circuits that prepare their fermionic Gaussian eigenstates.The transformation exploits matrix representations stored by the QuadraticHamiltonian class and numerical linear algebra routines.
- Model generation: The package can generate Hamiltonians for Hubbard, jellium, plane-wave, and d-wave superconductivity models.For example, a Fermi-Hubbard Hamiltonian can represent a 10×10 square lattice with periodic boundary conditions.
- Model generation: A two-dimensional homogeneous electron gas can be discretized as a spinful fermionic Hamiltonian on a 10 × 10 plane-wave grid and then transformed into qubit operators.The resulting operator can be used in a quantum algorithm of choice.
- Circuit utilities: OpenFermion outputs Trotter-Suzuki decompositions and corresponding QASM circuits for arbitrary operators, simplifying transfer to other simulation packages.The pauli_exp_to_qasm function accepts QubitOperators and an optional evolution time, returning a QASM specification.
- Circuit utilities: Additional utilities evaluate Trotter error operators and prepare arbitrary Slater determinants using a linear-depth procedure.Numerical simulation support is included for testing, while specialized plugins handle heavier simulation tasks.
IV. OPEN SOURCE MANAGEMENT AND PROJECT PHILOSOPHY
OpenFermion is managed as an open-source, framework-independent project with documented code, reviewed contributions, automated tests, and several distribution options. Its community-oriented design aims to support developers across industry, academia, and research institutions.
- Project philosophy: OpenFermion uses an open-source, framework-independent model intended to support developers in industry, academia, and research institutions.The project also encourages users to contribute useful code back to the community.
- Development practices: The primarily Python code follows PEP8, uses descriptive names, and requires extensive documentation to improve readability and support reliable contributions.Optional C++ backends are being introduced when higher performance is needed.
- Development practices: GitHub pull requests require review by at least one experienced OpenFermion team member, with familiar contributors potentially becoming approved reviewers.Review covers both coding style and integration prospects.
- Development practices: Unit tests run automatically through Travis continuous integration, and code is required to remain compatible with both Python 2 and Python 3.These practices aim to reduce accidental breakage of crucial functionality and support a smooth development and execution experience.
- Distribution: Users can install OpenFermion from GitHub, PyPI, or a development checkout, while Docker provides a portable option for supported systems and non-standard architectures.The GitHub route offers maximum control but minimal convenience; PyPI prioritizes simpler installation.
- Distribution: Future distribution support for other platforms is described as a possibility rather than an available feature.The project also requires plugins and their dependencies to be installed separately.