pygsti.processors.random_compilation.RandomCompilation#

class RandomCompilation(rc_strategy=None, return_bs=False, testing=False, rand_state=None)#

Bases: object

A class for performing randomized circuit compilation.

rc_strategy#

The strategy used for randomized compilation. Currently, ‘pauli_rc’ (pauli randomized compiling on a U3-CX-CZ gate set) and ‘central_pauli’ (central Pauli propagation for a U3-CX-CZ gate set) are supported.

Type:

str

return_bs#

If True, the compile method will return the target bitstring for the randomly compiled circuit.

Type:

bool

testing#

Flag for unit testing. If True, the user can provide test Pauli layers for random compilation instead of the layers being randomly generated.

Type:

bool

rand_state#

A random state for reproducibility of random operations.

Type:

np.random.RandomState

Initialize the RandomCompilation object.

Parameters:
  • rc_strategy (str) – The strategy used for randomized compilation. Currently, ‘pauli_rc’ (pauli randomized compiling on a U3-CX-CZ gate set, see https://arxiv.org/abs/2204.07568) and ‘central_pauli’ (central Pauli propagation for a U3-CX-CZ gate set, see https://www.nature.com/articles/s41567-021-01409-7) are supported. Defaults to ‘pauli_rc’.

  • return_bs (bool) – If True, the compile method will return the target bitstring for the randomly compiled circuit. Default is False.

  • testing (bool) – Flag for unit testing. If True, the user can provide test Pauli layers for random compilation instead of the layers being randomly generated. Default is False.

  • rand_state (np.random.RandomState) – A random state for reproducibility of random operations. Default is None.

Methods

__init__([rc_strategy, return_bs, testing, ...])

Initialize the RandomCompilation object.

compile(circ[, test_layers])

Compiles the given circuit using the specified randomized compilation strategy.

compile(circ, test_layers=None)#

Compiles the given circuit using the specified randomized compilation strategy.

Parameters:
  • circ (pygsti.circuits.Circuit) – The n-qubit circuit to be compiled.

  • test_layers (list[np.ndarray[int]], optional) – A list of test layers to be used in the random compilation if self.testing is True. Layers are specified by a length-2*n array whose entries are either 0 or 2. Indices 0:n correspond to Pauli Z errors: a 2 indicates the presence an error. Likewise indices n:2*n indicate a Pauli Z error. If using central Pauli, only one layer must be provided. If using random compilation, a number of layers equal to the number of layers of single-qubit gates must be provided. Default is None.

Returns:

A list containing the randomized circuit, and optionally the bitstring and target Pauli vector.

Return type:

list[pygsti.circuits.Circuit, str (optional), np.ndarray (optional)]