CZ gate
The controlled-Z gate: matrix, effect on the basis states, the cz() call in Python and JS, and what it becomes on IonQ hardware.
The CZ gate flips the sign of the amplitude and leaves the other three basis states alone. It acts on two qubits and takes no parameters. Control and target are interchangeable: cz(0, 1) and cz(1, 0) are the same gate. The Circuit panel draws a dot on the control wire joined to a Z box on the target wire. On its own it changes nothing a measurement can see; the sign shows once the qubits are in superposition.
Kets such as name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.
Call
| Where | Call |
|---|---|
| Python | qc.cz(control, target) |
| JS | circuit.cz(control, target) |
| Qiskit class | CZGate |
Matrix
The matrix uses the basis order .
The matrix is diagonal and symmetric in the two qubits, which is why the roles of control and target do not matter. CZ is the special case cp(π) of the CP gate.
Effect on basis states
| Input | Output |
|---|---|
A measurement straight after CZ shows no change on any basis state. The sign flip shows once the qubits are in superposition: an H gate on the target before and after a CZ turns it into a CX.
Inverse
CZ is its own inverse. Two CZ gates in a row on the same pair cancel.
Usage
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.h(1)
qc.cz(0, 1)
qc.h(1)
qc.measure([0, 1], [0, 1])
import { QuantumCircuit } from 'qiskit';
const circuit = QuantumCircuit(2, 2);
circuit.h(0);
circuit.h(1);
circuit.cz(0, 1);
circuit.h(1);
circuit.measure([0, 1], [0, 1]);
On a noiseless simulator every shot reads 00 or 11, in close to equal numbers: the H, CZ, H on the target is a CX, so this is the Bell pair.
On IonQ hardware
CZ is not a native gate, but it is close to one. On Forte it is a single ZZ gate with virtual Z rotations on both qubits, up to a global phase, and no single-qubit pulses at all; on Aria it is one MS gate with single-qubit pulses around it. Either way it is one entangling gate before IonQ's optimiser runs. See How your circuit is compiled.
Related
Stay in the loop.
Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.
Gates