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:
Returns:

The directed acyclic graph

Return type:

dict[int, set[int]]

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:
Returns:

Inverse DAG represented as node -> dependencies.

Return type:

dict[int, set[int]]

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:

list[int]

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:
graphqomb.feedforward.signal_shifting(graph, xflow, zflow=None)[source]

Convert the correction maps into more parallel-friendly forms using signal shifting.

Parameters:
Returns:

Updated correction maps for X and Z after signal shifting.

Return type:

tuple[dict[int, set[int]], dict[int, set[int]]]

graphqomb.feedforward.propagate_correction_map(target_node, graph, xflow, zflow=None)[source]

Propagate the correction map through a measurement at the target node.

Parameters:
Returns:

Updated correction maps for X and Z after measurement at the target node.

Return type:

tuple[dict[int, set[int]], dict[int, set[int]]]

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.