AWS Open Source Blog

Creating a bridge between machine learning and quantum computing with PennyLane

In this post, Josh Izaac (Xanadu) and Eric Kessler (AWS) explain how the open source PennyLane project helps bridge the gap between the quantum computing and machine learning communities.

Today, we are announcing that AWS is joining the steering council of the PennyLane open source project for variational quantum computing and quantum machine learning. Our goal is to help build better tools for developers and researchers by bringing together ideas and concepts from machine learning (ML) and quantum computing (QC). Together with our partner Xanadu, we want to continue to evolve PennyLane as an open, community-driven project, and we are inviting contributors from QC, ML, and other fields to join us. But let’s step back for a moment and explain why it makes sense to bridge the worlds of quantum computing and machine learning with PennyLane.

The roots of the current machine learning revolution were first laid down in the 1980s—so why did it take more than three decades for machine learning to become pervasive in our everyday lives? Although an increase in computational power was a major contribution to the rise of machine learning, the availability of user-friendly open source software was also a huge part of the success story of machine learning over the past decade. By making the workhorse algorithms underpinning machine learning—such as the backpropagation algorithm for auto-differentiation of neural network models— accessible, easy to use, and high-performing, open source software has allowed rapid innovation across a worldwide community.

In many ways, quantum computing today mirrors the early days of machine learning. Every day, researchers from academia and industry are contributing new ideas, algorithms, and hardware advances. But some of the same barriers also exist. Often it seems that one must first go through many years of specialized training in order to contribute to quantum computing, just as was the case in the early days of machine learning.

So now that quantum hardware has become more readily available through cloud services such as Amazon Braket, how can we make quantum computing more accessible to different communities and apply decades of learnings and insights from machine learning to this nascent field?

PennyLane infographic.

PennyLane is an open source project that is trying to bridge the gap between the two communities of quantum computing and machine learning—which can learn a lot from each other.

Quantum computing in the NISQ era

Until less than a decade ago, the quantum computing community was almost exclusively focused on developing theoretical proofs of how large-scale and noise-free quantum computers can provide computational speed-ups. The resulting algorithms, such as the famous Shor’s algorithm, illustrate the enormous potential of quantum computers, but require device capabilities that are deep in the future. With the advent of the first devices with their relatively few (10s to 100s) noisy qubits, a paradigm shift occurred. In this so-called Noisy Intermediate-Scale Quantum (NISQ) regime, a new class of quantum algorithms has been developed that is based on heuristics—practical methods that are not guaranteed to be optimal but nevertheless useful by getting us close to a correct answer.

Although affirmatively proving computational speedups is hard, there are promising results that these algorithms could find applications in a diverse set of use cases, from computational chemistry to optimization. How can we find out for sure? Likely, we will have to build and try. This is exactly the situation that machine learning was in many years ago. There was no theoretical proof (and there still isn’t one today) that a neural network could recommend a book to read next or help navigate a delivery drone around obstacles. What ignited the field of machine learning was when data, compute power, and open source software tooling became widely available. This made it practical for a broad ecosystem of researchers and developers to build and try out different algorithms for a variety of use cases. Quantum computing can learn from this journey and, in a sense, this is what we are trying to do with Amazon Braket and PennyLane. Together, we provide ready access to a variety of quantum computing technologies and open source tooling to developers and researchers on AWS.

But the alignment between ML and QC goes even deeper. As it turns out, the heuristic, NISQ-era quantum algorithms we are talking about today are based on the same principles that let us train neural networks.

In the same way that the weights of a neural network are iteratively adjusted based on the error in the training set, these so-called variational quantum algorithms use classical optimization routines to iteratively adjust the parameters of a quantum circuit, for instance, the rotation angle in a qubit gate. In machine learning, the neural network processes a batch of data, calculates the gradient of an objective function, and based on that information, updates the weights of the network. Analogously, in a variational quantum algorithm, a batch of circuits is processed, the results are then combined into the objective function (or the gradient thereof), which in turn is used to update the parameters of the quantum circuit. Then, like in ML, this cycle is repeated until the algorithm converges to an answer close enough to the objective.

