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 single-qubit phase gate The single-qubit T gate The single-qubit Square-Root 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 controlled-NOT operator The controlled-Z operator The controlled-Y operator The swap operator U1 gate. U2 gate. Arbitrary single qubit unitary. The controlled-Rot operator The controlled-RX operator The controlled-RY operator The controlled-RZ operator Toffoli (controlled-controlled-X) gate. The controlled-swap 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¶
Single-qubit amplitude damping error channel. Single-qubit generalized amplitude damping error channel. Single-qubit phase damping error channel. Single-qubit symmetrically depolarizing error channel. Single-qubit bit flip (Pauli \(X\)) error channel. Single-qubit 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, post-measurement 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 post-measurement 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.
Continuous-variable (CV) operations¶
CV Gates¶
Beamsplitter interaction. Controlled addition operation. Controlled phase operation. Cross-Kerr 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 two-mode 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 second-order polynomial observable. The generalized quadrature observable \(\x_\phi = \x cos\phi+\p\sin\phi\). The position quadrature observable \(\hat{x}\).
NumberOperator
acting on different wires.
Contents
Downloads