pygsti.algorithms.randomcircuit.create_mirror_rb_circuit#
- create_mirror_rb_circuit(pspec, absolute_compilation, length, qubit_labels=None, sampler='Qelimination', samplerargs=None, localclifford=True, paulirandomize=True, seed=None)#
Generates a “mirror randomized benchmarking” (MRB) circuit.
This is specific to the case of Clifford gates and can be performed, optionally, with Pauli-randomization and Clifford-twirling. This RB method is currently in development; this docstring will be updated in the future with further information on this technique.
To implement mirror RB it is necessary for U^(-1) to in the gate-set for every U in the gate-set.
- Parameters:
pspec (QubitProcessorSpec) – The QubitProcessorSpec for the device that the circuit is being sampled for. The pspec is always handed to the sampler, as the first argument of the sampler function.
absolute_compilation (CompilationRules) – Rules for exactly (absolutely) compiling the “native” gates of pspec into clifford gates.
length (int) –
The “mirror RB length” of the circuit, which is closely related to the circuit depth. It must be an even integer, and can be zero.
If localclifford and paulirandomize are False, this is the depth of the sampled circuit. The first length/2 layers are all sampled independently according to the sampler specified by sampler. The remaining half of the circuit is the “inversion” circuit that is determined by the first half.
If paulirandomize is True and localclifford is False, the depth of the circuits is 2*length+1 with odd-indexed layers sampled according to the sampler specified by sampler, and the the zeroth layer + the even-indexed layers consisting of random 1-qubit Pauli gates.
If paulirandomize and localclifford are True, the depth of the circuits is 2*length+1 + X where X is a random variable (between 0 and normally <= ~12-16) that accounts for the depth from the layer of random 1-qubit Cliffords at the start and end of the circuit.
If paulirandomize is False and localclifford is True, the depth of the circuits is length + X where X is a random variable (between 0 and normally <= ~12-16) that accounts for the depth from the layer of random 1-qubit Cliffords at the start and end of the circuit.
qubit_labels (list, optional) – If not None, a list of the qubits that the RB circuit is to be sampled for. This should be all or a subset of the qubits in the device specified by the QubitProcessorSpec pspec. If None, it is assumed that the RB circuit should be over all the qubits. Note that the ordering of this list is the order of the “wires” in the returned circuit, but is otherwise irrelevant.
sampler (str or function, optional) – If a string, this should be one of: {‘pairingQs’, ‘Qelimination’, ‘co2Qgates’, ‘local’}. Except for ‘local’, this corresponds to sampling layers according to the sampling function in rb.sampler named circuit_layer_by* (with * replaced by ‘sampler’). For ‘local’, this corresponds to sampling according to rb.sampler.circuit_layer_of_oneQgates [which is not a valid option for n-qubit MRB – it results in sim. 1-qubit MRB – but it is not explicitly forbidden by this function]. If sampler is a function, it should be a function that takes as the first argument a QubitProcessorSpec, and returns a random circuit layer as a list of gate Label objects. Note that the default ‘Qelimination’ is not necessarily the most useful in-built sampler, but it is the only sampler that requires no parameters beyond the QubitProcessorSpec and works for arbitrary connectivity devices. See the docstrings for each of these samplers for more information.
samplerargs (list, optional) – A list of arguments that are handed to the sampler function, specified by sampler. The first argument handed to the sampler is pspec and samplerargs lists the remaining arguments handed to the sampler.
localclifford (bool, optional) – Whether to start the circuit with uniformly random 1-qubit Cliffords and all of the qubits (compiled into the native gates of the device).
paulirandomize (bool, optional) – Whether to have uniformly random Pauli operators on all of the qubits before and after all of the layers in the “out” and “back” random circuits. At length 0 there is a single layer of random Pauli operators (in between two layers of 1-qubit Clifford gates if localclifford is True); at length l there are 2l+1 Pauli layers as there are
seed (int, optional) – A seed to initialize the random number generator used for creating random clifford circuits.
- Returns:
Circuit – A random MRB circuit, sampled as specified, of depth:
length, if not paulirandomize and not local clifford.
2*`length`+1 if paulirandomize and not local clifford.
length + X, if not paulirandomize and local clifford, where X is a random variable that accounts for the depth from the layers of random 1-qubit Cliffords (X = 2 if the 1 qubit Clifford gates are “native” gates in the QubitProcessorSpec).
2*`length`+1 + X, if paulirandomize and local clifford, where X is a random variable that accounts for the depth from the layers of random 1-qubit Cliffords (X = 2 if the 1 qubit Clifford gates are “native” gates in the QubitProcessorSpec).
Tuple – A length-n tuple of integers in [0,1], corresponding to the error-free outcome of the circuit. Always all zeros if randomizeout is False. The ith element of the tuple corresponds to the error-free outcome for the qubit labelled by: the ith element of qubit_labels, if qubit_labels is not None; the ith element of pspec.qubit_labels, otherwise. In both cases, the ith element of the tuple corresponds to the error-free outcome for the qubit on the ith wire of the output circuit.