qp

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

Functions

apply(op[, context])

Apply an instantiated operator or measurement to a queuing context.

qjit([fn, compiler])

A decorator for just-in-time compilation of hybrid quantum programs in PennyLane.

for_loop([start, ]stop[, step])

A qjit() compatible for-loop for PennyLane programs.

while_loop(cond_fn[, allow_array_resizing])

A qjit() compatible while-loop for PennyLane programs.

allocate(num_wires[, state, restored])

Dynamically allocates new wires in-line, or as a context manager which also safely deallocates the new wires upon exiting the context.

deallocate(wires)

Deallocates wires that have previously been allocated with allocate().

register_resources(ops[, qfunc, work_wires, ...])

Binds a quantum function to its required resources.

register_condition(condition[, qfunc])

Binds a condition to a decomposition rule for when it is applicable.

add_decomps(op_type, *decomps)

Globally registers new decomposition rules with an operator class.

list_decomps(op)

Lists all stored decomposition rules for an operator class.

inspect_decomps(op, *rules[, ...])

Inspect the decomposition rules of an operator.

resource_rep(op_type, **params)

Binds an operator type with additional resource parameters.

pauli_decompose(H[, hide_identity, ...])

Decomposes a Hermitian matrix into a linear combination of Pauli operators.

specs(qnode[, level, compute_depth])

Provides the specifications of a quantum circuit.

jordan_wigner(fermi_operator[, ps, ...])

Convert a fermionic operator to a qubit operator using the Jordan-Wigner mapping.

parity_transform(fermi_operator, n[, ps, ...])

Convert a fermionic operator to a qubit operator using the parity mapping.

bravyi_kitaev(fermi_operator, n[, ps, ...])

Convert a fermionic operator to a qubit operator using the Bravyi-Kitaev mapping.

binary_mapping(bose_operator[, n_states, ...])

Convert a bosonic operator to a qubit operator using the standard-binary mapping.

unary_mapping(bose_operator[, n_states, ps, ...])

Convert a bosonic operator to a qubit operator using the unary mapping.

christiansen_mapping(bose_operator[, ps, ...])

Convert a bosonic operator to a qubit operator using the Christiansen mapping.

taper(h, generators, paulixops, paulix_sector)

Transform a Hamiltonian with a Clifford operator and then taper qubits.

symmetry_generators(h)

Compute the generators \(\{\tau_1, \ldots, \tau_k\}\) for a Hamiltonian over the binary field \(\mathbb{Z}_2\).

paulix_ops(generators, num_qubits)

Generate the single qubit Pauli-X operators \(\sigma^{x}_{i}\) for each symmetry \(\tau_j\), such that it anti-commutes with \(\tau_j\) and commutes with all others symmetries \(\tau_{k\neq j}\).

taper_operation(operation, generators, ...)

Transform a gate operation with a Clifford operator and then taper qubits.

import_operator(qubit_observable[, format, ...])

Convert an external operator to a PennyLane operator.

from_openfermion(openfermion_op[, wires, tol])

Convert OpenFermion FermionOperator to PennyLane FermiWord or FermiSentence and OpenFermion QubitOperator to PennyLane LinearCombination.

to_openfermion(pennylane_op[, wires, tol])

Convert a PennyLane operator to OpenFermion QubitOperator or FermionOperator.

vjp(f, params, cotangents[, method, h, argnums])

A qjit() compatible Vector-Jacobian product of PennyLane programs.

jvp(f, params, tangents[, method, h, argnums])

A qjit() compatible Jacobian-vector product of PennyLane programs.

about()

Prints the information for pennylane installation.

registers(register_dict)

Returns a dictionary that maps register names to Wires.

counts([op, wires, all_outcomes])

Sample from the supplied observable, with the number of shots determined from QNode, returning the number of counts for each sample.

density_matrix(wires)

Quantum density matrix in the computational basis.

expval(op)

Expectation value of the supplied observable.

probs([wires, op])

Probability of each computational basis state.

sample([op, wires, dtype])

Sample from the supplied observable, with the number of shots determined from QNode, returning raw samples.

state()

Quantum state in the computational basis.

var(op)

Variance of the supplied observable.

vn_entropy(wires[, log_base])

Von Neumann entropy of the system prior to measurement.

purity(wires)

The purity of the system prior to measurement.

mutual_info(wires0, wires1[, log_base])

Mutual information between the subsystems prior to measurement:

classical_shadow(wires[, seed])

The classical shadow measurement protocol.

shadow_expval(H[, k, seed])

Estimate expectation values using Classical Shadows with full differentiability support.

measure(wires[, reset, postselect])

Perform a mid-circuit measurement in the computational basis on the supplied qubit.

pauli_measure(pauli_word, wires[, postselect])

Perform a Pauli product measurement.

