Pattern Optimization

graphix.pattern module

class graphix.pattern.Pattern(width=0)[source]

MBQC pattern class

Pattern holds a sequence of commands to operate the MBQC (Pattern.seq), and provide modification strategies to improve the structure and simulation efficiency of the pattern accoring to measurement calculus.

ref: V. Danos, E. Kashefi and P. Panangaden. J. ACM 54.2 8 (2007)

width

number of output qubits

Type

int

seq

list of commands.

each command is a list [type, nodes, attr] which will be applied in the order of list indices.
type: one of {‘N’, ‘M’, ‘E’, ‘X’, ‘Z’, ‘S’, ‘C’}
nodes: int for {‘N’, ‘M’, ‘X’, ‘Z’, ‘S’, ‘C’} commands, tuple (i, j) for {‘E’} command
attr for N: none
attr for M: meas_plane, angle, s_domain, t_domain
attr for X: signal_domain
attr for Z: signal_domain
attr for S: signal_domain
attr for C: clifford_index, as defined in graphix.clifford
Type

list

Nnode

total number of nodes in the resource state

Type

int

__init__(width=0)[source]
Parameters

width – number of input/output qubits

simulate_pattern(backend='statevector', **kwargs)[source]

Simulate the execution of the pattern by using graphix.simulator.PatternSimulator.

Available backend: [‘statevector’, ‘tensornetwork’]

Parameters
  • backend (str) – optional parameter to select simulator backend.

  • kwargs (keyword args for specified backend.) –

Returns

perform_pauli_measurements()[source]

Perform Pauli measurements in the pattern using efficient stabilizer simulator.

See also

measure_pauli()

print_pattern(lim=40, filter=None)[source]

print the pattern sequence (Pattern.seq).

Parameters
  • lim (int, optional) – maximum number of commands to show

  • filter (list of str, optional) – show only specified commands, e.g. [‘M’, ‘X’, ‘Z’]

standardize()[source]

Executes standardization of the pattern. ‘standard’ pattern is one where commands are sorted in the order of ‘N’, ‘E’, ‘M’ and then byproduct commands (‘X’ and ‘Z’).

shift_signals()[source]

Performs signal shifting procedure Extract the t-dependence of the measurement into ‘S’ commands and commute them towards the end of the command sequence, where it can be deleted. In many cases, this procedure simplifies the dependence structure of the pattern. For patterns transpiled from gate sequencees, this result in the removal of s- and t- domains on Pauli measurement commands.

Ref: V. Danos, E. Kashefi and P. Panangaden. J. ACM 54.2 8 (2007)

is_standard()[source]

determines whether the command sequence is standard

Returns

is_standard – True if the pattern is standard

Return type

bool

get_graph()[source]

returns the list of nodes and edges from the command sequence, extracted from ‘N’ and ‘E’ commands.

Returns

  • node_list (list) – list of node indices.

  • edge_list (list) – list of tuples (i,j) specifying edges

parallelize_pattern()[source]

Optimize the pattern to reduce the depth of the computation by gathering measurement commands that can be performed simultaneously. This optimized pattern runs efficiently on GPUs and quantum hardwares with depth (e.g. coherence time) limitations.

minimize_space()[source]

Optimize the pattern to minimize the max_space property of the pattern i.e. the optimized pattern has significantly reduced space requirement (memory space for classical simulation, and maximum simultaneously prepared qubits for quantum hardwares).

max_space()[source]

The maximum number of nodes that must be present in the graph (graph space) during the execution of the pattern. For statevector simulation, this is equivalent to the maximum memory needed for classical simulation.

Returns

n_nodes – max number of nodes present in the graph during pattern execution.

Return type

int

get_layers()[source]

Construct layers(l_k) from dependency information. kth layer must be measured before measuring k+1th layer and nodes in the same layer can be measured simultaneously.

Returns

  • depth (int) – depth of graph

  • layers (dict of set) – nodes grouped by layer index(k)

to_qasm3(filename)[source]

Export measurement pattern to OpenQASM 3.0 file

Parameters

filename (str) – file name to export to. example: “filename.qasm”

graphix.pattern.measure_pauli(pattern, copy=False)[source]

Perform Pauli measurement of a pattern by fast graph state simulator uses the decorated-graph method implemented in graphix.graphsim to perform the measurements in Pauli bases, and then sort remaining nodes back into pattern together with Clifford commands.

TODO: non-XY plane measurements in original pattern

Parameters
  • pattern (graphix.pattern.Pattern object) –

  • copy (bool) – True: changes will be applied to new copied object and will be returned False: changes will be applied to the supplied Pattern object

Returns

new_pattern – pattern with Pauli measurement removed. only returned if copy argument is True.

Return type

graphix.Pattern object