Generate a random quantum circuit.

Used in the notebooks

Used in the tutorials

This construction is based on the circuits used in the paper

The generated circuit consists of a number of "cycles", this number being specified by depth. Each cycle is actually composed of two sub-layers: a layer of single-qubit gates followed by a layer of two-qubit gates. The single-qubit gates are chosen randomly from the gates specified by single_qubit_gates, but with the constraint that no qubit is acted upon by the same single-qubit gate in consecutive cycles. In the layer of two-qubit gates, which pairs of qubits undergo interaction is determined by pattern, which is a sequence of two-qubit interaction sets. The set of interactions in a two-qubit layer rotates through this sequence. The two-qubit operations themselves are generated by the call two_qubit_op_factory(a, b, prng), where a and b are the qubits and prng is the pseudorandom number generator.

At the end of the circuit, an additional layer of single-qubit gates is appended, subject to the same constraint regarding consecutive cycles described above.

If only one choice of single-qubit gate is given, then the constraint that excludes repeating single-qubit gates in consecutive cycles is not enforced.

qubits The qubits to use.
depth The number of cycles.
two_qubit_op_factory A factory to generate two-qubit operations. These operations will be generated with calls of the form two_qubit_op_factory(a, b, prng), where a and b are the qubits to operate on and prng is the pseudorandom number generator.
pattern The pattern of grid interaction layers to use.
single_qubit_gates The single-qubit gates to use.
add_final_single_qubit_layer Whether to include a final layer of single-qubit gates after the last cycle.
seed A seed or random state to use for the pseudorandom number generator.