Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
A Practical Guide to Quantum Machine Learning and Quantum Optimization

You're reading from   A Practical Guide to Quantum Machine Learning and Quantum Optimization Hands-on Approach to Modern Quantum Algorithms

Arrow left icon
Product type Paperback
Published in Mar 2023
Publisher Packt
ISBN-13 9781804613832
Length 680 pages
Edition 1st Edition
Arrow right icon
Authors (2):
Arrow left icon
Elías F. Combarro Fernández-Combarro Álvarez Elías F. Combarro Fernández-Combarro Álvarez
Author Profile Icon Elías F. Combarro Fernández-Combarro Álvarez
Elías F. Combarro Fernández-Combarro Álvarez
Samuel González Castillo Samuel González Castillo
Author Profile Icon Samuel González Castillo
Samuel González Castillo
Arrow right icon
View More author details
Toc

Table of Contents (27) Chapters Close

Preface 1. Part I: I, for One, Welcome our New Quantum Overlords
2. Chapter 1: Foundations of Quantum Computing FREE CHAPTER 3. Chapter 2: The Tools of the Trade in Quantum Computing 4. Part II: When Time is Gold: Tools for Quantum Optimization
5. Chapter 3: Working with Quadratic Unconstrained Binary Optimization Problems 6. Chapter 4: Adiabatic Quantum Computing and Quantum Annealing 7. Chapter 5: QAOA: Quantum Approximate Optimization Algorithm 8. Chapter 6: GAS: Grover Adaptive Search 9. Chapter 7: VQE: Variational Quantum Eigensolver 10. Part III: A Match Made in Heaven: Quantum Machine Learning
11. Chapter 8: What Is Quantum Machine Learning? 12. Chapter 9: Quantum Support Vector Machines 13. Chapter 10: Quantum Neural Networks 14. Chapter 11: The Best of Both Worlds: Hybrid Architectures 15. Chapter 12: Quantum Generative Adversarial Networks 16. Part IV: Afterword and Appendices
17. Chapter 13: Afterword: The Future of Quantum Computing
18. Assessments 19. Bibliography
20. Index
21. Other Books You May Enjoy Appendix A: Complex Numbers
1. Appendix B: Basic Linear Algebra 2. Appendix C: Computational Complexity 3. Appendix D: Installing the Tools 4. Appendix E: Production Notes

1.5 Working with multiple qubits and universality

Now that we have mastered working with two-qubit systems, it will be fairly straightforward to generalize all the notions that we have been studying to the case in which the number of qubits in our circuits is arbitrarily big. You know the drill: we will start by defining, mathematically, what a multi-qubit system is, we will then learn how to measure it and, finally, we will introduce quantum gates that act on many qubits at the same time.

1.5.1 Multi-qubit systems

With all that we have learned so far, it will now be very easy to understand how to work with multi-qubit systems.

As you may have already deduced, if we have qubits, the states that constitute the computational basis are

\begin{matrix} {\left| 0 \right\rangle \otimes \left| 0 \right\rangle \otimes \cdots \otimes \left| 0 \right\rangle,} & \\ {\left| 0 \right\rangle \otimes \left| 0 \right\rangle \otimes \cdots \otimes \left| 1 \right\rangle,} & \\ {\vdots} & \\ {\left| 1 \right\rangle \otimes \left| 1 \right\rangle \otimes \cdots \otimes \left| 1 \right\rangle.} & \\ \end{matrix}

We usually omit the symbol to write

\begin{matrix} {\left| 0 \right\rangle\left| 0 \right\rangle\cdots\left| 0 \right\rangle,} & \\ {\left| 0 \right\rangle\left| 0 \right\rangle\cdots\left| 1 \right\rangle,} & \\ {\left| 1 \right\rangle\left| 1 \right\rangle\cdots\left| 1 \right\rangle} & \\ \end{matrix}

or

\left| {00\cdots 0} \right\rangle,\left| {00\cdots 1} \right\rangle,\ldots,\left| {11\cdots 1} \right\rangle

or simply

\left| 0 \right\rangle,\left| 1 \right\rangle,\ldots,\left| {2^{n} - 1} \right\rangle.

Important note

When using the notation for basis states, the total number of qubits must be clear from context. Otherwise, a state like, for example, might mean either , , , or any string with leading zeroes and ending in …and that would be an intolerable ambiguity!

Of course, a generic state of the system will then be of the form

\left| \psi \right\rangle = a_{0}\left| 0 \right\rangle + a_{1}\left| 1 \right\rangle + \ldots + a_{2^{n} - 1}\left| {2^{n} - 1} \right\rangle

subject to the only condition that the amplitudes should be complex numbers such that . Our dear old friend, the normalization condition!

To learn more

Notice that the number of parameters describing the general state of an -qubit system is exponential in . For highly entangled states, we do not know how to represent all this information in a more succinct way and it is strongly suspected that it is not possible. Part of the power of quantum computing comes from this possibility of implicitly working with complex numbers by manipulating just qubits.

Exercise 1.18

Check that the basis state is represented by a -dimensional column vector whose -th component is 1, while the rest are 0 (Hint: Use, repeatedly, the expression for the tensor product of column vectors that we discussed in Section 1.4.1 and the fact that the tensor product is associative). Deduce that any -qubit state can be represented by a -dimensional column vector with unit length.

If we decide to measure all the qubits of the system in the computational basis, we will obtain with probability . If that is the case, then the state will collapse to . But if we only measure one of the qubits, say the -th one, then we will obtain with probability

