Path: blob/main/notebooks/quantum-machine-learning/pqc.ipynb
3855 views
Parameterized quantum circuits
In this section, we introduce parameterized quantum circuits, then describe their properties and implement some examples used in quantum machine learning.
Introduction
Parameterized quantum circuits, where the gates are defined through tunable parameters, are a fundamental building block of near-term quantum machine learning algorithms. In the literature, depending on the context, parameterized quantum circuits are also called parameterized trial states, variational forms, or ansatzes.
Here is an example of a simple parameterized circuit, with two parameterized gates, a single-qubit -rotation gate, with a variable rotation , followed by a two-qubit controlled -rotation gate, with the same variable rotation :
We can create the parameterized circuit above using the QuantumCircuit and Parameter classes. The Parameter class lets us add rotation gates, without having to specify what the angles are yet:
If we want the gates to have different parameters, we can use two Parameters, or we create a ParameterVector, which acts like a list of Parameters:
As all quantum gates used in a quantum circuit are unitary, a parameterized circuit itself can be described as a unitary operation on qubits, , acting on some initial state , often set to . The resulting parameterized quantum state is where is a set of tunable parameters.
Quick quiz
Why are parameterized quantum circuits useful for near-term machine learning algorithms?
Parameterized quantum circuits offer a way to implement algorithms on near-term quantum devices.
Parameterized quantum circuits cannot be used to encode classical data.
Parameterized quantum circuits cannot express complex quantum states.
Parameterized quantum circuit properties
How do we choose one parameterized circuit over the other? To use parameterized quantum circuits as a machine learning model, we need them to generalize well. This means that the circuit should be able to generate a significant subset of the states within the output Hilbert space. To avoid being easy to simulate on a classical computer, the circuit should also entangle qubits.
In Reference 1, the authors propose the measures of expressibility and entangling capability to discriminate between different parameterized quantum circuits. We can think of the expressibility of a circuit as the extent to which it can generate states within the Hilbert space, while the entangling capability of a circuit describes its ability to generate entangled states.
Expressibility
The expressibility of a parameterized quantum circuit is essentially the coverage of the Hilbert space by the circuit's hypothesis space. Highly expressive parameterized quantum circuits can represent many different unitaries. There are many ways to represent this expressibility, one such example can be found in Reference 1. Here the authors quantify it by computing the extent to which the states generated from the circuit deviate from the uniform distribution.
Let's compare the two following single-qubit circuits to get a sense of what it means for a circuit to be expressible or not, by sampling 2000 output states for each circuit and plotting them on a Bloch sphere.
Exploring expressibility
For Circuit A, we see output states distributed about the equator of the Bloch sphere. With Circuit B's additional parameterized -rotation gate, we can cover all the Bloch sphere with output states, but the coverage is not uniform; there are concentrations of points on the and poles of the Bloch sphere.
Expressibility is a way to quantify what we just observed for these single-qubit circuits. Circuit A would have a low expressibility score due to the limited set of states it can explore, whereas Circuit B would have a high expressibility score.
Extra code
Code to produce the Bloch sphere plots used in the exercise above
Entangling capability
Entanglement is a key resource in quantum computing. The Meyer-Wallach measure is one of many metrics that measures how entangled a given state is. The Meyer-Wallach measure of an unentangled product state is 0, while the Meyer-Wallach measure of a highly entangled state, such as the Bell state, is 1. In Reference 1, the authors define the entangling capability of a parameterized quantum circuit as the average Meyer-Wallach measure for the states it can generate.
For example, consider the following multi-qubit parameterized circuits:
Circuit A has no entangling operations, that is, no two-qubit gates, so it has no entangling capability. Thus, this circuit would produce states that have Meyer-Wallach measures of 0, leading to an averaged value of 0. Circuit B has several two-qubit gates, so it can generate quantum states with some entanglement. Therefore, the average Meyer-Wallach measure would be greater than 0.
Using these two parameterized quantum circuit descriptors, expressibility and entangling capability, we can identify circuits that have limited capabilities. We expect that limited circuits are poor candidates for quantum machine learning applications. Reference 2 investigates this for the variational quantum classifier; and for its datasets and parameterized circuits, it finds that there is a strong correlation between classification accuracy and expressibility, and a weak correlation between classification accuracy entangling capability.
Hardware efficiency
In this era of near term quantum computing, where devices have limited qubit connectivity, coherence times and gate fidelities, the depth of the circuits we run directly affects the accuracy of our results, since there is limited error correction or mitigation.
Reference 3 introduces a class of hardware efficient parameterized circuits to accommodate device constraints. The common trait of these circuits is the use of a limited set of quantum gates as well as a particular qubit connection topology. The gate set usually consists of one two-qubit entangling gate and up to three single-qubit gates. The circuit is then constructed from blocks of single-qubit gates and entangling gates, which are applied to multiple or all qubits in parallel. One sequence of a single-qubit and an entangling block is called a layer, and the parameterized circuit generally has multiple layers.
Circuit B depicted in the 'Entangling Capability' section (also shown below) is an example of a single layer hardware efficient parameterized circuit.
Quick quiz
Parameterized quantum circuits for machine learning
In quantum machine learning, parameterized quantum circuits tend to be used for two things:
To encode data, where the parameters are determined by the data being encoded
As a quantum model, where the parameters are determined by an optimization process.
Here we will give some examples of how to build parameterized quantum circuits used in the quantum machine learning literature using Qiskit.
In Reference 4, the authors introduce the following parameterized circuit, used to encode data, which we will study in detail later:
which contains layers of Hadamard gates interleaved with entangling blocks, . This unitary was chosen because it is classically difficult to compute, but tractable on near term hardware. Within the entangling blocks, : denotes the Pauli matrices, the index describes connectivity between different qubits: , and the data mapping function is
Specifically, they use , which in Qiskit is the ZZFeatureMap circuit:
In Reference 4, the authors also use a hardware efficient circuit as a quantum model, consisting of alternating layers of single-qubit rotation gates, followed by two-qubit gates. In particular, they use -and--rotation gates, and controlled- gates, which we can build using the TwoLocal circuit:
The TwoLocal circuit in Qiskit can create many parameterized circuits, such as circuit 13 in Reference 1:
Qiskit's NLocal circuit can also create more general parameterized circuits with alternating rotation and entanglement layers.
Here is a NLocal circuit, with a rotation block on 2 qubits and an entanglement block on 4 qubits using linear entanglement:
Try it
Try build your own parameterized quantum circuit using one of the NLocal Circuits or Data Encoding Circuits in the Qiskit Circuit Library in the IBM Quantum Lab.
References
Sukin Sim, Peter D. Johnson and Alan Aspuru-Guzik, Expressibility and entangling capability of parameterized quantum circuits for hybrid quantum-classical algorithms, Advanced Quantum Technology 2 (2019) 1900070, doi:10.1002/qute.201900070, arXiv:1905.10876.
Thomas Hubregtsen, Josef Pichlmeier, and Koen Bertels, Evaluation of Parameterized Quantum Circuits: On the Design, and the Relation between Classification Accuracy, Expressibility and Entangling Capability 2020, arXiv:2003.09887.
Abhinav Kandala, Antonio Mezzacapo, Kristan Temme, Maika Takita, Markus Brink, Jerry M. Chow and Jay M. Gambetta, Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets, Nature 549, 242–246 (2017), doi.org/10.1038/nature23879, arXiv:1704.05018
Vojtech Havlicek, Antonio D. Córcoles, Kristan Temme, Aram W. Harrow, Abhinav Kandala, Jerry M. Chow and Jay M. Gambetta, Supervised learning with quantum enhanced feature spaces, Nature 567, 209-212 (2019), doi.org:10.1038/s41586-019-0980-2, arXiv:1804.11326.