adjoint(fn[, lazy])

Create the adjoint of an Operator or a function that applies the adjoint of the provided function.

ctrl(op, control[, control_values, ...])

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

cond(condition[, true_fn, false_fn, elifs])

Quantum-compatible if-else conditionals --- condition quantum operations on parameters such as the results of mid-circuit qubit measurements.

change_op_basis(compute_op, target_op[, ...])

Construct an operator that represents the product of the operators provided; particularly a compute-uncompute pattern.

exp(op[, coeff, id])

Take the exponential of an Operator times a coefficient.

sum(*summands[, grouping_type, method, id, lazy])

Construct an operator which is the sum of the given operators.

pow(base[, z, lazy, id])

Raise an Operator to a power.

prod(*ops[, id, lazy])

Construct an operator which represents the generalized product of the operators provided.

s_prod(scalar, operator[, lazy, id])

Construct an operator which is the scalar product of the given scalar and operator provided.

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

Repeatedly applies a unitary a given number of times.

order_states(basis_states)

This function maps a given list of \(m\) computational basis states to the first \(m\) computational basis states, except for input states that are among the first \(m\) computational basis states, which are mapped to themselves.

right_canonicalize_mps(mps)

Transform a matrix product state (MPS) into its right-canonical form.

compute_sos_encoding(bits)

Map \(D\) different bitstrings of length \(r\) to \(D\) different bitstrings \(b\) of length \(m = \min(r, 2d-1)\) where \(d=\lceil\log_2(D)\rceil\).

select_sos_rows(bits)

Select rows of a bit array of differing columns such that the stacked array of the selected rows still contains differing columns.

trotterize(qfunc[, n, order, reverse])

Generates higher order Suzuki-Trotter product formulas from a set of operations defined in a function.

poly_to_angles(poly, routine[, angle_solver])

Computes the angles needed to implement a polynomial transformation with quantum signal processing (QSP), quantum singular value transformation (QSVT) or generalized quantum signal processing (GQSP).

qsvt(A, poly, encoding_wires[, ...])

Implements the Quantum Singular Value Transformation (QSVT) for a matrix or Hamiltonian A, using a polynomial defined by poly and a block encoding specified by block_encoding.

transform_angles(angles, routine1, routine2)

Converts angles for quantum signal processing (QSP) and quantum singular value transformation (QSVT) routines.

qnode(func, device[, interface, ...])

Represents a quantum node in the hybrid computational graph.

execute(tapes, device[, diff_method, ...])

A function for executing a batch of tapes on a device with compatibility for auto-differentiation.

set_shots(*args[, shots])

Transform used to set or update a circuit's shots.

marker([obj, label])

Mark a location in a compilation pipeline for easy access with inspectability.

transform([tape_transform, pass_name, ...])

Generalizes a function that transforms tapes to work with additional circuit-like objects such as a QNode.

batch_params(tape[, all_operations])

Transform a QNode to support an initial batch dimension for operation parameters.

batch_input(tape, argnum)

Transform a circuit to support an initial batch dimension for gate inputs.

batch_partial(qnode[, all_operations, ...])

Create a batched partial callable object from the QNode specified.

compile(tape[, pipeline, basis_set, num_passes])

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

decompose(tape, *[, gate_set, ...])

Decomposes a quantum circuit into a user-specified gate set.

decomp_inspector(tape, *[, gate_set, ...])

Returns a DecompGraphInspector for querying the decomposition decisions made for a given circuit and target gate set.

defer_measurements(tape[, ...])

Quantum function transform that substitutes operations conditioned on measurement outcomes to controlled operations.

dynamic_one_shot(tape[, postselect_mode])

Transform a QNode to into several one-shot tapes to support dynamic circuit execution.

quantum_monte_carlo(tape, wires, ...)

Applies the transform quantum Monte Carlo estimation algorithm.

apply_controlled_Q(tape, wires, target_wire, ...)

Applies the transform that performs a controlled version of the \(\mathcal{Q}\) unitary defined in this paper.

commutation_dag(tape)

Construct the pairwise-commutation DAG (directed acyclic graph) representation of a quantum circuit.

pattern_matching(circuit_dag, pattern_dag)

Function that applies the pattern matching algorithm and returns the list of maximal matches.

pattern_matching_optimization(tape, ...[, ...])

Quantum function transform to optimize a circuit given a list of patterns (templates).

clifford_t_decomposition(tape[, epsilon, ...])

Decomposes a circuit into the Clifford+T basis.

gridsynth(qnode[, epsilon, ppr_basis])

Decomposes RZ and PhaseShift gates into the Clifford+T basis or the PPR basis.

add_noise(tape, noise_model[, level])

Insert operations according to a provided noise model.

insert(tape, op, op_args[, position, before])