\sum\limits_{l \in J_{0}}\left| a_{l} \right|^{2},

where is the set of numbers whose -th bit is . In this scenario, the state of the system after measuring would be

\frac{\sum\limits_{l \in J_{0}}a_{l}\left| l \right\rangle}{\sqrt{\sum\limits_{l \in J_{0}}\left| a_{i} \right|^{2}}}.

Exercise 1.19

Derive the formulas for the case in which the result of the measurement is .

Exercise 1.20

What is the probability of getting when we measure the second qubit of ? What will the state be after the measurement if we indeed get ?

Computing inner products of -qubit systems in Dirac notation is very similar to doing it with two-qubit systems. The procedure is analogous to the one we showed in Section 1.4.1, but taking into account that

\left( {\left\langle \psi_{1} \right| \otimes \ldots \otimes \left\langle \psi_{n} \right|} \right)\left( {\left| \varphi_{1} \right\rangle \otimes \ldots \otimes \left| \varphi_{n} \right\rangle} \right) = \left\langle \psi_{1} \middle| \varphi_{1} \right\rangle\ldots\left\langle \psi_{n} \middle| \varphi_{n} \right\rangle.

Exercise 1.21

Compute the inner product of and , where and are both binary strings of length . Use your result to prove that is, indeed, an orthonormal basis.

Exercise 1.22

Compute the inner product of the states and .

We can now turn to the question of how to operate on many qubits at once. Let's define multi-qubit gates!

1.5.2 Multi-qubit gates

Since -qubit states are represented by -dimensional column vectors, -qubit gates can be identified with unitary matrices. Similar to the two-qubit case, we can construct -qubit gates by taking the tensor product of gates on a smaller number of qubits. Namely, if is an -qubit gate and is an -qubit gate, then is an -qubit gate and its matrix is given by the tensor product of the matrices and .

To learn more

The expression for the tensor product of two matrices and is

\begin{pmatrix} a_{11} & {\ldots} & a_{1q} \\ {\vdots} & \ddots & {\vdots} \\ a_{p1} & {\ldots} & a_{pq} \\ \end{pmatrix} \otimes B = \begin{pmatrix} {a_{11}B} & {\ldots} & {a_{1q}B} \\ {\vdots} & \ddots & {\vdots} \\ {a_{p1}B} & {\ldots} & {a_{pq}B} \\ \end{pmatrix}.

However, there are -qubit gates that cannot be constructed as tensor products of smaller gates. One such example is the Toffoli or CCNOT gate, a three-qubit gate that acts on the computational basis as

\text{CCNOT}\left| x \right\rangle\left| y \right\rangle\left| z \right\rangle = \left| x \right\rangle\left| y \right\rangle\left| {z \oplus \left( {x \land y} \right)} \right\rangle,

where is the XOR function and is the symbol for the AND Boolean function. Thus, CCNOT applies a doubly controlled (in this case, by the first two qubits) NOT gate to the third qubit — hence the name!

Exercise 1.23

Obtain the matrix for the CCNOT gate and verify that it is unitary.

The Toffoli gate is important because, using it and with the help of auxiliary qubits, we can construct any classical Boolean operator. For instance, (where is the negation of ) and . This shows that, with quantum circuits, we can simulate the behavior of any classical digital circuit at the cost of using some additional ancillary qubits, since any Boolean function can be built with just negations and conjunctions. This is somewhat surprising, because we know that all quantum gates are invertible, while not all Boolean functions are. It then follows that we could make all of our digital circuits reversible just by implementing a classical version of the Toffoli gate!

We will not be studying any other concrete examples of gates that act on three (or more!) qubits because, in fact, we can simulate their behavior with circuits that only use one- and two-qubit gates. Keep on reading to know how!

1.5.3 Universal gates in quantum computing

Current quantum computers can't implement every possible quantum gate. Instead, they rely on universality results that show how any unitary operation can be decomposed as a circuit that uses a reduced set of primitive gates. In previous sections, we mentioned, for instance, that any one-qubit gate can be obtained by using just and rotations. It turns out that similar results exist for the general case of -qubit quantum gates.

To us, it will be important to know that, for any unitary operation, we can construct a circuit that implements it using only one-qubit gates and the CNOT gate. For this reason, we say that those gates are universal — in the same sense that, for example, negation and conjunction are universal for Boolean logic. This fact will be crucial for our study of feature maps and variational forms in connection to quantum neural networks and other quantum machine learning models.

To learn more

In addition to one-qubit gates plus CNOT, there are many other sets of universal gates. For instance, it can be shown that the three gates , , and CNOT can be used to approximate any unitary operation to any desired accuracy — and they are universal in that sense. See Section 4.5 of the book by Nielsen and Chuang [69] for proofs of these facts and for more examples of universal gate sets.

To illustrate how CNOT and one-qubit gates can be used to implement any other quantum gate, the following circuit shows a possible decomposition of the Toffoli gate targeting the top qubit:

HTTTTHTTT††† .

Exercise 1.24

Verify that the preceding circuit implements the Toffoli gate by checking its action on the states of the computational basis.

This concludes our review of the fundamentals of quantum computing. We've come a long way since the beginning of this chapter, but by now we have mastered all the mathematics that we will need in order to study quantum machine learning and quantum optimization algorithms. Soon, we will see all these concepts in action!

You have been reading a chapter from
A Practical Guide to Quantum Machine Learning and Quantum Optimization
Published in: Mar 2023
Publisher: Packt
ISBN-13: 9781804613832
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image