The CNOT gate is two-qubit operation, where the first qubit is usually referred to as the control qubit and the second qubit as the target qubit. Expressed in basis states, the CNOT gate:
- leaves the control qubit unchanged and performs a Pauli-X gate on the target qubit when the control qubit is in state ;
- leaves the target qubit unchanged when the control qubit is in state .
version 1.0 qubits 2 H q # execute Hadamard gate on qubit 0 to create a superposition state CNOT q, q # entangle both qubits using CNOT gate
Note: For multi-qubit gates, it must always be checked whether the topology (connectivity) allows for a direct implementation of the operation. A compilation step may be required in order to map an operation.
As an example, on the Starmon-5 backend
q are not connected. An operation such as
cnot q,q should therefore be rewritten as
cnot q,q or compiled by inserting swap gates, when the intended operation is indeed a a cnot between