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

Molecular Docking via DC-QAOA

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

Pose a drug-binding problem as a weighted graph clique search and solve it with Digitized Counterdiabatic QAOA, which adds counterdiabatic driving for faster convergence.

The problem it solves

Molecular docking asks how a small molecule (a candidate drug, the ligand) fits into a protein's binding site, and how strongly it binds. The space of possibilities is combinatorial: there are enormously many ways to position, orient, and flex the ligand, and to pair up its chemical groups with complementary spots on the protein. Scoring every arrangement exhaustively is hopeless, so docking is fundamentally a hard combinatorial optimization problem — and this kind of discretized combinatorial optimization is well suited to modeling and exploration with variational quantum optimizers like QAOA.

From docking to a graph problem

The standard reformulation turns docking into a graph. Each candidate ligand–protein contact (a specific chemical group sitting at a specific pocket location) becomes a vertex, weighted by how favourable that contact is. Two contacts are joined by an edge when they are mutually compatible — geometrically consistent, not clashing. A valid binding pose is then a set of contacts that are all pairwise compatible, i.e. a clique in this graph, and the best pose is the maximum-weight clique: the mutually consistent set of contacts with the highest total interaction strength.

The cost Hamiltonian — QUBO and Ising

To run this on a quantum computer, assign one binary variable (one qubit) to each candidate contact: xi = 1 if the contact is included in the pose, 0 otherwise. Write a cost function that is a QUBO (quadratic unconstrained binary optimization): if edges encode compatibility, the QUBO rewards the weights of selected vertices and adds a penalty for pairs of vertices not joined by a compatibility edge, preventing incompatible contacts from being chosen together. Substituting xi → (1 − Zi)/2 turns the QUBO into a diagonal Ising cost Hamiltonian HC whose lowest-energy computational-basis state encodes exactly the maximum-weight clique. To turn the maximization into a ground-state search, the reward terms are written as negative energy, i.e. minimize "negative clique weight + incompatibility penalty". Solving the docking problem is now: find the ground state of HC.

QAOA with counterdiabatic driving

QAOA approximates that ground state by alternating two kinds of layer: a cost layer e−iγHC that imprints the problem's energy as phases, and a mixer layer e−iβHM that drives transitions between candidate solutions. Tuning the angles (γ, β) steers the state toward low cost. Plain QAOA needs many layers — deep circuits — to mimic a slow adiabatic sweep. Digitized counterdiabatic QAOA (DC-QAOA) adds an extra driving term that approximately cancels the diabatic transitions an over-fast sweep would cause, so good solutions emerge at shallower depth — a real advantage on near-term hardware.

Seeing it in code

Read the kernel against the layers above. h(q) prepares the uniform superposition over all candidate inclusion patterns; the cost layer (commented) applies HC built from the clique weights; here a single-qubit Y rotation ry(alphas[l], q[i]) is used as a simplified approximation of the counter-diabatic drive — in real DC-QAOA the form of the counter-diabatic term depends on the chosen approximation and the problem Hamiltonian; and rx(2.0 * betas[l], q[i]) is the standard mixer. The three angle arrays gammas, betas, alphas are what a classical optimizer tunes.

DC-QAOA kernel

import qalgora

@qalgora.kernel
def dc_qaoa(gammas: list[float], betas: list[float],
            alphas: list[float], layers: int, n: int):
    q = qalgora.qvector(n)
    h(q)
    for l in range(layers):
        # cost layer (clique weights) ...
        # counterdiabatic term: extra Y-rotations speed convergence
        for i in range(n):
            ry(alphas[l], q[i])
        # mixer layer
        for i in range(n):
            rx(2.0 * betas[l], q[i])
    mz(q)

Honest limits

  • It is a heuristic. QAOA gives no guarantee of finding the true maximum-weight clique; like all variational methods, the result depends on depth, the optimizer, and the landscape.
  • One qubit per contact caps the scale. The QUBO needs a qubit for every candidate contact, so realistic docking problems quickly exceed near-term qubit counts — this is a proof-of-concept formulation, not a production docking engine.
  • Counterdiabatic terms are approximate. The added driving only approximately suppresses diabatic transitions; it reduces the required depth but does not make the result exact.
  • Classical methods are strong competitors. Well-tuned classical solvers handle clique and QUBO problems at this scale very effectively, so the quantum approach must be judged honestly against them.
Counterdiabatic boost
The extra driving term suppresses diabatic transitions, so on some problems and parameter settings, this may let DC-QAOA reach higher-quality candidate solutions at shallower circuit depth than vanilla QAOA — valuable on near-term hardware.

