Skip to content

Quantum chemistry

FermiLib

Maintained by ProjectQ-Framework

FermiLib: Open source software for analyzing fermionic quantum simulation algorithms

PythonApache-2.0
FermiLib illustration

Resource snapshot

Category

Quantum chemistry

Stars

90

Last pushed

May 4, 2018Updated 8y ago

Open issues

4

What it is

FermiLib is maintained by ProjectQ-Framework and sits in the Quantum chemistry lane of the open-source quantum map.

FermiLib: Open source software for analyzing fermionic quantum simulation algorithms It commonly appears alongside projectq-framework-projectq in example workflows.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Researchers, students, and developers exploring how quantum software is used for chemistry and electronic-structure problems.

What you can build or learn

  • See how chemistry problems are mapped into quantum-friendly representations.
  • Understand the workflow around Hamiltonians, ansatze, and measurement loops.
  • Compare beginner-friendly entry points into chemistry-focused quantum tooling.

Code samples

Examples from the repository.

Fermilib Demo (examples/fermilib_demo.ipynb)
from fermilib.ops import FermionOperator

my_term = FermionOperator(((3, 1), (1, 0)))
print(my_term)

my_term = FermionOperator('3^ 1')
print(my_term)
Performance Benchmarks (examples/performance_benchmarks.py)
#   Copyright 2017 ProjectQ-Framework (www.projectq.ch)
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
"""This file contains tests of code performance to reveal bottlenecks."""
import numpy
import time
from fermilib.ops import FermionOperator, InteractionOperator, normal_ordered
from fermilib.transforms import get_fermion_operator, jordan_wigner
from fermilib.utils import jordan_wigner_sparse
def artificial_molecular_operator(n_qubits):
    """Make an artificial random InteractionOperator for testing purposes."""
    # Initialize.
    constant = numpy.random.randn()
    one_body_coefficients = numpy.zeros((n_qubits, n_qubits), float)
    two_body_coefficients = numpy.zeros((n_qubits, n_qubits,
                                         n_qubits, n_qubits), float)
    # Randomly generate the one-body and two-body integrals.
    for p in range(n_qubits):
        for q in range(n_qubits):
            # One-body terms.
            if (p <= p) and (p % 2 == q % 2):
                one_body_coefficients[p, q] = numpy.random.randn()
                one_body_coefficients[q, p] = one_body_coefficients[p, q]
            # Keep looping.
            for r in range(n_qubits):
                for s in range(n_qubits):
                    # Skip zero terms.
                    if (p == q) or (r == s):
                        continue
                    # Identify and skip one of the complex conjugates.

Plays well with

License

Apache-2.0

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~462 words · about 2 min readOpen on GitHub

FermiLib - Open source software for analyzing quantum simulation algorithms

.. image:: https://travis-ci.org/ProjectQ-Framework/FermiLib.svg?branch=master :target: https://travis-ci.org/ProjectQ-Framework/FermiLib

.. image:: https://coveralls.io/repos/github/ProjectQ-Framework/FermiLib/badge.svg :target: https://coveralls.io/github/ProjectQ-Framework/FermiLib

.. image:: https://readthedocs.org/projects/fermilib/badge/?version=latest :target: http://fermilib.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

FermiLib is an open source effort for compiling and analyzing quantum simulation algorithms.

The current version is an alpha release which features data structures and tools for obtaining and manipulating representations of fermionic Hamiltonians. FermiLib is designed as a library on top of ProjectQ <https://github.com/ProjectQ-Framework/ProjectQ>__ and leverages ProjectQ to compile, emulate and simulate quantum circuits. There are also plugins <http://projectq.ch/code-and-docs/#Fermilib>__ available for FermiLib.

You may also be interested in OpenFermion <http://openfermion.org>__, an actively developed FermiLib fork which is designed without an explicit dependency on ProjectQ in order to support a variety of circuit compilation and simulation frameworks.

Getting started

