What To Look For In A Quantum Machine Learning Framework?
An overview of the relevant quantum machine learning frameworks
My Kickstarter Campaign on Hands-On Quantum Machine Learning With Python ends in less than two days! If you’re interested, make sure to claim your copy.
In quantum machine learning, we aim to harness the phenomena of quantum mechanics to deliver a huge leap forward in the computation of machine learning algorithms.
Machine learning still is a relatively new technology. But in comparison to quantum computing, it is quite mature. A look at the landscape of frameworks makes this apparent.
When the success of deep neural networks ended the third AI winter around 2014, we saw plenty of frameworks compete for supremacy. Some names have almost been forgotten, such as Theano and Caffe. Others were merged, such as Keras. And only two seem to stay, Google-backed Tensorflow and Facebook-backed PyTorch.
We witnessed the same consolidation concerning programming languages. Python became the predominant programming language in machine learning. It condemned Julia and R to the lower ranks.
Quantum computing is so new. It is not even a real technology. We’re just about to start figuring out how to build quantum computers and what we can do with them.
Even though the theory of quantum computation is out there for a while already, practical quantum computing is in its absolute infancies.
In quantum computing, we’ll likely see a similar consolidation. Of course, you’ll want to use a framework that persists. Yet, the winners are not determined. The contestants are just about getting ready right now.
These contestants are:
IBMs Qiskit
Google’s Cirq
Amazon’s AWS Braket
Microsoft’s Q# and Azure Quantum
Rigetti’s Forest
Xanadu’s Pennylane
A few more …
For those students and practitioners who enter the field now, it is not easy to decide which framework to start with. So the apparent question is, which one to use if you want to apply quantum machine learning?
Like early machine learning libraries, quantum computing frameworks differ in the number of functions, syntax, and abstraction levels.
The lower-level frameworks are closer to the hardware. While they offer a high degree of control, they may be cumbersome to use when developing end-to-end applications.
On the contrary, higher-level frameworks abstract away many hardware-related details. As a result, they make the development of applications convenient but lack fine-grained control.
When we talk about quantum machine learning, we rather tend to the application side of the spectrum. But, as we said, we want to use quantum computing for the computation of machine learning algorithms. So for quantum machine learning, quantum computing is the means to achieve a goal. So, to succeed with quantum machine learning, you’ll likely choose a higher-level language.
Quantum computing frameworks are essential to translate ideas into instructions that a quantum computer can execute. Unfortunately, quantum computers are rare devices. Unless you work for a privileged academic institution or one of the manufacturers of quantum computers, you won’t have access to a state-of-the-art quantum computer.
Yet, this doesn’t mean you can’t use quantum computing to enhance your machine learning algorithms. The quantum computing frameworks provide simulators you can use to run quantum algorithms on a classical computer. Of course, your classical computer won’t compute circuits as fast as a quantum computer can. In fact, your classical computer will be absurdly slow. So, while you won’t observe any speed up (the overall performance will be worse than a purely classical algorithm), you can use simulators to verify whether your quantum algorithm works. And if it does, you’ll be prepared for the time when quantum computers become available. Consequently, you’ll want to use a framework that provides powerful simulators.
Finally, unless you’re already an expert in quantum machine learning, you’ll need training material. For example, these may consist of online tutorials, books, and API references. The best framework wouldn’t help if you didn’t know how to use it.
Roughly speaking, there are two kinds of training material. There is official material provided by the developer. And there is the material provided by the community that already works with the framework.
Official material is a building block to get started for anyone. Even experts wouldn’t be able to learn a framework if it had no documentation. Extensive official documentation indicates how serious the developers are with their ambitions. It is an investment, and it costs a lot of time and therefore money to create training material. A framework developer not able or willing to invest in their framework is not a good sign.
But official docs are often hard to understand for newcomers. The framework developers often assume prior knowledge of the domain, in our case, quantum machine learning. They concentrate on explaining how to implement a certain algorithm with their framework. But they usually don’t explain the algorithm in general. While this is completely reasonable, it doesn’t help you to get started.
On the contrary, community-driven resources come in flavors. They range from beginner-level to advanced and to expert-level material. Furthermore, frameworks with a larger community are more likely to persist. And, when you struggle with a problem, having someone you can reach out to is good as gold.
To summarize, these are things you may want to look for in a quantum machine learning framework:
Who is the developer?
Level of abstraction (does it support higher-level machine learning algorithms?)
Provided simulators
Learning material (official, community)
With these things in mind, let’s look at the current state of the existing frameworks.
IBM Qiskit
Qiskit (Quantum Information Software Kit) is IBM’s quantum software development framework. Qiskit is free and open source.
It consists of four parts:
QASM is the quantum instruction language that operates at the hardware-level
Terra is the low-level API, which allows you to program at the level of quantum pulses to form quantum gates.
Aqua is the higher-lever API supporting algorithms used in quantum chemistry, optimization problems, and machine learning.
Aer is a high-performance simulator for quantum circuits that even includes noise models.
IBM is serious about its quantum program. They are one of the leading manufacturers of quantum hardware. They provide extensive API documentation and a comprehensive textbook. However, even though the textbook appears to be starter-level, it addresses experts (of quantum physics) rather than beginners. You might find it easy to read as a physicist, but if you’re a software developer, you’ll be lost pretty soon.
The community around Qiskit is pretty big and active. Of course, you can’t compare it to the community around Tensorflow or PyTorch. But in relation to the communities of the other frameworks, Qiskit seems to be the biggest and most active.
Further, IBM even hosts a summer school aiming to teach quantum computing to high-school students.
Finally, Qiskit integrates with PyTorch. It allows you to replace parts of a neural network with a quantum counterpart.
And, there is one more gimmick. IBM lets you run your quantum circuits for free in the IBM cloud — on real quantum hardware. However, you have to wait a few hours until they compute your circuit. And, the quantum computers they offer have less than ten qubits. Your local simulator is pretty fast for such small circuits, too. So, this is more marketing than a serious development tool.
But, all these things form a convincing package. As a result, IBM Qiskit is my current number one framework for quantum machine learning.
Google Cirq
Cirq is Google’s quantum SDK. Cirq is an open-source Python framework for “creating, editing, and invoking Noisy Intermediate-Scale Quantum (NISQ) circuits. Cirq is in the alpha phase and not (yet?) an official Google product.
Cirq works on the same abstraction as Qiskit. Furthermore, it provides a few libraries and extensions. Their number will likely increase in the future. Yet, the most exciting already exists. This is TensorFlow Quantum. Like Qiskit’s PyTorch integration, TensorFlow Quantum allows you to use quantum circuits inside your neural network.
The official documentation is pretty extensive and of good quality. As far as I see it, the community is growing steadily, with Google’s active support.
Cirq comes with simulators, and you can run your code in the cloud using Colab.
There’s no doubt. Google aims to win the race for quantum supremacy. And its chances are not too bad.
I will definitely check out Cirq. Particularly, TensorFlow Quantum promises to be a tool I don’t want to miss.
Microsoft Q#
Microsoft pursues a separate way. Again. While all the other frameworks use Python as a programming language, Microsoft brings its own language. This is Q#. It integrates with the Quantum Development Kit, which comprises a quantum simulator, libraries to implement quantum algorithms.
Microsoft also provides simulators, and you can run your code in the cloud.
The official training material seems quite good, too. And the community is surprisingly active. You can find quite a few tutorials out there.
But, to be honest, I’d like to use Python. Qiskit and Cirq integrate with PyTorch and TensorFlow. And even if they didn’t, the sole fact that they use Python makes it so much easier to integrate your quantum circuit with whatever you want it to work. Such things are harder if you use a programming language that doesn’t provide the needed bindings.
Amazon AWS Braket
I have to admit. I am a big fan of Amazon AWS. It is my favorite cloud provider. But, when it comes to quantum computing, I still have some doubts. AWS Braket is relatively new. It launched in August 2020. There is some training material on the internet. But it is not as extensive as the material of other contestants.
I don’t see the benefit of using the AWS software tools. But, and this is a big “but,” AWS Braket provides access to real IonQ and Rigetti quantum hardware. So, if you aim to run quantum algorithms in a productive setting already, AWS Braket might be your way to go. But then, AWS is not for free anymore.
Rigetti Computing
Rigetti is one of the leading hardware manufacturers. It provides its own quantum programming framework PyQuil — a binding for the lower-level quantum instruction set Quil. PyQuil generates Quil programs from quantum gates and classical operations. It comes with a compiler (quilc) and a simulator, the Quantum Virtual Machine (QVM). And, most importantly, you can run PyQuil programs on real quantum processors (QPUs) using Rigetti’s Quantum Cloud Service (QCS) or AWS Braket.
Rigetti bundles all these components in their Forest SDK. It is optimized for near-term quantum computers that operate as coprocessors, working in concert with traditional processors to run hybrid quantum-classical algorithms.
Rigetti is not as big as IBM, Google, and Microsoft. So is the learning material not as extensive as it is for the other frameworks. PyQuil and Forest wouldn’t be my first choice as a beginner. But they are certainly a valid option for experienced developers.
Xanadu
Finally, there is Xanadu — (not just) another quantum hardware manufacturer. Their Python library, “Strawberry Fields,” allows you to design, simulate, and optimize quantum circuits. Further, it provides high-level functions for solving practical problems, including quantum machine learning.
Xanadu provides comprehensive learning material — for professionals. Yet, it is hard to find material provided by a broader community.
What makes Xanadu not just another quantum hardware provider has the name “PennyLane.” PennyLane is a cross-platform Python library for differentiable programming of quantum computers. It is not limited to Xanadu’s own quantum framework, Forest. But it integrates with all the aforementioned devices, IBM Qiskit, Google Cirq, Microsoft QDK, Amazon Braket, and Rigetti Forest.
Therefore, it is an exciting framework for quantum machine learning. There is also a pretty active community. Unfortunately, though, most resources expect you to know about machine learning and quantum algorithms.
Conclusion
The four major cloud providers compete for supremacy in the quantum computing market. IBM and Google follow a similar approach. They provide Python frameworks and a lot of training material. Moreover, they integrate with the major machine learning frameworks. These are sound offers.
Microsoft pursues a different path because it does not build upon Python. Finally, Amazon follows a re-selling approach. They rather sell access to real quantum hardware than focusing on the development of an own platform.
The quantum-specific competitors Rigetti and Xanadu provide surprisingly attractive frameworks. Especially Xanadu’s PennyLane has the potential of becoming the major framework for integrating quantum computing and machine learning.
Don’t miss the party!
Get your copy by supporting the Kickstarter Campaign. It ends soon!