qsim 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.qsim is Google's high-performance Schrödinger statevector simulator, with gate fusion and SIMD/GPU acceleration. qsim typically consumes Cirq circuits; qalgora-Q imports the same kind of Cirq circuit through a Cirq adapter and runs it on a qalgora-Q backend — with Cirq as the exchange layer.
Import a Cirq circuit (qsim's input format)
The Cirq adapter is a planned interface. The runnable default target is the open reference implementation's CPU simulator; the GPU target is a planned optional plugin.
import qalgora
# qalgora-Q imports the same kind of Cirq circuit that qsim consumes,
# then runs it on a qalgora-Q backend — Cirq acts as the exchange layer.
qalgora.set_target("qpp-cpu")
# optional: requires the qalgora-gpu plugin (planned)
# qalgora.set_target("gpu")
# Planned Cirq adapter:
# kernel = qalgora.from_cirq(cirq_circuit)
# 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.qsim vs. the qalgora targets
| qsim | qalgora qpp-cpu | qalgora gpu | |
|---|---|---|---|
| Method | Statevector + gate fusion | Statevector (CPU) | Statevector + gate fusion |
| Input | Cirq circuits | qalgora-Q kernels (Cirq via planned adapter) | same |
| Acceleration | AVX / GPU | CPU (NumPy) | GPU (planned plugin) |
| Status | — | Reference implementation available | Planned optional backend |
Cirq as exchange layer
Both compute the exact statevector. qalgora-Q's runnable target today is qpp-cpu;
the GPU and multi-GPU backends are planned. Cirq import relies on the planned from_cirq
adapter, so circuit portability depends on that interface and the gates it covers.
qsim 互操作
◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。qsim 是 Google 的高性能 Schrödinger 态矢量模拟器,支持门融合与 SIMD/GPU 加速。qsim 通常接收 Cirq 电路;qalgora-Q 通过 Cirq 适配器导入同一类 Cirq 电路,再交给 qalgora-Q 后端执行——以 Cirq 作为交换层。
导入 Cirq 电路(qsim 的输入格式)
Cirq 适配器为规划接口。可运行的默认目标是开放参考实现的 CPU 模拟器;GPU 目标为规划中的可选插件。
import qalgora
# qalgora-Q 导入 qsim 所接收的同一类 Cirq 电路,
# 再交给 qalgora-Q 后端执行——Cirq 作为交换层。
qalgora.set_target("qpp-cpu")
# 可选:需安装 qalgora-gpu 插件(规划中)
# qalgora.set_target("gpu")
# 规划中的 Cirq 适配器:
# kernel = qalgora.from_cirq(cirq_circuit)
# print(qalgora.sample(kernel, shots_count=1000))规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。qsim 与 qalgora 目标后端对比
| qsim | qalgora qpp-cpu | qalgora gpu | |
|---|---|---|---|
| 方法 | 态矢量 + 门融合 | 态矢量(CPU) | 态矢量 + 门融合 |
| 输入 | Cirq 电路 | qalgora-Q 内核(Cirq 经规划适配器导入) | 同上 |
| 加速 | AVX / GPU | CPU(NumPy) | GPU(规划中的插件) |
| 状态 | — | 参考实现可用 | 规划后端(planned) |
以 Cirq 作为交换层
两者均精确计算态矢量。qalgora-Q 当前可运行的目标是 qpp-cpu;GPU 与多 GPU 后端属于规划中。Cirq 导入依赖规划中的 from_cirq 适配器,因此电路可移植性取决于该接口及其所覆盖的门集。