Quantum operations¶
PennyLane supports a wide variety of quantum operations—such as gates, noisy channels, state preparations and measurements. These operations can be used exclusively in quantum functions, like shown in the following example:
import pennylane as qml
def my_quantum_function(x, y):
qml.RZ(x, wires=0)
qml.CNOT(wires=[0,1])
qml.RY(y, wires=1)
qml.T(wires=0).inv()
qml.AmplitudeDamping(0.1, wires=0)
return qml.expval(qml.PauliZ(1))
This quantum function uses the RZ
,
CNOT
,
RY
gates, the
AmplitudeDamping
noisy channel as well as the
PauliZ
observable.
Note that PennyLane supports inverting quantum operations via the
Op(param, wires).inv()
method. Additionally, PennyLane
provides a function qml.inv
that can be used to invert sequences
of operations and Templates.
Below is a list of all quantum operations supported by PennyLane.
Qubit operations¶
Qubit gates¶
The Hadamard operator 

The Pauli X operator 

The Pauli Y operator 

The Pauli Z operator 

The singlequbit phase gate 

The singlequbit T gate 

The singlequbit SquareRoot X operator. 

Arbitrary single qubit rotation 

The single qubit X rotation 

The single qubit Y rotation 

The single qubit Z rotation 

Arbitrary multi Z rotation. 

Arbitrary Pauli word rotation. 

Arbitrary single qubit local phase shift 

The controlledNOT operator 

The controlledZ operator 

The controlledY operator 

The swap operator 

U1 gate. 

U2 gate. 

Arbitrary single qubit unitary. 

The controlledRot operator 

The controlledRX operator 

The controlledRY operator 

The controlledRZ operator 

Toffoli (controlledcontrolledX) gate. 

The controlledswap operator 

Apply an arbitrary fixed unitary matrix. 

Apply an arbitrary fixed diagonal unitary matrix. 
Qubit state preparation¶
Prepares a single computational basis state. 

Prepare subsystems using the given ket vector in the computational basis. 
Noisy channels¶
Singlequbit amplitude damping error channel. 

Singlequbit generalized amplitude damping error channel. 

Singlequbit phase damping error channel. 

Singlequbit symmetrically depolarizing error channel. 

Singlequbit bit flip (Pauli \(X\)) error channel. 

Singlequbit bit flip (Pauli \(Z\)) error channel. 

Apply an arbitrary fixed quantum channel. 
Qubit observables¶
Grouping Pauli words¶
Grouping Pauli words can be used for the optimizing the measurement of qubit
Hamiltonians. Along with groups of observables, postmeasurement rotations can
also be obtained using optimize_measurements()
:
>>> obs = [qml.PauliY(0), qml.PauliX(0) @ qml.PauliX(1), qml.PauliZ(1)]
>>> coeffs = [1.43, 4.21, 0.97]
>>> post_rotations, diagonalized_groupings, grouped_coeffs = optimize_measurements(obs, coeffs)
>>> post_rotations
[[RY(1.5707963267948966, wires=[0]), RY(1.5707963267948966, wires=[1])],
[RX(1.5707963267948966, wires=[0])]]
The postmeasurement rotations can be used to diagonalize the partitions of observables found.
For further details on measurement optimization, grouping observables through solving the minimum clique cover problem, and auxiliary functions, refer to the qml.grouping subpackage.
Continuousvariable (CV) operations¶
CV Gates¶
Beamsplitter interaction. 

Controlled addition operation. 

Controlled phase operation. 

CrossKerr interaction. 

Cubic phase shift. 

Phase space displacement. 

A linear interferometer transforming the bosonic operators according to the unitary matrix \(U\). 

Kerr interaction. 

Quadratic phase shift. 

Phase space rotation. 

Phase space squeezing. 

Phase space twomode squeezing. 
CV state preparation¶
Prepares a cat state. 

Prepares a coherent state. 

Prepares a displaced squeezed vacuum state. 

Prepare subsystems using the given density matrix in the Fock basis. 

Prepares a single Fock state. 

Prepare subsystems using the given ket vector in the Fock basis. 

Prepare subsystems in a given Gaussian state. 

Prepares a squeezed vacuum state. 

Prepares a thermal state. 
CV observables¶
The number state observable \(\ket{n}\bra{n}\). 

The photon number observable \(\langle \hat{n}\rangle\). 

The tensor product of the 

The momentum quadrature observable \(\hat{p}\). 

An arbitrary secondorder polynomial observable. 

The generalized quadrature observable \(\x_\phi = \x cos\phi+\p\sin\phi\). 

The position quadrature observable \(\hat{x}\). 
Contents
Downloads