Skip to main content

BloqNode

Struct BloqNode 

Source
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: BloqNodeKind

Node payload.

§provenance: NodeProvenance

Source 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

Source

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.

Source

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).

Source

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).

Source

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

Source

pub fn from_members(members: Vec<SourceBlockRef>) -> Self

Create a quantum node for a source block component.

Source

pub fn from_temporal_pipe(pipe: TemporalPipeRef) -> Self

Create a quantum node for a temporal pipe.

Source

pub fn memory_padding(pipe: TemporalPipeRef, rounds: u32) -> Self

A memory-round padding node on pipe’s seam, waiting rounds syndrome-extraction rounds.

Source

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.

Source

pub fn region(region: RegionNode) -> Self

A control-flow region node (RegionNode), with no provenance.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn try_quantum(&self) -> Option<&QuantumNode>

The node’s quantum payload, or None for a non-quantum (classical or region) node.

Source

pub fn try_classical(&self) -> Option<&ClassicalNode>

The node’s classical payload, or None for a non-classical node.

Source

pub fn try_classical_mut(&mut self) -> Option<&mut ClassicalNode>

Mutable classical payload, detaching a shared definition before editing.

Source

pub fn try_region(&self) -> Option<&RegionNode>

The node’s region payload, or None for a non-region node.

Source

pub fn block_members(&self) -> &[SourceBlockRef]

Source block members, or an empty slice for another provenance kind.

Source

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.

Source

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

Source

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.

Trait Implementations§

Source§

impl Clone for BloqNode

Source§

fn clone(&self) -> BloqNode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BloqNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BloqNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BloqNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
where T: BorrowMut<BorrowedSelf>, BorrowedSelf: BitwiseMut + ?Sized,

§

fn assign_index(&mut self, index: usize, to: bool)

§

fn negate_index(&mut self, index: usize)

§

fn clear_bits(&mut self)

§

fn assign_random( &mut self, bit_count: usize, random_number_generator: &mut impl RngExt, )
where BorrowedSelf: BitLength,

§

impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
where Bits: BorrowMut<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePairMut<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn assign(&mut self, other: &Other)

§

fn bitxor_assign(&mut self, other: &Other)

§

fn bitand_assign(&mut self, other: &Other)

§

fn bitor_assign(&mut self, other: &Other)

§

impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
where T: Borrow<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePair<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn dot(&self, other: &Other) -> bool

§

fn and_weight(&self, other: &Other) -> usize

§

fn or_weight(&self, other: &Other) -> usize

§

fn xor_weight(&self, other: &Other) -> usize

§

impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
where T: Borrow<BorrowedSelf>, BorrowedSelf: Bitwise + ?Sized,

§

fn index(&self, index: usize) -> bool

§

fn weight(&self) -> usize

§

fn parity(&self) -> bool

§

fn is_zero(&self) -> bool

§

fn is_unit(&self, index: usize) -> bool

§

fn support<'a>(&'a self) -> impl SortedIterator
where BorrowedSelf: 'a,

§

fn max_support(&self) -> Option<usize>

§

fn min_support(&self) -> Option<usize>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.