Generative Quantum Eigensolver (GQE)
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-VQE | GQE | |
|---|---|---|
| What is optimised | continuous gate angles | weights of a generative model |
| How circuits are chosen | fixed or greedily grown ansatz | sampled from the model's distribution |
| Gradients on the QPU | parameter-shift each step | no parameter-shift gradients on the QPU; training the generative model still uses energy feedback to update the model weights classically |
| Strength | smooth, well-conditioned landscapes | may 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.
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)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.
生成式量子本征求解器 GQE
GQE 用生成模型代替变分参数搜索:让一个 transformer 学着生成算符序列来构造低能态,再把采样线路的能量当作训练信号
与 VQE 有何不同
| VQE / ADAPT-VQE | GQE | |
|---|---|---|
| 优化对象 | 连续的门角度 | 生成模型的权重 |
| 线路如何选取 | 固定或贪心扩展的拟设 | 从模型分布中采样 |
| 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)返回什么
- 所有采样线路里找到的最低能量
- 对应的最优线路,可以直接重跑,也可以用几步 VQE 精修
- 训练好的模型,可以为相近的哈密顿量做热启动