Insert an operation into specified points in an input circuit.

mitigate_with_zne(tape, scale_factors, ...)

Mitigate an input circuit using zero-noise extrapolation.

fold_global(tape, scale_factor)

Differentiable circuit folding of the global unitary circuit.

poly_extrapolate(x, y, order)

Extrapolator to \(f(0)\) for polynomial fit.

richardson_extrapolate(x, y)

Polynomial fit where the degree of the polynomial is fixed to being equal to the length of x.

exponential_extrapolate(x, y[, asymptote, eps])

Extrapolate to the zero-noise limit using an exponential model (\(Ae^{Bx} + C\)).

dot(coeffs, ops[, pauli, grouping_type, method])

Returns the dot product between the coeffs vector and the ops list of operators.

eigvals(op[, k, which])

The eigenvalues of one or more operations.

equal(op1, op2[, check_interface, ...])

Function for determining operator, measurement, and tape equality.

assert_equal(op1, op2[, check_interface, ...])

Function to assert that two operators, measurements, or tapes are equal

evolve()

This method is dispatched and its functionality depends on the type of the input op.

generator(op[, format])

Returns the generator of an operation.

is_commuting(operation1, operation2)

Check if two operations are commuting using a lookup table.

is_hermitian(op)

Check if the operation is hermitian.

is_unitary(op)

Check if the operation is unitary.

map_wires(input, wire_map[, queue, replace])

Changes the wires of an operator, tape, qnode or quantum function according to the given wire map.

matrix(op[, wire_order])

The dense matrix representation of an operation or quantum circuit.

simplify(input)

Simplifies an operator, tape, qnode or quantum function by reducing its arithmetic depth or number of rotation parameters.

iterative_qpe(base, aux_wire, iters)

Performs the iterative quantum phase estimation circuit.

commutator(op1, op2[, pauli])

Compute commutator between two operators in PennyLane

comm(op1, op2[, pauli])

Compute commutator between two operators in PennyLane

snapshots(tape)

This transform processes Snapshot instances contained in a circuit, depending on the compatibility of the execution device.

breakpoint()

A function which freezes execution and launches the PennyLane debugger (PLDB).

debug_expval(op)

Compute the expectation value of an observable at the current point in the quantum circuit.

debug_state()

Compute the quantum state at the current point in the quantum circuit.

debug_probs([wires, op])

Compute the probability distribution for the state at the current point in the quantum circuit.

debug_tape()

Access the tape of the quantum circuit.

cut_circuit(tape[, auto_cutter, ...])

Cut up a quantum circuit into smaller circuit fragments.

cut_circuit_mc(tape[, ...])

Cut up a circuit containing sample measurements into smaller fragments using a Monte Carlo method.

metric_tensor(tape[, argnum, approx, ...])

Returns a function that computes the metric tensor of a given QNode or quantum tape.

adjoint_metric_tensor(tape)

Implements the adjoint method outlined in Jones to compute the metric tensor.

draw(qnode[, wire_order, show_all_wires, ...])

Create a function that draws the given QNode or quantum function.

draw_mpl(qnode[, wire_order, ...])

Draw a qnode with matplotlib

from_pyquil(pyquil_program)

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

from_qasm(quantum_circuit[, measurements])

Loads quantum circuits from a QASM string using the converter in the PennyLane-Qiskit plugin.

to_openqasm(circuit[, wires, rotations, ...])

Convert a circuit to an OpenQASM 2.0 program.

from_qiskit(quantum_circuit[, measurements])

Converts a Qiskit QuantumCircuit into a PennyLane quantum function.

from_qiskit_noise(noise_model[, verbose, ...])

Converts a Qiskit NoiseModel into a PennyLane NoiseModel.

from_qiskit_op(qiskit_op[, params, wires])

Converts a Qiskit SparsePauliOp into a PennyLane Operator.

from_quil(quil)

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

from_quil_file(quil_filename)

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

bloq_registers(bloq)

Reads a Qualtran Bloq signature and returns a dictionary mapping the Bloq's register names to Wires.

from_qasm3(quantum_circuit[, wire_map])

Converts an OpenQASM 3.0 circuit into a quantum function that can be used within a QNode.

to_bloq(circuit[, map_ops, custom_mapping, ...])

Converts a PennyLane QNode, Qfunc, or Operation to the corresponding Qualtran Bloq.

device(name, *args, **kwargs)

Load a device and return the instance.

refresh_devices()

Scan installed PennyLane plugins to refresh the device list.

lie_closure(generators, *[, max_iterations, ...])

Compute the (dynamical) Lie algebra from a set of generators.

structure_constants(g[, pauli, matrix, ...])

Compute the structure constants that make up the adjoint representation of a Lie algebra.

center(g[, pauli])

Compute the center of a Lie algebra.

