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

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

ModeBest for
JobOne independent circuit or estimation
BatchMany independent circuits — scheduled together to cut queue overhead
SessionIterative workloads (VQE/QAOA) needing a dedicated, low-latency window

Execution context comparison

ContextUse caseStatus
RemoteSessionReal-time, low-latency device session held open on the QPUPlanned interface
SessionCloud / vendor scheduling window (shared backend)Planned interface
BatchIndependent jobs submitted and scheduled togetherPlanned interface
ServerlessManaged long-running hybrid jobsPlanned 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 batch
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.

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 window
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.
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
经验法则
彼此独立的任务 → 批处理。每一步都要用上一步结果的反馈循环 → 会话。一次性任务 → 普通作业