Pattern

graphqomb.pattern module

Pattern module.

This module provides:

Pattern Classes

class graphqomb.pattern.Pattern[source]

Pattern class.

input_node_indices

The map of input nodes to their logical qubit indices

Type:

dict[int, int]

output_node_indices

The map of output nodes to their logical qubit indices

Type:

dict[int, int]

commands

Commands of the pattern

Type:

tuple[Command, …]

pauli_frame

Pauli frame of the pattern to track the Pauli state of each node

Type:

PauliFrame

input_coordinates

Coordinates for input nodes (2D or 3D)

Type:

dict[int, tuple[float, …]]

property max_space: int[source]

Maximum number of qubits prepared at any point in the pattern.

Returns:

Maximum number of qubits prepared at any point in the pattern

Return type:

int

property space: list[int][source]

List of qubits prepared at each point in the pattern.

Returns:

List of qubits prepared at each point in the pattern

Return type:

list[int]

property depth: int

Depth of the pattern (number of TICK commands).

Returns:

Depth of the pattern

Return type:

int

property coordinates: dict[int, tuple[float, ...]]

Get all node coordinates from N commands and input coordinates.

Returns:

mapping from node index to coordinate tuple (2D or 3D)

Return type:

dict[int, tuple[float, …]]

property active_volume: int

Calculate tha active volume, summation of space for each timeslice.

Returns:

Active volume of the pattern

Return type:

int

property volume: int

Calculate the volume, defined as max_space * depth.

Returns:

Volume of the pattern

Return type:

int

property idle_times: dict[int, int]

Calculate the idle times for each qubit in the pattern.

Returns:

A dictionary mapping each qubit index to its idle time.

Return type:

dict[int, int]

property throughput: float

Calculate the number of measurements per TICK in the pattern.

Returns:

Number of measurements per TICK

Return type:

float

Raises:

ValueError – If the pattern has zero depth (no TICK commands)

__init__(input_node_indices, output_node_indices, commands, pauli_frame, input_coordinates=<factory>)

Helper Functions

graphqomb.pattern.is_runnable(pattern)[source]

Check if the pattern is runnable.

Parameters:

pattern (Pattern) – Pattern to check

graphqomb.pattern.print_pattern(pattern, *, file=None, lim=40, cmd_filter=None)[source]

Print a pattern.

Parameters:
  • pattern (Pattern) – Pattern to print

  • file (typing.TextIO, optional) – File to print to, by default None (prints to stdout)

  • lim (int, optional) – Maximum number of commands to print, by default 40

  • cmd_filter (typing.Callable[[Command], Command | None] | None, optional) – Command filter, by default None