draw_graph(qnode, *[, level])

Visualize a single QJIT compiled QNode, showing wire flow through quantum operations, program structure, and pass-by-pass impacts on compiled programs.

Classes

BooleanFn(fn[, name])

Wrapper for simple callables with Boolean output that can be manipulated and combined with bitwise operators.

QueuingManager()

Singleton global entry point for managing active recording contexts.

FermiC(orbital)

The fermionic creation operator \(a^{\dagger}\)

FermiA(orbital)

The fermionic annihilation operator \(a\)

FermiWord(operator[, _skip_sorting])

Immutable dictionary used to represent a Fermi word, a product of fermionic creation and annihilation operators, that can be constructed from a standard dictionary.

FermiSentence(operator)

Dictionary-based representation of a linear combination of FermiWord instances.

BoseSentence(operator)

Dictionary used to represent a Bose sentence, a linear combination of Bose words, with the keys as BoseWord instances and the values correspond to coefficients.

BoseWord(operator)

Dictionary used to represent a Bose word, a product of bosonic creation and annihilation operators, that can be constructed from a standard dictionary.

grad(func[, argnums, h, method])

Returns the gradient as a callable function of hybrid quantum-classical functions.

jacobian(func[, argnums, method, h])

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

value_and_grad(func[, argnums, method, h])

A qjit()-compatible transformation for returning the result and jacobian of a function.

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

Represents a quantum circuit as a directed acyclic graph.

Configuration(name)

Configuration class.

FockStateVector(state, wires[, id])

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

QuadX(wires)

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

Beamsplitter(theta, phi, wires[, id])

Beamsplitter interaction.

PolyXP(q, wires[, id])

An arbitrary second-order polynomial observable.

NumberOperator(wires)

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

TensorN(wires)

The tensor product of the NumberOperator acting on different wires.

QuadraticPhase(s, wires[, id])

Quadratic phase shift.

FockState(n, wires[, id])

Prepares a single Fock state.

QuadP(wires)

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

CatState(a, phi, p, wires[, id])

Prepares a cat state.

FockStateProjector(n, wires[, id])

The number state observable \(\ket{n}\bra{n}\).

ThermalState(nbar, wires[, id])

Prepares a thermal state.

CrossKerr(kappa, wires[, id])

Cross-Kerr interaction.

ControlledAddition(s, wires[, id])

Controlled addition operation.

Kerr(kappa, wires[, id])

Kerr interaction.

CubicPhase(gamma, wires[, id])

Cubic phase shift.

Rotation(phi, wires[, id])

Phase space rotation.

SqueezedState(r, phi, wires[, id])

Prepares a squeezed vacuum state.

TwoModeSqueezing(r, phi, wires[, id])

Phase space two-mode squeezing.

Squeezing(r, phi, wires[, id])

Phase space squeezing.

ControlledPhase(s, wires[, id])

Controlled phase operation.

CoherentState(a, phi, wires[, id])

Prepares a coherent state.

QuadOperator(phi, wires[, id])

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

InterferometerUnitary(U, wires[, id])

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

GaussianState(V, r, wires[, id])

Prepare subsystems in a given Gaussian state.

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

Prepares a displaced squeezed vacuum state.

Displacement(a, phi, wires[, id])

Phase space displacement.

FockDensityMatrix(state, wires[, id])

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

OrbitalRotation(phi, wires[, id])

Spin-adapted spatial orbital rotation.

DoubleExcitation(phi, wires[, id])

Double excitation rotation.

SingleExcitationMinus(phi, wires[, id])

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

H

alias of Hadamard

SingleExcitationPlus(phi, wires[, id])

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

QubitSum(wires)

Apply a QubitSum operation on three input wires.

SparseHamiltonian(H, wires[, id])

A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format.

Rot(phi, theta, omega, wires[, id])

Arbitrary single qubit rotation

PhaseShift(phi, wires[, id])

Arbitrary single qubit local phase shift

SX(wires)

The single-qubit Square-Root X operator.

Hadamard(wires)

The Hadamard operator

SISWAP(wires)

The square root of i-swap operator.

U3(theta, phi, delta, wires[, id])

Arbitrary single qubit unitary.

DoubleExcitationMinus(*params[, wires, id])

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

RZ(phi, wires[, id])

The single qubit Z rotation

U1(phi, wires[, id])

U1 gate.

S(wires)

The single-qubit phase gate

IsingXX(phi, wires[, id])

Ising XX coupling gate

BlockEncode(A, wires)

Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block.

PauliX(wires[, id])

The Pauli X operator

CPhaseShift01(phi, wires[, id])

A qubit controlled phase shift.

PauliZ(wires[, id])

The Pauli Z operator

QubitDensityMatrix(state, wires)

Prepare subsystems using the given density matrix.

