API Reference
◐ 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.Core entry points of the qalgora-Q Python API. C++ mirrors these in the
qalgora:: namespace.
This page is the at-a-glance index. For depth, see Python API, C++ API, and the Quantum Operations Reference.
Reference-build status
The Status column reflects the open reference build:
Supported = runs today on the local CPU NumPy simulator;
Spec API = documented specification interface, not implemented in the open build yet;
Planned = a distribution or hardware path not released yet. The gpu and
tensornet targets are Planned. See
Capability Coverage for the full matrix.
Execution
| Function | Purpose | Status |
|---|---|---|
qalgora.sample(kernel, *args, shots_count=1000) | Sample measurement bitstrings | Supported |
qalgora.run(kernel, *args) | List of typed kernel return values | Spec API |
qalgora.observe(kernel, spin_op, *args) | Compute expectation values | Supported |
qalgora.get_state(kernel, *args) | Return the full statevector | Supported |
*_async(...) | Non-blocking variant of each primitive, returns a future | Supported (sample/observe/evolve) |
qalgora.vqe(...) | Run a variational eigensolver loop | Spec API |
qalgora.evolve(...) | Time-evolve a system (dynamics) | Supported |
qalgora.draw / get_ir / estimate_resources | Visualize / inspect / cost a kernel | Spec API |
Targets & configuration
| Function | Purpose | Status |
|---|---|---|
qalgora.set_target(name, **opts) | Choose the execution backend | Supported |
qalgora.get_target() / get_targets() | Query the active / available targets | Supported |
qalgora.reset_target() | Restore the default target | Supported |
qalgora.set_noise() / unset_noise() | Attach / clear a global noise model | Supported |
qalgora.set_random_seed(n) | Make sampling reproducible | Supported |
qalgora.num_available_gpus() | Count usable GPUs | Planned |
Submodules
| Module | Contents | Status |
|---|---|---|
qalgora.optimizers / qalgora.gradients | Variational optimization | Spec API |
qalgora.spin / qalgora.operators | Build Hamiltonians and observables | Supported |
qalgora.mpi | Distributed execution primitives | Spec API |
qalgora.dynamics | Time-evolution integrators | Supported |
Operators
from qalgora import spin
op = spin.x(0) * spin.z(1) + 0.5 * spin.y(0)
print(op) # human-readable Pauli sum
print(op.get_qubit_count())
API 参考
◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。qalgora-Q Python API 的核心入口。C++ 侧的对应接口位于 qalgora:: 命名空间下。
本页为速查索引。如需详细说明,请参阅Python API、C++ API 及量子操作参考。
参考实现状态
状态列反映开放参考实现的现状:参考实现已支持表示当前可在本地 CPU NumPy 模拟器上运行;规范接口·暂未实现表示已写入规范、开放实现暂未提供;规划中·尚未发布表示分发或硬件路径尚未发布。其中 gpu 与 tensornet 目标后端属于规划中·尚未发布。完整对照见能力覆盖。
执行
| 函数 | 用途 | 状态 |
|---|---|---|
qalgora.sample(kernel, *args, shots_count=1000) | 对测量比特串进行采样 | 参考实现已支持 |
qalgora.run(kernel, *args) | 返回内核带类型的返回值列表 | 规范接口·暂未实现 |
qalgora.observe(kernel, spin_op, *args) | 计算期望值 | 参考实现已支持 |
qalgora.get_state(kernel, *args) | 返回完整态矢量 | 参考实现已支持 |
*_async(...) | 各原语的非阻塞变体,返回 future(异步句柄) | 参考实现已支持(sample/observe/evolve) |
qalgora.vqe(...) | 运行变分本征求解器循环 | 规范接口·暂未实现 |
qalgora.evolve(...) | 对系统进行时间演化(动力学模拟) | 参考实现已支持 |
qalgora.draw / get_ir / estimate_resources | 可视化 / 检查 / 估算内核资源开销 | 规范接口·暂未实现 |
目标后端与配置
| 函数 | 用途 | 状态 |
|---|---|---|
qalgora.set_target(name, **opts) | 选择执行后端 | 参考实现已支持 |
qalgora.get_target() / get_targets() | 查询当前激活的后端 / 所有可用后端 | 参考实现已支持 |
qalgora.reset_target() | 恢复默认目标后端 | 参考实现已支持 |
qalgora.set_noise() / unset_noise() | 挂载 / 清除全局噪声模型 | 参考实现已支持 |
qalgora.set_random_seed(n) | 固定随机种子以使采样可复现 | 参考实现已支持 |
qalgora.num_available_gpus() | 统计可用 GPU 数量 | 规划中·尚未发布 |
子模块
| 模块 | 内容 | 状态 |
|---|---|---|
qalgora.optimizers / qalgora.gradients | 变分优化 | 规范接口·暂未实现 |
qalgora.spin / qalgora.operators | 构建哈密顿量与可观测量 | 参考实现已支持 |
qalgora.mpi | 分布式执行原语 | 规范接口·暂未实现 |
qalgora.dynamics | 时间演化积分器 | 参考实现已支持 |
算符
from qalgora import spin
op = spin.x(0) * spin.z(1) + 0.5 * spin.y(0)
print(op) # human-readable Pauli sum
print(op.get_qubit_count())