Reader small image

You're reading from  A Practical Guide to Quantum Machine Learning and Quantum Optimization

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804613832
Edition1st Edition
Right arrow
Authors (2):
Elías F. Combarro
Elías F. Combarro
author image
Elías F. Combarro

Elías F. Combarro holds degrees from the University of Oviedo (Spain) in both Mathematics (1997, award for second highest grades in the country) and Computer Science (2002, award for highest grades in the country). After some research stays at the Novosibirsk State University (Russia), he obtained a Ph.D. in Mathematics (Oviedo, 2001) with a dissertation on the properties of some computable predicates under the supervision of Prof. Andrey Morozov and Prof. Consuelo Martínez. Since 2009, Elías F. Combarro has been an associate professor at the Computer Science Department of the University of Oviedo. He has published more than 50 research papers in international journals on topics such as Computability Theory, Machine Learning, Fuzzy Measures and Computational Algebra. His current research focuses on the application Quantum Computing to algebraic, optimisation and machine learning problems. From July 2020 to January 2021, he was a Cooperation Associate at CERN openlab. Currently, he is the Spain representative in the Advisory Board of CERN Quantum Technology Initiative, a member of the Advisory Board of SheQuantum and one of the founders of the QSpain, a quantum computing think tank based in Spain.
Read more about Elías F. Combarro

Samuel González-Castillo
Samuel González-Castillo
author image
Samuel González-Castillo

Samuel González-Castillo holds degrees from the University of Oviedo (Spain) in both Mathematics and Physics (2021). He is currently a mathematics research student at the National University of Ireland, Maynooth, where he works as a graduate teaching assistant. He completed his physics bachelor thesis under the supervision of Prof. Elías F. Combarro and Prof. Ignacio F. Rúa (University of Oviedo), and Dr. Sofia Vallecorsa (CERN). In it, he worked alongside other researchers from ETH Zürich on the application of Quantum Machine Learning to classification problems in High Energy Physis. In 2021, he was a summer student at CERN developing a benchmarking framework for quantum simulators. He has contributed to several conferences on quantum computing.
Read more about Samuel González-Castillo

View More author details
Right arrow

Chapter 2
The Tools of the Trade in Quantum Computing

Give us the tools, and we will finish the job.
— Winston Churchill

We are all very much looking forward to having a ”Q1 Pro” quantum chip in our laptops, but — much to our regret — the technology is not there just yet. Nevertheless, we do have some actual quantum computers that, with their limitations, are able to execute quantum algorithms. And, furthermore, our good old classical computers can actually do a very decent job at simulating ideal quantum computers, at least for a low number of qubits.

In this chapter, we will explore the tools that allow us to implement quantum algorithms using the quantum circuit model and run them on simulators or on real quantum hardware.

We will begin by going through some of the most widely-used quantum software frameworks and platforms out there. Then, we will see how to work with the two software frameworks that we are going to use more extensively throughout...

2.1 Tools for quantum computing: a non-exhaustive overview

In this book, we will work mostly with two quantum frameworks: Qiskit and PennyLane. These frameworks are powerful, very widely used, and are backed by strong user communities, but they are by no means the only interesting options available. There is currently a plethora of wonderful software frameworks for quantum computing, so much so that it can sometimes feel overwhelming!

2.1.1 A non-exhaustive survey of frameworks and platforms