DiagonalQubitUnitary(D, wires)

Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two.

StatePrep(state, wires[, pad_with, ...])

Prepare subsystems using a state vector in the computational basis.

SWAP(wires)

The swap operator

SQISW

alias of SISWAP

GlobalPhase(phi[, wires, id])

A global phase operation that multiplies all components of the state by \(e^{-i \phi}\).

Y

alias of PauliY

BasisState(state, wires)

Prepares a single computational basis state.

FermionicSWAP(phi, wires[, id])

Fermionic SWAP rotation.

IntegerComparator(value, geq, wires)

Apply a controlled Pauli X gate using integer comparison as the condition.

ISWAP(wires)

The i-swap operator

Barrier(wires)

The Barrier operator, used to separate the compilation process into blocks or as a visual tool.

SingleExcitation(phi, wires[, id])

Single excitation rotation.

Hermitian(A, wires[, id])

An arbitrary Hermitian observable.

PauliY(wires[, id])

The Pauli Y operator

PSWAP(phi, wires[, id])

Phase SWAP gate

QubitCarry(wires)

Apply the QubitCarry operation to four input wires.

CPhaseShift00(phi, wires[, id])

A qubit controlled phase shift.

RX(phi, wires[, id])

The single qubit X rotation

U2(phi, delta, wires[, id])

U2 gate.

Z

alias of PauliZ

MultiRZ(theta, wires[, id])

Arbitrary multi Z rotation.

CPhaseShift10(phi, wires[, id])

A qubit controlled phase shift.

RY(phi, wires[, id])

The single qubit Y rotation

IsingZZ(phi, wires[, id])

Ising ZZ coupling gate

WireCut(wires)

The wire cut operation, used to manually mark locations for wire cuts.

Snapshot([tag, measurement, shots])

The Snapshot operation saves the internal execution state of the quantum function at a specific point in the execution pipeline.

T(wires)

The single-qubit T gate

DoubleExcitationPlus(phi, wires[, id])

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

IsingYY(phi, wires[, id])

Ising YY coupling gate

X

alias of PauliX

SpecialUnitary(theta, wires[, id])

Gate from the group \(SU(N)\) with \(N=2^n\) for \(n\) qubits.

IsingXY(phi, wires[, id])

Ising (XX + YY) coupling gate

PCPhase(phi, dim, wires)

A projector-controlled phase gate.

ECR(wires)

An echoed RZX(\(\pi/2\)) gate.

Identity([wires, id])

The Identity operator

Projector(state, wires[, id])

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

PauliRot(theta, pauli_word, wires[, id])

Arbitrary Pauli word rotation.

QubitUnitary(U, wires)

Apply an arbitrary unitary matrix with a dimension that is a power of two.

Toffoli(wires)

Toffoli (controlled-controlled-X) gate.

ControlledPhaseShift(phi, wires[, id])

A qubit controlled phase shift.

CCZ(wires)

CCZ (controlled-controlled-Z) gate.

CNOT(wires)

The controlled-NOT operator

CY(wires)

The controlled-Y operator

CH(wires)

The controlled-Hadamard operator

CSWAP(wires)

The controlled-swap operator

CZ(wires)

The controlled-Z operator

MultiControlledX(wires[, control_values, ...])

Apply a PauliX gate controlled on an arbitrary computational basis state.

CRZ(phi, wires[, id])

The controlled-RZ operator

CRX(phi, wires[, id])

The controlled-RX operator

CPhase

alias of ControlledPhaseShift

ControlledQubitUnitary(U, wires)

Apply an arbitrary fixed unitary matrix U to wires.

CRY(phi, wires[, id])

The controlled-RY operator

CRot(phi, theta, omega, wires[, id])

The controlled-Rot operator

QutritUnitary(*params, wires)

Apply an arbitrary, fixed unitary matrix.

GellMann(wires[, index, id])

The Gell-Mann observables for qutrits

TSWAP(wires)

The ternary swap operator.

TRX(phi, wires[, subspace, id])

The single qutrit X rotation

THermitian(A, wires[, id])

An arbitrary Hermitian observable for qutrits.

TShift(wires)

The qutrit shift operator

TritFlip(p_01, p_02, p_12, wires[, id])

Single-qutrit trit flip error channel, used for applying "bit flips" on each qutrit subspace.

THadamard(wires, subspace)

The ternary Hadamard operator

TRZ(phi, wires[, subspace, id])

The single qutrit Z rotation

QutritChannel(K_list[, wires, id])

Apply an arbitrary fixed qutrit channel.

TAdd(wires)

The 2-qutrit controlled add gate

QutritDepolarizingChannel(p, wires[, id])

Single-qutrit symmetrically depolarizing error channel.

QutritAmplitudeDamping(gamma_10, gamma_20, ...)

