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.

adjoint(fn)

Create a function that applies the adjoint (inverse) of the provided operation or template.

apply(op[, context])

Apply an instantiated operator or measurement to a queuing context.

apply_controlled_Q(fn, wires, target_wire, …)

Provides the circuit to apply a controlled version of the \(\mathcal{Q}\) unitary defined in this paper.

broadcast(unitary, wires, pattern[, …])

Applies a unitary multiple times to a specific pattern of wires.

compile

Compile a circuit by applying a series of transforms to a quantum function.

ctrl(fn, control)

Create a method that applies a controlled version of the provided method.

density_matrix(wires)

Quantum density matrix in the computational basis.

device(name[, wires])

Load a Device and return the instance.

dot(x, y)

Lazily perform the dot product between arrays, tensors, and QNodeCollection.

draw(qnode[, charset, wire_order, …])

Create a function that draws the given qnode.

execute(tapes, device, gradient_fn[, …])

Execute a batch of tapes on a device in an autodifferentiable-compatible manner.

expval(op)

Expectation value of the supplied observable.

finite_diff(f[, N, argnum, idx, delta])

Returns a function that can be evaluated to compute the gradient or the second-order derivative of the callable function f using a centered finite difference approximation.

from_pyquil(pyquil_program)

Loads pyQuil Program objects by using the converter in the PennyLane-Forest plugin.

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.

from_quil(quil)

Loads quantum circuits from a Quil string using the converter in the PennyLane-Forest plugin.

from_quil_file(quil_filename)

Loads quantum circuits from a Quil file using the converter in the PennyLane-Forest plugin.

inv(operation_list)

Invert a list of operations or a template.

jacobian(func[, argnum])

Returns the Jacobian as a callable function of vector-valued (functions of) QNodes.

layer(template, depth, *args, **kwargs)

Repeatedly applies a unitary a given number of times.

load(quantum_circuit_object, format)

Load external quantum assembly and quantum circuits from supported frameworks into PennyLane templates.

map(template, observables, device[, …])

Map a quantum template over a list of observables to create a QNodeCollection.

measurement_grouping(tape, obs_list, coeffs_list)

Returns a list of measurement optimized tapes, and a classical processing function, for evaluating the expectation value of a provided Hamiltonian.

probs(wires)

Probability of each computational basis state.

qfunc_transform(tape_transform)

Given a function which defines a tape transform, convert the function into one that applies the tape transform to quantum functions (qfuncs).

qnode(device[, interface, diff_method, …])

Decorator for creating QNodes.

quantum_monte_carlo(fn, wires, target_wire, …)

Provides the circuit to perform the quantum Monte Carlo estimation algorithm.

refresh_devices()

Scan installed PennyLane plugins to refresh the device list.

sample([op, wires])

Sample from the supplied observable, with the number of shots determined from the dev.shots attribute of the corresponding device.

specs(qnode[, max_expansion])

Resource information about a quantum circuit.

state()

Quantum state in the computational basis.

sum(x)

Lazily sum the constituent QNodes of a QNodeCollection.

template(func)

Register a quantum template with PennyLane.

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.

AmplitudeDamping(gamma, wires)

Single-qubit amplitude damping error channel.

BasisState(n, wires)

Prepares a single computational basis state.

Beamsplitter(theta, phi, wires)

Beamsplitter interaction.

BitFlip(p, wires)

Single-qubit bit flip (Pauli \(X\)) error channel.

CNOT(wires)

The controlled-NOT operator

CPhase

alias of pennylane.ops.qubit.parametric_ops.ControlledPhaseShift

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

CY(wires)

The controlled-Y operator

CZ(wires)

The controlled-Z operator

CatState(a, phi, p, wires)

Prepares a cat state.

CircuitGraph(ops, obs, wires[, par_info, …])

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.

ControlledOperation(tape, control_wires[, …])

A Controlled Operation.

ControlledPhase(s, wires)

Controlled phase operation.

ControlledPhaseShift(phi, wires)

A qubit controlled phase shift.

ControlledQubitUnitary(U, control_wires, …)

Apply an arbitrary fixed unitary to wires with control from the control_wires.

CrossKerr(kappa, wires)

Cross-Kerr interaction.

CubicPhase(gamma, wires)

Cubic phase shift.

