qp¶
This is the top level module from which all basic functions and classes of PennyLane can be directly imported.
Functions¶
|
Apply an instantiated operator or measurement to the active program. |
|
A decorator for just-in-time compilation of hybrid quantum programs in PennyLane. |
|
Attaches a compiler hint to applicable functionality. |
|
A |
|
A |
|
Dynamically allocates new wires in-line, or as a context manager which also safely deallocates the new wires upon exiting the context. |
|
Deallocates wires that have previously been allocated with |
|
Binds a quantum function to its required resources. |
|
Binds a condition to a decomposition rule for when it is applicable. |
|
Globally registers new decomposition rules with an operator class. |
|
Lists all stored decomposition rules for an operator class. |
|
Excludes decomposition rules of an operator by name. |
|
Inspect the decomposition rules of an operator. |
|
Binds an operator type with additional resource parameters. |
|
Decomposes a Hermitian matrix into a linear combination of Pauli operators. |
|
Convert a fermionic operator to a qubit operator using the Jordan-Wigner mapping. |
|
Convert a fermionic operator to a qubit operator using the parity mapping. |
|
Convert a fermionic operator to a qubit operator using the Bravyi-Kitaev mapping. |
|
Convert a bosonic operator to a qubit operator using the standard-binary mapping. |
|
Convert a bosonic operator to a qubit operator using the unary mapping. |
|
Convert a bosonic operator to a qubit operator using the Christiansen mapping. |
|
Transform a Hamiltonian with a Clifford operator and then taper qubits. |
Compute the generators \(\{\tau_1, \ldots, \tau_k\}\) for a Hamiltonian over the binary field \(\mathbb{Z}_2\). |
|
|
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}\). |
|
Transform a gate operation with a Clifford operator and then taper qubits. |
|
Convert an external operator to a PennyLane operator. |
|
Convert OpenFermion FermionOperator to PennyLane |
|
Convert a PennyLane operator to OpenFermion QubitOperator or FermionOperator. |
|
A |
|
A |
|
Prints the information for pennylane installation. |
|
Returns a dictionary that maps register names to |
|
Sample from the supplied observable, with the number of shots determined from QNode, returning the number of counts for each sample. |
|
Quantum density matrix in the computational basis. |
|
Expectation value of the supplied observable. |
|
Probability of each computational basis state. |
|
Sample from the supplied observable, with the number of shots determined from QNode, returning raw samples. |
|
Quantum state in the computational basis. |
|
Variance of the supplied observable. |
|
Von Neumann entropy of the system prior to measurement. |
|
The purity of the system prior to measurement. |
|
Mutual information between the subsystems prior to measurement: |
|
The classical shadow measurement protocol. |
|
Estimate expectation values using Classical Shadows with full differentiability support. |
|
Perform a mid-circuit measurement in the computational basis on the supplied qubit. |
|
Perform a Pauli product measurement. |
|
Create the adjoint of an Operator or a function that applies the adjoint of the provided function. |
|
Construct a symbolic controlled operator or a function that applies controlled operators. |
|
Quantum-compatible if-else conditionals --- condition quantum operations on parameters such as the results of mid-circuit qubit measurements. |
|
Construct an operator that represents the product of the operators provided; particularly a compute-uncompute pattern. |
|
Take the exponential of an Operator times a coefficient. |
|
Construct an operator which is the sum of the given operators. |
|
Raise an Operator to a power. |
|
Construct an operator which represents the generalized product of the operators provided. |
|
Construct an operator which is the scalar product of the given scalar and operator provided. |
|
Repeatedly applies a unitary a given number of times. |
|
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. |
Transform a matrix product state (MPS) into its right-canonical form. |
|
|
Map \(D\) different bitstrings of length \(r\) to \(D\) different bitstrings \(b\). |
|
Select rows of a bit array of differing columns such that the stacked array of the selected rows still contains differing columns. |
|
Generates higher order Suzuki-Trotter product formulas from a set of operations defined in a function. |
|
Compute the size of the three registers that |
|
Return the wire counts required by |
|
Return the wire counts required by |
|
Return the wire counts required by |
|
Returns the sizes of the three wire registers required by |
|
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). |
|
Implements the Quantum Singular Value Transformation (QSVT) for a matrix or Hamiltonian |
|
Converts angles for quantum signal processing (QSP) and quantum singular value transformation (QSVT) routines. |
|
Represents a quantum node in the hybrid computational graph. |
|
A function for executing a batch of tapes on a device with compatibility for auto-differentiation. |
|
Transform used to set or update a circuit's shots. |
|
Mark a location in a compilation pipeline for easy access with inspectability. |
|
Provides a compile-time resource estimate of a quantum circuit, obtained by analyzing its intermediate representation at the specified compilation level. |
|
Provides a resource estimate of a quantum circuit with respect to the provided compilation target, via rapid analysis of decomposition pathways. |
|
Provides the specifications of a quantum circuit. |
|
Executes a quantum circuit and tracks the resources it uses. |
|
Generalizes a function that transforms tapes to work with additional circuit-like objects such as a |
|
Transform a QNode to support an initial batch dimension for operation parameters. |
|
Transform a circuit to support an initial batch dimension for gate inputs. |
|
Create a batched partial callable object from the QNode specified. |
|
Compile a circuit by applying a series of transforms to a quantum function. |
|
Decompose a quantum circuit toward a target gate set via Catalyst's graph-decomposition pass. |
|
Returns a |
|
Quantum function transform that substitutes operations conditioned on measurement outcomes to controlled operations. |
|
Transform a QNode to into several one-shot tapes to support dynamic circuit execution. |
|
Applies the transform quantum Monte Carlo estimation algorithm. |
|
Applies the transform that performs a controlled version of the \(\mathcal{Q}\) unitary defined in this paper. |
|
Construct the pairwise-commutation DAG (directed acyclic graph) representation of a quantum circuit. |
|
Function that applies the pattern matching algorithm and returns the list of maximal matches. |
|
Quantum function transform to optimize a circuit given a list of patterns (templates). |
|
Decomposes a circuit into the Clifford+T basis. |
|
Decomposes RZ and PhaseShift gates into the Clifford+T basis or the PPR basis. |
|
Insert operations according to a provided noise model. |
|
Insert an operation into specified points in an input circuit. |
|
Mitigate an input circuit using zero-noise extrapolation. |
|
Differentiable circuit folding of the global unitary |
|
Extrapolator to \(f(0)\) for polynomial fit. |
|
Polynomial fit where the degree of the polynomial is fixed to being equal to the length of |
|
Extrapolate to the zero-noise limit using an exponential model (\(Ae^{Bx} + C\)). |
|
Returns the dot product between the |
|
The eigenvalues of one or more operations. |
|
Function for determining operator, measurement, and tape equality. |
|
Function to assert that two operators, measurements, or tapes are equal |
|
Returns a new operator that computes the evolution of |
|
Returns the generator of an operation. |
|
Check if two operations are commuting using a lookup table. |
|
Check if the operation is hermitian. |
|
Check if the operation is unitary. |
|
Changes the wires of an operator, tape, qnode or quantum function according to the given wire map. |
|
The dense matrix representation of an operation or quantum circuit. |
|
Simplifies an operator, tape, qnode or quantum function by reducing its arithmetic depth or number of rotation parameters. |
|
Performs the iterative quantum phase estimation circuit. |
|
Compute commutator between two operators in PennyLane |
|
Compute commutator between two operators in PennyLane |
Returns the equivalent ZYZ rotation angles of a single-qubit operator. |
|
|
A decorator for turning a quantum function with registered resources into an |
|
Reconstruct an expectation value QNode along a single parameter direction. |
|
This transform processes |
A function which freezes execution and launches the PennyLane debugger (PLDB). |
|
|
Compute the expectation value of an observable at the current point in the quantum circuit. |
Compute the quantum state at the current point in the quantum circuit. |
|
|
Compute the probability distribution for the state at the current point in the quantum circuit. |
Access the tape of the quantum circuit. |
|
|
Returns a function that computes the metric tensor of a given QNode or quantum tape. |
|
Implements the adjoint method outlined in Jones to compute the metric tensor. |
|
Create a function that draws the given QNode or quantum function. |
|
Draw a qnode with matplotlib |
|
Loads pyQuil Program objects by using the converter in the PennyLane-Rigetti plugin. |
|
Loads quantum circuits from a QASM string using the converter in the PennyLane-Qiskit plugin. |
|
Convert a circuit to an OpenQASM 2.0 program. |
|
Converts a Qiskit QuantumCircuit into a PennyLane quantum function. |
|
Converts a Qiskit NoiseModel into a PennyLane |
|
Converts a Qiskit SparsePauliOp into a PennyLane |
|
Loads quantum circuits from a Quil string using the converter in the PennyLane-Rigetti plugin. |
|
Loads quantum circuits from a Quil file using the converter in the PennyLane-Rigetti plugin. |
|
Reads a Qualtran Bloq signature and returns a dictionary mapping the Bloq's register names to |
|
Converts an OpenQASM 3.0 circuit into a quantum function that can be used within a QNode. |
|
Converts a PennyLane |
|
Load a device and return the instance. |
Scan installed PennyLane plugins to refresh the device list. |
|
|
Declare the signature of a runtime symbol so it can be called by name. |
|
Call a declared runtime symbol, in-process or on the executor it is addressed to. |
|
Compute the (dynamical) Lie algebra from a set of generators. |
|
Compute the structure constants that make up the adjoint representation of a Lie algebra. |
|
Compute the center of a Lie algebra. |
|
Visualize a single QJIT compiled QNode, showing wire flow through quantum operations, program structure, and pass-by-pass impacts on compiled programs. |
Classes¶
|
Wrapper for simple callables with Boolean output that can be manipulated and combined with bitwise operators. |
Singleton global entry point for managing active recording contexts. |
|
|
The fermionic creation operator \(a^{\dagger}\) |
|
The fermionic annihilation operator \(a\) |
|
Immutable dictionary used to represent a Fermi word, a product of fermionic creation and annihilation operators, that can be constructed from a standard dictionary. |
|
Dictionary-based representation of a linear combination of |
|
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. |
|
Dictionary used to represent a Bose word, a product of bosonic creation and annihilation operators, that can be constructed from a standard dictionary. |
|
A compressed double-factorized (CDF) electronic Hamiltonian. |
|
A Christiansen greedy-fragmentation (CGF) vibrational Hamiltonian. |
|
A real-space vibronic Hamiltonian, given as dense Taylor coefficients per fragment. |
|
Returns the gradient as a callable function of hybrid quantum-classical functions. |
|
Returns the Jacobian as a callable function of vector-valued (functions of) QNodes. |
|
A |
|
Represents a quantum circuit as a directed acyclic graph. |
|
The square root of i-swap operator. |
|
The single qubit X rotation |
|
A Pauli product rotation (PPR) by the angle \(\pm\pi/2\). |
|
Apply the |
|
U1 gate. |
|
The Snapshot operation saves the internal execution state of the quantum function at a specific point in the execution pipeline. |
|
Observable corresponding to the state projector \(P=\ket{\phi}\bra{\phi}\). |
|
A qubit controlled phase shift. |
|
The Pauli X operator |
|
Double excitation rotation with negative phase-shift outside the rotation subspace. |
|
Arbitrary Pauli word rotation. |
|
Arbitrary single qubit rotation |
|
Ising (XX + YY) coupling gate |
|
Spin-adapted spatial orbital rotation. |
|
Arbitrary single qubit unitary. |
|
The Barrier operator, used to separate the compilation process into blocks or as a visual tool. |
|
Ising ZZ coupling gate |
|
Prepares a single computational basis state. |
|
A qubit controlled phase shift. |
|
An arbitrary Hermitian observable. |
|
Ising YY coupling gate |
|
A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format. |
|
The single-qubit T gate |
|
Ising XX coupling gate |
|
The Hadamard operator |
|
Double excitation rotation. |
|
Apply an arbitrary unitary matrix with a dimension that is a power of two. |
|
The single qubit Y rotation |
|
The swap operator |
|
The Pauli Y operator |
|
Gate from the group \(SU(N)\) with \(N=2^n\) for \(n\) qubits. |
|
The single-qubit Square-Root X operator. |
|
The Pauli Z operator |
|
Fermionic SWAP rotation. |
|
Prepare subsystems using a state vector in the computational basis. |
|
A non-Clifford Pauli product rotation (PPR) by the angle \(\pm\pi/8\). |
|
U2 gate. |
|
Single excitation rotation with negative phase-shift outside the rotation subspace. |
|
The single qubit Z rotation |
|
A Clifford Pauli product rotation (PPR) by the angle \(\pm\pi/4\). |
|
The single-qubit phase gate |
|
Apply a controlled Pauli X gate using integer comparison as the condition. |
|
Apply a |
|
A qubit controlled phase shift. |
|
Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block. |
|
A projector-controlled phase gate. |
|
The Identity operator |
|
Arbitrary single qubit local phase shift |
|
Single excitation rotation with positive phase-shift outside the rotation subspace. |
|
Arbitrary multi Z rotation. |
|
Single excitation rotation. |
|
The i-swap operator |
|
Phase SWAP gate |
|
A global phase operation that multiplies all components of the state by \(e^{-i \phi}\). |
|
An echoed RZX(\(\pi/2\)) gate. |
|
Prepare subsystems using the given density matrix. |
|
Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two. |
|
Double excitation rotation with positive phase-shift outside the rotation subspace. |
|
The controlled-RZ operator |
|
The controlled-RX operator |
|
The controlled-Z operator |
|
The controlled-NOT operator |
|
The controlled-swap operator |
|
Toffoli (controlled-controlled-X) gate. |
|
Apply an arbitrary fixed unitary matrix |
|
The controlled-RY operator |
|
The controlled-Rot operator |
|
A qubit controlled phase shift. |
|
The controlled-Hadamard operator |
|
CCZ (controlled-controlled-Z) gate. |
|
Apply a |
|
The controlled-Y operator |
|
Single-qubit bit flip (Pauli \(Z\)) error channel. |
|
Single-qubit amplitude damping error channel. |
|
Apply an arbitrary fixed quantum channel. |
|
Single-qubit generalized amplitude damping error channel. |
|
Pauli operator error channel for an arbitrary number of qubits. |
|
Single-qubit bit flip (Pauli \(X\)) error channel. |
|
Single-qubit symmetrically depolarizing error channel. |
|
Thermal relaxation error channel. |
|
Single-qubit Reset error channel. |
|
Single-qubit phase damping error channel. |
|
Encodes \(2^n\) features into the amplitude vector of \(n\) qubits. |
|
Encodes \(N\) features into the rotation angles of \(n\) qubits, where \(N \leq n\). |
|
Encodes \(n\) features into \(n\) qubits using diagonal gates of an IQP circuit. |
|
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). |
|
Layers consisting of one-parameter single-qubit rotations on each qubit, followed by a closed chain or ring of CNOT gates. |
|
Implements a local, expressive, and quantum-number-preserving ansatz proposed by Anselmetti et al. (2021). |
|
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. |
|
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. |
|
Layers of randomly chosen single qubit rotations and 2-qubit entangling gates, acting on randomly chosen qubits. |
|
Layers consisting of a simplified 2-design architecture of Pauli-Y rotations and controlled-Z entanglers proposed in Cerezo et al. (2021). |
|
Layers consisting of single qubit rotations and entanglers, inspired by the circuit-centric classifier design arXiv:1804.00633. |
|
The MERA template broadcasts an input circuit across many wires following the architecture of a multi-scale entanglement renormalization ansatz tensor network. |
|
The MPS template broadcasts an input circuit across many wires following the architecture of a Matrix Product State tensor network. |
|
The TTN template broadcasts an input circuit across many wires following the architecture of a tree tensor network. |
|
Apply two-local gate operations using a canonical 2-complete linear (2-CCL) swap network. |
|
Implements an arbitrary state preparation on the specified wires. |
|
Prepares an initial state with a cosine wave function. |
|
Prepares an arbitrary state on the given wires using a decomposition into gates developed by Möttönen et al. (2004). |
|
Prepare a superposition of computational basis states. |
|
Prepares a quantum state using Quantum Read-Only Memory (QROM). |
|
Prepares an initial state from a matrix product state (MPS) representation. |
|
Prepares a quantum state using multiplexed rotations. |
|
Prepare an arbitrary quantum state with the sum-of-Slaters technique. |
|
Prepare a sparse quantum state with the partial unary iteration technique. |
|
Classical algorithm that finds the isometry circuit and bijection for |
|
Prepares a phase gradient state. |
|
Implements an arbitrary unitary on the specified wires. |
|
Applies the Trotterized time-evolution operator for an arbitrary Hamiltonian, expressed in terms of Pauli gates. |
|
Bucket-brigade QRAM with explicit bus routing using 3 wires per node. |
|
Applies the time-evolution operator for a Hamiltonian expressed as a linear combination of mutually commuting Pauli words. |
|
An operation representing the QDrift approximation for the complex matrix exponential of a given Hamiltonian. |
|
Second-order Trotter time evolution for a Compressed Double Factorization (CDF) Hamiltonian. |
|
Second-order Trotter time evolution for a Christiansen Greedy Fragmentation (CGF) Hamiltonian. |
|
An operation representing the Suzuki-Trotter product approximation applied to a set of operations defined in a function. |
|
An operation representing the Suzuki-Trotter product approximation for the complex matrix exponential of a given Hamiltonian. |
|
Second-order Trotter circuit for vibronic Hamiltonian simulation using phase-gradient arithmetic. |
|
Increment the input |
|
This operator performs an inequality test between a quantum register \(\lvert x\rangle\) and a classical integer \(\mathrm{value}\), storing the result in a target qubit. |
|
Perform an inequality test \(\lvert x\rangle\lvert y\rangle\lvert 0\rangle \mapsto \lvert x\rangle \lvert y\rangle\lvert x \leq y\rangle\) between two states in separate quantum registers. |
|
A template that builds an Instantaneous Quantum Polynomial (IQP) circuit. |
|
Applies a permutation to a set of wires. |
|
Apply a quantum Fourier transform (QFT). |
|
Performs the quantum phase estimation circuit. |
|
Performs the Grover Diffusion Operator. |
|
Create a Hilbert-Schmidt template that can be used to compute the Hilbert-Schmidt Test (HST). |
|
A QRAM implementation that provides a width-depth tradeoff by combining behaviour from |
|
Create a Local Hilbert-Schmidt template that can be used to compute the Local Hilbert-Schmidt Test (LHST). |
|
Flips the sign of a given basis state. |
|
Implements a circuit that performs an exact single-body basis rotation using Givens rotations and phase shifts. |
|
Performs the quantum Monte Carlo estimation algorithm. |
|
Construct a unitary with the fast approximate block encoding method. |
|
Performs a Fast Fermionic Fourier Transform (FFFT) operation based on arXiv:1310.7605. |
|
The two-qubit unitary operator that corresponds to a Fourier transform on fermions, encoded using a Jordan-Wigner transformation. |
|
The |
|
A QRAM implementation comprising |
|
Implements a block-encoding of a linear combination of unitaries. |
|
Conditionally applies PauliX gates according to a non-empty bitstring. |
|
Apply a reflection about a state \(|\Psi\rangle\). |
|
Applies the Qubitization operator. |
|
Creates a sequence of controlled gates raised to decreasing powers of 2. |
|
Apply an approximate quantum Fourier transform (AQFT). |
|
Applies amplitude amplification. |
|
Applies the QROM operator. |
|
Prepare a state with real and positive amplitudes via coherent alias sampling. |
|
Coefficient oracle for tensor hypercontraction (THC) qubitization via coherent alias (Walker) sampling. |
|
Self-inverse Hamiltonian selection oracle for tensor hypercontraction (THC). |
|
Prepare the uniform superposition over the valid \((\mu, \nu)\) index pairs of the tensor hypercontraction (THC) representation. |
|
Apply the qubitization walk operator of a tensor hypercontracted (THC) Hamiltonian. |
|
Prepare a uniform superposition over the first |
|
Block-encoding of a one-body operator. |
|
Implements the generalized quantum signal processing (GQSP) circuit. |
|
Applies individual single-qubit Pauli rotations depending on the state of designated control qubits. |
|
Implements the quantum singular value transformation (QSVT) circuit. |
|
Circuit to exponentiate the tensor product of Pauli matrices representing the double-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
Circuit to exponentiate the tensor product of Pauli matrices representing the single-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
Builds a quantum circuit to prepare correlated states of molecules by applying all |
|
Implements the k-Unitary Pair Coupled-Cluster Generalized Singles and Doubles (k-UpCCGSD) ansatz. |
|
Performs the in-place modular phase addition operation. |
|
Performs the in-place modular addition operation. |
|
Performs the in-place modular multiplication operation. |
|
Performs the out-place modular multiplication operation. |
|
Implements signed out-place multiplication |
|
Performs the out-place modular addition operation. |
|
Performs out-of-place squaring. |
|
Performs out-of-place squaring of a signed integer. |
|
Performs the out-place modular exponentiation operation. |
|
Performs the out-of-place polynomial operation. |
|
This operator performs the plain addition of two integers \(x\) and \(y\) in the computational basis: |
|
The |
|
Flip-flop QRAM (FF-QRAM) with an even-superposition initialization. |
|
Represents a quantum node in the hybrid computational graph. |
|
A sequence of transforms to be applied to a quantum function or a |
|
Gradient-descent optimizer with past-gradient-dependent learning rate in each dimension. |
|
Gradient-descent optimizer with adaptive learning rate, first and second moment. |
|
Optimizer for building fully trained quantum circuits by adding gates adaptively. |
|
Basic gradient-descent optimizer. |
|
Gradient-descent optimizer with momentum. |
|
A generalization of the Quantum Natural Gradient (QNG) optimizer by considering a discrete-time Langevin equation with QNG force. |
|
Gradient-descent optimizer with Nesterov momentum. |
|
Root mean squared propagation optimizer. |
|
Optimizer with adaptive learning rate, via calculation of the diagonal or block-diagonal approximation to the Fubini-Study metric tensor. |
|
Quantum natural SPSA (QNSPSA) optimizer. |
|
Riemannian gradient optimizer. |
|
Rotosolve gradient-free optimizer. |
|
Rotoselect gradient-free optimizer. |
|
Optimizer where the shot rate is adaptively calculated using the variances of the parameter-shift gradient. |
|
The Simultaneous Perturbation Stochastic Approximation method (SPSA) is a stochastic approximation algorithm for optimizing cost functions whose evaluation may involve noise. |
|
Optax-like and |
|
Optax-like and |
|
Class for classical shadow post-processing expectation values, approximate states, and entropies. |
|
An adapter for using a Qualtran Bloq as a PennyLane |
|
Builds a noise model based on the mappings of conditionals to callables that define noise operations using some optional metadata. |
|
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. |
|
A device for heterogeneous compilation and execution over a backline placement. |
|
The node that controls the QPU and initiates data transfers. |
|
The node that runs a coprocessor function per received message. |
|
A precompiled function run on a |
|
The address the controller dials to bring up a connection to a coprocessor. |