qml.templates¶
This module provides a growing library of templates of common variational circuit architectures that can be used to easily build, evaluate, and train quantum nodes.
Embeddings¶
Embeddings are templates encode features (i.e., classical data) into a quantum state. They can optionally be repeated, and may contain trainable parameters. Embeddings are typically used at the beginning of a circuit.
Functions¶
|
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. |
|
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¶
Layers are trainable templates that are typically repeated, using different adjustable parameters in each repetition. They implement a transformation from a quantum state to another quantum state.
Functions¶
|
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 arXiv:1806.06871. |
|
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.(2020).. |
|
Layers consisting of single qubit rotations and entanglers, inspired by the circuit-centric classifier design arXiv:1804.00633. |
Subroutines¶
Subroutines are the most basic template, consisting of a collection of quantum operations, and not fulfilling any of the characteristics of other templates (i.e. to prepare a specific state, to be repeated or to encode features).
Functions¶
|
Applies the Trotterized time-evolution operator for an arbitrary Hamiltonian, expressed in terms of Pauli gates. |
|
Implements an arbitrary unitary on the specified wires. |
|
Circuit to exponentiate the tensor product of Pauli matrices representing the double-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
|
General linear interferometer, an array of beamsplitters and phase shifters. |
|
Applies a permutation to a set of 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. |
|
Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. |
State preperations¶
State preperations are templates that prepare a given quantum state, by decomposing it into elementary operations.
Functions¶
|
Implements an arbitrary state preparation on the specified wires. |
|
Prepares a basis state on the given wires using a sequence of Pauli X gates. |
|
Prepares an arbitrary state on the given wires using a decomposition into gates developed by Möttönen et al.(2004).. |
Custom templates¶
The template decorator can used to register a quantum function as a template.
Register a quantum template with PennyLane. |
Broadcasting function¶
The broadcast function creates a new template by broadcasting templates (or normal gates) over wires in a
predefined pattern. You can import this function both via qml.broadcast
and qml.templates.broadcast
.
|
Applies a unitary multiple times to a specific pattern of wires. |
Layering Function¶
The layer function creates a new template by repeatedly applying a sequence of quantum
gates to a set of wires. You can import this function both via
qml.layer
and qml.templates.layer
.
|
Repeatedly applies a unitary a given number of times. |
Utility functions for input checks¶
Utility functions provided for the templates. These are useful for standard input checks, for example to make sure that arguments have the right shape, range or type.
Functions¶
|
Check that the value of |
|
Checks that |
|
Check that all sequences in |
|
Check that the shape of |
|
Check that the shape of elements in the |
|
Check that the type of |
|
Checks that |
|
Turn |
Contents
Downloads