OpenFermion: the electronic structure package for quantum computers

Jarrod R. McClean, Kevin J. Sung, Ian Kivlichan, Yudong Cao, Chengyu Dai, Eliot Fried, Craig Gidney, Brendan Gimby, Pranav Gokhale, Thomas Häner, Tarini Hardikar, Vojtěch Havlíček, Oscar Higgott, Cupjin Huang, Josh Izaac, Jiang Zhang, Xinle Liu, Sam McArdle, M. Neeley, Thomas E. O’Brien, Bryan O’Gorman, Isil Ozfidan, Maxwell D. Radin, Jonathan Romero, Nicholas C. Rubin, Nicolas P. D. Sawaya, Kanav Setia, Sukin Sim, Damian S. Steiger, Mark Steudtner, Qiming Sun, W. Sun, Daochen Wang, Fang Zhang, Ryan BabbushQuantum 2020 · DOI

Abstract

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 and bosonic 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

Quantum simulation of chemistry and materials is widely considered the "killer app" for both near-term (NISQ) and future fault-tolerant quantum computers. However, a massive "domain knowledge gap" exists between two critical fields. Quantum chemists are experts in basis sets, molecular integrals, and Hartree-Fock methods but may not know how to map these to qubits and gates. Conversely, quantum algorithmists understand qubits and circuit complexity but are often stymied by the jargon and prohibitive data requirements (like $O(N^4)$ two-electron integrals) of chemistry.

Manually bridging this gap is error-prone and tedious. OpenFermion provides a standardized, modular "middleware" that handles the heavy lifting of generating, storing, and transforming chemical Hamiltonians into quantum-ready formats, allowing researchers to focus on algorithm development rather than data translation.

Methods and Architecture

OpenFermion is built on a modular, plugin-based architecture that remains agnostic to specific quantum hardware or programming languages. Key components include:

  • Classical Interfaces: Plugins pull data from established electronic structure packages like Psi4 and PySCF.
  • Specialized Data Structures:
    • FermionOperator and BosonOperator: Handle symbolic second-quantized operators with automatic "normal-ordering."
    • InteractionOperator: A memory-efficient way to store the $O(N^4)$ coefficients of a molecular Hamiltonian.
  • MolecularData: A central hub that organizes molecular properties (geometry, integrals, energies) and stores them in HDF5 format.
  • Mappings: Standard transformations—such as Jordan-Wigner and Bravyi-Kitaev—convert fermionic operators into QubitOperator objects (sums of Pauli strings).
  • Circuit Generation: Through plugins like OpenFermion-Cirq, the library can automatically generate quantum circuits for tasks like Trotterized time evolution or Gaussian state preparation.
A text-based representation of a quantum circuit generated by OpenFermion, illustrating the mapping of fermionic operators to a sequence of gates across multiple qubits.

Key Insights and Design Philosophy

Several design choices ensure OpenFermion is both efficient and flexible:

  • The Power of Hashing: Internally, operators are stored as hash tables (Python dictionaries). This allows for near-constant-time combination of terms, which is essential when dealing with Hamiltonians that can have millions of terms.
  • Agnosticism as a Feature: By not tying itself to a single quantum language (like Q# or Quil), OpenFermion acts as a universal translator that benefits the entire ecosystem.
  • Symbolic vs. Numerical: The library excels at symbolic manipulation (e.g., verifying a Fourier transform of a plane-wave basis) while providing the numerical hooks needed for classical simulation and debugging.
  • Active Development Philosophy: The authors prioritize ease of use and extensibility, choosing structures like InteractionOperator that are intuitive for researchers, with plans to optimize for memory only as verified bottlenecks arise.

Key Results

The paper demonstrates that a researcher can go from a simple XYZ molecular geometry to a fully optimized quantum circuit in just a few dozen lines of Python code. OpenFermion successfully handles both fermionic systems (electrons in molecules) and bosonic systems (photons in qumodes). It provides a unified interface for major quantum frameworks, including Google’s Cirq, Rigetti’s Forest, and IBM’s Qiskit. Furthermore, the library has demonstrated the ability to compute Trotter error operators for systems with hundreds of qubits, a task that would be classically intractable without efficient symbolic handling.

Limitations and Future Work

While robust, the current version of OpenFermion has areas for growth. The InteractionOperator does not yet fully exploit the 8-fold symmetry of real molecular integrals to save memory. Additionally, the $O(N^4)$ scaling of terms in standard Gaussian basis sets remains a challenge for very large molecules. Future work will focus on expanding plugin support for more classical chemistry packages and implementing more sophisticated quantum state preparation algorithms and error mitigation strategies.

Summary updated

BibTeX
@inproceedings{mcclean2020openfermion,
  author = {Jarrod R. McClean and Kevin J. Sung and Ian Kivlichan and Yudong Cao and Chengyu Dai and Eliot Fried and Craig Gidney and Brendan Gimby and Pranav Gokhale and Thomas Häner and Tarini Hardikar and Vojtěch Havlíček and Oscar Higgott and Cupjin Huang and Josh Izaac and Jiang Zhang and Xinle Liu and Sam McArdle and M. Neeley and Thomas E. O’Brien and Bryan O’Gorman and Isil Ozfidan and Maxwell D. Radin and Jonathan Romero and Nicholas C. Rubin and Nicolas P. D. Sawaya and Kanav Setia and Sukin Sim and Damian S. Steiger and Mark Steudtner and Qiming Sun and W. Sun and Daochen Wang and Fang Zhang and Ryan Babbush and Fang Zhang and Ryan Babbush},
  title = {{OpenFermion: the electronic structure package for quantum computers}},
  booktitle = {Quantum},
  year = {2020},
  doi = {10.1088/2058-9565/ab8ebc},
}
Figure