Single-qutrit amplitude damping error channel.

TClock(wires)

Ternary Clock gate

QutritBasisState(n, wires)

Prepares a single computational basis state for a qutrit system.

ControlledQutritUnitary(U, control_wires, ...)

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

TRY(phi, wires[, subspace, id])

The single qutrit Y rotation

ResetError(p0, p1, wires[, id])

Single-qubit Reset error channel.

DepolarizingChannel(p, wires[, id])

Single-qubit symmetrically depolarizing error channel.

GeneralizedAmplitudeDamping(gamma, p, wires)

Single-qubit generalized amplitude damping error channel.

PhaseDamping(gamma, wires[, id])

Single-qubit phase damping error channel.

PhaseFlip(p, wires[, id])

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

PauliError(operators, p, wires[, id])

Pauli operator error channel for an arbitrary number of qubits.

ThermalRelaxationError(pe, t1, t2, tg, wires)

Thermal relaxation error channel.

BitFlip(p, wires[, id])

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

AmplitudeDamping(gamma, wires[, id])

Single-qubit amplitude damping error channel.

QubitChannel(K_list, wires[, id])

Apply an arbitrary fixed quantum channel.

Hamiltonian

alias of LinearCombination

AmplitudeEmbedding(features, wires, *[, ...])

Encodes \(2^n\) features into the amplitude vector of \(n\) qubits.

AngleEmbedding(features, wires[, rotation, id])

Encodes \(N\) features into the rotation angles of \(n\) qubits, where \(N \leq n\).

BasisEmbedding(features, wires[, id])

Encodes \(n\) binary features into a basis state of \(n\) qubits.

DisplacementEmbedding(features, wires[, ...])

Encodes \(N\) features into the displacement amplitudes \(r\) or phases \(\phi\) of \(M\) modes, where \(N\leq M\).

IQPEmbedding(features, wires[, n_repeats, ...])

Encodes \(n\) features into \(n\) qubits using diagonal gates of an IQP circuit.

QAOAEmbedding(features, weights, wires[, ...])

Encodes \(N\) features into \(n>N\) qubits, using a layered, trainable quantum circuit that is inspired by the QAOA ansatz proposed by Killoran et al. (2020).

SqueezingEmbedding(features, wires[, ...])

Encodes \(N\) features into the squeezing amplitudes \(r \geq 0\) or phases \(\phi \in [0, 2\pi)\) of \(M\) modes, where \(N\leq M\).

BasicEntanglerLayers(weights[, wires, ...])

Layers consisting of one-parameter single-qubit rotations on each qubit, followed by a closed chain or ring of CNOT gates.

CVNeuralNetLayers(theta_1, phi_1, varphi_1, ...)

A sequence of layers of a continuous-variable quantum neural network, as specified in Killoran et al. (2019).

GateFabric(weights, wires, init_state[, ...])

Implements a local, expressive, and quantum-number-preserving ansatz proposed by Anselmetti et al. (2021).

ParticleConservingU1(weights, wires[, ...])

Implements the heuristic VQE ansatz for quantum chemistry simulations using the particle-conserving gate \(U_{1,\mathrm{ex}}\) proposed by Barkoutsos et al. in arXiv:1805.04340.

ParticleConservingU2(weights, wires[, ...])

Implements the heuristic VQE ansatz for Quantum Chemistry simulations using the particle-conserving entangler \(U_\mathrm{ent}(\vec{\theta}, \vec{\phi})\) proposed in arXiv:1805.04340.

RandomLayers(weights, wires[, ratio_imprim, ...])

Layers of randomly chosen single qubit rotations and 2-qubit entangling gates, acting on randomly chosen qubits.

SimplifiedTwoDesign(initial_layer_weights, ...)

Layers consisting of a simplified 2-design architecture of Pauli-Y rotations and controlled-Z entanglers proposed in Cerezo et al. (2021).

StronglyEntanglingLayers(weights, wires[, ...])

Layers consisting of single qubit rotations and entanglers, inspired by the circuit-centric classifier design arXiv:1804.00633.

MERA(wires, n_block_wires, block, n_params_block)

The MERA template broadcasts an input circuit across many wires following the architecture of a multi-scale entanglement renormalization ansatz tensor network.

MPS(wires, n_block_wires, block[, ...])

The MPS template broadcasts an input circuit across many wires following the architecture of a Matrix Product State tensor network.

TTN(wires, n_block_wires, block, n_params_block)

The TTN template broadcasts an input circuit across many wires following the architecture of a tree tensor network.

TwoLocalSwapNetwork(wires[, acquaintances, ...])

Apply two-local gate operations using a canonical 2-complete linear (2-CCL) swap network.

ArbitraryStatePreparation(weights, wires[, id])

Implements an arbitrary state preparation on the specified wires.

