pygsti.algorithms.randomcircuit.sample_circuit_layer_by_co2_q_gates

pygsti.algorithms.randomcircuit.sample_circuit_layer_by_co2_q_gates#

sample_circuit_layer_by_co2_q_gates(pspec, qubit_labels, co2_q_gates, co2_q_gates_prob='uniform', two_q_prob=1.0, one_q_gate_names='all', rand_state=None)#

Samples a random circuit layer using the specified list of “compatible two-qubit gates” (co2_q_gates).

That is, the user inputs a list (co2_q_gates) specifying 2-qubit gates that are “compatible” – meaning that they can be implemented simultaneously – and a distribution over the different compatible sets, and a layer is sampled from this via:

1. Pick a set of compatible two-qubit gates from the list co2_q_gates, according to the distribution specified by co2_q_gates_prob. 2. For each 2-qubit gate in the chosen set of compatible gates, with probability two_q_prob add this gate to the layer. 3. Uniformly sample 1-qubit gates for any qubits that don’t yet have a gate on them, from those 1-qubit gates specified by one_q_gate_names.

For example, consider 4 qubits with linear connectivity. a valid co2_q_gates list is co2_q_gates = [[,],[Label(Gcphase,(0,1)),Label(Gcphase,(2,3))]] which consists of an element containing zero 2-qubit gates and an element containing two 2-qubit gates that can be applied in parallel. In this example there are 5 possible sets of compatible 2-qubit gates:

  1. [,] (zero 2-qubit gates)

  2. [Label(Gcphase,(0,1)),] (one of the three 2-qubit gate)

  3. [Label(Gcphase,(1,2)),] (one of the three 2-qubit gate)

  4. [Label(Gcphase,(2,3)),] (one of the three 2-qubit gate)

  5. [Label(Gcphase,(0,1)), Label(Gcphase,(2,3)),] (the only compatible pair of 2-qubit gates).

The list of compatible two-qubit gates co2_q_gates can be any list containing anywhere from 1 to all 5 of these lists.

In order to allow for convenient sampling of some commonly useful distributions, co2_q_gates can be a list of lists of lists of compatible 2-qubit gates (“nested” sampling). In this case, a list of lists of compatible 2-qubit gates is picked according to the distribution co2_q_gates_prob, and then one of the sublists of compatible 2-qubit gates in the selected list is then chosen uniformly at random. For example, this is useful for sampling a layer containing one uniformly random 2-qubit gate with probability p and a layer of 1-qubit gates with probability 1-p. Here, we can specify co2_q_gates as [[],[[the 1st 2Q-gate,],[the 2nd 2Q-gate,], …]] and set two_q_prob=1 and co2_q_gates_prob = [1-p,p].

Parameters:
  • pspec (QubitProcessorSpec) – The QubitProcessorSpec for the device that the circuit layer is being sampled for. Unless qubit_labels is not None, a circuit layer is sampled over all the qubits in pspec.

  • qubit_labels (list) – If not None, a list of the qubits to sample the circuit layer for. This is a subset of pspec.qubit_labels. If None, the circuit layer is sampled to act on all the qubits in pspec.

  • co2_q_gates (list) –

    This is either:

    1. A list of lists of 2-qubit gate Labels that can be applied in parallel.

    2. A list of lists of lists of 2-qubit gate Labels that can be applied in parallel.

    In case (1) each list in co2_q_gates should contain 2-qubit gates, in the form of Labels, that can be applied in parallel and act only on the qubits in pspec if qubit_labels is None, or act only on the qubits in qubit_labels if qubit_labels is not None. The sampler then picks one of these compatible sets of gates (with probability specified by co2_q_gates_prob, and converts this into a circuit layer by applying the 2-qubit gates it contains with the user-specified probability two_q_prob, and augmenting these 2-qubit gates with 1-qubit gates on all other qubits.

    In case (2) a sublist of lists is sampled from co2_q_gates according to co2_q_gates_prob and then we proceed as in case (1) but as though co2_q_gates_prob is the uniform distribution.

  • co2_q_gates_prob (str or list of floats) – If a list, they are unnormalized probabilities to sample each of the elements of co2_q_gates. So it is a list of non-negative floats of the same length as co2_q_gates. If ‘uniform’, then the uniform distribution is used.

  • two_q_prob (float, optional) – The probability for each two-qubit gate to be applied to a pair of qubits, after a set of compatible 2-qubit gates has been chosen. The expected number of 2-qubit gates in a layer is two_q_prob times the expected number of 2-qubit gates in a set of compatible 2-qubit gates sampled according to co2_q_gates_prob.

  • one_q_gate_names ('all' or list of strs, optional) – If not ‘all’, a list of the names of the 1-qubit gates to be sampled from when applying a 1-qubit gate to a qubit. If this is ‘all’, the full set of 1-qubit gate names is extracted from the QubitProcessorSpec.

  • rand_state (RandomState, optional) – A np.random.RandomState object for seeding RNG

Returns:

A list of gate Labels that defines a “complete” circuit layer (there is one and only one gate acting on each qubit).

Return type:

list of gates