Feedforward¶
graphqomb.feedforward module¶
Feedforward correction functions.
This module provides:
dag_from_flow: Construct a directed acyclic graph (DAG) from a flowlike object.inverse_dag_from_dag: Construct an inverse DAG (node -> dependencies).topo_order_from_inv_dag: Construct a topological order from an inverse DAG.check_dag: Check if a directed acyclic graph (DAG) does not contain a cycle.check_flow: Check if the flowlike object is causal with respect to the graph state.signal_shifting: Convert the correction maps into more parallel-friendly forms using signal shifting.propagate_correction_map: Propagate the correction map through a measurement at the target node.
Functions¶
- graphqomb.feedforward.dag_from_flow(graph, xflow, zflow=None)[source]¶
Construct a directed acyclic graph (DAG) from a flowlike object.
- Parameters:
graph (
BaseGraphState) – The graph statexflow (
collections.abc.Mapping[int,int] |collections.abc.Mapping[int,collections.abc.Set[int]]) – The X correction flow (flow and gflow are included)zflow (
collections.abc.Mapping[int,int] |collections.abc.Mapping[int,collections.abc.Set[int]] |None) – The Z correction flow. IfNone, it is generated from xflow by odd neighbors.
- Returns:
The directed acyclic graph
- Return type:
- Raises:
TypeError – If the flowlike object is not a Flow or GFlow
- graphqomb.feedforward.inverse_dag_from_dag(dag, all_nodes=None)[source]¶
Build inverse DAG (node -> dependencies) from parent->children DAG.
- Parameters:
dag (
collections.abc.Mapping[int,collections.abc.Iterable[int]]) – DAG represented as parent node -> children.all_nodes (
collections.abc.Iterable[int] |None, optional) – Optional full node set to include isolated nodes.
- Returns:
Inverse DAG represented as node -> dependencies.
- Return type:
- graphqomb.feedforward.topo_order_from_inv_dag(inv_dag)[source]¶
Build topological order from an inverse DAG (node -> dependencies).
- Parameters:
inv_dag (
collections.abc.Mapping[int,collections.abc.Iterable[int]]) – Inverse DAG where each node maps to the nodes it depends on.- Returns:
Topological order from dependencies to dependents.
- Return type:
- Raises:
RuntimeError – If topological ordering is not possible due to a cycle.
- graphqomb.feedforward.check_dag(dag)[source]¶
Check if a directed acyclic graph (DAG) does not contain a cycle.
- Parameters:
dag (
collections.abc.Mapping[int,collections.abc.Iterable[int]]) – directed acyclic graph- Raises:
ValueError – If the flowlike object is not causal with respect to the graph state
- graphqomb.feedforward.check_flow(graph, xflow, zflow=None)[source]¶
Check if the flowlike object is causal with respect to the graph state.
- Parameters:
graph (
BaseGraphState) – The graph statexflow (
collections.abc.Mapping[int,int] |collections.abc.Mapping[int,collections.abc.Set[int]]) – The X correction flow (flow and gflow are included)zflow (
collections.abc.Mapping[int,int] |collections.abc.Mapping[int,collections.abc.Set[int]] |None) – The Z correction flow. IfNone, it is generated from xflow by odd neighbors.
- graphqomb.feedforward.signal_shifting(graph, xflow, zflow=None)[source]¶
Convert the correction maps into more parallel-friendly forms using signal shifting.
- Parameters:
graph (
BaseGraphState) – Underlying graph state.xflow (
collections.abc.Mapping[int,collections.abc.Set[int]]) – Correction map for X.zflow (
collections.abc.Mapping[int,collections.abc.Set[int]] |None) – Correction map for Z. IfNone, it is generated from xflow by odd neighbors.
- Returns:
Updated correction maps for X and Z after signal shifting.
- Return type:
- graphqomb.feedforward.propagate_correction_map(target_node, graph, xflow, zflow=None)[source]¶
Propagate the correction map through a measurement at the target node.
- Parameters:
target_node (
int) – Node at which the measurement is performed.graph (
BaseGraphState) – Underlying graph state.xflow (
collections.abc.Mapping[int,collections.abc.Set[int]]) – Correction map for X.zflow (
collections.abc.Mapping[int,collections.abc.Set[int]] |None) – Correction map for Z. IfNone, it is generated from xflow by odd neighbors.
- Returns:
Updated correction maps for X and Z after measurement at the target node.
- Return type:
- Raises:
ValueError – If the target node is an output node.
ValueError – If the measurement plane is unsupported.
Notes
This function converts the correction maps into more parallel-friendly forms. It is equivalent to the signal shifting technique in the measurement calculus.