We're celebrating World Quantum Day 2022! Join us


Generate a random two-qubit quantum circuit.

Used in the notebooks

Used in the tutorials

This construction uses a similar structure to those in the paper https://www.nature.com/articles/s41586-019-1666-5

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, controlled by their respective arguments, see below.

q0 The first qubit
q1 The second qubit
depth The number of cycles.
two_qubit_op_factory A callable that returns a two-qubit operation. These operations will be generated with calls of the form two_qubit_op_factory(q0, q1, prng), where prng is the pseudorandom number generator.
single_qubit_gates Single-qubit gates are selected randomly from this sequence. No qubit is acted upon by the same single-qubit gate in consecutive cycles. If only one choice of single-qubit gate is given, then this constraint is not enforced.
add_final_single_qubit_layer Whether to include a final layer of single-qubit gates after the last cycle (subject to the same non-consecutivity constraint).
seed A seed or random state to use for the pseudorandom number generator.