pygsti.algorithms.randomcircuit.create_binary_rb_circuit

pygsti.algorithms.randomcircuit.create_binary_rb_circuit#

create_binary_rb_circuit(pspec, clifford_compilations, length, qubit_labels=None, layer_sampling='mixed1q2q', sampler='Qelimination', samplerargs=None, addlocal=False, lsargs=None, seed=None)#

Generates a “binary randomized benchmarking” (BiRB) circuit.

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.

  • clifford_compilations (CompilationRules) – Rules for exactly (absolutely) compiling the “native” gates of pspec into Clifford gates.

  • length (int) – The “benchmark depth” of the circuit, which is the number of randomly sampled layers of gates in the core circuit. The full BiRB circuit has depth=length+2.

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

  • layer_sampling (str, optional) –

    Determines the structure of the randomly sampled layers of gates:

    1. ‘mixed1q2q’: Layers contain radomly-sampled two-qubit gates and randomly-sampled single-qubit gates on all remaining qubits. 2. ‘alternating1q2q’: Each layer consists of radomly-sampled two-qubit gates, with all other qubits idling, followed by randomly sampled single-qubit gates on all qubits.

  • 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 BiRB, 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.

  • seed (int, optional) –

    A seed to initialize the random number generator used for creating random clifford

    circuits.

    addlocalbool, optional

    Whether to follow each layer in the “core” circuits, sampled according to sampler with a layer of 1-qubit gates.

  • lsargs (list, optional) – Only used if addlocal is True. A list of optional arguments handed to the 1Q gate layer sampler circuit_layer_by_oneQgate(). Specifies how to sample 1Q-gate layers.

Returns:

  • Circuit – A random BiRB circuit.

  • String – A length-n string of ‘Z’s and ‘I’s, which describes the target Pauli measurement for the BiRB circuit. The circuit, when run without errors, produces an eigenstate of the target Pauli operator.

  • Int (Either 1 or -1) – Specifies the sign of the target Pauli measurement.