Execution Modes: Batch & Session
○ Planned · Not yet implemented
The capabilities described on this page are planned and not yet implemented or released. They explain future design directions and should not be interpreted as delivered features.How jobs are scheduled on shared hardware matters. qalgora-Q offers three modes: single job, parallel batch, and dedicated session.
The three modes
| Mode | Best for |
|---|---|
| Job | One independent circuit or estimation |
| Batch | Many independent circuits — scheduled together to cut queue overhead |
| Session | Iterative workloads (VQE/QAOA) needing a dedicated, low-latency window |
Execution context comparison
| Context | Use case | Status |
|---|---|---|
RemoteSession | Real-time, low-latency device session held open on the QPU | Planned interface |
Session | Cloud / vendor scheduling window (shared backend) | Planned interface |
Batch | Independent jobs submitted and scheduled together | Planned interface |
Serverless | Managed long-running hybrid jobs | Planned interface |
These four contexts are planned interfaces; the open reference build runs every example on the local CPU simulator.
Batch — many independent jobs
import qalgora
with qalgora.Batch(target="ibm", machine="ibm_torino") as batch:
jobs = [qalgora.sample_async(circ, shots_count=1000) for circ in circuits]
results = [j.get() for j in jobs] # scheduled efficiently as one batchSpecification 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.Session — iterative variational loop
with qalgora.Session(target="ibm", machine="ibm_torino") as session:
energy, params = qalgora.vqe(ansatz, hamiltonian, optimizer,
parameter_count=n) # all iterations share the windowSpecification 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.Where does the session come in?
Inside with qalgora.Session(...) as session: the session becomes the current
default execution context, so vqe runs inside it even though it takes no
session= argument here. Pass session=session explicitly if you prefer
the binding to be visible.
Rule of thumb
Independent work → batch. A feedback loop where each step depends on the last →
session. A one-off → plain job.
执行模式:批处理与会话
○ 规划中
本页所述能力属于规划功能,当前尚未发布或尚未实现。相关内容仅用于说明未来设计方向,不应理解为已交付能力。在共享硬件上,作业怎么调度很关键。qalgora-Q 给出三种模式: 单次作业、并行批处理,以及独占会话。
三种模式
| 模式 | 适用场景 |
|---|---|
| 作业 | 单个独立电路或估算任务 |
| 批处理 | 大批互不依赖的电路——集中调度,减少排队开销 |
| 会话 | 需要独占、低延迟时间窗的迭代任务(VQE/QAOA) |
执行上下文对比
| 上下文 | 适用场景 | 状态 |
|---|---|---|
RemoteSession | 在 QPU 上保持开启的实时、低延迟设备会话 | 规划接口 |
Session | 云端 / 厂商调度时间窗(共享后端) | 规划接口 |
Batch | 集中提交、集中调度的互相独立作业 | 规划接口 |
Serverless | 托管的长时间运行混合作业 | 规划接口 |
以上四种上下文均为规划接口;开放参考实现会在本地 CPU 模拟器上运行所有示例。
批处理——多个独立作业
import qalgora
with qalgora.Batch(target="ibm", machine="ibm_torino") as batch:
jobs = [qalgora.sample_async(circ, shots_count=1000) for circ in circuits]
results = [j.get() for j in jobs] # scheduled efficiently as one batch规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。会话——迭代变分循环
with qalgora.Session(target="ibm", machine="ibm_torino") as session:
energy, params = qalgora.vqe(ansatz, hamiltonian, optimizer,
parameter_count=n) # all iterations share the window规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。会话从哪里生效
在 with qalgora.Session(...) as session: 块内,该 Session 上下文会成为当前默认执行上下文,
因此即使这里没有传入 session= 参数,vqe 也会在其中运行。若想让绑定更明确,
可以显式传入 session=session。
经验法则
彼此独立的任务 → 批处理。每一步都要用上一步结果的反馈循环 →
会话。一次性任务 → 普通作业。