DepolarizingChannel(p, wires)

Single-qubit symmetrically depolarizing error channel.

Device([wires, shots, analytic])

Abstract base class for PennyLane devices.

DeviceError

Exception raised by a Device when it encounters an illegal operation in the quantum circuit.

DiagonalQubitUnitary(D, wires)

Apply an arbitrary fixed diagonal unitary matrix.

DisplacedSqueezedState(a, phi_a, r, phi_r, wires)

Prepares a displaced squeezed vacuum state.

Displacement(a, phi, wires)

Phase space displacement.

DoubleExcitation(phi, wires)

Double excitation rotation.

DoubleExcitationMinus(phi, wires)

Double excitation rotation with negative phase-shift outside the rotation subspace.

DoubleExcitationPlus(phi, wires)

Double excitation rotation with positive phase-shift outside the rotation subspace.

ExpvalCost(ansatz, hamiltonian, device[, …])

Create a cost function that gives the expectation value of an input Hamiltonian.

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(V, r, wires)

Prepare subsystems in a given Gaussian state.

GeneralizedAmplitudeDamping(gamma, p, wires)

Single-qubit generalized amplitude damping error channel.

GradientDescentOptimizer([stepsize])

Basic gradient-descent optimizer.

Hadamard(wires)

The Hadamard operator

Hamiltonian(coeffs, observables[, simplify, …])

Operator representing a Hamiltonian.

Hermitian(A, wires)

An arbitrary Hermitian observable.

ISWAP(wires)

The i-swap operator

Identity(wires)

The identity observable \(\I\).

Interferometer(U, wires)

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

IsingXX(phi, wires)

Ising XX coupling gate

IsingYY(phi, wires)

Ising YY coupling gate

IsingZZ(phi, wires)

Ising ZZ coupling gate

Kerr(kappa, wires)

Kerr interaction.

MomentumOptimizer([stepsize, momentum])

Gradient-descent optimizer with momentum.

MultiControlledX(control_wires, wires, …)

Apply a Pauli X gate controlled on an arbitrary computational basis state.

MultiRZ(theta, wires)

Arbitrary multi Z rotation.

NestedAttrError()

This class mocks out the qchem module in case it is not installed.

NesterovMomentumOptimizer([stepsize, momentum])

Gradient-descent optimizer with Nesterov momentum.

NumberOperator(wires)

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

OrbitalRotation(phi, wires)

Spin-adapted spatial orbital rotation.

P(wires)

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

PauliRot(theta, pauli_word, wires)

Arbitrary Pauli word rotation.

PauliX(wires)

The Pauli X operator

PauliY(wires)

The Pauli Y operator

PauliZ(wires)

The Pauli Z operator

PhaseDamping(gamma, wires)

Single-qubit phase damping error channel.

PhaseFlip(p, wires)

Single-qubit bit flip (Pauli \(Z\)) error channel.

PhaseShift(phi, wires)

Arbitrary single qubit local phase shift

PolyXP(q, wires)

An arbitrary second-order polynomial observable.

Projector(basis_state, wires)

Observable corresponding to the computational basis state projector \(P=\ket{i}\bra{i}\).

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[, interface, …])

Represents a quantum node in the hybrid computational graph.

QNodeCollection([qnodes])

Represents a sequence of independent QNodes that all share the same signature.

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.

QubitCarry(wires)

Apply the QubitCarry operation to four input wires.

QubitChannel(K_list, wires)

Apply an arbitrary fixed quantum channel.

QubitDevice([wires, shots, cache, analytic])

Abstract base class for PennyLane qubit devices.

QubitStateVector(state, wires)

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

QubitSum(wires)

Apply a QubitSum operation on three input wires.

QubitUnitary(U, wires)

Apply an arbitrary fixed unitary matrix.

QueuingContext()

Abstract base class for classes that exposes a queue for objects.

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

ResetError(p_0, p_1, wires)

Single-qubit Reset error channel.

Rot(phi, theta, omega, wires)

Arbitrary single qubit rotation

Rotation(phi, wires)

Phase space rotation.

RotoselectOptimizer([possible_generators])

Rotoselect gradient-free optimizer.

RotosolveOptimizer()

Rotosolve gradient-free optimizer.

S(wires)

The single-qubit phase gate

SISWAP(wires)

