pub struct BloqNode {
pub kind: BloqNodeKind,
pub provenance: NodeProvenance,
pub activation: Option<u32>,
}Expand description
A graph node, tagged by what kind of work it represents.
kind is what the node computes; provenance is why it exists — its tie
back to the source block graph, a stabilizer generator, a source action, or
an output frame (NodeProvenance).
Fields§
§kind: BloqNodeKindNode payload.
provenance: NodeProvenanceSource provenance.
activation: Option<u32>Optional activation Value slot for a classical or region node. When false,
bit results are zero, boundary bindings are empty, and no read, decoder
request, region-body execution, or discard occurs. It is not a data operand.
Implementations§
Source§impl BloqNode
impl BloqNode
Sourcepub fn select_quantum_members(
&self,
input: impl FnMut(u32) -> Option<bool>,
) -> Result<Self, NodeTemplateInstanceMergeError>
pub fn select_quantum_members( &self, input: impl FnMut(u32) -> Option<bool>, ) -> Result<Self, NodeTemplateInstanceMergeError>
Resolve the component’s conditional registrations without executing it. Unselected instances produce no gates, records, detectors, or restarts. The returned node retains the selected instances’ identities.
§Errors
Returns NodeTemplateInstanceMergeError for missing inputs or an
invalid, incomplete, or duplicate membership registration.
Sourcepub fn instantiate_circuit(
&self,
templates: &BloqTemplatePool,
) -> Result<CoordCircuit, NodeTemplateInstanceMergeError>
pub fn instantiate_circuit( &self, templates: &BloqTemplatePool, ) -> Result<CoordCircuit, NodeTemplateInstanceMergeError>
The node’s merged circuit — its instances translated by offset and merged moment-by-moment.
This is Self::emission_plan keeping only the circuit; take the plan
when the instance-space id maps matter, or
Self::emission_plan_with_options to apply noise.
§Errors
Returns NodeTemplateInstanceMergeError when the instances do not
merge (mismatched tick/repeat structure, incompatible qubit overlap, a
missing template).
Sourcepub fn emission_plan(
&self,
templates: &BloqTemplatePool,
) -> Result<NodeEmissionPlan, NodeTemplateInstanceMergeError>
pub fn emission_plan( &self, templates: &BloqTemplatePool, ) -> Result<NodeEmissionPlan, NodeTemplateInstanceMergeError>
Instantiate and merge the node’s template instances into one circuit,
returning the circuit together with the instance-space id maps
(NodeEmissionPlan). A classical or region node has no instances and
yields an empty plan.
§Errors
Returns NodeTemplateInstanceMergeError when the instances do not
merge (mismatched tick/repeat structure, incompatible qubit overlap, a
missing template).
Sourcepub fn emission_plan_with_options(
&self,
templates: &BloqTemplatePool,
options: InstantiationOptions<'_>,
) -> Result<NodeEmissionPlan, NodeTemplateInstanceMergeError>
pub fn emission_plan_with_options( &self, templates: &BloqTemplatePool, options: InstantiationOptions<'_>, ) -> Result<NodeEmissionPlan, NodeTemplateInstanceMergeError>
Self::emission_plan with options applied once after instantiation.
§Errors
Returns NodeTemplateInstanceMergeError for unresolved membership,
invalid templates or noise, coordinate overflow, or an invalid merge.
§Panics
Panics only if an internally generated merged circuit body is missing.
Source§impl BloqNode
impl BloqNode
Sourcepub fn from_members(members: Vec<SourceBlockRef>) -> Self
pub fn from_members(members: Vec<SourceBlockRef>) -> Self
Create a quantum node for a source block component.
Sourcepub fn from_temporal_pipe(pipe: TemporalPipeRef) -> Self
pub fn from_temporal_pipe(pipe: TemporalPipeRef) -> Self
Create a quantum node for a temporal pipe.
Sourcepub fn memory_padding(pipe: TemporalPipeRef, rounds: u32) -> Self
pub fn memory_padding(pipe: TemporalPipeRef, rounds: u32) -> Self
A memory-round padding node on pipe’s seam, waiting rounds
syndrome-extraction rounds.
Sourcepub fn quantum(quantum: QuantumNode) -> Self
pub fn quantum(quantum: QuantumNode) -> Self
A template-backed quantum node with no provenance. Its payload shares
across snapshots until Self::expect_quantum_mut edits it.
Sourcepub fn region(region: RegionNode) -> Self
pub fn region(region: RegionNode) -> Self
A control-flow region node (RegionNode), with no provenance.
Sourcepub fn classical(node: impl Into<Arc<ClassicalNode>>) -> Self
pub fn classical(node: impl Into<Arc<ClassicalNode>>) -> Self
A classical-dataflow node (ClassicalNode), with no provenance.
Lowering stamps the real provenance (NodeProvenance::Generator /
NodeProvenance::Action / NodeProvenance::OutputFrame) via
Self::with_provenance where it knows the origin.
Sourcepub fn with_provenance(self, provenance: NodeProvenance) -> Self
pub fn with_provenance(self, provenance: NodeProvenance) -> Self
The same node with its provenance replaced — builder-style, for lowering sites that know what a classical node realizes.
Sourcepub fn expect_quantum(&self) -> &QuantumNode
pub fn expect_quantum(&self) -> &QuantumNode
The node’s quantum payload, panicking on a non-quantum node (the
rustc expect_* convention for panicking accessors). Most passes only
ever see quantum nodes (lowering produces no others on the static
path), so they call this directly; a pass that must tolerate other
kinds uses Self::try_quantum instead.
§Panics
Panics when this node is classical or a region.
Sourcepub fn expect_quantum_mut(&mut self) -> &mut QuantumNode
pub fn expect_quantum_mut(&mut self) -> &mut QuantumNode
Mutable twin of Self::expect_quantum; detaches shared quantum data.
Panics on a non-quantum node.
§Panics
Panics when this node is classical or a region.
Sourcepub fn try_quantum(&self) -> Option<&QuantumNode>
pub fn try_quantum(&self) -> Option<&QuantumNode>
The node’s quantum payload, or None for a non-quantum (classical or
region) node.
Sourcepub fn try_classical(&self) -> Option<&ClassicalNode>
pub fn try_classical(&self) -> Option<&ClassicalNode>
The node’s classical payload, or None for a non-classical node.
Sourcepub fn try_classical_mut(&mut self) -> Option<&mut ClassicalNode>
pub fn try_classical_mut(&mut self) -> Option<&mut ClassicalNode>
Mutable classical payload, detaching a shared definition before editing.
Sourcepub fn try_region(&self) -> Option<&RegionNode>
pub fn try_region(&self) -> Option<&RegionNode>
The node’s region payload, or None for a non-region node.
Sourcepub fn block_members(&self) -> &[SourceBlockRef]
pub fn block_members(&self) -> &[SourceBlockRef]
Source block members, or an empty slice for another provenance kind.
Sourcepub fn memory_rounds(&self) -> Option<u32>
pub fn memory_rounds(&self) -> Option<u32>
The spliced node’s wait duration in syndrome-extraction rounds, or
None for anything that is not a wait on a seam.
Sourcepub fn layer(&self) -> i64
pub fn layer(&self) -> i64
The node’s spatial layer on the doubled-z axis: block layers land on
even values (2z) and the pipe seams between them on odd values
(2z + 1), so temporally adjacent blocks and their connecting seam
stay strictly ordered. Classical, frame, and action nodes have no
spatial layer and report 0.
Source§impl BloqNode
impl BloqNode
Sourcepub fn stable_key(&self) -> Option<NodeKey>
pub fn stable_key(&self) -> Option<NodeKey>
This node’s provenance-derived key, at ordinal 0.
None for a node with no provenance (a region node, or a hand-built
synthetic one), which has no cross-program identity to report.
Use SubGraph::stable_keys when nodes may share a provenance: the
ordinal that separates them is a property of the level, not of any one
node. Memory padding is the case that needs it — several padding nodes
can idle on one pipe for the same number of rounds.