PennyLane Explained: The Quantum Machine Learning Framework for Quantum-AI

PennyLane is a free, open-source Python library from Xanadu for building quantum circuits, running them on simulators or real quantum hardware, and training them the way you train a neural network. Its makers describe it as a cross-platform library for quantum computing, quantum machine learning and quantum chemistry.
Not to be confused with Pennylane, the accounting software. This article is about the open-source quantum computing framework built by Xanadu.
Here is PennyLane at a glance. These are the facts developers usually want first, and each one is covered below.
- Who makes it: Xanadu. It is research-first, Apache 2.0 licensed, actively developed and the standard tool in academic quantum machine learning.
- Core idea: circuits are differentiable, so you can train one like a neural-network layer.
- Building blocks: a device, a quantum function and a QNode that joins them.
- ML integration: PyTorch and JAX, plus its own NumPy interface.
- Where it runs: local simulators by default, and real hardware through plugins.
In short, PennyLane is less about running circuits than training them. That choice explains how it differs from Qiskit and why it fits so naturally into PyTorch.
The Quantum Machine Learning Framework for Quantum-AI
PennyLane earns the label “quantum machine learning framework” through one idea: a circuit you can differentiate like a neural-network layer. Everything else in the framework builds on that idea.
How PennyLane Turns a Quantum Circuit Into a Trainable Machine Learning Model
Every deep-learning framework trains models with the same loop. PennyLane lets a quantum circuit join that loop.
The table below matches each training step in a neural network with its PennyLane equivalent. The steps are identical. Only what fills them changes.
| Step | Neural-network layer | PennyLane circuit |
| Parameters | Weights and biases | Gate rotation angles |
| Output | Activations | Expectation value (the average measurement over many runs) |
| Loss | Compare with a target | Same |
| Gradient | Backpropagation | Gradient for each angle |
| Update | Optimiser nudges weights | Optimiser nudges angles |
Once a circuit reports its gradients, any optimiser can train it, including PyTorch’s Adam.
What Is the Parameter-Shift Rule in PennyLane and Why Does Real Quantum Hardware Need It?
On a simulator, PennyLane can backpropagate because every intermediate value is held in memory. Real hardware only returns final measurements, which leaves nothing to backpropagate through.
So PennyLane uses the parameter-shift rule. It reruns the circuit with one angle shifted up, then down, and compares the results. For standard rotation gates, the slope is
[f(θ + π/2) − f(θ − π/2)] ÷ 2.
You can think of it as a better-behaved cousin of finite differences: a large, fixed shift that gives the exact gradient. It needs only two extra runs per parameter, so it works on any hardware.
PennyLane vs Qiskit: Differences, Features, and Which Framework to Use
This is the most common question about PennyLane. Qiskit is built around circuits and hardware, while PennyLane is built around differentiation, so they are less rivals than people assume.
PennyLane vs Qiskit: Comparison of Features, Hardware Access, and Machine Learning Support
The table below compares the two on the five points that decide which one to open first. Read it as a question of fit, not quality.
| Aspect | PennyLane | Qiskit |
| Made by | Xanadu | IBM |
| Built around | Training circuits | Running circuits on hardware |
| ML integration | Native: PyTorch, JAX | Via add-on packages |
| Hardware reach | Many vendors via plugins, including IBM | Deepest on IBM hardware |
| Best for | Hybrid models, QML, chemistry | Learning circuits, IBM hardware |
Running circuits on IBM hardware? Start with Qiskit. Training circuit parameters inside a PyTorch model? That’s what PennyLane was built for.
Which Quantum Simulators and Hardware Devices Can PennyLane Run On?
PennyLane ships with several simulators, and qml.about() lists the ones installed. Real hardware is added separately, through plugins.
Run this to see your version and devices. The output below is trimmed to the device list.
python
import pennylane as qml
qml.about()
text
Installed devices:
– default.clifford (pennylane-0.45.1)
– default.gaussian (pennylane-0.45.1)
– default.mixed (pennylane-0.45.1)
– default.qubit (pennylane-0.45.1)
– default.qutrit (pennylane-0.45.1)
– default.qutrit.mixed (pennylane-0.45.1)
– default.tensor (pennylane-0.45.1)
– null.qubit (pennylane-0.45.1)
– reference.qubit (pennylane-0.45.1)
– lightning.qubit (pennylane_lightning-0.45.0)
You’ll mostly use three of these: default.qubit for everyday work, lightning.qubit when speed matters, and default.mixed for modelling noise.
Every snippet in this article runs locally. Hardware plugins for IBM (via Qiskit), IonQ, AWS Braket and others install separately and usually need a provider account.
How to Use PennyLane With PyTorch and JAX for Hybrid Quantum-Classical Machine Learning
A PennyLane QNode can sit inside a PyTorch model as a layer. Gradients flow through it during loss.backward(), just like any other layer.
The diagram below shows what you’ll build: classical, quantum and classical layers, with gradients flowing back through all three.

