CP gate
The controlled-phase gate: matrix, effect on the basis states, the cp() call in Python and JS, and what it becomes on IonQ hardware.
The CP gate multiplies the amplitude by and leaves the other three basis states alone. It acts on two qubits and takes one parameter, the angle in radians. Control and target are interchangeable. The Circuit panel draws a dot on the control wire joined to a P(λ) box on the target wire, with the angle shown as a multiple of π. On its own it changes nothing a measurement can see, whatever the angle; the phase 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.cp(λ, control, target) |
| JS | circuit.cp(λ, control, target) |
| Qiskit class | CPhaseGate |
| More controls | mcp(λ, [controls], target) |
Matrix
The matrix uses the basis order .
cp(π) is a CZ gate. CP is the controlled form of the P gate.
Effect on basis states
| Input | Output |
|---|---|
A measurement straight after CP shows no change on any basis state, whatever the angle. The phase shows once the qubits are in superposition, which is what the quantum Fourier transform and phase-estimation circuits rely on.
Inverse
The inverse of cp(λ) is cp(-λ).
Usage
from math import pi
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.h(1)
qc.cp(pi, 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.cp(Math.PI, 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: at the CP is a CZ, and H, CZ, H on the target is a CX.
On IonQ hardware
CP is not a native gate, but it maps onto one entangling gate for any angle. Up to a global phase, cp(λ) is an rzz(-λ/2) with an rz(λ/2) on each qubit, and the rz rotations are virtual, so on Forte it is a single arbitrary-angle ZZ gate with no single-qubit pulses; on Aria it is one partially entangling MS gate with single-qubit pulses around it. 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