qml¶
This is the top level module from which all basic functions and classes of PennyLane can be directly imported.
Functions¶
|
Prints the information for pennylane installation. |
|
Globally registers new decomposition rules with an operator class. |
|
Insert operations according to a provided noise model. |
|
Create the adjoint of an Operator or a function that applies the adjoint of the provided function. |
|
Implements the adjoint method outlined in Jones to compute the metric tensor. |
|
Apply an instantiated operator or measurement to a queuing context. |
|
Applies the transform that performs a controlled version of the \(\mathcal{Q}\) unitary defined in this paper. |
|
Function to assert that two operators, measurements, or tapes are equal |
|
Transform a circuit to support an initial batch dimension for gate inputs. |
|
Transform a QNode to support an initial batch dimension for operation parameters. |
|
Create a batched partial callable object from the QNode specified. |
|
Convert a bosonic operator to a qubit operator using the standard-binary mapping. |
|
Reads a Qualtran Bloq signature and returns a dictionary mapping the Bloq's register names to |
|
Convert a fermionic operator to a qubit operator using the Bravyi-Kitaev mapping. |
A function which freezes execution and launches the PennyLane debugger (PLDB). |
|
|
Compute the center of a Lie algebra. |
|
Construct an operator that represents the product of the operators provided. |
|
Convert a bosonic operator to a qubit operator using the Christiansen mapping. |
|
The classical shadow measurement protocol. |
|
Decomposes a circuit into the Clifford+T basis. |
|
Compute commutator between two operators in PennyLane |
|
Construct the pairwise-commutation DAG (directed acyclic graph) representation of a quantum circuit. |
|
Compute commutator between two operators in PennyLane |
|
Compile a circuit by applying a series of transforms to a quantum function. |
|
Quantum-compatible if-else conditionals --- condition quantum operations on parameters such as the results of mid-circuit qubit measurements. |
|
Sample from the supplied observable, with the number of shots determined from QNode, returning the number of counts for each sample. |
|
Create a method that applies a controlled version of the provided op. |
|
Cut up a quantum circuit into smaller circuit fragments. |
|
Cut up a circuit containing sample measurements into smaller fragments using a Monte Carlo method. |
|
Compute the expectation value of an observable at the current point in the quantum circuit. |
|
Compute the probability distribution for the state at the current point in the quantum circuit. |
Compute the quantum state at the current point in the quantum circuit. |
|
Access the tape of the quantum circuit. |
|
|
Quantum function transform that substitutes operations conditioned on measurement outcomes to controlled operations. |
|
Quantum density matrix in the computational basis. |
|
Load a device and return the instance. |
|
Returns the dot product between the |
|
Create a function that draws the given QNode or quantum function. |
|
Draw a qnode with matplotlib |
|
Transform a QNode to into several one-shot tapes to support dynamic circuit execution. |
|
The eigenvalues of one or more operations. |
|
Function for determining operator, measurement, and tape equality. |
|
This method is dispatched and its functionality depends on the type of the input |
|
A function for executing a batch of tapes on a device with compatibility for auto-differentiation. |
|
Take the exponential of an Operator times a coefficient. |
|
Extrapolate to the zero-noise limit using an exponential model (\(Ae^{Bx} + C\)). |
|
Expectation value of the supplied observable. |
|
Differentiable circuit folding of the global unitary |
|
A |
|
Convert OpenFermion FermionOperator to PennyLane |
|
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. |
|
Converts an OpenQASM 3.0 circuit into a quantum function that can be used within a QNode. |
|
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. |
|
Returns the generator of an operation. |
|
Convert an external operator to a PennyLane operator. |
|
Insert an operation into specified points in an input circuit. |
|
Check if two operations are commuting using a lookup table. |
|
Check if the operation is hermitian. |
|
Check if the operation is unitary. |
|
Performs the iterative quantum phase estimation circuit. |
|
Returns the Jacobian as a callable function of vector-valued (functions of) QNodes. |
|
Convert a fermionic operator to a qubit operator using the Jordan-Wigner mapping. |
|
A |
|
Repeatedly applies a unitary a given number of times. |
|
Compute the (dynamical) Lie algebra from a set of generators. |
|
Lists all stored decomposition rules for an operator class. |
|
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. |
|
Perform a mid-circuit measurement in the computational basis on the supplied qubit. |
|
Returns a function that computes the metric tensor of a given QNode or quantum tape. |
|
Mitigate an input circuit using zero-noise extrapolation. |
|
Mutual information between the subsystems prior to measurement: |
|
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. |
|
Convert a fermionic operator to a qubit operator using the parity mapping. |
|
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 Hermitian matrix into a linear combination of Pauli operators. |
|
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}\). |
|
Extrapolator to \(f(0)\) for polynomial fit. |
|
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). |
|
Raise an Operator to a power. |
|
Probability of each computational basis state. |
|
Construct an operator which represents the generalized product of the operators provided. |
|
The purity of the system prior to measurement. |
|
A decorator for just-in-time compilation of hybrid quantum programs in PennyLane. |
|
Represents a quantum node in the hybrid computational graph. |
|
Implements the Quantum Singular Value Transformation (QSVT) for a matrix or Hamiltonian |
|
Applies the transform quantum Monte Carlo estimation algorithm. |
Scan installed PennyLane plugins to refresh the device list. |
|
|
Binds a condition to a decomposition rule for when it is applicable. |
|
Binds a quantum function to its required resources. |
|
Returns a dictionary that maps register names to |
|
Binds an operator type with additional resource parameters. |
|
Polynomial fit where the degree of the polynomial is fixed to being equal to the length of |
Transform a matrix product state (MPS) into its right-canonical form. |
|
|
Construct an operator which is the scalar product of the given scalar and operator provided. |
|
Sample from the supplied observable, with the number of shots determined from QNode, returning raw samples. |
|
Transform used to set or update a circuit's shots. |
|
Compute expectation values using classical shadows in a differentiable manner. |
|
Simplifies an operator, tape, qnode or quantum function by reducing its arithmetic depth or number of rotation parameters. |
|
This transform processes |
|
Resource information about a quantum circuit. |
|
Quantum state in the computational basis. |
|
Compute the structure constants that make up the adjoint representation of a Lie algebra. |
|
Construct an operator which is the sum of the given operators. |
Compute the generators \(\{\tau_1, \ldots, \tau_k\}\) for a Hamiltonian over the binary field \(\mathbb{Z}_2\). |
|
|
Transform a Hamiltonian with a Clifford operator and then taper qubits. |
|
Transform a gate operation with a Clifford operator and then taper qubits. |
|
Converts a PennyLane |
|
Convert a PennyLane operator to OpenFermion QubitOperator or FermionOperator. |
|
Convert a circuit to an OpenQASM 2.0 program. |
|
Generalizes a function that transforms tapes to work with additional circuit-like objects such as a |
|
Converts angles for quantum signal processing (QSP) and quantum singular value transformation (QSVT) routines. |
|
Generates higher order Suzuki-Trotter product formulas from a set of operations defined in a function. |
|
Convert a bosonic operator to a qubit operator using the unary mapping. |
|
Variance of the supplied observable. |
|
Returns the PennyLane version number. |
|
A |
|
Von Neumann entropy of the system prior to measurement. |
|
A |
Classes¶
|
Apply an approximate quantum Fourier transform (AQFT). |
|
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. |
|
Performs the in-place modular addition operation. |
|
Builds a quantum circuit to prepare correlated states of molecules by applying all |
|
Applies amplitude amplification. |
|
Single-qubit amplitude 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\). |
|
Applies the Trotterized time-evolution operator for an arbitrary Hamiltonian, expressed in terms of Pauli gates. |
|
Implements an arbitrary state preparation on the specified wires. |
|
Implements an arbitrary unitary on the specified wires. |
|
The Barrier operator, used to separate the compilation process into blocks or as a visual tool. |
|
Layers consisting of one-parameter single-qubit rotations on each qubit, followed by a closed chain or ring of CNOT gates. |
|
Encodes \(n\) binary features into a basis state of \(n\) qubits. |
|
Implements a circuit that performs an exact single-body basis rotation using Givens rotations and phase shifts. |
|
Prepares a single computational basis state. |
|
Beamsplitter interaction. |
|
Single-qubit bit flip (Pauli \(X\)) error channel. |
|
Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block. |
|
Wrapper for simple callables with Boolean output that can be manipulated and combined with bitwise operators. |
|
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. |
|
CCZ (controlled-controlled-Z) gate. |
|
The controlled-Hadamard operator |
|
The controlled-NOT operator |
alias of |
|
|
A qubit controlled phase shift. |
|
A qubit controlled phase shift. |
|
A qubit controlled phase shift. |
|
The controlled-RX operator |
|
The controlled-RY operator |
|
The controlled-RZ operator |
|
The controlled-Rot operator |
|
The controlled-swap operator |
|
A sequence of layers of a continuous-variable quantum neural network, as specified in Killoran et al. (2019). |
|
The controlled-Y operator |
|
The controlled-Z operator |
|
Prepares a cat state. |
|
Represents a quantum circuit as a directed acyclic graph. |
|
Class for classical shadow post-processing expectation values, approximate states, and entropies. |
|
Prepares a coherent state. |
|
Applies the time-evolution operator for a Hamiltonian expressed as a linear combination of mutually commuting Pauli words. |
|
Configuration class. |
|
Controlled addition operation. |
|
Controlled phase operation. |
|
A qubit controlled phase shift. |
|
Apply an arbitrary fixed unitary matrix |
|
Apply an arbitrary fixed unitary to |
|
Creates a sequence of controlled gates raised to decreasing powers of 2. |
|
Prepares an initial state with a cosine wave function. |
|
Cross-Kerr interaction. |
|
Cubic phase shift. |
|
Single-qubit symmetrically depolarizing error channel. |
|
Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two. |
|
Prepares a displaced squeezed vacuum state. |
|
Phase space displacement. |
|
Encodes \(N\) features into the displacement amplitudes \(r\) or phases \(\phi\) of \(M\) modes, where \(N\leq M\). |
|
Double excitation rotation. |
|
Double excitation rotation with negative phase-shift outside the rotation subspace. |
|
Double excitation rotation with positive phase-shift outside the rotation subspace. |
|
An echoed RZX(\(\pi/2\)) gate. |
alias of |
|
|
Construct a unitary with the fast approximate block encoding method. |
|
The fermionic annihilation operator \(a\) |
|
The fermionic creation operator \(a^{\dagger}\) |
|
Immutable dictionary used to represent a Fermi sentence, a linear combination of Fermi words, with the keys as FermiWord instances and the values correspond to coefficients. |
|
Immutable dictionary used to represent a Fermi word, a product of fermionic creation and annihilation operators, that can be constructed from a standard dictionary. |
|
Circuit to exponentiate the tensor product of Pauli matrices representing the double-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
Fermionic SWAP rotation. |
|
Circuit to exponentiate the tensor product of Pauli matrices representing the single-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
Flips the sign of a given basis state. |
|
Prepare subsystems using the given density matrix in the Fock basis. |
|
Prepares a single Fock state. |
|
The number state observable \(\ket{n}\bra{n}\). |
|
Prepare subsystems using the given ket vector in the Fock basis. |
|
An adapter for using a Qualtran Bloq as a PennyLane |
|
Implements the generalized quantum signal processing (GQSP) circuit. |
|
Implements a local, expressive, and quantum-number-preserving ansatz proposed by Anselmetti et al. (2021). |
|
Prepare subsystems in a given Gaussian state. |
|
The Gell-Mann observables for qutrits |
|
Single-qubit generalized amplitude damping error channel. |
|
A global phase operation that multiplies all components of the state by \(e^{-i \phi}\). |
|
Basic gradient-descent optimizer. |
|
Performs the Grover Diffusion Operator. |
alias of |
|
|
The Hadamard operator |
alias of |
|
|
An arbitrary Hermitian observable. |
|
Create a Hilbert-Schmidt template that can be used to compute the Hilbert-Schmidt Test (HST). |
alias of |
|
|
Encodes \(n\) features into \(n\) qubits using diagonal gates of an IQP circuit. |
|
The i-swap operator |
|
The Identity operator |
|
Apply a controlled Pauli X gate using integer comparison as the condition. |
|
General linear interferometer, an array of beamsplitters and phase shifters. |
|
A linear interferometer transforming the bosonic operators according to the unitary matrix \(U\). |
|
Ising XX coupling gate |
|
Ising (XX + YY) coupling gate |
|
Ising YY coupling gate |
|
Ising ZZ coupling gate |
|
Kerr interaction. |
|
Create a Local Hilbert-Schmidt template that can be used to compute the Local Hilbert-Schmidt Test (LHST). |
|
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. |
|
Prepares an initial state from a matrix product state (MPS) representation. |
|
Performs the out-place modular exponentiation operation. |
|
Gradient-descent optimizer with momentum. |
|
A generalization of the Quantum Natural Gradient (QNG) optimizer by considering a discrete-time Langevin equation with QNG force. |
|
Optax-like and |
|
Prepares an arbitrary state on the given wires using a decomposition into gates developed by Möttönen et al. (2004). |
|
Apply a |
|
Arbitrary multi Z rotation. |
|
Performs the in-place modular multiplication operation. |
|
Gradient-descent optimizer with Nesterov momentum. |
|
Builds a noise model based on the mappings of conditionals to callables that define noise operations using some optional metadata. |
|
The photon number observable \(\langle \hat{n}\rangle\). |
|
Spin-adapted spatial orbital rotation. |
|
Performs the out-place modular addition operation. |
|
Performs the out-place modular multiplication operation. |
|
Performs the out-of-place polynomial operation. |
|
A projector-controlled phase gate. |
|
Phase SWAP gate |
|
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. |
|
Pauli operator error channel for an arbitrary number of qubits. |
|
Arbitrary Pauli word rotation. |
|
The Pauli X operator |
|
The Pauli Y operator |
|
The Pauli Z operator |
|
Applies a permutation to a set of wires. |
|
Performs the in-place modular phase addition operation. |
|
Single-qubit phase damping error channel. |
|
Single-qubit bit flip (Pauli \(Z\)) error channel. |
|
Arbitrary single qubit local phase shift |
|
An arbitrary second-order polynomial observable. |
|
Implements a block-encoding of a linear combination of unitaries. |
|
Observable corresponding to the state projector \(P=\ket{\phi}\bra{\phi}\). |
|
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). |
|
An operation representing the QDrift approximation for the complex matrix exponential of a given Hamiltonian. |
|
Apply a quantum Fourier transform (QFT). |
|
Optimizer with adaptive learning rate, via calculation of the diagonal or block-diagonal approximation to the Fubini-Study metric tensor. |
|
Optax-like and |
|
Quantum natural SPSA (QNSPSA) optimizer. |
|
Represents a quantum node in the hybrid computational graph. |
|
Applies the QROM operator. |
|
Prepares a quantum state using Quantum Read-Only Memory (QROM). |
|
Implements the quantum singular value transformation (QSVT) circuit. |
|
The generalized quadrature observable \(\x_\phi = \x cos\phi+\p\sin\phi\). |
|
The momentum quadrature observable \(\hat{p}\). |
|
The position quadrature observable \(\hat{x}\). |
|
Quadratic phase shift. |
|
Performs the quantum Monte Carlo estimation algorithm. |
|
Performs the quantum phase estimation circuit. |
|
Apply the |
|
Apply an arbitrary fixed quantum channel. |
|
Prepare subsystems using the given density matrix. |
|
Apply a |
|
Apply an arbitrary unitary matrix with a dimension that is a power of two. |
|
Applies the Qubitization operator. |
Singleton global entry point for managing active recording contexts. |
|
|
Single-qutrit amplitude damping error channel. |
|
Prepares a single computational basis state for a qutrit system. |
|
Prepares a basis state on the given wires using a sequence of TShift gates. |
|
Apply an arbitrary fixed qutrit channel. |
|
Single-qutrit symmetrically depolarizing error channel. |
|
Apply an arbitrary, fixed unitary matrix. |
|
Root mean squared propagation optimizer. |
|
The single qubit X rotation |
|
The single qubit Y rotation |
|
The single qubit Z rotation |
|
Layers of randomly chosen single qubit rotations and 2-qubit entangling gates, acting on randomly chosen qubits. |
|
Apply a reflection about a state \(|\Psi\rangle\). |
|
Single-qubit Reset error channel. |
|
Riemannian gradient optimizer. |
|
Arbitrary single qubit rotation |
|
Phase space rotation. |
|
Rotoselect gradient-free optimizer. |
|
Rotosolve gradient-free optimizer. |
|
The single-qubit phase gate |
|
The square root of i-swap operator. |
|
The Simultaneous Perturbation Stochastic Approximation method (SPSA) is a stochastic approximation algorithm for optimizing cost functions whose evaluation may involve noise. |
alias of |
|
|
The swap operator |
|
The single-qubit Square-Root X operator. |
|
The |
|
Applies individual single-qubit Pauli rotations depending on the state of designated control qubits. |
|
This operator performs the plain addition of two integers \(x\) and \(y\) in the computational basis: |
|
Optimizer where the shot rate is adaptively calculated using the variances of the parameter-shift gradient. |
|
Layers consisting of a simplified 2-design architecture of Pauli-Y rotations and controlled-Z entanglers proposed in Cerezo et al. (2021). |
|
Single excitation rotation. |
|
Single excitation rotation with negative phase-shift outside the rotation subspace. |
|
Single excitation rotation with positive phase-shift outside the rotation subspace. |
|
The Snapshot operation saves the internal execution state of the quantum function at a specific point in the execution pipeline. |
|
A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format. |
|
Gate from the group \(SU(N)\) with \(N=2^n\) for \(n\) qubits. |
|
Prepares a squeezed vacuum state. |
|
Phase space squeezing. |
|
Encodes \(N\) features into the squeezing amplitudes \(r \geq 0\) or phases \(\phi \in [0, 2\pi)\) of \(M\) modes, where \(N\leq M\). |
|
Prepare subsystems using a state vector in the computational basis. |
|
Layers consisting of single qubit rotations and entanglers, inspired by the circuit-centric classifier design arXiv:1804.00633. |
|
Prepare a superposition of computational basis states. |
|
The single-qubit T gate |
|
The 2-qutrit controlled add gate |
|
Ternary Clock gate |
|
The ternary Hadamard operator |
|
An arbitrary Hermitian observable for qutrits. |
|
The single qutrit X rotation |
|
The single qutrit Y rotation |
|
The single qutrit Z rotation |
|
The ternary swap operator. |
|
The qutrit shift operator |
|
The TTN template broadcasts an input circuit across many wires following the architecture of a tree tensor network. |
|
The |
|
The tensor product of the |
|
Thermal relaxation error channel. |
|
Prepares a thermal state. |
|
Toffoli (controlled-controlled-X) gate. |
|
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. |
|
Single-qutrit trit flip error channel, used for applying "bit flips" on each qutrit subspace. |
|
An operation representing the Suzuki-Trotter product 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. |
|
Apply two-local gate operations using a canonical 2-complete linear (2-CCL) swap network. |
|
Phase space two-mode squeezing. |
|
U1 gate. |
|
U2 gate. |
|
Arbitrary single qubit unitary. |
|
Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
The wire cut operation, used to manually mark locations for wire cuts. |
alias of |
|
alias of |
|
alias of |
|
|
Returns the gradient as a callable function of hybrid quantum-classical functions. |
|
Implements the k-Unitary Pair Coupled-Cluster Generalized Singles and Doubles (k-UpCCGSD) ansatz. |
Variables¶
Configuration class. |
|
This class abstracts handling of a project's versions. |