Gates

Single Qubit Gates

Contains a variety of single qubit components which act across a pair of adjacent dual-rail encoded modes, assuming 0 is the first mode and 1 is the second mode.

class lightworks.qubit.gates.single_qubit_gates.H

Implements a Hadamard across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.I

Implements the identity gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.P(theta: float | Parameter[float])

Implements a phase gate with phase theta across a pair of modes corresponding to a dual-rail encoded qubit.

Parameters:

theta (float | Parameter) – The phase angle implemented on the qubit.

class lightworks.qubit.gates.single_qubit_gates.Rx(theta: float | Parameter[float])

Implements a Rx gate with angle theta across a pair of modes corresponding to a dual-rail encoded qubit.

Parameters:

theta (float | Parameter) – The rotation angle of the gate.

class lightworks.qubit.gates.single_qubit_gates.Ry(theta: float | Parameter[float])

Implements a Ry gate with angle theta across a pair of modes corresponding to a dual-rail encoded qubit.

Parameters:

theta (float | Parameter) – The rotation angle of the gate.

class lightworks.qubit.gates.single_qubit_gates.Rz(theta: float | Parameter[float])

Implements a Rz gate with angle theta across a pair of modes corresponding to a dual-rail encoded qubit.

Parameters:

theta (float | Parameter) – The rotation angle of the gate.

class lightworks.qubit.gates.single_qubit_gates.S

Implements an S gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.SX

Implements a SX gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.Sadj

Implements the adjoint S gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.T

Implements a T gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.Tadj

Implements the adjoint T gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.X

Implements an X gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.Y

Implements a Y gate across a pair of modes corresponding to a dual-rail encoded qubit.

class lightworks.qubit.gates.single_qubit_gates.Z

Implements a Z gate across a pair of modes corresponding to a dual-rail encoded qubit.

lightworks.qubit.gates.single_qubit_gates.get_name(param: Any) str

Returns the name of the parameter if it has a label, otherwise returns default theta.

Two Qubit Gates

Contains a variety of qubit two components, designed for implementing required qubit processing functionality across pairs of dual-rail encoded qubits in lightworks.

class lightworks.qubit.gates.two_qubit_gates.CNOT(target_qubit: int = 1)

Post-selected CNOT gate that acts across two dual-rail encoded qubits. This gate occupies a total of 6 modes, where modes 0 & 5 are used for 0 photon heralds, modes 1 & 2 correspond to the 0 & 1 states of the first qubit and modes 3 & 4 correspond to the 0 & 1 states of the second qubit. This gate requires additional post-selection in which only one photon should be measured across each of the pairs of modes which encode a qubit.

Parameters:

target_qubit (int, optional) – Sets which of the two qubits is used as the target qubit for the gate. Should be either 0 or 1.

class lightworks.qubit.gates.two_qubit_gates.CNOT_Heralded(target_qubit: int = 1)

Heralded version of the CNOT gate which acts across two dual-rail encoded qubits, using two NS gates with ancillary photons to herald the success of the transformation. This gate occupies 8 modes, where modes 0 & 7 are used as 0 photon heralds, modes 1 & 6 are used as 1 photon heralds, mode 2 & 3 correspond to the 0 & 1 states of the first qubit and modes 4 & 5 correspond to the 0 & 1 states of the second qubit. The heralded gate does not require any post-selection on the output qubits, other than that they are not lost (i.e a total of 4 photons should be measured at the output of the system), allowing it to be cascaded with other two qubit gates.

Parameters:

target_qubit (int, optional) – Sets which of the two qubits is used as the target qubit for the gate. Should be either 0 or 1.

class lightworks.qubit.gates.two_qubit_gates.CZ

Post-selected CZ gate that acts across two dual-rail encoded qubits. This gate occupies a total of 6 modes, where modes 0 & 5 are used for 0 photon heralds, modes 1 & 2 correspond to the 0 & 1 states of the first qubit and modes 3 & 4 correspond to the 0 & 1 states of the second qubit. This gate requires additional post-selection in which only one photon should be measured across each of the pairs of modes which encode a qubit.

class lightworks.qubit.gates.two_qubit_gates.CZ_Heralded

Heralded version of the CZ gate which acts across two dual-rail encoded qubits, using two NS gates with ancillary photons to herald the success of the transformation. This gate occupies 8 modes, where modes 0 & 7 are used as 0 photon heralds, modes 1 & 6 are used as 1 photon heralds, mode 2 & 3 correspond to the 0 & 1 states of the first qubit and modes 4 & 5 correspond to the 0 & 1 states of the second qubit. The heralded gate does not require any post-selection on the output qubits, other than that they are not lost (i.e a total of 4 photons should be measured at the output of the system), allowing it to be cascaded with other two qubit gates.

class lightworks.qubit.gates.two_qubit_gates.SWAP(qubit_1: tuple[int, int], qubit_2: tuple[int, int])

Performs a swap between the modes encoding two qubits. To do this, it needs to be provided with two tuples, each detailing the two modes used to encode the qubit.

Parameters:
  • qubit_1 (tuple) – A tuple detailing the modes used to encode the 0 & 1 modes of the first qubit. Should be of the form (m0, m1).

  • qubit_2 (tuple) – A tuple detailing the modes used to encode the 0 & 1 modes of the second qubit. Should be of the form (m0, m1).

Three Qubit Gates

Contains a variety of three qubit components, designed for implementing required qubit processing functionality in lightworks.

class lightworks.qubit.gates.three_qubit_gates.CCNOT(target_qubit: int = 2)

Post-selected CCNOT (Toffoli) gate which acts across three dual-rail encoded qubits. There is a total of 4 heralded modes also included, each requiring 0 photons on the input and output. For correct functioning of this gate it must be post-selected on the condition that only one photon is measured across the two modes used to encode each of the qubits.

Parameters:

target_qubit (int, optional) – Sets which of the three qubits is used as the target qubit for the gate. Should be either 0, 1 or 2.

class lightworks.qubit.gates.three_qubit_gates.CCZ

Post-selected CCZ gate which acts across three dual-rail encoded qubits. There is a total of 4 heralded modes also included, each requiring 0 photons on the input and output. For correct functioning of this gate it must be post-selected on the condition that only one photon is measured across the two modes used to encode each of the qubits.