Quantum Circuits (qiskit.circuit
)¶
Overview¶
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 realtime 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 neartime computation.
In Qiskit, this core element is represented by the QuantumCircuit
class.
Below is an example of a quantum circuit that makes a threequbit GHZ state
defined as:
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>.
circ.h(0)
# A CX (CNOT) gate on control qubit 0 and target qubit 1 generating a Bell state.
circ.cx(0, 1)
# CX (CNOT) gate on control qubit 0 and target qubit 2 resulting in a GHZ state.
circ.cx(0, 2)
# Draw the circuit
circ.draw('mpl')
(Source code, png, hires.png, pdf)
Supplementary Information¶
Quantum Circuit API¶
Quantum Circuit Construction¶

Create a new circuit. 

Implement a quantum register. 

Implement a quantum bit. 

Implement a classical register. 

Implement a classical bit. 

Implement an ancilla register. 

A qubit used as ancillary qubit. 

A single instruction in a 
Gates and Instructions¶

Unitary gate. 

Controlled unitary gate. 

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

Generic quantum instruction. 

Instruction collection, and their contexts. 
Quantum Operation Interface Class. 


A library providing a oneway mapping of Gates to their equivalent implementations as QuantumCircuits. 
Control Flow Operations¶

Abstract class to encapsulate all control flow operations. 

A circuit operation which executes a program ( 

A circuit operation which repeatedly executes a subcircuit ( 

A circuit operation which repeatedly executes a subcircuit ( 

A circuit operation which, when encountered, jumps to the end of the nearest enclosing loop. 

A circuit operation which, when encountered, moves to the next iteration of the nearest enclosing loop. 
Parametric Quantum Circuits¶

Parameter Class for variable parameters. 

ParameterVector class to quickly generate lists of parameters. 

ParameterExpression class to enable creating expressions of Parameters. 
Random Circuits¶

Generate random circuit of arbitrary size and form. 