qalgora-Q Docs Hub量子文档 ✦ Ask AI✦ 问问文档

OpenFermion Interop

◐ Design-level API
This page documents qalgora-Q API design, architecture, or adaptation workflows. Code examples illustrate intended usage and are not guaranteed to run in the current reference implementation.

OpenFermion is Google's library for fermionic operators and quantum chemistry. qalgora-Q maps its operators to spin operators so you can run quantum-chemistry workflows on backends that support the relevant gate set, observable measurement, and parameterized circuits.

Fermion to qubit operator

The from_openfermion adapter and the VQE workflow below are planned interfaces. The OpenFermion construction itself is standard OpenFermion; the qalgora-Q conversion and execution lines are shown as a spec.

import qalgora
import openfermion as of

# a fermionic Hamiltonian from OpenFermion, Jordan-Wigner mapped
fermion_op = of.FermionOperator("0^ 1", 1.0) + of.FermionOperator("1^ 0", 1.0)
qubit_op = of.jordan_wigner(fermion_op)

# Planned adapter:
# hamiltonian = qalgora.from_openfermion(qubit_op)   # -> qalgora spin_op
# print(hamiltonian)
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.

Run VQE on the converted Hamiltonian

# Planned VQE workflow on the converted Hamiltonian:
# energy, params = qalgora.vqe(ansatz, hamiltonian, optimizer,
#                              parameter_count=n)
# print("ground-state energy:", energy)
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.
Whole pipeline
Build the molecule in OpenFermion, convert here (planned adapter), and run on the open reference CPU simulator, or export to vendor hardware via their SDK — see Quantum Chemistry.
Notes
On real QPUs, VQE is more than "any backend": it also involves Pauli-term grouping, shot budgets, error mitigation, ansatz transpilation to the native gate set, and measurement-basis rotation for each observable.

References

  • J. R. McClean et al., "OpenFermion: the electronic structure package for quantum computers," Quantum Sci. Technol. 5, 034014 (2020). doi:10.1088/2058-9565/ab8ebc

OpenFermion 互操作

◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。

OpenFermion 是 Google 的费米子算符与量子化学库。qalgora-Q 将其算符映射为自旋算符,使你可以在支持相应门集、可观测量测量和参数化线路的后端上运行量子化学工作流。

费米子到量子比特算符的映射

下面的 from_openfermion 适配器与 VQE 工作流均为规划接口。OpenFermion 部分本身是标准 OpenFermion;qalgora-Q 的转换与执行行以规范形式给出。

import qalgora
import openfermion as of

# a fermionic Hamiltonian from OpenFermion, Jordan-Wigner mapped
fermion_op = of.FermionOperator("0^ 1", 1.0) + of.FermionOperator("1^ 0", 1.0)
qubit_op = of.jordan_wigner(fermion_op)

# 规划中的适配器:
# hamiltonian = qalgora.from_openfermion(qubit_op)   # -> qalgora spin_op
# print(hamiltonian)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。

在转换后的哈密顿量上运行 VQE

# 规划中的 VQE 工作流(在转换后的哈密顿量上):
# energy, params = qalgora.vqe(ansatz, hamiltonian, optimizer,
#                              parameter_count=n)
# print("ground-state energy:", energy)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
完整流程
在 OpenFermion 中构建分子模型,在此处完成转换(规划中的适配器),再交由开放参考实现的 CPU 模拟器运行,或经厂商 SDK 导出到真机执行——详见 量子化学
注意事项
在真实 QPU 上,VQE 远不止"任意后端":它还涉及 Pauli 项分组、采样次数预算、误差缓解、ansatz 到原生门集的转译,以及针对每个可观测量的测量基旋转。

参考文献

  • J. R. McClean et al., "OpenFermion: the electronic structure package for quantum computers," Quantum Sci. Technol. 5, 034014 (2020). doi:10.1088/2058-9565/ab8ebc