Qiskit + PyTorch + Python = Quantum Machine Learning. Hybrid Quantum Machine Learning is getting easier.

For many in the classical Machine Learning community the interest is when Quantum Computing gets pulled into the mix to create Hybrid Learning networks that consist of both classical and quantum components. As more and more researchers are looking at this lucrative area it should come as no surprise that it is possible to combine the classical and the quantum world to potentially exploit the best of both worlds.

A new tutorial from Qiskit (the Open Source Quantum Programming Language) illustrates how the also popular machine learning framework, PyTorch can be employed to create a Hybrid Learning environment. Glued together with Python, the two worlds can be used to create a system with a classical neural network, but with some of the nodes replaced with a quantum circuit. For some researchers, they might be asking how a combined hybrid circuit can actually work given that a classical neural network relies of something called back-propagation.

Hybrid Classical and Quantum Networks

Over coming back propagation with quantum circuits

One of the purported difficulties of employing quantum circuits for learning is how they can be trained. In a classical neural network, whether it is a convolutional or simple feed forward errors must be propagated back through the network such that the weights of the network can be adjusted to learn the target pattern. This process is employed in deep-learning and has been one of the biggest innovations in AI or Machine Learning in decades. Knowing how to compute the re-adjusted weights relies on computing gradients – and in the classical world that means having a differentiable activation function. However the case when a quantum circuit is employed the case is not quite so clear, but do not be alarmed, even though a quantum circuit can be complex, there are techniques such as the parameter shift rule or even just doing numerically that can use the existing quantum gates to produce the gradient required to update the weights.

Putting it all together

Ultimately the example given shows how the classical and quantum world can be combined in a simple manner. There is not any advantage to this other than proof of concept and for the simple cases the pure classical case will be more performant. However the interest is in using more complex quantum circuits, potentially with entanglement that might be able to offer an advantage, especially when learning complex patterns. Researchers have shown that Quantum Neural networks can potentially learn more complex patterns.

Learning more about QML

If you want to learn more, check out our book section on both classical Machine Learning and Quantum Machine learning. We also have some tutorials that cover some basic topics in quantum machine learning. There are also courses on QML (Quantum Machine Learning) which you can see from the courses pages.