Skip to main content
Multi-qubit gates act on two or more wires simultaneously. All wires passed to a multi-qubit gate must be distinct — passing the same wire twice raises DSLValidationError. Like single-qubit gates, multi-qubit gates route automatically to the exact or broad IR path depending on which decorator wraps the calling function. Parametric two-qubit gates (cry, crz) are only available in @parametric and @adaptive programs.

Gate overview


cx

Controlled-NOT (CNOT) gate. Flips the target qubit when the control qubit is |1⟩. cx is self-inverse. Allowed in: exact programs, compute blocks.
control
Wire
required
The control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from control.

cz

Controlled-Z gate. Applies a Z gate to the target when the control is |1⟩. Equivalent to applying Z then CX, or H · CX · H on the target. cz is self-inverse and symmetric: cz(a, b) == cz(b, a). Allowed in: exact programs, phase blocks.
control
Wire
required
The control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from control.

swap

SWAP gate. Exchanges the states of two qubits. swap is self-inverse. Allowed in: exact programs, compute blocks.
a
Wire
required
The first qubit wire.
b
Wire
required
The second qubit wire. Must be distinct from a.

cry

Controlled-RY gate. Applies ry(theta) to the target when the control is |1⟩. Parametric — not in the exact gate set. Allowed in: @parametric and @adaptive programs only.
theta
float
required
Rotation angle in radians.
control
Wire
required
The control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from control.

crz

Controlled-RZ gate. Applies rz(theta) to the target when the control is |1⟩. Parametric — not in the exact gate set. Allowed in: @parametric and @adaptive programs only.
theta
float
required
Rotation angle in radians.
control
Wire
required
The control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from control.

ccx

Toffoli gate (CCX). Flips the target qubit when both c0 and c1 are |1⟩. ccx is self-inverse and is the canonical three-qubit gate for reversible classical computation. Allowed in: exact programs, compute blocks.
c0
Wire
required
The first control qubit wire.
c1
Wire
required
The second control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from c0 and c1.

ccz

Controlled-Controlled-Z gate. Applies Z to the target when both controls are |1⟩. ccz is self-inverse and a diagonal gate. Allowed in: exact programs, phase blocks.
c0
Wire
required
The first control qubit wire.
c1
Wire
required
The second control qubit wire.
target
Wire
required
The target qubit wire. Must be distinct from both controls.

mcx

Multi-controlled X gate. Flips the target qubit when all control qubits are |1⟩. Requires at least one control wire. mcx generalises cx (one control) and ccx (two controls) to any number of controls. Allowed in: exact programs, compute blocks.
controls
Sequence[Wire]
required
A sequence of one or more control qubit wires. All wires must be distinct from each other and from target.
target
Wire
required
The target qubit wire.

mcz

Multi-controlled Z gate. Applies Z to the target when all control qubits are |1⟩. Requires at least one control wire. mcz is a diagonal gate. Allowed in: exact programs, phase blocks.
controls
Sequence[Wire]
required
A sequence of one or more control qubit wires. All wires must be distinct from each other and from target.
target
Wire
required
The target qubit wire.