# qml¶

This is the top level module from which all basic functions and classes of PennyLane can be directly imported.

## Functions¶

 about() Prints the information for pennylane installation. device(name[, wires]) Load a plugin Device and return the instance. expval(op) Expectation value of the supplied observable. from_qasm(quantum_circuit) Loads quantum circuits from a QASM string using the converter in the PennyLane-Qiskit plugin. from_qasm_file(qasm_filename) Loads quantum circuits from a QASM file using the converter in the PennyLane-Qiskit plugin. from_qiskit(quantum_circuit) Loads Qiskit QuantumCircuit objects by using the converter in the PennyLane-Qiskit plugin. grad(func, argnum) Returns the gradient as a callable function of (functions of) QNodes. jacobian(func, argnum) Returns the Jacobian as a callable function of vector-valued (functions of) QNodes. load(quantum_circuit_object, format) Load external quantum assembly and quantum circuits from supported frameworks into PennyLane templates. qnode(device[, interface, cache]) QNode decorator. sample(op) Sample from the supplied observable, with the number of shots determined from the dev.shots attribute of the corresponding device. var(op) Variance of the supplied observable. version() Returns the PennyLane version number.

## Classes¶

 AdagradOptimizer([stepsize, eps]) Gradient-descent optimizer with past-gradient-dependent learning rate in each dimension. AdamOptimizer([stepsize, beta1, beta2, eps]) Gradient-descent optimizer with adaptive learning rate, first and second moment. BasisState(n, wires) Prepares a single computational basis state. Beamsplitter(theta, phi, wires) Beamsplitter interaction. CNOT(wires) The controlled-NOT operator CRX(phi, wires) The controlled-RX operator CRY(phi, wires) The controlled-RY operator CRZ(phi, wires) The controlled-RZ operator CRot(phi, theta, omega, wires) The controlled-Rot operator CSWAP(wires) The controlled-swap operator CZ(wires) The controlled-Z operator CatState(a, phi, p, wires) Prepares a cat state. CircuitGraph(ops, variable_deps) Represents a quantum circuit as a directed acyclic graph. CoherentState(a, phi, wires) Prepares a coherent state. Configuration(name) Configuration class. ControlledAddition(s, wires) Controlled addition operation. ControlledPhase(s, wires) Controlled phase operation. CrossKerr(kappa, wires) Cross-Kerr interaction. CubicPhase(gamma, wires) Cubic phase shift. Device([wires, shots]) Abstract base class for PennyLane devices. DeviceError Exception raised by a Device when it encounters an illegal operation in the quantum circuit. DisplacedSqueezedState(a, phi_a, r, phi_r, wires) Prepares a displaced squeezed vacuum state. Displacement(a, phi, wires) Phase space displacement. FockDensityMatrix(state, wires) Prepare subsystems using the given density matrix in the Fock basis. FockState(n, wires) Prepares a single Fock state. FockStateProjector(n, wires) The number state observable $$\ket{n}\bra{n}$$. FockStateVector(state, wires) Prepare subsystems using the given ket vector in the Fock basis. GaussianState(r, V, wires) Prepare subsystems in a given Gaussian state. GradientDescentOptimizer([stepsize]) Basic gradient-descent optimizer. Hadamard(wires) The Hadamard operator Hermitian(A, wires) An arbitrary Hermitian observable. Identity(wires) The identity observable $$\I$$. Interferometer(U, wires) A linear interferometer transforming the bosonic operators according to the unitary matrix $$U$$. Kerr(kappa, wires) Kerr interaction. MomentumOptimizer([stepsize, momentum]) Gradient-descent optimizer with momentum. NesterovMomentumOptimizer([stepsize, momentum]) Gradient-descent optimizer with Nesterov momentum. NumberOperator(wires) The photon number observable $$\langle \hat{n}\rangle$$. P(wires) The momentum quadrature observable $$\hat{p}$$. PauliX(wires) The Pauli X operator PauliY(wires) The Pauli Y operator PauliZ(wires) The Pauli Z operator PhaseShift(phi, wires) Arbitrary single qubit local phase shift PolyXP(q, wires) An arbitrary second-order polynomial observable. QNGOptimizer([stepsize, diag_approx, lam]) Optimizer with adaptive learning rate, via calculation of the diagonal or block-diagonal approximation to the Fubini-Study metric tensor. QNode(func, device[, cache]) Quantum node in the hybrid computational graph. QuadOperator(phi, wires) The generalized quadrature observable $$\x_\phi = \x cos\phi+\p\sin\phi$$. QuadraticPhase(s, wires) Quadratic phase shift. QuantumFunctionError Exception raised when an illegal operation is defined in a quantum function. QubitStateVector(state, wires) Prepare subsystems using the given ket vector in the computational basis. QubitUnitary(U, wires) Apply an arbitrary fixed unitary matrix. RMSPropOptimizer([stepsize, decay, eps]) Root mean squared propagation optimizer. RX(phi, wires) The single qubit X rotation RY(phi, wires) The single qubit Y rotation RZ(phi, wires) The single qubit Z rotation Rot(phi, theta, omega, wires) Arbitrary single qubit rotation Rotation(phi, wires) Phase space rotation. S(wires) The single-qubit phase gate SWAP(wires) The swap operator SqueezedState(r, phi, wires) Prepares a squeezed vacuum state. Squeezing(r, phi, wires) Phase space squeezing. T(wires) The single-qubit T gate ThermalState(nbar, wires) Prepares a thermal state. Toffoli(wires) Toffoli (controlled-controlled-X) gate. TwoModeSqueezing(r, phi, wires) Phase space two-mode squeezing. U1(phi) U1 gate. U2(phi, lambda, wires) U2 gate. U3(theta, phi, lambda, wires) Arbitrary single qubit unitary. X(wires) The position quadrature observable $$\hat{x}$$.