pygsti.algorithms.randomcircuit.sample_circuit_layer_by_q_elimination#
- sample_circuit_layer_by_q_elimination(pspec, qubit_labels=None, two_q_prob=0.5, rand_state=None)#
Samples a random circuit layer by eliminating qubits one by one.
This sampler works with any connectivity, but the expected number of 2-qubit gates in a layer depends on both the specified 2-qubit gate probability and the exact connectivity graph.
This sampler is the following algorithm: List all the qubits, and repeat the following steps until all qubits are deleted from this list. 1) Uniformly at random pick a qubit from the list, and delete it from the list 2) Flip a coin with bias two_q_prob to be “Heads”. 3) If “Heads” then – if there is one or more 2-qubit gates from this qubit to other qubits still in the list – pick one of these at random. 4) If we haven’t chosen a 2-qubit gate for this qubit (“Tails” or “Heads” but there are no possible 2-qubit gates) then pick a uniformly random 1-qubit gate to apply to this qubit.
- 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, optional) – 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 acton all the qubits in pspec.
two_q_prob (float, optional) – If a 2-qubit can is still possible on a qubit at that stage of the sampling, this is the probability a 2-qubit gate is chosen for that qubit. The expected number of 2-qubit gates per layer depend on this quantity and the connectivity graph of the device.
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 in pspec or qubit_labels).
- Return type:
list of gates