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

Generative Quantum Eigensolver (GQE)

◐ 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.

GQE replaces the variational parameter search with a generative model: a transformer learns to emit sequences of operators that build low-energy states, trained on the energies of the circuits it samples.

How it differs from VQE

VQE / ADAPT-VQEGQE
What is optimisedcontinuous gate anglesweights of a generative model
How circuits are chosenfixed or greedily grown ansatzsampled from the model's distribution
Gradients on the QPUparameter-shift each stepno parameter-shift gradients on the QPU; training the generative model still uses energy feedback to update the model weights classically
Strengthsmooth, well-conditioned landscapesmay suit discrete circuit-structure search; sampling explores many candidate circuits, which can help ease continuous-parameter optimization difficulties on some problems

The training loop

Each iteration the model proposes a batch of operator sequences; each sequence is assembled into a circuit, its energy is measured with observe, and the energies become the training signal that biases the model toward lower-energy circuits. These energies are black-box feedback signals used to update the generative model's sampling distribution — for example via policy-gradient or cross-entropy methods.

Illustrative interface
The calls below sketch a normative interface; the generative-solver API is not a built-in module today. Treat solvers.gqe.Transformer(...) as the model constructor and solvers.gqe.run(...) as the training driver.
import qalgora
import qalgora_solvers as solvers
from qalgora import spin

hamiltonian = spin.z(0) + spin.z(1) - 0.5 * spin.x(0) * spin.x(1)
pool = solvers.get_operator_pool("spin_complement", num_qubits=2)

# normative interface (illustrative): gqe is a module, not a callable
model = solvers.gqe.Transformer(layers=4, d_model=128)

energy, circuit = solvers.gqe.run(
    hamiltonian, pool,
    model=model,
    batch_size=32,        # circuits sampled per iteration
    iterations=200,
    temperature=1.0,      # exploration vs. exploitation of the sampler
)
print("estimated 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.

What you get back

  • The lowest energy found across all sampled circuits.
  • The best circuit itself, ready to re-run or refine with a few VQE steps.
  • The trained model, which can warm-start a related Hamiltonian.
Pairs well with
Seed GQE from a small ADAPT-VQE run, or polish the GQE-found circuit with a short gradient optimisation — the two are complementary.

生成式量子本征求解器 GQE

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

GQE 用生成模型代替变分参数搜索:让一个 transformer 学着生成算符序列来构造低能态,再把采样线路的能量当作训练信号

与 VQE 有何不同

VQE / ADAPT-VQEGQE
优化对象连续的门角度生成模型的权重
线路如何选取固定或贪心扩展的拟设从模型分布中采样
QPU 上的梯度每步参数移位QPU 上不需要参数移位梯度;训练生成模型时仍需在经典端用能量反馈更新模型权重
擅长平滑、良态的能量面可能更适合离散线路结构搜索;通过采样探索多个候选线路,在某些问题上有助于缓解连续参数优化困难

训练回路

每次迭代,模型给出一批算符序列,每条序列组装成一个线路,用 observe 测出能量;这些能量再作为训练信号,引导模型偏向能量更低的线路。这些能量是黑箱反馈信号,用于更新生成模型采样分布,例如通过策略梯度、交叉熵法等。

规范接口示意
下面的调用只是规范接口示意,生成式求解器目前并非内置模块。请把 solvers.gqe.Transformer(...) 理解为模型构造器,solvers.gqe.run(...) 理解为训练驱动入口。
import qalgora
import qalgora_solvers as solvers
from qalgora import spin

hamiltonian = spin.z(0) + spin.z(1) - 0.5 * spin.x(0) * spin.x(1)
pool = solvers.get_operator_pool("spin_complement", num_qubits=2)

# 规范接口示意:gqe 是模块而非可调用对象
model = solvers.gqe.Transformer(layers=4, d_model=128)

energy, circuit = solvers.gqe.run(
    hamiltonian, pool,
    model=model,
    batch_size=32,        # 每次迭代采样的线路数
    iterations=200,
    temperature=1.0,      # 采样器的探索与利用权衡
)
print("estimated ground-state energy:", energy)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。

返回什么

  • 所有采样线路里找到的最低能量
  • 对应的最优线路,可以直接重跑,也可以用几步 VQE 精修
  • 训练好的模型,可以为相近的哈密顿量做热启动
搭配使用
可以先跑一小段 ADAPT-VQE 为 GQE 提供种子,也可以用一小段梯度优化来精修 GQE 找到的线路,两者互为补充