基于 DC-QAOA 的分子对接

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

将药物结合问题建模为加权图的团搜索,使用数字化反绝热 QAOA 求解——反绝热驱动项可加速收敛。

它解决的问题

分子对接要回答的是:一个小分子(候选药物,即配体)如何嵌入蛋白质的结合位点,又结合得有多牢。其可能性空间是组合式的:配体的位置、取向与构象,以及它的化学基团与蛋白质上互补位点的配对方式,多到难以计数。穷举打分每一种排布毫无希望,因此对接本质上是一个困难的组合优化问题——这类离散化后的组合优化问题适合用 QAOA 这类变分量子优化算法进行建模探索。

从对接问题到图问题

标准的重构把对接化为一张图。每个候选的配体与蛋白质接触(某一化学基团落在某一口袋位置)成为一个顶点,其权重表示该接触的有利程度。当两个接触彼此相容——几何上一致、互不冲突——时,便以一条相连。于是一个有效的结合构象就是一组两两相容的接触,即该图中的一个,而最优构象即最大权团:总相互作用强度最高的那组互相一致的接触。

代价哈密顿量 QUBO 与 Ising

要在量子计算机上运行,给每个候选接触分配一个二元变量(一个量子比特):若该接触被纳入构象则 xi = 1,否则为 0。写出一个 QUBO(二次无约束二元优化)代价函数:若图中的边表示相容关系,则 QUBO 中奖励被选中的顶点权重,并对没有相容边连接的顶点对加入惩罚项,避免不相容接触被同时选中。代入 xi → (1 − Zi)/2 便把 QUBO 转为一个对角的 Ising 代价哈密顿量 HC,其能量最低的计算基态恰好编码了最大权团。为了把最大化问题转成基态搜索,通常把奖励项写成负能量,或等价地最小化「负的团权重 + 不相容惩罚」。于是求解对接问题就变成了:找出 HC 的基态。

带反绝热驱动的 QAOA

QAOA 通过交替施加两类层来逼近该基态:一个代价e−iγHC,把问题的能量印为相位;以及一个混合e−iβHM,驱动候选解之间的跃迁。调节角度 (γ, β) 便把状态导向低代价。普通 QAOA 需要很多层——很深的线路——才能模拟一次缓慢的绝热扫描。数字化反绝热 QAOA(DC-QAOA)额外加入一个驱动项,近似抵消过快扫描会引发的非绝热跃迁,于是好解能在更浅的深度下浮现——这在近期硬件上是实打实的优势。

对照代码理解

请对照上文各层来读这段内核。h(q) 在所有候选纳入模式上制备均匀叠加;代价层(注释处)施加由团权重构建的 HC;这里用单比特 Y 旋转 ry(alphas[l], q[i]) 作为反绝热驱动的简化近似——真实 DC-QAOA 中反绝热项的形式取决于所选近似和问题哈密顿量;而 rx(2.0 * betas[l], q[i]) 是标准混合层。三个角度数组 gammasbetasalphas 正是经典优化器要调节的对象。

DC-QAOA 内核

import qalgora

@qalgora.kernel
def dc_qaoa(gammas: list[float], betas: list[float],
            alphas: list[float], layers: int, n: int):
    q = qalgora.qvector(n)
    h(q)
    for l in range(layers):
        # cost layer (clique weights) ...
        # counterdiabatic term: extra Y-rotations speed convergence
        for i in range(n):
            ry(alphas[l], q[i])
        # mixer layer
        for i in range(n):
            rx(2.0 * betas[l], q[i])
    mz(q)

诚实的局限

  • 它是一种启发式方法。QAOA 并不保证找到真正的最大权团;与所有变分方法一样,结果取决于深度、优化器与优化地形。
  • 每个接触一个量子比特限制了规模。QUBO 需要为每个候选接触分配一个量子比特,因此真实的对接问题很快就会超出近期的量子比特数——这是一个概念验证式的建模,而非生产级的对接引擎。
  • 反绝热项是近似的。所加的驱动只是近似抑制非绝热跃迁;它降低了所需深度,却并不使结果精确。
  • 经典方法是强劲对手。调校良好的经典求解器在此规模上处理团与 QUBO 问题非常有效,因此量子方法必须诚实地与它们相比较。
反绝热加速
额外的驱动项抑制了非绝热跃迁,在一些问题和参数设置下,可能使 DC-QAOA 在较浅线路深度下获得更高质量的候选解——对近期量子硬件尤为关键。