Of course, the analogy goes both ways, and there may be benefits to the machine learning community from quantum computing as well. Using a quantum computer to build predictive ML models is an active area of research, and it has been shown that such quantum neural networks have greater expressiveness for certain data sets. However, that’s a deep dive for another day.

PennyLane is built around these parallels between ML and QC, and brings the fields closer together to accelerate innovation. In particular, PennyLane introduces a new paradigm: quantum differentiable programming. Quantum differentiable programming extends one of the foundational concepts of machine learning—auto-differentiation—to quantum circuits. But rather than reinventing the wheel, PennyLane allows us to directly use existing ML libraries, such as PyTorch, JAX, or TensorFlow, to train quantum circuits, just like neural networks. On the one hand, quantum computing researchers may benefit from the mature and comprehensive tooling that was developed over many years in ML, while on the other hand, machine learning experts can start experimenting with quantum computing while still using familiar tools and terminology.

At AWS, we are convinced that bringing together the open source communities in ML and QC can accelerate innovation in both fields. Over the past year we have worked closely with the PennyLane team to contribute to the open source project and bring PennyLane to Amazon Braket. This allows customers to build variational algorithms with PennyLane, fine-tune them on Amazon Braket’s high-performance, managed simulators, and to do so ten times faster by using parallel circuit execution. Of course, customers also can run those variational algorithms on one of the quantum computers available on Amazon Braket. Check out the Braket Example repository on GitHub, or view the Amazon Braket tutorial on the PennyLane website to get started.

PennyLane work flow.

Conclusion

This is only the beginning. As we’ve seen from open source tools in machine learning, there has been a positive feedback loop of software driving research, and research driving software. New research results have been rapidly ported over to software frameworks and generalized, increasing the richness of these software products. In the other direction, new software features open up avenues of research previously inaccessible; for example, the define-by-run paradigm first introduced by Chainer allowed for more flexible and accessible differentiable programming.

By integrating quantum computing into a rich scientific and machine learning ecosystem, we can all drive forward the field of quantum computing. There are many ideas common in machine learning that are yet to be explored in quantum computing—why not have a go at building something and find out?

This is a great time to get started with quantum computing and quantum machine learning, as QHack, PennyLane’s community event, starts February 17. The event will begin with three days of sessions on quantum machine learning featuring experts from AWS, Xanadu, and other companies. It continues with a hackathon challenge, a great way to have fun and to hone your PennyLane skills. The top teams will be able to use AWS credits to test their algorithms on Amazon Braket. For more details, visit the QHack website.

The PennyLane QML website also has a large collection of quantum machine learning demonstrations and tutorials—from introductions to quantum machine learning, to implementations of the latest QML research. Finally, visit the PennyLane project on GitHub, let us know your feedback, and join the community. And if you would like to get involved, contributions are always welcome!

Josh Izaac

Josh Izaac

Josh Izaac is a theoretical physicist and Quantum Software Team Lead at Xanadu, and one of the founding developers of PennyLane, an open source quantum machine learning software library. At Xanadu, he contributes to the development and growth of Xanadu’s open-source quantum software products. Josh holds a PhD in quantum computing and computational physics from the University of Western Australia. Follow Josh on twitter: @3rdquantization

Eric Kessler

Eric Kessler

Eric Kessler is a Sr. Manager Applied Science at Amazon Braket, working to bring quantum computing technology to the AWS cloud. Over the past decade, Eric has been working in various industry roles across quantum computing and machine learning, enabling enterprises in their adoption of emerging technologies. Eric has a PhD from the Max-Planck-Institute for Quantum Optics and has worked several years as an academic researcher in quantum information theory and computing.