In this section, we will briefly go through some of the most popular frameworks out there. Most of these frameworks are free, both as in free beer and as in free speech.

  • Quirk: We can begin with a simple yet powerful simulator of quantum circuits: Quirk (https://algassert.com/quirk). Unlike all the other frameworks that we will discuss, this one does not work with code, but with a graphical user interface that runs as a web application. This makes it ideal for running demonstrations of algorithms...

2.2 Working with Qiskit

In this section, we will learn how to work with the Qiskit framework. We will first discuss the general structure of Qiskit, and then we will study how to implement quantum circuits in Qiskit using quantum gates and measurements. Then, we will explore how to run these circuits using the simulators provided by Qiksit and also real quantum computers available for free thanks to IBM. This section is key, for we will use Qiskit extensively in this book.

Important note

Quantum computing is a rapidly-evolving field…and so are its software frameworks! We are going to work with version 0.39.2 of Qiskit. Keep in mind that, if you are using a different version, things may have changed. In case of doubt, you should always refer to the documentation (https://qiskit.org/documentation/).

2.2.1 An overview of the Qiskit framework

The Qiskit framework [102] consists of the components depicted in Figure 2.1. At the very foundation of Qiskit lies Qiskit Terra. This...

2.3 Working with PennyLane

The structure of PennyLane [103] is more simple than that of Qiskit. PennyLane mainly consists of a core software package, which comes with all the features that you would expect: it allows you to implement quantum circuits, it comes with some wonderful built-in simulators, and it also allows you to train quantum machine learning models (both with native tools and with a TensorFlow interface).

In addition to this core package, PennyLane can be extended with a wide selection of plugins that provide interfaces to other quantum computing frameworks and platforms. At the time of writing, these include Qiskit, Amazon Braket, the Microsoft QDK, and Cirq, among many others that we have not mentioned in our introduction. In addition, there is a community plugin, PyQuest, that makes PennyLane interoperable with the QuEST simulator (https://github.com/johannesjmeyer/pennylane-pyquest).

In short, with PennyLane, it’s not that you get the best of both worlds. You...

Summary

In this chapter, we have explored some of the frameworks and platforms that can enable us to implement, simulate, and run quantum algorithms. We have also learned how to work with two of these frameworks: Qiskit and PennyLane, which are very widely used. In addition to this, we have learned how to use the IBM Quantum platform to execute quantum circuits on real hardware, sending them from either Qiskit or PennyLane.

With the skills that you have gained in this chapter, you are now able to implement and execute your own circuits. Moreover, you are now well-prepared to read the rest of the book, since we will be using Qiskit and PennyLane extensively.

In the next chapter, we will take our first steps in putting all this knowledge into practice. We shall dive into the world of quantum optimization!

lock icon
The rest of the chapter is locked
You have been reading a chapter from
A Practical Guide to Quantum Machine Learning and Quantum Optimization
Published in: Mar 2023Publisher: PacktISBN-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.
undefined
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 $15.99/month. Cancel anytime

Authors (2)

author image
Elías F. Combarro

Elías F. Combarro holds degrees from the University of Oviedo (Spain) in both Mathematics (1997, award for second highest grades in the country) and Computer Science (2002, award for highest grades in the country). After some research stays at the Novosibirsk State University (Russia), he obtained a Ph.D. in Mathematics (Oviedo, 2001) with a dissertation on the properties of some computable predicates under the supervision of Prof. Andrey Morozov and Prof. Consuelo Martínez. Since 2009, Elías F. Combarro has been an associate professor at the Computer Science Department of the University of Oviedo. He has published more than 50 research papers in international journals on topics such as Computability Theory, Machine Learning, Fuzzy Measures and Computational Algebra. His current research focuses on the application Quantum Computing to algebraic, optimisation and machine learning problems. From July 2020 to January 2021, he was a Cooperation Associate at CERN openlab. Currently, he is the Spain representative in the Advisory Board of CERN Quantum Technology Initiative, a member of the Advisory Board of SheQuantum and one of the founders of the QSpain, a quantum computing think tank based in Spain.
Read more about Elías F. Combarro

author image
Samuel González-Castillo

Samuel González-Castillo holds degrees from the University of Oviedo (Spain) in both Mathematics and Physics (2021). He is currently a mathematics research student at the National University of Ireland, Maynooth, where he works as a graduate teaching assistant. He completed his physics bachelor thesis under the supervision of Prof. Elías F. Combarro and Prof. Ignacio F. Rúa (University of Oviedo), and Dr. Sofia Vallecorsa (CERN). In it, he worked alongside other researchers from ETH Zürich on the application of Quantum Machine Learning to classification problems in High Energy Physis. In 2021, he was a summer student at CERN developing a benchmarking framework for quantum simulators. He has contributed to several conferences on quantum computing.
Read more about Samuel González-Castillo