Expand description
Block graph representation for fault-tolerant surface code quantum computing.
This crate provides the core data structures for expressing quantum
computations as graphs of surface code blocks connected by pipes
(lattice surgery operations). It includes the .blog DSL parser,
a block-graph gallery of standard circuits, ZX-calculus stabilizer
analysis, and GLTF export for 3D visualization.
§Public dependency: glam
glam is a public dependency: coordinates in the public API use
[glam::IVec3], so its types appear in this crate’s signatures. The version
is pinned to match the glam that bevy re-exports, keeping the editor and
this crate on one vector type. A glam major-version bump is therefore a
breaking change for this crate’s API even when nothing else here changes.
Re-exports§
pub use bloq_utils::Basis;pub use bloq_utils::Direction;pub use bloq_utils::DirectionParseError;pub use bloq_utils::Pauli;pub use bloq_utils::PauliBasis;pub use bloq_utils::PauliError;pub use bloq_utils::PauliString;pub use bloq_utils::PhasedPauliString;pub use bloq_utils::PortRole;pub use bloq_utils::RGBA;pub use bloq_utils::UDirection;pub use rustc_hash::FxHashMap;
Modules§
- ast
- Abstract syntax tree for
.blogsource text. - prelude
- The most commonly used items, for
use bloq_graph::prelude::*. - verify
- Graph-level logical verification by sampled ZX-diagram contraction.
Structs§
- Action
Dag - An ordered dependency graph over a program’s
Actions. - Action
Node - A source action and its cached measurement metadata.
- Action
Owner - Authored module ownership of an action in a composed dependency graph.
- BitBinding
- One explicit binding to a child Boolean input.
- BitOutput
- One exported Boolean expression.
- BitRef
- A Boolean value in the parent or exported by a child.
- Block
- A single block placed at a 3D lattice position in a
BlockGraph. - Block
Graph - A graph of surface code blocks connected by lattice-surgery pipes.
- Block
Layer View - A read-only view of a single time (
z) layer of aBlockGraph. - Branch
- A branch ready to attach to a parent graph, including its resolve condition.
Both arms use coordinates in the parent graph. External seams are supplied
once to
BlockGraph::try_add_branches. - Branch
Arm - Blocks and pipes authored as one arm of a named branch region.
- Branch
Cut - One temporal pipe crossing from the unconditional prefix into an arm.
- Branch
Projection - One jointly reachable structural-branch assignment and its projected ordinary static graph.
- Branch
Region - A named branch region with two explicitly authored static arms.
- Cancellation
Token - Shared cancellation state for one request.
- Computation
Cancelled - A computation was cancelled before producing its result. Cancellation is neither a resource failure nor a semantic diagnosis.
- Cube
Height - A cube’s height, written
k*d + nover the code distanced. - Derived
Surface - A materialized stabilizer surface with readable-value provenance.
- Feedback
Options - Correspondence and resource bounds for feedback inference.
- Feedback
Target - A single Pauli correction site for an
Action::Feedback. - Gallery
Entry - A gallery example: its description, categories, and embedded
.blogsource. - Gltf
Data - Intermediate geometry for glTF export: colored triangles, colored line segments, and text labels, accumulated before serialization to a glTF model.
- Instance
Port - A named port on one child instance.
- Leaf
Module Certificate - A certified signed boundary projection for one leaf module.
- Module
Certification Limits - Limits applied before and during leaf-module certification.
- Module
Instance - One rotated, then translated, use of another module definition.
- Module
Interface - Public quantum and classical interface of a module.
- Module
Join Options - Docking preferences for module composition.
- Module
Rotation - A child-module quarter turn applied before translation.
- Module
Summary - Canonical signed Pauli relation over one module’s declared Ports.
- Module
View - Definition ownership for a flat rendering projection of an authored graph.
- Module
View Module - One visible definition in a module view.
- Output
Correction Row - One equation in the terminal output-correction system.
- Patch
Rotation Kind - A patch-rotation block: rotates a surface code patch by 90 degrees over one
time layer, translating it by an axis-aligned
movementstep. - Pipe
- A directed pipe connecting one block to an adjacent block.
- Quantum
Port - One named quantum boundary of a module.
- Readout
Plan - One frozen named readout, indexed by its already available resolve choices.
- Resolve
Value Domain - Distinct jointly reachable values of an ordered set of Boolean action conditions.
- Runtime
Stabilizer Basis - The live stabilizer basis of a ZX graph, tracking the generators and the selective nodes whose runtime basis choice can still update it.
- Selective
Fixing - The canonical fixing-row binding for one selective site.
- Selective
Fixing Target - A selective node and the Pauli basis it is forbidden from taking, used to constrain how selective supports are normalized.
- Stabilizer
- A stabilizer of a ZX graph, with its Pauli support broken out by the graph elements (ports, interior nodes, interior edges) it acts on for rendering.
- Stabilizer
Generator - A stabilizer generator paired with the
StabilizerRowKindit plays. - Stabilizer
Generators - Stabilizer state for a ZX graph: a stable public presentation plus private algebraic rank completion.
- Symbolic
Frame Pair - One output’s frame bits, each expressed as the constraint-index set whose
runtime RHS bits XOR into it. An empty set is the constant
false. - Symbolic
Output Correction - The eliminated system: per-output frame-bit assignments plus the dependent rows whose RHS must XOR to zero for the system to be consistent at runtime.
- Symbolic
Site - One selective site and the fixing row that resolves it.
- Symbolic
Stabilizer Basis - The surviving basis represented as an affine function of the fill assignment.
- Unknown
Certification Limit - A configuration names no field in
ModuleCertificationLimits. - Walking
Kind - A walking block: a boundary orientation plus a diagonal in-plane movement
that advances one time layer while shifting the patch by
movement. - ZXEdge
- An edge in a
ZXGraphconnecting two nodes, optionally Hadamard-typed. - ZXGraph
- A ZX-calculus graph derived from a
BlockGraph. - ZXLayer
View - A precomputed snapshot of one time (
z) layer of aZXGraph: its nodes, in-layer edges, and the nodes with edges into the past or future layers. - ZXNode
- A node in a
ZXGraph: a spider or boundary at a lattice position.
Enums§
- Action
- A classical-control action attached to a block graph program.
- Action
Dependency - Why one action must complete before another.
- Binary
Op - A binary operator in an action expression.
- Block
Error - Errors produced when constructing or converting block kinds.
- Block
Graph Error - Errors from constructing, editing, parsing, validating, transforming, or
exporting a
BlockGraph. - Block
Kind - The kind of a
Block, determining its surface code semantics and lattice footprint. - Cube
Kind - A cube block’s boundary orientation, named by the Pauli basis (
XorZ) assigned to each of the three axes in order. - Expr
- A boolean expression tree over measurement outcome variables.
- Feedback
Inference Error - A source/realization mismatch, unsupported contract, or inference limit.
- Fill
Ports Error - An error from filling a graph’s open ports with concrete boundary spiders.
- Gallery
Category - A tag used to filter
GalleryItementries. - Gallery
Item - A built-in example block graph, identified by a stable string id.
- Gltf
Face Selector - Selects filled block-graph faces to remove from a glTF export.
- Invalid
Action Error - A semantic or graph-constraint violation found while validating a graph’s
Actions. - Invalid
Block Graph Error - A structural well-formedness violation found while validating a
BlockGraph’s blocks, pipes, and lattice-surgery geometry. - Measure
Target - The target of a measurement action — either a node or a specific edge.
- Measurement
Observable - The Pauli basis a measurement action observes.
- Module
Certification Error - Error from certifying one independently authored module.
- Module
Error - Error while loading or validating a module program.
- Named
Readout - Executable named-readout recipe. Fixed rows borrow their existing storage.
- Node
Kind - The kind of a
ZXNode: an X/Y/Z spider or a boundary node. - Output
Correction Error - An error from solving or evaluating the output-correction system.
- Parse
Error - An error from parsing or lowering
.blogsource text. - Port
Direction - Direction of a quantum module port.
- Quantum
Connection - Explicit quantum composition authored by the parent module.
- Readout
Coordinates - Coordinates carried by a selected readout’s coefficient ordinals.
- Resolve
Domain Error - A bounded value query exhausted Boolean work or found too many values.
- Runtime
Basis Error - An error from deriving or updating a
RuntimeStabilizerBasis. - Selective
Kind - The two Pauli bases a selective block chooses between when resolved. The resolve condition being true selects the first named basis, false the second.
- Stabilizer
Error - An error from deriving stabilizer generators or measurement surfaces.
- Stabilizer
RowKind - The role a stabilizer generator row plays in the basis.
- Symbolic
Basis Error - A symbolic basis cannot represent a selective site’s fixing structure. This reports an unsupported symbolic model, not an invalid source graph. Callers can fall back to runtime-basis replay.
- Walking
Boundary Kind - Boundary orientation of a walking block, restricted to the four temporal (non-spatial) cube orientations.
- ZXError
- An error from constructing, validating, or filling a
ZXGraph.
Constants§
- EDITOR_
AMBIENT_ BRIGHTNESS - Ambient brightness shared by the editor and its baked glTF lighting.
- EDITOR_
DIRECTIONAL_ ILLUMINANCE - Diagonal key-light illuminance shared by the editor and its baked glTF lighting.
- MAX_
CUBE_ HEIGHT_ CELLS - Largest supported cube footprint along the time axis, in cells.
Functions§
- block_
as_ gltf_ data - Builds the geometry for a single block, with unit pipe length.
- block_
as_ gltf_ data_ with_ pipe_ length - Builds the geometry for a single block, using
pipe_lengthto size the gaps between blocks that pipes span. - block_
graph_ as_ gltf_ data - Builds the geometry for an entire block graph, laying blocks out on a grid
with
pipe_length-sized gaps between adjacent cells. - block_
graph_ as_ gltf_ data_ with_ popped_ faces - Builds an entire block graph while removing the selected filled faces.
- checked_
add_ position - Adds
offsettoposition, rejecting ani32coordinate overflow. - default_
module_ jobs - Default worker count for summarizing or compiling a module hierarchy: the machine’s parallelism capped at 4, and always 1 on wasm.
- infer_
feedback - Derives additional Pauli feedback for an existing realization.
- infer_
feedback_ with - Derives missing feedback under an explicit component contract.
- is_
valid_ tag - Returns whether
tagis a legal block/pipe tag. - lower_
blog_ ast_ deferred - Lowers parsed BLOG while deferring stabilizer-derived action dependencies.
- lower_
blog_ ast_ lenient - Lower editor drafts with checked geometry/syntax and lenient actions.
Constraint failures remain in
BlockGraph::action_graph_error. - lower_
blog_ graph_ ast_ deferred - Lowers parsed modular BLOG while deferring stabilizer-derived dependencies.
- map_
jobs - Maps
foveritemsacross at mostjobsscoped worker threads, keeping the results in input order. - module_
color - Stable ownership colors used by Bloq Editor and exported module viewers.
- parse_
actions - Parse an action snippet and lower it to
Actionvalues. - parse_
blog_ program_ to_ ast - Parse a BLOG module program without lowering it.
- parse_
blog_ to_ ast - Parse BLOG source text into its
ast::SourceFilewithout lowering. - parse_
blog_ to_ graph - Parse BLOG source text and lower it into a
BlockGraph. - parse_
blog_ to_ graph_ with_ limits - Parses BLOG into a hierarchy-preserving graph with explicit source budgets.
- pipe_
as_ gltf_ data - Builds the geometry for a pipe between two blocks.
- pipe_
between_ positions_ as_ gltf_ data - Builds the geometry for a pipe between two lattice positions.
- qualified_
name - Joins a module instance prefix and a local name with the
__separator used throughout module linking. An empty prefix returnsnameunchanged. - selective_
fixings - Builds the canonical selective-site fixing map from generator row kinds.
- selective_
selector_ name - The source-selector name used to pin a selective measurement at
position. - solve_
output_ correction_ symbolic - Solve the joint output-correction system once, symbolically.
- solve_
output_ correction_ symbolic_ prefix - Solve the full joint system, materializing at most its first
output_countoutputs. All constraints and runtime consistency checks remain active. - stabilizer_
as_ gltf_ data - Builds the geometry visualizing a stabilizer’s support overlaid on the graph.
Type Aliases§
- Analyzed
Branch Projections - Stabilizer tables for the jointly reachable static projections of a conditional block graph.
- Selective
Fixings - Selective site to its fixing-row binding.