Expand description
Execute compiled Bloq programs.
run_bloq and its variants retain the noiseless physical-verification
path. lower() produces the backend-independent Instruction stream
consumed by runtime, which adds dynamic timing, noise, retries, waits,
idling, and mock streaming-decoder decisions.
use bloq_compile::compile;
use bloq_graph::GalleryItem;
use bloq_vm::{LoweringConfig, lower};
let ir = compile(&GalleryItem::CNOT.build(), 3)?;
let options = LoweringConfig::default();
let program = lower(&ir, &options)?;
let result = program.run(options.runtime_config(42))?;
assert!(!result.artifact.discarded);Physical verification executes compiled circuits, independently of
bloq_graph’s logical QuiZX verifier. It supports non-Clifford programs;
Clifford circuits can also be checked with Stim.
The physical verifier adds no noise and assumes zero decoder flips. It still
executes explicit noise instructions already present in a circuit. Its
IR-mandated retries are bounded by DEFAULT_RUS_ATTEMPT_CAP. The dynamic
runtime uses decoder instead.
CircuitExecutor is the flat counterpart for a single
CoordCircuit; ShotRecord is the
per-shot measurement outcome map both paths produce.
§Where items live
The crate root carries what it takes to drive the VM: lower() and its
configuration, run() and its configuration, the run_bloq family, the
Program they exchange, and the error types. The public modules carry the
full vocabularies a consumer reads results back with, which are too large
to flatten into one root namespace:
instruction— the whole lowered ISA (Task,QuantumOp,BoolOp,MemoryCycle, …).runtime— the execution trace vocabulary (ExecutionEvent,MeasurementRecord,WaitReason, …) behind anExecutionArtifact.decoder— the mock streaming-decoder policy model.verify— the physical verifier’s report and expectation readouts.
The names that appear in root signatures are re-exported at the root as
well, so those have two paths on purpose: a signature stays nameable
without reaching into a module. From instruction that is
Program, Instruction, SourceRole, SourceSchedule,
TaskOrigin, TaskFunction, and DEFAULT_DECODER_LATENCY_ROUNDS;
from runtime it is run, RunResult, RunMetadata,
RuntimeConfig, RuntimeLimits, RuntimeError,
ExecutionArtifact, LogicalInputState, and TaskMetadata.
Prefer the root path for those; reach into the module for the rest of the
vocabulary. Everything in the private modules has exactly one path.
The engine (ticit) vocabulary is re-exported at the root only, under
Engine-prefixed aliases where its names would otherwise collide with this
crate’s own (EnginePauli against instruction::Pauli,
EngineInstruction against Instruction).
Re-exports§
pub use instruction::DEFAULT_DECODER_LATENCY_ROUNDS;pub use instruction::Instruction;pub use instruction::Program;pub use instruction::SourceRole;pub use instruction::SourceSchedule;pub use instruction::TaskFunction;pub use instruction::TaskOrigin;pub use runtime::ExecutionArtifact;pub use runtime::LogicalInputState;pub use runtime::RunMetadata;pub use runtime::RunResult;pub use runtime::RuntimeConfig;pub use runtime::RuntimeError;pub use runtime::RuntimeLimits;pub use runtime::TaskMetadata;pub use runtime::run;
Modules§
- decoder
- Seeded mock streaming decoder for dynamic VM runs.
- instruction
- Backend-independent instructions executed by the Bloq VM.
- runtime
- Dynamic execution of lowered VM instruction streams.
- verify
- Physical verification: run compiled bloq circuits on the
Simulatorengine and check them.
Structs§
- Batch
Outcome - What one
TableauSimulator::apply_batchrun produced. - Circuit
Executor - Replays a flattened
CoordCircuitagainst aSimulator. - Engine
Pauli String - A Pauli operator on
nqubitsqubits, with a two-bit phase exponent ofi. - Input
Seed - One private seed qubit prepared before execution and injected at its input Port’s safe schedule cut.
- Lowering
Config - Bounded lowering and timing options.
- Measure
Result - Outcome of a Pauli measurement.
- Output
Logical - Logical
XandZoperators for one program output. - Preparation
Context - Per-shot private-seed context for
run_bloq_with_io. - Saved
Output - A logical output swapped onto a private engine qubit before its physical patch was reused later in the program.
- Shot
Context - Per-shot context handed to a
run_bloq_with_hookhook, evaluated after the program finishes but before the shot’s simulator is dropped. - Shot
Frame - One output’s terminal Pauli-frame value for the current shot.
- Shot
Record - The measurement outcomes of one shot, indexed by (global) measurement id.
- Simulator
- A stim-
TableauSimulator-style procedural quantum-state simulator. - Source
Timing - Absolute release epochs for independently schedulable source classes.
Enums§
- Engine
Instruction - One step of a
TableauSimulator::apply_batchprogram. - Engine
Pauli - A single-qubit Pauli operator.
- Exec
Error - Failures on the noiseless physical-verification path.
- Gate1Q
- A named single-qubit Clifford, identified by the signed Pauli images
(X → …, Z → …)ofGate1Q::images. - Lower
Error - Failure to produce a finite, standalone VM program.
- Pauli
Basis - A Pauli basis — the non-identity Paulis, as an axis to rotate onto or measure along.
- SimError
- Errors returned by
TableauSimulatoroperations.
Constants§
- DEFAULT_
MAX_ QUANTUM_ VARIANTS - Default maximum number of reachable alternatives for one guarded quantum stage.
- DEFAULT_
RUS_ ATTEMPT_ CAP - Retry bound for a
RepeatUntilSuccessregion: a shot still restarting after this many attempts is discarded rather than looping forever.
Functions§
- lower
- Lower
bloqto a self-contained VM program. - run_
bloq - Verify a whole
Bloqprogram over a seeded shot batch. - run_
bloq_ with_ captured_ outputs - Run
run_bloq_with_hookwhile preserving reused output patches. - run_
bloq_ with_ hook - Run
run_bloqwith a per-shot hook. - run_
bloq_ with_ io run_bloqwith private input seeds and a post-shot output hook.