What Is PennyLane Used For? Quantum Machine Learning, Chemistry, and Variational Algorithms
PennyLane fits wherever circuits need to be trained, compared or taught. Whether its field is ready for production is a separate question.
Four areas benefit most from its design. Each one needs circuits that behave like trainable models.
- Variational quantum algorithms, tuned by an optimiser.
- Quantum machine learning research, in PyTorch or JAX.
- Quantum chemistry, with built-in molecular tools.
- Teaching, since it matches how ML students already think.
The honest limit is that the framework is excellent, but its field is still research. There is no demonstrated practical quantum advantage for machine learning on real-world data, and PennyLane’s own community says so. Our quantum machine learning guide covers why.
The “not yet” comes with a way forward. The skills PennyLane builds, from PyTorch to gradient-based optimisation, are in demand now.
PennyLane makes a quantum circuit behave like a layer in a neural network, which is exactly where quantum computing and AI are meeting. If you want to work at that intersection with a proper foundation under it, look at the
Certification in Applied Quantum Computing and AI from IIT Delhi.
Frequently Asked Questions
Yes. PennyLane can be used entirely on a local simulator, so you can develop and test quantum circuits without access to quantum hardware. Real quantum processors can be added later through supported plugins.
No. PennyLane is a Python library and framework for quantum computing and quantum machine learning. You write quantum circuits using Python and PennyLane’s APIs rather than learning a separate programming language.
Yes. PennyLane can place a trainable quantum circuit inside a classical deep-learning model, allowing quantum and classical layers to be optimised together. Its PyTorch and JAX integrations make this especially useful for hybrid quantum-classical models.
PennyLane primarily uses Python. Its Python interface lets developers create quantum circuits, run them on simulators or hardware, calculate gradients and connect quantum circuits with machine-learning frameworks.
Yes, depending on the PennyLane simulator and configuration being used. GPU acceleration can be useful when simulating quantum circuits, particularly for larger computational workloads, although the available performance depends on the backend and hardware.
PennyLane and Qiskit are designed around somewhat different workflows. PennyLane places a strong emphasis on differentiable circuits and hybrid quantum-classical machine learning, while Qiskit has a strong focus on quantum circuits and IBM’s hardware ecosystem. Which framework fits better depends on the task and hardware stack.
Yes. PennyLane can work with IBM quantum hardware through its Qiskit integration. This allows developers to combine PennyLane’s differentiable-circuit workflow with access to IBM’s quantum ecosystem.
PennyLane can connect to quantum hardware from multiple providers through plugins and integrations. The article’s examples include IBM through Qiskit, IonQ and AWS Braket, allowing developers to move from local simulation to hardware without rebuilding their entire workflow.
Yes. Quantum chemistry is one of PennyLane’s supported application areas. The framework includes tools for working with molecular systems and can be used to develop variational quantum algorithms for chemistry-related research.
Yes. PennyLane is particularly useful for learning QML because it combines quantum circuits with familiar machine-learning concepts such as parameters, gradients, loss functions and optimisers. Developers with Python and basic machine-learning knowledge can therefore experiment with hybrid models without building the training workflow from scratch.
PennyLane is primarily a Python-based development framework rather than a graphical circuit builder. However, it can generate circuit diagrams from code, making it easier to inspect and understand the circuits being executed.
Yes. PennyLane can calculate gradients of trainable circuit parameters and use them with optimisation algorithms such as gradient descent or Adam. This makes it possible to train quantum circuits using a workflow similar to conventional machine-learning models.






