# OpenFermion

**OpenFermion** 是一个开源 Python 库，采用 Apache 2.0 许可证，用于编译和分析模拟费米子系统（包括量子化学）的量子算法。它提供数据结构和工具，用于获取和操作费米子与量子比特哈密顿量的表示形式，并能将分子规格转换为可作为量子电路运行的形式。<sup>[1](https://github.com/quantumlib/openfermion)</sup><sup> • </sup><sup>[2](https://arxiv.org/abs/1710.07629)</sup>

| 关键事实 | 详情 |
|---|---|
| 简介 | 用于编译和分析模拟费米子系统（包括量子化学）的量子算法的开源 Python 包<sup>[1](https://github.com/quantumlib/openfermion)</sup> |
| 首次发布 | 2017 年 10 月 25 日公布，Google 称其为首个将化学与材料问题转化为量子电路的开源平台<sup>[3](https://opensource.googleblog.com/2017/10/announcing-openfermion-open-source.html)</sup> |
| 许可证与论文 | Apache 2.0；发布论文由 Jarrod R. McClean 及另外 34 位作者撰写，arXiv:1710.07629，2017 年 10 月 20 日提交<sup>[2](https://arxiv.org/abs/1710.07629)</sup> |
| 核心数据结构 | `FermionOperator`，即费米子产生算符 \( a^\dagger_k \) 与湮灭算符 \( a_k \) 之积的加权和<sup>[4](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=661122158)</sup> |
| 量子比特映射 | Jordan-Wigner 变换与 Bravyi-Kitaev 变换可将 `FermionOperator` 映射为 `QubitOperator`，同时保持正则反对易关系<sup>[5](https://colab.research.google.com/github/quantumlib/OpenFermion/blob/main/docs/tutorials/intro_workshop_exercises.ipynb)</sup> |
| 插件 | 电子结构方面有 OpenFermion-Psi4、OpenFermion-PySCF、OpenFermion-Dirac 和 OpenFermion-QChem；电路框架方面有 Forest-OpenFermion 和 SFOpenBoson；模拟方面有 OpenFermion-FQE<sup>[1](https://github.com/quantumlib/openfermion)</sup> |
| 当前版本 | v1.8.1，恢复了 `PolynomialTensor.rotate_basis()` 在 1.8.0 之前的行为；v1.7.0 将最低 Python 版本要求提高到 3.10<sup>[6](https://github.com/quantumlib/OpenFermion/releases)</sup> |

## 目的与起源

在量子计算机上模拟化学与材料问题，有望成为近期乃至容错量子设备的主要用途之一，然而为这些问题设计算法需要同时具备化学和量子算法两方面的专业知识。OpenFermion 正是为了弥合这一鸿沟而创建的：它简化了分子规格与量子电路之间的转换，将进入该领域所需的专业知识降到最低。<sup>[2](https://arxiv.org/abs/1710.07629)</sup>

该项目始于 Google，苏黎世联邦理工学院、劳伦斯伯克利国家实验室、密歇根大学、哈佛大学、牛津大学、达特茅斯学院、Rigetti Computing 和 NASA 的合作者参与了 alpha 版本的开发。<sup>[3](https://opensource.googleblog.com/2017/10/announcing-openfermion-open-source.html)</sup> 发布论文《OpenFermion：面向量子计算机的电子结构软件包》由 Jarrod R. McClean、Kevin J. Sung、Ian D. Kivlichan、曹宇东及另外 31 位作者于 2017 年 10 月 20 日提交至 arXiv，Ryan Babbush 亦为贡献者之一。<sup>[2](https://arxiv.org/abs/1710.07629)</sup>

## 如何表示费米子系统

费米子系统在二次量子化（以场而非粒子数为基本对象的表述形式）框架下处理，其中算符由满足正则反对易关系 \( \{a^\dagger_i, a^\dagger_j\} = \{a_i, a_j\} = 0 \) 与 \( \{a_i, a^\dagger_j\} = \delta_{ij} \) 的产生算符 \( a^\dagger_k \) 和湮灭算符 \( a_k \) 构建。这些升降算符之积的任意加权和由 `FermionOperator` 类表示，其实现为一个 Python 字典，键编码算符字符串，值存储系数。<sup>[4](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=661122158)</sup>

对于结构已知的哈密顿量，则用专门的基于数组的结构来存储，以便快速进行数值操作：<sup>[7](https://quantumai.google/openfermion/tutorials/intro_workshop_exercises?authuser=557)</sup>

- `InteractionOperator` 存储分子哈密顿量 \( \sum_{pq} T_{pq} a_p^\dagger a_q + \sum_{pqrs} V_{pqrs} a_p^\dagger a_q^\dagger a_r a_s \) 的单体和双体张量 \( T_{pq} \) 与 \( V_{pqrs} \)，是分子哈密顿量的默认数据结构。
- `DiagonalCoulombHamiltonian` 存储带有对角库仑项的哈密顿量，这种形式可导出特别高效的量子模拟算法。
- `QuadraticHamiltonian` 存储一般二次哈密顿量的厄米矩阵 \( M_{pq} \) 与反对称矩阵 \( \Delta_{pq} \)，并附带高效对角化例程，可处理数千个费米子模式。

## 将费米子映射到量子比特

费米子变换将 `FermionOperator` 映射为 `QubitOperator`，同时保持正则反对易关系。最基本的变换是 Jordan-Wigner 变换（JWT）与 Bravyi-Kitaev 变换（BKT）；BKT 要求预先确定量子比特总数，而凡隐式应用变换之处，用的都是 JWT。<sup>[5](https://colab.research.google.com/github/quantumlib/OpenFermion/blob/main/docs/tutorials/intro_workshop_exercises.ipynb)</sup> OpenFermion 还实现了 Bravyi-Kitaev 超快（BKSF）变换。<sup>[8](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/6c6d49fa6a7ec788f4611cf41c393907da2c7c37.pdf)</sup>

## 插件与生态

OpenFermion 的大量功能依赖模块化插件包，用于模拟和编译量子电路，以及执行经典电子结构计算：<sup>[1](https://github.com/quantumlib/openfermion)</sup>

- **电子结构插件**连接经典化学软件包：OpenFermion-Psi4（Psi4）、OpenFermion-PySCF（PySCF）、OpenFermion-Dirac（DIRAC）和 OpenFermion-QChem（Q-Chem）。这些插件让第三方软件包能够使用高斯基组计算分子轨道、哈密顿量、能量、约化密度矩阵和耦合簇振幅。<sup>[1](https://github.com/quantumlib/openfermion)</sup><sup> • </sup><sup>[9](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=610)</sup>
- **电路编译插件**与量子框架集成：Forest-OpenFermion 对接 Rigetti 的 Forest，SFOpenBoson 对接 Strawberry Fields。<sup>[1](https://github.com/quantumlib/openfermion)</sup>
- **OpenFermion-FQE**（费米子量子模拟器）是一个高性能的费米子量子演化模拟器，利用粒子数和自旋等费米子对称性。它与 OpenFermion 完全集成，可作为模拟后端，相比量子比特态矢量模拟器可减少内存占用。<sup>[1](https://github.com/quantumlib/openfermion)</sup><sup> • </sup><sup>[10](https://arxiv.org/abs/2104.13944)</sup>

Cirq 集成通过独立的 OpenFermion-Cirq 包提供，其文档涵盖门、原语、哈密顿量模拟、变分算法和优化。<sup>[11](https://openfermion-cirq.readthedocs.io/en/latest/)</sup> 计算结果保存在 OpenFermion 的 `MolecularData` 对象中，并采用数据溯源策略，将关键结果（包括指向分子积分文件的指针）存储在 HDF5 容器中。<sup>[9](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=610)</sup>

## 与其他化学工具的关系

OpenFermion、Qiskit Nature 以及 PennyLane 的量子化学模块都处理费米子到量子比特哈密顿量的构建问题，但设计理念各不相同。OpenFermion 暴露 `FermionOperator`、`InteractionOperator` 和各个映射函数等较底层的原语，其核心与框架无关，允许将哈密顿量导出到 Cirq、Qiskit 或 PennyLane 等执行框架；代价是用户需要自行搭建转译与执行流水线。Qiskit Nature 和 PennyLane 则将更多流水线封装进高层求解器类中。<sup>[12](https://quantumcomputingcourses.com/reference/openfermion)</sup><sup> • </sup><sup>[13](https://inferensys.com/differences/quantum-machine-learning-qml-software-frameworks/variational-quantum-algorithm-implementations/qiskit-nature-vs-openfermion-for-chemistry-hamiltonians)</sup> PennyLane 可通过其 `import_operator()` 函数，将用 OpenFermion 工具构建的哈密顿量转换为 PennyLane 可观测量。<sup>[14](https://docs.pennylane.ai/en/stable/introduction/chemistry.html)</sup>

## 安装与当前开发

OpenFermion 可通过 pip 从 PyPI 安装（`python -m pip install --user openfermion`），已在 Mac、Windows 和 Linux 上测试，但电子结构插件仅兼容 Mac 和 Linux；其他情况下可使用预装 OpenFermion 及部分插件的 Docker 镜像。文档托管于 quantumai.google/openfermion，交互式 Jupyter 教程可在 Colab 或 MyBinder 中运行。<sup>[1](https://github.com/quantumlib/openfermion)</sup>

近期版本显示出对周边 Python 生态兼容性的积极维护。1.7.0 版将最低 Python 版本提高到 3.10，并更新了 Cirq 等依赖项；1.7.1 版增加了对 NumPy 2 的兼容性；1.8.0 版新增了 `trotter_steps_required_propagator`、`MolecularData` 中对任意多重度的支持，以及 `SymbolicOperator.isclose` 的容差参数；1.8.1 版修复了 1.8.0 引入的 `PolynomialTensor.rotate_basis()` 向后不兼容问题，通过显式的 `transpose` 参数默认恢复原有行为。<sup>[6](https://github.com/quantumlib/OpenFermion/releases)</sup> 该 GitHub 仓库隶属于 quantumlib 组织，约有 1700 颗星和 442 次复刻。<sup>[1](https://github.com/quantumlib/openfermion)</sup>

## References

1. [OpenFermion GitHub repository (quantumlib/OpenFermion)](https://github.com/quantumlib/openfermion)
2. [McClean, J. R., et al. OpenFermion: The Electronic Structure Package for Quantum Computers. arXiv:1710.07629](https://arxiv.org/abs/1710.07629)
3. [Announcing OpenFermion: the open source chemistry package for quantum computers, Google Open Source Blog (October 25, 2017)](https://opensource.googleblog.com/2017/10/announcing-openfermion-open-source.html)
4. [Introduction to OpenFermion, Google Quantum AI](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=661122158)
5. [Quantum simulation of electronic structure workshop exercises (Colab notebook), Google Quantum AI](https://colab.research.google.com/github/quantumlib/OpenFermion/blob/main/docs/tutorials/intro_workshop_exercises.ipynb)
6. [Releases, quantumlib/OpenFermion, GitHub](https://github.com/quantumlib/OpenFermion/releases)
7. [Quantum simulation of electronic structure tutorial, Google Quantum AI](https://quantumai.google/openfermion/tutorials/intro_workshop_exercises?authuser=557)
8. [OpenFermion: The Electronic Structure Package for Quantum Computers (PDF), Google Research](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/6c6d49fa6a7ec788f4611cf41c393907da2c7c37.pdf)
9. [Introduction to OpenFermion (data provenance and plugins), Google Quantum AI](https://quantumai.google/openfermion/tutorials/intro_to_openfermion?authuser=610)
10. [Rubin, N. C., et al. The Fermionic Quantum Emulator. arXiv:2104.13944](https://arxiv.org/abs/2104.13944)
11. [OpenFermion-Cirq documentation](https://openfermion-cirq.readthedocs.io/en/latest/)
12. [OpenFermion Reference Dictionary, Quantum Computing Courses](https://quantumcomputingcourses.com/reference/openfermion)
13. [Qiskit Nature vs OpenFermion: Chemistry Hamiltonian Guide, Inference Systems](https://inferensys.com/differences/quantum-machine-learning-qml-software-frameworks/variational-quantum-algorithm-implementations/qiskit-nature-vs-openfermion-for-chemistry-hamiltonians)
14. [Quantum Chemistry, PennyLane documentation](https://docs.pennylane.ai/en/stable/introduction/chemistry.html)

---
*Initially written Oct 22, 2026*

Topic: 物质世界与数学 › 物理学 › 量子物理学 › Quantum information science › Quantum computing and algorithms › Quantum simulation › Quantum simulation for chemistry and electronic structure

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/openfermion

English original: https://www.edgepedia.org/openfermion
