OpenFermion
repository·main·Indexed 23 days ago
https://github.com/quantumlib/openfermionAn open-source Python package for compiling and analyzing quantum algorithms to simulate fermionic systems, such as those in quantum chemistry. It provides tools for manipulating fermionic and qubit Hamiltonians and includes a modular plugin architecture for high-performance simulators (OpenFermion-FQE), circuit compilation (Forest-OpenFermion, SFOpenBoson), and electronic structure packages (Psi4, PySCF, DIRAC, Q-Chem). It also features a cloud library for molecular data and resource estimation for periodic systems.
What's inside OpenFermion
- OpenFermion is an open-source library designed for compiling and analyzing quantum algorithms used to simulate fermionic systems, such as those found in quantum chemistry. It provides specialized data structures and tools for creating, obtaining, and manipulating representations of both fermionic and qubit Hamiltonians.
Explore OpenFermion projects and use cases
mainYou can find implementation examples and research projects that utilize OpenFermion:
- Hackathon Quantum Autoencoder (QCompress): Combines OpenFermion with Rigetti's framework to compress molecular representations using an autoencoder.
- CUSP Implementation: Uses OpenFermion and Cirq to implement the Compressed Unsupervised State Preparation (CUSP) protocol, which utilizes quantum autoencoders to synthesize compact circuits for algorithms like VQE.
Explore OpenFermion plugins
mainOpenFermion uses a modular plugin architecture to extend its functionality for simulation, circuit compilation, and electronic structure calculations.
High-performance simulators
- OpenFermion-FQE: A high-performance emulator of fermionic quantum evolutions that exploits symmetries like spin and particle number.
Circuit compilation plugins
- Forest-OpenFermion: Integrates with Forest.
- SFOpenBoson: Integrates with Strawberry Fields.
Electronic structure package plugins
Extend OpenFermion with plugins
mainOpenFermion uses a modular plugin architecture to extend its core functionality. Users can install specific plugins to enable circuit compilation, quantum circuit simulation, or integration with classical electronic structure calculation packages.
Circuit compilation and simulation plugins
To integrate OpenFermion with specific quantum computing frameworks, use:
- Forest-OpenFermion: For integration with Forest.
- SFOpenBoson: For integration with Strawberry Fields.
Electronic structure package plugins
To perform classical electronic structure calculations using established chemistry software, use:
Install OpenFermion via Docker (Windows/Alternative)
mainOpenFermion is primarily tested on Mac and Linux because its electronic structure plugins require these environments. For Windows users or those facing installation issues, a Docker image is available in thedocker/folder of the repository. This image provides a virtual environment with OpenFermion and selected plugins pre-installed and can run on any operating system.Install OpenFermion with resource estimation dependencies
mainTo use the
openfermion.resource_estimates.pbcmodule, you must install theresourcesextra dependency. This ensures that the necessary requirements for resource estimation are present in your environment.pip install openfermion[resources]Upload data files to the OpenFermion Cloud Library
mainContributing data to the OpenFermion Cloud Library involves a multi-step process using Google Cloud Storage and GitHub. Follow these steps to share your molecular data:
- Prepare files: Generate your data files and compress them into a single archive (e.g.,
.zip). If using a different compression format, specify it in your pull request. - Create a manifest: Open a pull request on the OpenFermion repository. Create a new file (for a new dataset) or edit an existing one (to expand a dataset). The filename must match the dataset name. The first line must describe the dataset, and subsequent lines must list the filenames within the dataset.
- Request a Signed URL: Provide your email address in the pull request or contact the OpenFermion team via email to request a signed URL for uploading.
- Upload to staging: Once you receive the signed URL via email, upload your compressed file to the staging bucket using
curl. - Review: OpenFermion administrators will perform a security review. Once approved, your data will be moved to the production bucket, and your pull request will be merged to signal public availability.
curl -X PUT --upload-file <your_files.zip> <signed_url>- Prepare files: Generate your data files and compress them into a single archive (e.g.,
Run Jupyter Notebook with a Docker backend
mainTo run Jupyter notebooks (like OpenFermion demos) in your web browser using the Docker container as the backend, follow these steps:
- Find the VM IP: Determine the IP address of your Docker virtual machine using
docker-machine ip default. - Start the container with port mapping: Run the container using the
-pflag to map the Jupyter port (e.g., 8888) from the container to your host. - Launch Jupyter: Inside the container terminal, execute the
jupyter-notebookcommand with specific flags to allow root access and remote connections. - Access via Browser: Copy the token provided in the terminal output and navigate to
[virtual machine ip]:8888in your browser.
- Find the VM IP: Determine the IP address of your Docker virtual machine using
Get started with the Fermionic Quantum Emulator (FQE)
mainThe Fermionic Quantum Emulator (FQE) is a high-performance simulator specialized for Fermionic circuits. To begin using FQE, you should consult the Introduction to FQE notebook and explore the available tutorials to understand its specialized simulation capabilities.Install OpenFermion for developers
mainTo install the latest version of OpenFermion in development mode, clone the repository and install it using
pipwith the-e(editable) flag. This allows you to make changes to the source code and have them reflected immediately without re-installing.git clone https://github.com/quantumlib/OpenFermion cd OpenFermion python -m pip install -e .Integrate OpenFermion with quantum computing frameworks
mainSeveral plugin libraries allow OpenFermion to interface with quantum computing and simulation frameworks:
- Forest-OpenFermion: Integrates with Rigetti's Forest framework to compile quantum simulation algorithms to NISQ circuits.
- PennyLane: The
pennylane.qchemmodule integrates OpenFermion with Xanadu's PennyLane framework, enabling optimization of quantum simulation algorithms using TensorFlow and PyTorch on quantum hardware. - SFOpenBoson: Integrates with Xanadu's Strawberry Fields framework for compiling quantum simulation algorithms related to boson simulation.
- OpenFermion-ProjectQ (Deprecated): An older integration with the ProjectQ framework for simulating quantum circuits.
Build OpenFermion API documentation
mainTo generate Markdown API documentation from the local repository, you must first install thetensorflow-docspackage. Then, run the provided build script to generate the files into a specified output directory.