The square root of i-swap operator.

SQISW

alias of pennylane.ops.qubit.non_parametric_ops.SISWAP

SWAP(wires)

The swap operator

SX(wires)

The single-qubit Square-Root X operator.

ShotAdaptiveOptimizer(min_shots[, …])

Optimizer where the shot rate is adaptively calculated using the variances of the parameter-shift gradient.

SingleExcitation(phi, wires)

Single excitation rotation.

SingleExcitationMinus(phi, wires)

Single excitation rotation with negative phase-shift outside the rotation subspace.

SingleExcitationPlus(phi, wires)

Single excitation rotation with positive phase-shift outside the rotation subspace.

SparseHamiltonian(H)

A Hamiltonian represented directly as a sparse matrix in coordinate list (COO) format.

SqueezedState(r, phi, wires)

Prepares a squeezed vacuum state.

Squeezing(r, phi, wires)

Phase space squeezing.

T(wires)

The single-qubit T gate

TensorN(wires)

The tensor product of the NumberOperator acting on different wires.

ThermalState(nbar, wires)

Prepares a thermal state.

Toffoli(wires)

Toffoli (controlled-controlled-X) gate.

Tracker([dev, callback, persistent])

This class stores information about device executions and allows users to interact with that data upon individual executions and batches, even within parameter-shift gradients and optimization steps.

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.

VQECost(*args, **kwargs)

Create a cost function that gives the expectation value of an input Hamiltonian.

X(wires)

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

batch_transform(transform_fn[, expand_fn, …])

Class for registering a tape transform that takes a tape, and outputs a batch of tapes to be independently executed on a quantum device.

grad(fun[, argnum])

Returns the gradient as a callable function of (functions of) QNodes.

single_tape_transform(transform_fn)

For registering a tape transform that takes a tape and outputs a single new tape.

Variables

entry

Object representing an advertised importable object

metric_tensor

Returns a function that computes the block-diagonal approximation of the metric tensor of a given QNode or quantum tape.

Class Inheritance Diagram

