Quantum Circuits (qiskit.circuit)


The fundamental element of quantum computing is the quantum circuit. A quantum circuit is a computational routine consisting of coherent quantum operations on quantum data, such as qubits. It is an ordered sequence of quantum gates, measurements and resets, which may be conditioned on real-time classical computation. A set of quantum gates is said to be universal if any unitary transformation of the quantum data can be efficiently approximated arbitrarily well as as sequence of gates in the set. Any quantum program can be represented by a sequence of quantum circuits and classical near-time computation.

In Qiskit, this core element is represented by the QuantumCircuit class. Below is an example of a quantum circuit that makes a three-qubit GHZ state defined as:

\[|\psi\rangle = \left(|000\rangle+|111\rangle\right)/\sqrt{2}\]
from qiskit import QuantumCircuit
# Create a circuit with a register of three qubits
circ = QuantumCircuit(3)
# H gate on qubit 0, putting this qubit in a superposition of |0> + |1>.
# A CX (CNOT) gate on control qubit 0 and target qubit 1 generating a Bell state., 1)
# CX (CNOT) gate on control qubit 0 and target qubit 2 resulting in a GHZ state., 2)
# Draw the circuit
q_0: ┤ H ├──■────■──
     └───┘┌─┴─┐  │  
q_1: ─────┤ X ├──┼──
q_2: ──────────┤ X ├

Supplementary Information

Quantum Circuit API

Quantum Circuit Construction

QuantumCircuit(*regs[, name, global_phase])

Create a new circuit.

QuantumRegister(size[, name])

Implement a quantum register.

Qubit(register, index)

Implement a quantum bit.

ClassicalRegister(size[, name])

Implement a classical register.

Clbit(register, index)

Implement a classical bit.

AncillaRegister(size[, name])

Implement an ancilla register.

AncillaQubit(register, index)

A qubit used as ancillary qubit.

Gates and Instructions

Gate(name, num_qubits, params[, label])

Unitary gate.

ControlledGate(name, num_qubits, params[, …])

Controlled unitary gate.

Delay(duration[, unit])

Do nothing and just delay/wait/idle for a specified duration.


Quantum measurement in the computational basis.


Qubit reset.

Instruction(name, num_qubits, num_clbits, params)

Generic quantum instruction.


Instruction collection, and their contexts.

EquivalenceLibrary(*[, base])

A library providing a one-way mapping of Gates to their equivalent implementations as QuantumCircuits.

Parametric Quantum Circuits


Parameter Class for variable parameters.

ParameterVector(name[, length])

ParameterVector class to quickly generate lists of parameters.

ParameterExpression(symbol_map, expr)

ParameterExpression class to enable creating expressions of Parameters.

Random Circuits

random.random_circuit(num_qubits, depth[, …])

Generate random circuit of arbitrary size and form.

Zu sehen ist lang: German