Expand description
Program IR for bloq compiler output.
Bloq is the public, circuit-bearing graph IR produced by bloq_compile
and consumed by backend emitters.
§Traversal
Reads are id-native: every graph level (the Bloq top level or a region
SubGraph body) exposes the same accessors — SubGraph::node,
SubGraph::nodes, SubGraph::incoming/SubGraph::outgoing (yielding
BloqEdgeRefs), the dataflow queries SubGraph::value_inputs /
SubGraph::value_output / SubGraph::boundary_outputs — and Bloq::walk/Bloq::levels
recurse through region bodies with a LevelPath for cross-level node
identity. The underlying petgraph storage is not public API.
§Derived reads
Three layers sit on top of raw traversal, for questions a consumer would otherwise answer by matching on node variants itself:
- Structural queries (
Bloq::regions_of,Bloq::selection_seams,Bloq::node_by_block,SubGraph::quantum_tail, …) name a program’s recurring landmarks. Callers use them to constructMemoryRoundTargets forBloq::insert_memory_roundsorBloq::insert_memory_rounds_batch. Bloq::resolve_classicalfolds the classical dataflow graph under a fixed path into the measurement recipe behind a node’s value, andBloq::classical_valueanswers the other half of the same question: the bit that path already fixes, including an activation predicate.NodeKeyis a provenance-derived node identity that survives recompilation, for lining one program up against another compile of the same block graph.
§Exhaustive data enums (deliberate)
The data enums (BloqNodeKind, ClassicalNode, RegionNode,
NodeProvenance, ValueRole, …) are intentionally not
#[non_exhaustive]: a backend must fail to compile — not silently
wildcard — when the IR grows a construct, because an unhandled node kind
would emit wrong output rather than error (e.g. bloq_stim rejects each region
variant by name). Do not “fix” this by adding #[non_exhaustive] to them;
error enums, by contrast, are non-exhaustive.
Modules§
- circuit
- Circuit vocabulary embedded by Bloq IR templates and annotations.
- lowering
- Compiler and backend lowering surface.
- prelude
- The most commonly used items, for
use bloq_ir::prelude::*. - visualization
- Graph visualization shared with the editor. Standalone SVG views of the physical program DAG, using the editor’s layout.
Structs§
- Aligned
Layer - Serial aligned slots projected onto one doubled-z display layer.
- Aligned
Moment Ref - One node-local moment placed into an aligned slot.
- Aligned
Slot - Concurrent compatible moments.
Noneis a real idle slot. - Bloq
- The compiled bloq circuit IR: a graph of quantum, classical, and region
nodes produced by
bloq_compile, consumed by emitters and the verifier. - Bloq
Edge Ref - A borrowed graph edge with id-space endpoints — the id-native view of one
BloqEdge, so traversal never exposes petgraph types. - Bloq
Node - A graph node, tagged by what kind of work it represents.
- Bloq
Node Id - A node’s slot index in its own graph level (a
crate::Bloqtop level or one regioncrate::SubGraphbody) — ids are level-local, not program-global. - Bloq
Stats - Structural counts across every graph level, including guarded and RUS bodies.
- Bundle
Detector - One row stored in a reusable detector bundle.
- Bundle
Measurement - A measurement in one bundle-local owner slot.
- Classical
Resolution - What a classical node’s value is made of, under one fixed path.
- Coordinate
Overflow Error - A coordinate plus layout offset does not fit the signed 32-bit lattice.
- Cycle
Detected - The graph contains a cycle, so it has no topological emit order.
- Detector
Bundle - Shared detector rows with an ordered template signature.
- Detector
Bundle Id - A detector bundle’s append-only index in a program.
- Detector
Bundle Pool - Append-only, clone-cheap bundle storage.
- Detector
Bundle Use - One node-local binding of a reusable detector bundle.
- Flatten
Limits - Work allowed when materializing a circuit’s repeated operation stream.
- Frame
Pair - Logical Pauli-frame sign nodes for one terminal output.
- Level
Path - Path from the top level to one graph level: the chain of enclosing region body hops. Empty = the top level.
- Level
Segment - One hop of a
LevelPath: the region descended through and its selected body. - Logical
Input - Input-port metadata for physical preparation hooks.
- Logical
Output - Terminal logical Pauli operators for one program output.
- Moment
Lane - One node’s raw moments and whole-circuit qubit footprint.
- Moment
Segment - One viewer moment: a bucket of visible same-kind ops plus any invisible measurement-controlled feedforward assigned to that boundary, in op order.
- Moment
Segmenter - Incremental viewer-moment segmentation for structural circuit walkers.
- NodeCx
- Context for one node visited by
Bloq::walk. - Node
Detector - An instance-space detector on a
crate::QuantumNode. - Node
Detector View - A borrowed detector row, mapped into instance space on demand.
- Node
Detectors - Inline rows followed by bundle uses in node order, then row order.
- NodeKey
- A node identity that survives recompilation and renumbering.
- NodeRef
- A tape-unique node reference.
- Node
Slices - Per-moment regions for one node.
- Pipe
Padding - Memory-padding provenance for one temporal pipe.
- Pipe
Seam - One temporal pipe on a quantum seam, with the memory-padding templates the compiler recorded for it.
- Program
Region - Identity and coordinates stored once for every program region.
- Program
Region Break - A gauge anticommutation located back to the node timeline it falls in.
- Program
Slice Options - Detector and logical-observable region choices for a pinned program.
- Program
Slices - The whole program’s detector-slice data, keyed by node.
- Quantum
Edge - A quantum face seam: its temporal pipes, each carrying the memory-padding templates that may subdivide it.
- Quantum
Guard - Members and side tables enabled by one quantum node’s
Valueinput. - Quantum
Node - A template-backed quantum node: its ops come from instantiating the referenced templates from the pool, not from any per-node circuit.
- Quantum
Timeline - Cumulative round cuts projecting a multi-layer block onto source z layers.
- Region
Ref - A program-unique address of one region node: the path to its graph level plus its level-local id.
- Region
View - One detector or logical-observable region at one moment.
- Source
Block Ref - A reference to one source block by its lattice position.
- SubGraph
- A nested region body.
- Template
Detector - One detector inside a template: a measurement
parityat optional decodercoords, tagged by the bodyscopeit lives in. - Template
Id - A template’s index into the program’s shared
crate::BloqTemplatePool. - Temporal
Pipe Ref - A reference to one source temporal pipe.
- Text
Parse Error - A syntax or structure error in Bloq IR text, with its 1-based line number.
- Validated
Plans - Quantum emission stages keyed by scoped node address.
- Value
Input - One
Valueinput of a node. - Value
Ref - A level-local Boolean source and its selected output.
Enums§
- Basis
- Pauli
XorZbasis (excludesYand identity). - Binary
Decode Error - Why a byte buffer failed to decode as a binary
.bloqartifact. - Bloq
Edge - Quantum seams, Boolean dependencies, recipe composition, and sequencing.
- Bloq
Node Kind - What a
BloqNodecomputes. - Bloq
Stats Error - Failure to inventory stored IR; this does not certify well-formedness.
- Bloq
Validation Error - A well-formedness violation or resource exhaustion from
Bloq::validate. - Body
Selector - The body of a
RegionNode. - Boundary
Face - Which temporal face of an instance a boundary operator binds.
- Classical
Assignment - The fixed path a
Bloq::resolve_classicalfold evaluates under. - Classical
Expr - Combinational logic over a classical node’s incoming
Valueedges. - Classical
Node - Classical logic and observable recipes. Composition edges include a child’s measurements and boundary bindings; value edges select a Boolean output.
- Detector
Bundle Error - Local structure errors found before any detector rows are expanded.
- Edit
Error - Why a post-compile graph edit was rejected.
- Flatten
Error - Why a template or program could not be flattened. The target is left unmodified on any of these.
- Instance
Provenance - Why a template instance exists.
- Membership
PinError - Why source membership choices could not be pinned to a static realization.
- Memory
Round Target - Program-unique location for physical memory-round insertion.
- Metadata
Value - A portable scalar stored in
Bloqproducer metadata. - Moment
Alignment Error - Why raw node moments could not be aligned against their graph level.
- Moment
Kind - The kind of a viewer moment: a bucket ops fall into within one tick segment.
- Node
Detector Address - Stable address of a node detector row.
- Node
Provenance - What source-level construct an IR node realizes.
- Observable
Output - Boolean output selected from an observable.
- Port
Role - Direction assigned to an open port.
- Program
Region Id - Stable identity of a detector or logical-observable region.
- Program
Slice Error - Why
program_detector_slicescould not build the tape. - Region
Kind - Which
RegionNodevariant a structural query selects. - Region
Node - A structured control-flow region.
- Resolve
Error - Why a classical fold could not be completed.
- Spatial
Port Part - Which half of a spatial-Port substitution an instance realizes.
- Structure
Error - Why a structural query found no unique answer.
- Value
Role - Edge provenance on a
BloqEdge::Valueedge: what source construct routed this bit here. - Walk
Control - Flow control returned from a
Bloq::walkcallback (MLIRWalkResult): whether to descend, prune, or stop after the current node.
Constants§
- BLOQ_
BINARY_ EXTENSION - The conventional file extension for the binary format.
- BLOQ_
BINARY_ MAGIC - File magic prefixing every binary
.bloqartifact. - BLOQ_
BINARY_ VERSION - Pre-release binary format version; stays at 1 during rapid development.
- BLOQ_
TEXT_ EXTENSION - The conventional file extension for the text format.
- BLOQ_
TEXT_ VERSION - The pre-release text format version. IR changes update the codec without bumping this value until the format is released.
Functions§
- align_
moment_ lanes - Align raw node moments into deterministic concurrent layer batches.
- aligned_
moment_ segments - Split a straight-line circuit into alignable kind buckets and idle gaps.
- moment_
segments - Split a straight-line op stream into viewer moments, first at
Op::Tick. - program_
detector_ slices - Compute detector-slice regions for every quantum node of
program. - program_
detector_ slices_ with_ options - Compute detector-slice regions using explicit region choices.
Type Aliases§
- Node
Detector Parity - A measurement-only detector parity in instance space (
InstanceMeasurement). Validation rejects the generic parity type’s loop-state terms (WF-6).