pygsti.algorithms.randomcircuit.create_clifford_rb_circuit

pygsti.algorithms.randomcircuit.create_clifford_rb_circuit#

create_clifford_rb_circuit(pspec, clifford_compilations, length, qubit_labels=None, randomizeout=False, citerations=20, compilerargs=None, interleaved_circuit=None, seed=None, return_native_gate_counts=False, exact_compilation_key=None)#

Generates a “Clifford randomized benchmarking” (CRB) circuit.

CRB is the current-standard RB protocol defined in “Scalable and robust randomized benchmarking of quantum processes”, Magesan et al. PRL 106 180504 (2011). This consists of a circuit of length`+1 uniformly random n-qubit Clifford gates followed by the unique inversion Clifford, with all the Cliffords compiled into the “native” gates of a device as specified by `pspec. The circuit output by this function will respect the connectivity of the device, as encoded into pspec (see the QubitProcessorSpec object docstring for how to construct the relevant pspec).

Note the convention that the the output Circuit consists of length+2 Clifford gates, rather than the more usual convention of defining the “CRB length” to be the number of Clifford gates - 1. This is for consistency with the other RB functions in pyGSTi: in all RB-circuit-generating functions in pyGSTi length zero corresponds to the minimum-length circuit allowed by the protocol. Note that changing the “RB depths” by a constant additive factor is irrelevant for fitting purposes (except that it changes the obtained “SPAM” fit parameter).

Parameters:
  • pspec (QubitProcessorSpec) – The QubitProcessorSpec for the device that the circuit is being sampled for, which defines the “native” gate-set and the connectivity of the device. The returned CRB circuit will be over the gates in pspec, and will respect the connectivity encoded by pspec.

  • clifford_compilations (dict) – A dictionary with at least the potential keys ‘absolute’ and ‘paulieq’ and corresponding CompilationRules values. These compilation rules specify how to compile the “native” gates of pspec into Clifford gates. Additional CompilationRules can be provided, particularly for use with exact_compilation_key.

  • length (int) – The “CRB length” of the circuit – an integer >= 0 – which is the number of Cliffords in the circuit - 2 before each Clifford is compiled into the native gate-set.

  • 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. If desired, a circuit that explicitly idles on the other qubits can be obtained by using methods of the Circuit object.

  • randomizeout (bool, optional) – If False, the ideal output of the circuit (the “success” or “survival” outcome) is the all-zeros bit string. This is probably considered to be the “standard” in CRB. If True, the ideal output of the circuit is randomized to a uniformly random bit-string. This setting is useful for, e.g., detecting leakage/loss/measurement-bias etc.

  • citerations (int, optional) – Some of the Clifford compilation algorithms in pyGSTi (including the default algorithm) are randomized, and the lowest-cost circuit is chosen from all the circuit generated in the iterations of the algorithm. This is the number of iterations used. The time required to generate a CRB circuit is linear in citerations * (length + 2). Lower-depth / lower 2-qubit gate count compilations of the Cliffords are important in order to successfully implement CRB on more qubits.

  • compilerargs (list, optional) –

    A list of arguments that are handed to compile_clifford() function, which includes all the optional arguments of compile_clifford() after the iterations option (set by citerations). In order, this list should be values for:

    algorithm : str. A string that specifies the compilation algorithm. The default in compile_clifford() will always be whatever we consider to be the ‘best’ all-round algorithm

    aargs : list. A list of optional arguments for the particular compilation algorithm.

    costfunction : ‘str’ or function. The cost-function from which the “best” compilation for a Clifford is chosen from all citerations compilations. The default costs a circuit as 10x the num. of 2-qubit gates in the circuit + 1x the depth of the circuit.

    prefixpaulis : bool. Whether to prefix or append the Paulis on each Clifford.

    paulirandomize : bool. Whether to follow each layer in the Clifford circuit with a random Pauli on each qubit (compiled into native gates). I.e., if this is True the native gates are Pauli-randomized. When True, this prevents any coherent errors adding (on average) inside the layers of each compiled Clifford, at the cost of increased circuit depth. Defaults to False.

    For more information on these options, see the :func:compile_clifford() docstring.

  • seed (int, optional) – A seed to initialize the random number generator used for creating random clifford circuits.

  • return_native_gate_counts (bool, optional) – Whether to return the number of native gates in the first `length`+1 compiled Cliffords

  • exact_compilation_key (str, optional) – The key into clifford_compilations to use for exact deterministic compilation of Cliffords. The underlying CompilationRules object must provide compilations for all possible n-qubit Cliffords that will be generated. This also requires the pspec is able to generate the symplectic representations for all n-qubit Cliffords in compute_clifford_symplectic_reps(). This is currently generally intended for use out-of-the-box with 1-qubit Clifford RB; however, larger number of qubits can be used so long as the user specifies the processor spec and compilation rules properly.

Returns:

  • full_circuit (Circuit) – A random CRB circuit over the “native” gate-set specified.

  • idealout (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.

  • native_gate_counts (dict) – Total number of native gates, native 2q gates, and native circuit size in the first length`+1 compiled Cliffords. Only returned when `return_num_native_gates is True