Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version


random_circuit(num_qubits, depth, max_operands=4, measure=False, conditional=False, reset=False, seed=None)

GitHub(opens in a new tab)

Generate random circuit of arbitrary size and form.

This function will generate a random circuit by randomly selecting gates from the set of standard gates in qiskit.extensions. For example:

from qiskit.circuit.random import random_circuit
circ = random_circuit(2, 2, measure=True)

(Source code, png, hires.png, pdf)



  • num_qubits (int) – number of quantum wires
  • depth (int) – layers of operations (i.e. critical path length)
  • max_operands (int) – maximum qubit operands of each gate (between 1 and 4)
  • measure (bool) – if True, measure all qubits at the end
  • conditional (bool) – if True, insert middle measurements and conditionals
  • reset (bool) – if True, insert middle resets
  • seed (int) – sets random seed (optional)


constructed circuit

Return type



CircuitError – when invalid options given

Was this page helpful?
Report a bug or request content on GitHub.