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 a queuing context. |
|
A decorator for just-in-time compilation of hybrid quantum programs in PennyLane. |
|
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. |
|
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. |
|
Provides the specifications of a quantum circuit. |
|
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. |
|
Create a method that applies a controlled version of the provided op. |
|
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\) of length \(m = \min(r, 2d-1)\) where \(d=\lceil\log_2(D)\rceil\). |
|
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. |
|
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. |
|
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. |
|
Decomposes a quantum circuit into a user-specified gate set. |
|
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 |
|
This method is dispatched and its functionality depends on the type of the input |
|
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 |
|
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. |
|
|
Cut up a quantum circuit into smaller circuit fragments. |
|
Cut up a circuit containing sample measurements into smaller fragments using a Monte Carlo method. |
|
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. |
|
|
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. |
|
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. |
|
Configuration class. |
|
Prepares a thermal state. |
|
Quadratic phase shift. |
|
Prepares a cat state. |
|
Cubic phase shift. |
|
Controlled addition operation. |
|
Prepare subsystems in a given Gaussian state. |
|
Prepare subsystems using the given ket vector in the Fock basis. |
|
Prepares a displaced squeezed vacuum state. |
|
Phase space displacement. |
|
Kerr interaction. |
|
Phase space squeezing. |
|
Beamsplitter interaction. |
|
An arbitrary second-order polynomial observable. |
|
The tensor product of the |
|
Cross-Kerr interaction. |
|
The position quadrature observable \(\hat{x}\). |
|
A linear interferometer transforming the bosonic operators according to the unitary matrix \(U\). |
|
The photon number observable \(\langle \hat{n}\rangle\). |
|
The generalized quadrature observable \(\x_\phi = \x cos\phi+\p\sin\phi\). |
|
Controlled phase operation. |
|
The momentum quadrature observable \(\hat{p}\). |
|
Prepares a single Fock state. |
|
Prepares a coherent state. |
|
Phase space rotation. |
|
Prepare subsystems using the given density matrix in the Fock basis. |
|
Phase space two-mode squeezing. |
|
Prepares a squeezed vacuum state. |
|
The number state observable \(\ket{n}\bra{n}\). |
|
The single-qubit Square-Root X operator. |
|
The swap operator |
|
A qubit controlled phase shift. |
alias of |
|
|
Arbitrary single qubit local phase shift |
|
Apply a controlled Pauli X gate using integer comparison as the condition. |
|
Double excitation rotation. |
|
Single excitation rotation with positive phase-shift outside the rotation subspace. |
|
Fermionic SWAP rotation. |
|
The Barrier operator, used to separate the compilation process into blocks or as a visual tool. |
|
The Pauli X operator |
|
Ising YY coupling gate |
|
A qubit controlled phase shift. |
|
The i-swap operator |
|
Prepare subsystems using a state vector in the computational basis. |
|
The single-qubit T gate |
|
Spin-adapted spatial orbital rotation. |
|
The single qubit Z rotation |
|
Arbitrary single qubit rotation |
|
Single excitation rotation with negative phase-shift outside the rotation subspace. |
|
The Pauli Y operator |
|
The Pauli Z operator |
|
An echoed RZX(\(\pi/2\)) gate. |
|
U2 gate. |
|
The single-qubit phase gate |
|
A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format. |
alias of |
|
|
The Identity operator |
|
Double excitation rotation with negative phase-shift outside the rotation subspace. |
|
Apply an arbitrary unitary matrix with a dimension that is a power of two. |
|
Apply the |
|
Arbitrary Pauli word rotation. |
|
Apply a |
|
A global phase operation that multiplies all components of the state by \(e^{-i \phi}\). |
|
A projector-controlled phase gate. |
|
Ising XX coupling gate |
|
Gate from the group \(SU(N)\) with \(N=2^n\) for \(n\) qubits. |
|
Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block. |
|
Ising ZZ coupling gate |
|
Arbitrary multi Z rotation. |
|
The Snapshot operation saves the internal execution state of the quantum function at a specific point in the execution pipeline. |
alias of |
|
|
Phase SWAP gate |
|
A qubit controlled phase shift. |
|
Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two. |
|
Observable corresponding to the state projector \(P=\ket{\phi}\bra{\phi}\). |
|
The single qubit X rotation |
|
U1 gate. |
|
Single excitation rotation. |
|
Prepare subsystems using the given density matrix. |
alias of |
|
|
Arbitrary single qubit unitary. |
|
An arbitrary Hermitian observable. |
|
The square root of i-swap operator. |
|
The wire cut operation, used to manually mark locations for wire cuts. |
|
The Hadamard operator |
|
Ising (XX + YY) coupling gate |
|
Double excitation rotation with positive phase-shift outside the rotation subspace. |
alias of |
|
|
Prepares a single computational basis state. |
|
The single qubit Y rotation |
|
CCZ (controlled-controlled-Z) gate. |
|
The controlled-RZ operator |
|
Toffoli (controlled-controlled-X) gate. |
|
The controlled-Z operator |
|
The controlled-swap operator |
|
The controlled-Rot operator |
alias of |
|
|
The controlled-Y operator |
|
The controlled-NOT operator |
|
A qubit controlled phase shift. |
|
The controlled-RY operator |
|
Apply a |
|
The controlled-RX operator |
|
Apply an arbitrary fixed unitary matrix |
|
The controlled-Hadamard operator |
|
Prepares a single computational basis state for a qutrit system. |
|
The Gell-Mann observables for qutrits |
|
The ternary Hadamard operator |
|
Apply an arbitrary, fixed unitary matrix. |
|
Single-qutrit trit flip error channel, used for applying "bit flips" on each qutrit subspace. |
|
The ternary swap operator. |
|
The single qutrit Y rotation |
|
Apply an arbitrary fixed unitary to |
|
The single qutrit X rotation |
|
An arbitrary Hermitian observable for qutrits. |
|
The single qutrit Z rotation |
|
The 2-qutrit controlled add gate |
|
Apply an arbitrary fixed qutrit channel. |
|
Single-qutrit symmetrically depolarizing error channel. |
|
The qutrit shift operator |
|
Ternary Clock gate |
|
Single-qutrit amplitude damping error channel. |
|
Single-qubit bit flip (Pauli \(X\)) error channel. |
|
Single-qubit Reset error channel. |
|
Apply an arbitrary fixed quantum channel. |
|
Single-qubit phase damping error channel. |
|
Thermal relaxation error channel. |
|
Single-qubit generalized amplitude damping error channel. |
|
Pauli operator error channel for an arbitrary number of qubits. |
|
Single-qubit amplitude damping error channel. |
|
Single-qubit bit flip (Pauli \(Z\)) error channel. |
|
Single-qubit symmetrically depolarizing error channel. |
alias of |
|
|
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\) binary features into a basis state of \(n\) qubits. |
|
Encodes \(N\) features into the displacement amplitudes \(r\) or phases \(\phi\) of \(M\) modes, where \(N\leq M\). |
|
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). |
|
Encodes \(N\) features into the squeezing amplitudes \(r \geq 0\) or phases \(\phi \in [0, 2\pi)\) of \(M\) modes, where \(N\leq M\). |
|
Layers consisting of one-parameter single-qubit rotations on each qubit, followed by a closed chain or ring of CNOT gates. |
|
A sequence of layers of a continuous-variable quantum neural network, as specified in Killoran et al. (2019). |
|
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 a basis state on the given wires using a sequence of TShift gates. |
|
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. |
|
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. |
|
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. |
|
General linear interferometer, an array of beamsplitters and phase shifters. |
|
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. |
|
Performs the quantum Monte Carlo estimation algorithm. |
|
Construct a unitary with the fast approximate block encoding method. |
|
The |
|
A QRAM implementation comprising |
|
Implements a block-encoding of a linear combination of unitaries. |
|
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. |
|
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. |
|
Performs the out-place modular addition operation. |
|
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: |
alias of |
|
|
The |
|
Represents a quantum node in the hybrid computational graph. |
|
A sequence of transforms to be applied to a quantum function or a |
alias of |
|
|
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. |
Variables¶
Implements a circuit that performs an exact single-body basis rotation using Givens rotations and phase shifts. |