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

Origin pyQPanda 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.

Adapt algorithms written with Origin Quantum's pyQPanda (QPanda) SDK so they run on qalgora-Q simulators and on Origin Wukong hardware.

Importing a QPanda program

import qalgora
import pyqpanda as pq

qvm = pq.CPUQVM(); qvm.init_qvm()
qubits = qvm.qAlloc_many(2)
prog = pq.QProg() << pq.H(qubits[0]) << pq.CNOT(qubits[0], qubits[1])

qalgora.set_target("qpp-cpu")
# Planned adapter:
# kernel = qalgora.from_qpanda(prog)        # -> qalgora-Q kernel
# print(qalgora.sample(kernel, shots_count=1000))
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.

Running on Origin Wukong

import qalgora
# Planned adapter workflow (requires the Origin SDK and credentials):
# kernel = qalgora.from_qpanda(prog)
# qalgora.set_target("origin", machine="wukong")
# job = qalgora.sample_async(kernel, shots_count=4000)
# print(job.get())
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.
Best of both
For compatible gate-model circuits, pyQPanda / QPanda can serve as an exchange layer for import or export; before actually running you still need target gate-set translation, coupling-map routing, shot configuration, SDK credentials, and device queue checks.

Origin pyQPanda 互操作

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

将使用 Origin Quantum 的 pyQPanda(QPanda)SDK 编写的算法适配到 qalgora-Q 模拟器,以及 Origin Wukong(本源悟空)硬件上运行。

导入 QPanda 程序

import qalgora
import pyqpanda as pq

qvm = pq.CPUQVM(); qvm.init_qvm()
qubits = qvm.qAlloc_many(2)
prog = pq.QProg() << pq.H(qubits[0]) << pq.CNOT(qubits[0], qubits[1])

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

在 Origin Wukong 上运行

import qalgora
# 规划中的适配器工作流(需 Origin SDK 与凭据):
# kernel = qalgora.from_qpanda(prog)
# qalgora.set_target("origin", machine="wukong")
# job = qalgora.sample_async(kernel, shots_count=4000)
# print(job.get())
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
两者兼得
对兼容的门模型线路,可通过 pyQPanda / QPanda 作为交换层导入或导出;实际运行前仍需目标门集转译、耦合图布线、shots 配置、SDK 凭据和设备队列检查。