Inheritance diagram of pennylane.optimize.adagrad.AdagradOptimizer, pennylane.optimize.adam.AdamOptimizer, pennylane.ops.channel.AmplitudeDamping, pennylane.ops.qubit.state_preparation.BasisState, pennylane.ops.cv.Beamsplitter, pennylane.ops.channel.BitFlip, pennylane.ops.qubit.non_parametric_ops.CNOT, pennylane.ops.qubit.parametric_ops.ControlledPhaseShift, pennylane.ops.qubit.parametric_ops.CRX, pennylane.ops.qubit.parametric_ops.CRY, pennylane.ops.qubit.parametric_ops.CRZ, pennylane.ops.qubit.parametric_ops.CRot, pennylane.ops.qubit.non_parametric_ops.CSWAP, pennylane.ops.qubit.non_parametric_ops.CY, pennylane.ops.qubit.non_parametric_ops.CZ, pennylane.ops.cv.CatState, pennylane.circuit_graph.CircuitGraph, pennylane.ops.cv.CoherentState, pennylane.configuration.Configuration, pennylane.ops.cv.ControlledAddition, pennylane.transforms.control.ControlledOperation, pennylane.ops.cv.ControlledPhase, pennylane.ops.qubit.parametric_ops.ControlledPhaseShift, pennylane.ops.qubit.matrix_ops.ControlledQubitUnitary, pennylane.ops.cv.CrossKerr, pennylane.ops.cv.CubicPhase, pennylane.ops.channel.DepolarizingChannel, pennylane._device.Device, pennylane._device.DeviceError, pennylane.ops.qubit.matrix_ops.DiagonalQubitUnitary, pennylane.ops.cv.DisplacedSqueezedState, pennylane.ops.cv.Displacement, pennylane.ops.qubit.qchem_ops.DoubleExcitation, pennylane.ops.qubit.qchem_ops.DoubleExcitationMinus, pennylane.ops.qubit.qchem_ops.DoubleExcitationPlus, pennylane.vqe.vqe.ExpvalCost, pennylane.ops.cv.FockDensityMatrix, pennylane.ops.cv.FockState, pennylane.ops.cv.FockStateProjector, pennylane.ops.cv.FockStateVector, pennylane.ops.cv.GaussianState, pennylane.ops.channel.GeneralizedAmplitudeDamping, pennylane.optimize.gradient_descent.GradientDescentOptimizer, pennylane.ops.qubit.non_parametric_ops.Hadamard, pennylane.ops.qubit.hamiltonian.Hamiltonian, pennylane.ops.qubit.observables.Hermitian, pennylane.ops.qubit.non_parametric_ops.ISWAP, pennylane.ops.Identity, pennylane.ops.cv.Interferometer, pennylane.ops.qubit.parametric_ops.IsingXX, pennylane.ops.qubit.parametric_ops.IsingYY, pennylane.ops.qubit.parametric_ops.IsingZZ, pennylane.ops.cv.Kerr, pennylane.optimize.momentum.MomentumOptimizer, pennylane.ops.qubit.non_parametric_ops.MultiControlledX, pennylane.ops.qubit.parametric_ops.MultiRZ, pennylane.NestedAttrError, pennylane.optimize.nesterov_momentum.NesterovMomentumOptimizer, pennylane.ops.cv.NumberOperator, pennylane.ops.qubit.qchem_ops.OrbitalRotation, pennylane.ops.cv.P, pennylane.ops.qubit.parametric_ops.PauliRot, pennylane.ops.qubit.non_parametric_ops.PauliX, pennylane.ops.qubit.non_parametric_ops.PauliY, pennylane.ops.qubit.non_parametric_ops.PauliZ, pennylane.ops.channel.PhaseDamping, pennylane.ops.channel.PhaseFlip, pennylane.ops.qubit.parametric_ops.PhaseShift, pennylane.ops.cv.PolyXP, pennylane.ops.qubit.observables.Projector, pennylane.optimize.qng.QNGOptimizer, pennylane.qnode.QNode, pennylane.collections.qnode_collection.QNodeCollection, pennylane.ops.cv.QuadOperator, pennylane.ops.cv.QuadraticPhase, pennylane.QuantumFunctionError, pennylane.ops.qubit.arithmetic_ops.QubitCarry, pennylane.ops.channel.QubitChannel, pennylane._qubit_device.QubitDevice, pennylane.ops.qubit.state_preparation.QubitStateVector, pennylane.ops.qubit.arithmetic_ops.QubitSum, pennylane.ops.qubit.matrix_ops.QubitUnitary, pennylane.queuing.QueuingContext, pennylane.optimize.rms_prop.RMSPropOptimizer, pennylane.ops.qubit.parametric_ops.RX, pennylane.ops.qubit.parametric_ops.RY, pennylane.ops.qubit.parametric_ops.RZ, pennylane.ops.channel.ResetError, pennylane.ops.qubit.parametric_ops.Rot, pennylane.ops.cv.Rotation, pennylane.optimize.rotoselect.RotoselectOptimizer, pennylane.optimize.rotosolve.RotosolveOptimizer, pennylane.ops.qubit.non_parametric_ops.S, pennylane.ops.qubit.non_parametric_ops.SISWAP, pennylane.ops.qubit.non_parametric_ops.SISWAP, pennylane.ops.qubit.non_parametric_ops.SWAP, pennylane.ops.qubit.non_parametric_ops.SX, pennylane.optimize.shot_adaptive.ShotAdaptiveOptimizer, pennylane.ops.qubit.qchem_ops.SingleExcitation, pennylane.ops.qubit.qchem_ops.SingleExcitationMinus, pennylane.ops.qubit.qchem_ops.SingleExcitationPlus, pennylane.ops.qubit.observables.SparseHamiltonian, pennylane.ops.cv.SqueezedState, pennylane.ops.cv.Squeezing, pennylane.ops.qubit.non_parametric_ops.T, pennylane.ops.cv.TensorN, pennylane.ops.cv.ThermalState, pennylane.ops.qubit.non_parametric_ops.Toffoli, pennylane.tracker.Tracker, pennylane.ops.cv.TwoModeSqueezing, pennylane.ops.qubit.parametric_ops.U1, pennylane.ops.qubit.parametric_ops.U2, pennylane.ops.qubit.parametric_ops.U3, pennylane.vqe.vqe.VQECost, pennylane.ops.cv.X, pennylane.transforms.batch_transform.batch_transform, pennylane._grad.grad, pennylane.transforms.qfunc_transforms.single_tape_transform