QutritBasisStatePreparation(basis_state, wires)

Prepares a basis state on the given wires using a sequence of TShift gates.

CosineWindow(wires)

Prepares an initial state with a cosine wave function.

MottonenStatePreparation(state_vector, wires)

Prepares an arbitrary state on the given wires using a decomposition into gates developed by Möttönen et al. (2004).

Superposition(coeffs, bases, wires, work_wire)

Prepare a superposition of computational basis states.

QROMStatePreparation(state_vector, wires, ...)

Prepares a quantum state using Quantum Read-Only Memory (QROM).

MPSPrep(mps, wires[, work_wires, ...])

Prepares an initial state from a matrix product state (MPS) representation.

MultiplexerStatePreparation(state_vector, wires)

Prepares a quantum state using multiplexed rotations.

SumOfSlatersPrep(coefficients, wires, indices)

Prepare an arbitrary quantum state with the sum-of-Slaters technique.

ArbitraryUnitary(weights, wires[, id])

Implements an arbitrary unitary on the specified wires.

ApproxTimeEvolution(hamiltonian, time, n[, id])

Applies the Trotterized time-evolution operator for an arbitrary Hamiltonian, expressed in terms of Pauli gates.

BBQRAM(data, control_wires, target_wires, ...)

Bucket-brigade QRAM with explicit bus routing using 3 wires per node.

CommutingEvolution(hamiltonian, time[, ...])

Applies the time-evolution operator for a Hamiltonian expressed as a linear combination of mutually commuting Pauli words.

QDrift(hamiltonian, time[, n, seed, id])

An operation representing the QDrift approximation for the complex matrix exponential of a given Hamiltonian.

TrotterizedQfunc(time, *trainable_args[, ...])

An operation representing the Suzuki-Trotter product approximation applied to a set of operations defined in a function.

TrotterProduct(hamiltonian, time[, n, ...])

An operation representing the Suzuki-Trotter product approximation for the complex matrix exponential of a given Hamiltonian.

Interferometer(theta, phi, varphi, wires[, ...])

General linear interferometer, an array of beamsplitters and phase shifters.

IQP(weights, num_wires, pattern[, spin_sym, id])

A template that builds an Instantaneous Quantum Polynomial (IQP) circuit.

Permute(permutation, wires[, id])

Applies a permutation to a set of wires.

QFT(wires)

Apply a quantum Fourier transform (QFT).

QuantumPhaseEstimation(unitary[, ...])

Performs the quantum phase estimation circuit.

GroverOperator(wires[, work_wires, id])

Performs the Grover Diffusion Operator.

HilbertSchmidt(V, U[, id])

Create a Hilbert-Schmidt template that can be used to compute the Hilbert-Schmidt Test (HST).

HybridQRAM(data, control_wires, ...[, id])

A QRAM implementation that provides a width-depth tradeoff by combining behaviour from SelectOnlyQRAM and BBQRAM.

LocalHilbertSchmidt(V, U[, id])

Create a Local Hilbert-Schmidt template that can be used to compute the Local Hilbert-Schmidt Test (LHST).

FlipSign(n, wires[, id])

Flips the sign of a given basis state.

BasisRotation(wires, unitary_matrix[, check, id])

Implements a circuit that performs an exact single-body basis rotation using Givens rotations and phase shifts.

QuantumMonteCarlo(probs, func, target_wires, ...)

Performs the quantum Monte Carlo estimation algorithm.

FABLE(input_matrix, wires[, tol, id])

Construct a unitary with the fast approximate block encoding method.

Select(ops, control[, work_wires, partial, id])

The Select operator, also known as multiplexer or multiplexed operation, applies different operations depending on the state of designated control wires.

SelectOnlyQRAM(data, control_wires, target_wires)

A QRAM implementation comprising MultiControlledX gates on target (bus) wires, controlled on all address wires.

PrepSelPrep(lcu, control[, id])

Implements a block-encoding of a linear combination of unitaries.

Reflection(U[, alpha, reflection_wires, id])

Apply a reflection about a state \(|\Psi\rangle\).

Qubitization(hamiltonian, control[, id])

Applies the Qubitization operator.

ControlledSequence(base, control[, id])

Creates a sequence of controlled gates raised to decreasing powers of 2.

AQFT(order, wires)

Apply an approximate quantum Fourier transform (AQFT).

AmplitudeAmplification(U, O[, iters, ...])

Applies amplitude amplification.

QROM(data, control_wires, target_wires, ...)

Applies the QROM operator.

GQSP(unitary, angles, control[, id])

Implements the generalized quantum signal processing (GQSP) circuit.

SelectPauliRot(angles, control_wires, ...[, ...])

Applies individual single-qubit Pauli rotations depending on the state of designated control qubits.

QSVT(UA, projectors)

