mqt.qmap.ph.graph

Routing graph construction and fidelity scoring for the photonic compiler.

Classes

RoutingGraph

Routing DAG and its per-layer node indices.

Functions

bar_fidelity(r) → float

Compute the straight-through probability of an MZI with bar phases.

cross_fidelity(r) → float

Compute the swap probability of an MZI with cross phases.

determine_routing_fidelities(...) → tuple[list[float], list[float]]

Compute bar and cross fidelities in layer and MZI order.

get_edge_cost_for_graph_layer(graph_layer, ...[, ...]) → float

Compute the cost of routing a dual-rail photon window through one layer.

construct_graph(chip_dim, target_dim, ...) → RoutingGraph

Construct the routing DAG for photon placement optimization.

Module Contents

bar_fidelity(r: Sequence[float]) → float[source]

Compute the straight-through probability of an MZI with bar phases.

Parameters:

r – Input and output beam-splitter reflectivities.

Returns:

Probability of remaining in the input mode.

cross_fidelity(r: Sequence[float]) → float[source]

Compute the swap probability of an MZI with cross phases.

Parameters:

r – Input and output beam-splitter reflectivities.

Returns:

Probability of moving to the paired mode.

determine_routing_fidelities(beam_splitter_reflectivities: list[float], chip_dim: int) → tuple[list[float], list[float]][source]

Compute bar and cross fidelities in layer and MZI order.

Parameters:
  • beam_splitter_reflectivities – Flat in/out reflectivity pairs.

  • chip_dim – Number of spatial modes and layers.

Returns:

Bar and cross fidelities for every MZI.

get_edge_cost_for_graph_layer(graph_layer: int, source_node_idx: int, target_node_idx: int, bar_fidelities: list[float], cross_fidelities: list[float], chip_dim: int, target_dim: int = 4) → float[source]

Compute the cost of routing a dual-rail photon window through one layer.

Parameters:
  • graph_layer – Graph layer being left; physical layer is one less.

  • source_node_idx – Physical mode occupied by the first photon.

  • target_node_idx – Physical mode of that photon after the layer.

  • bar_fidelities – Bar probabilities in layer and MZI order.

  • cross_fidelities – Cross probabilities in layer and MZI order.

  • chip_dim – Number of spatial modes.

  • target_dim – Even width of the computation zone.

Returns:

Sum of negative log probabilities for the traversed MZIs. Uncoupled edge modes contribute no loss.

Raises:

ValueError – If the transition does not follow the mesh pairing or the target dimension is odd.

class RoutingGraph[source]

Routing DAG and its per-layer node indices.

construct_graph(chip_dim: int, target_dim: int, input_transmission: list[float], output_transmission: list[float], beam_splitter_reflectivities: list[float]) → RoutingGraph[source]

Construct the routing DAG for photon placement optimization.

Source edges select dual-rail input modes. Each intermediate edge routes those photons through one physical layer. Sink edges select the output window. Weights are negative log transmission probabilities.

Parameters:
  • chip_dim – Total number of spatial modes on the chip.

  • target_dim – Dimension of the target unitary.

  • input_transmission – Per-mode input transmission probabilities.

  • output_transmission – Per-mode output transmission probabilities.

  • beam_splitter_reflectivities – Flat in/out reflectivity pairs in layer and MZI order.

Returns:

Weighted directed acyclic graph and its layer indices.

Raises:

ValueError – If the target is not positive and even, the chip is no larger than the target, or the chip dimension is odd.