To start using FermiLib, follow the installation instructions in the intro <http://fermilib.readthedocs.io/en/latest/intro.html>. There, you will also find code examples <http://fermilib.readthedocs.io/en/latest/examples.html>. Also, make sure to check out the ProjectQ website <http://www.projectq.ch>__ and the detailed code documentation <http://fermilib.readthedocs.io/en/latest/fermilib.html>__. Alternatively, consider creating a Docker container defined by the Dockerfile found inside the docker directory. Moreover, take a look at the available plugins for FermiLib.

Plugins

In order to generate molecular hamiltonians in Gaussian basis sets and perform other complicated electronic structure calculations, one can install plugins. We currently support Psi4 (plugin here <https://github.com/ProjectQ-Framework/FermiLib-Plugin-Psi4>, recommended) and PySCF (plugin here <https://github.com/ProjectQ-Framework/FermiLib-Plugin-PySCF>).

How to contribute

To contribute code please adhere to the following very simple rules:

  1. Make sure your new code comes with extensive tests!
  2. Make sure you adhere to our style guide. Until we release a code style guide, just have a look at our code for clues. We mostly follow pep8 and use the pep8 linter to check for it.
  3. Put global constants and configuration parameters into src/fermilib/config.py, and add *from config import ** in the file that uses the constants/parameters.

Documentation can be found here <http://fermilib.readthedocs.io/>_.

Authors

The first release of FermiLib (v0.1a0) was developed by Ryan Babbush <https://research.google.com/pubs/RyanBabbush.html>, Jarrod McClean <https://crd.lbl.gov/departments/computational-science/ccmc/staff/alvarez-fellows/jarrod-mcclean/>, Damian S. Steiger <http://www.comp.phys.ethz.ch/people/person-detail.html?persid=165677>, Ian D. Kivlichan <http://aspuru.chem.harvard.edu/ian-kivlichan/>, Thomas Häner <http://www.comp.phys.ethz.ch/people/person-detail.html?persid=179208>, Vojtech Havlicek <https://github.com/VojtaHavlicek>, Matthew Neeley <https://maffoo.net/>, and Wei Sun <https://github.com/Spaceenter>.

How to cite

When using FermiLib for research projects, please cite:

Jarrod R. McClean, Ian D. Kivlichan, Kevin J. Sung, Damian S. Steiger,
Yudong Cao, Chengyu Dai, E. Schuyler Fried, Craig Gidney, Brendan Gimby,
Thomas Häner, Tarini Hardikar, Vojtĕch Havlíček, Cupjin Huang, Zhang Jiang,
Matthew Neeley, Thomas O'Brien, Isil Ozfidan, Maxwell D. Radin, Jhonathan Romero,
Nicholas Rubin, Nicolas P. D. Sawaya, Kanav Setia, Sukin Sim, Mark Steudtner,
Wei Sun, Fang Zhang and Ryan Babbush.
*OpenFermion: The Electronic Structure Package for Quantum Computers*.
`arXiv:1710.07629 <https://arxiv.org/abs/1710.07629>`__. 2017.

Questions?

If you have any other questions, please contact fermilib@projectq.ch.

License

FermiLib is released under the Apache 2 license.

Read on GitHub

Activity

Latest release

—

Watchers

23

Python support

—

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

cda-tum

mqt-dasqa

MQT DASQA - Designer for Superconducting Quantum Architectures

PythonMIT

21 stars · Updated 1y ago

quantumlib

OpenFermion

Python package for compiling and analyzing quantum algorithms to simulate electronic structures.

PythonApache-2.0Flagship

1,697 stars · Updated 3mo ago

Qiskit

qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.

PythonApache-2.0

385 stars · Updated 3mo ago

eclipse-qrisp

Qrisp

Qrisp - The next generation of quantum algorithm development

PythonEPL-2.0

267 stars · Updated 3mo ago

aspuru-guzik-group

tequila

A High-Level Abstraction Framework for Quantum Algorithms

PythonMITFlagship

428 stars · Updated 3mo ago

ornl-qci

xacc-vqe

DEPRECATED - Variational quantum eigensolver built on XACC

C++BSD-3-Clause

14 stars · Updated 7y ago