Implements the quantum singular value transformation (QSVT) circuit.

FermionicDoubleExcitation(weight, wires1, ...)

Circuit to exponentiate the tensor product of Pauli matrices representing the double-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz.

FermionicSingleExcitation(weight, wires, *)

Circuit to exponentiate the tensor product of Pauli matrices representing the single-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz.

UCCSD(weights, wires[, s_wires, d_wires, ...])

Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz.

AllSinglesDoubles(weights, wires, hf_state)

Builds a quantum circuit to prepare correlated states of molecules by applying all SingleExcitation and DoubleExcitation operations to the initial Hartree-Fock state.

kUpCCGSD(weights, wires[, k, delta_sz, ...])

Implements the k-Unitary Pair Coupled-Cluster Generalized Singles and Doubles (k-UpCCGSD) ansatz.

PhaseAdder(k, x_wires[, mod, work_wire, id])

Performs the in-place modular phase addition operation.

Adder(k, x_wires[, mod, work_wires, id])

Performs the in-place modular addition operation.

Multiplier(k, x_wires[, mod, work_wires, id])

Performs the in-place modular multiplication operation.

OutMultiplier(x_wires, y_wires, output_wires)

Performs the out-place modular multiplication operation.

OutAdder(x_wires, y_wires, output_wires[, ...])

Performs the out-place modular addition operation.

ModExp(x_wires, output_wires, base[, mod, ...])

Performs the out-place modular exponentiation operation.

OutPoly(polynomial_function, ...[, mod, ...])

Performs the out-of-place polynomial operation.

SemiAdder(x_wires, y_wires, work_wires[, id])

This operator performs the plain addition of two integers \(x\) and \(y\) in the computational basis:

Elbow

alias of TemporaryAND

TemporaryAND(wires, control_values)

The TemporaryAND operation is a three-qubit gate equivalent to a reversible AND, or Toffoli, gate that leverages extra information about the target wire to enable more efficient circuit decompositions.

QNode(func, device[, interface, ...])

Represents a quantum node in the hybrid computational graph.

CompilePipeline(*transforms[, cotransform_cache])

A sequence of transforms to be applied to a quantum function or a QNode.

I

alias of Identity

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.

AdaptiveOptimizer([param_steps, stepsize])

Optimizer for building fully trained quantum circuits by adding gates adaptively.

GradientDescentOptimizer([stepsize])

Basic gradient-descent optimizer.

MomentumOptimizer([stepsize, momentum])

Gradient-descent optimizer with momentum.

MomentumQNGOptimizer([stepsize, momentum, ...])

A generalization of the Quantum Natural Gradient (QNG) optimizer by considering a discrete-time Langevin equation with QNG force.

NesterovMomentumOptimizer([stepsize, momentum])

Gradient-descent optimizer with Nesterov momentum.

RMSPropOptimizer([stepsize, decay, eps])

Root mean squared propagation optimizer.

QNGOptimizer([stepsize, approx, lam])

Optimizer with adaptive learning rate, via calculation of the diagonal or block-diagonal approximation to the Fubini-Study metric tensor.

QNSPSAOptimizer([stepsize, regularization, ...])

Quantum natural SPSA (QNSPSA) optimizer.

RiemannianGradientOptimizer(circuit[, ...])

Riemannian gradient optimizer.

RotosolveOptimizer([substep_optimizer, ...])

Rotosolve gradient-free optimizer.

RotoselectOptimizer([possible_generators])

Rotoselect gradient-free optimizer.

ShotAdaptiveOptimizer(min_shots[, ...])

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

SPSAOptimizer([maxiter, alpha, gamma, c, A, a])

The Simultaneous Perturbation Stochastic Approximation method (SPSA) is a stochastic approximation algorithm for optimizing cost functions whose evaluation may involve noise.

QNGOptimizerQJIT([stepsize, approx, lam])

Optax-like and jax.jit/qp.qjit-compatible implementation of the QNGOptimizer, a step- and parameter-dependent learning rate optimizer, leveraging a reparameterization of the optimization space based on the Fubini-Study metric tensor.

MomentumQNGOptimizerQJIT([stepsize, ...])

Optax-like and jax.jit/qp.qjit-compatible implementation of the MomentumQNGOptimizer, a generalized Quantum Natural Gradient (QNG) optimizer considering a discrete-time Langevin equation with QNG force.

ClassicalShadow(bits, recipes[, wire_map])

Class for classical shadow post-processing expectation values, approximate states, and entropies.

FromBloq(bloq, wires)

An adapter for using a Qualtran Bloq as a PennyLane Operation.

NoiseModel(model_map[, meas_map])

Builds a noise model based on the mappings of conditionals to callables that define noise operations using some optional metadata.

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.

Contents

Using PennyLane

Release news

Development

API

Internals