Registry / ai-ml / pennylane

pennylane

JSON →
library0.45.0pypypi✓ verified 89d ago

PennyLane is a cross-platform Python library for differentiable programming of quantum computers, quantum machine learning, and quantum chemistry. It enables users to build, optimize, and deploy hybrid quantum-classical applications by seamlessly integrating with popular machine learning frameworks like NumPy, PyTorch, TensorFlow, and JAX. The library is under active development, with new versions and features released every few months, aiming to make quantum computing accessible for research and application development.

pip install pennylane
INSTALL
IMPORT
SIG · PENNYLANE
P
pennylane
ai-mlpythonv0.45.0
Install
13.6s avg
Import
4957ms
Disk
388MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.42.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 4.078s · 340.9MB
glibc
py 3.10–3.940 runs
installs and imports cleanly · install 13.6s · import 3.853s · 338MB
388MB installed
● package 388MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pennylane
✓ import pennylane as qml
The official documentation and community widely adopt `qml` as the standard alias for PennyLane.

This quickstart demonstrates how to define a quantum device, create a quantum circuit (QNode) with parameters, execute it, and compute gradients using PennyLane's automatic differentiation capabilities. This is a fundamental workflow for variational quantum algorithms.

import pennylane as qml from pennylane import numpy as np # Define a quantum device dev = qml.device("default.qubit", wires=2) # Define a QNode (quantum function) @qml.qnode(dev) def circuit(phi, theta): qml.RX(phi[0], wires=0) qml.RY(phi[1], wires=1) qml.CNOT(wires=[0, 1]) qml.RX(theta, wires=0) return qml.expval(qml.PauliZ(0)) # Define parameters with automatic differentiation enabled phi_params = np.array([0.54, 0.12], requires_grad=True) theta_param = np.array(0.9, requires_grad=True) # Execute the circuit result = circuit(phi_params, theta_param) print(f"Circuit output: {result}") # Compute gradients grad_fn = qml.grad(circuit) gradients = grad_fn(phi_params, theta_param) print(f"Gradients: {gradients}")
Debug
Known issues
breakingMaintenance support for NumPy versions less than 2.0 is deprecated as of PennyLane v0.44.x and will be completely dropped in v0.45. Future versions of PennyLane will only work with NumPy >= 2.0.
fix
Upgrade your NumPy installation to version 2.0 or newer: `pip install "numpy>=2.0"`.
affects: >=0.44.0 (deprecation), >=0.45.0 (removal)
breakingSupport for Intel MacOS platforms (x86) has been removed as of PennyLane v0.44.x, impacting Macs running on Intel processors. Support for Python 3.10 was deprecated in v0.42 and removed in subsequent releases. Minimum Python version for current PennyLane is 3.11.
fix
If on MacOS, migrate to an ARM-based Mac or build x86 wheels manually if absolutely necessary. Ensure your Python environment is 3.11 or newer.
affects: >=0.44.0 (Intel Mac), >=0.42.0 (Python 3.10 deprecation)
deprecatedThe `custom_decomps` keyword argument for `qml.device` is deprecated and will be removed in v0.45. New decomposition rules should be defined as quantum functions with registered resources using `qml.decomposition.enable_graph`.
fix
Refactor custom decomposition logic to use the new graph-based decomposition system and `qml.decomposition` module.
affects: >=0.44.0 (deprecation), >=0.45.0 (removal)
deprecatedAccessing hermiticity via `pennylane.operation.Operator.is_hermitian` is deprecated. Use `is_verified_hermitian` for better reflection of functionality or the `is_hermitian()` function for thorough verification.
fix
Update code to use `operator.is_verified_hermitian` property or call the `qml.is_hermitian(operator)` function for a more comprehensive check.
affects: >=0.44.0 (deprecation), >=0.45.0 (removal)
breakingThe argument `level=None` is no longer valid for functions like `qml.specs()`, `qml.draw()`, `workflow.get_transform_program()`, `workflow.construct_batch()`, `drawer.draw_mpl()`. It must be replaced with `level='device'` to apply all transforms.
fix
Change any instances of `level=None` to `level='device'` when calling these introspection and workflow functions.
affects: >=0.44.0
Errors
Common errors & fixes
DeviceError: Device does not exist. Make sure the required plugin is installed.
This error occurs when trying to use a PennyLane quantum device (e.g., 'qiskit.aer', 'qulacs.simulator') whose corresponding plugin has not been installed, or when running in environments like Google Colab without restarting the runtime after installation.
fix
Install the required PennyLane plugin for the device (e.g., `pip install pennylane-qiskit` for Qiskit devices, `pip install pennylane-qulacs` for Qulacs). If in a notebook environment like Google Colab, ensure you restart the runtime after installation.
AttributeError: module 'pennylane' has no attribute '...' (e.g., 'matrix', 'template', 'workflow')
This error indicates that the PennyLane library version is outdated, and a function, module, or attribute being accessed has been renamed, moved, or removed in a newer release, leading to an 'AttributeError' or similar import issues for refactored internal modules.
fix
Upgrade PennyLane to the latest version using `pip install --upgrade pennylane`. If the issue persists, consult the PennyLane release notes or documentation for specific API changes related to the attribute or module in question.
ImportError: This feature requires quimb, a library for tensor network manipulations. It can be installed with: pip install quimb
This error arises when attempting to use the `default.tensor` device or other tensor-network-related functionalities in PennyLane without having the `quimb` library installed in the Python environment.
fix
Install the `quimb` library by running `pip install quimb` in your terminal or command prompt.
ValueError: cannot reshape array of size X into shape (2, 2, 2, ...)
This specific `ValueError` often occurs with the `default.mixed` device when attempting to simulate circuits with a large number of qubits (typically more than 16-17). The `default.mixed` device simulates density matrices, which leads to an exponential increase in memory requirements with the number of qubits, quickly exhausting available memory.
fix
Reduce the number of qubits in your circuit when using `default.mixed`. For larger qubit counts, consider using a state-vector simulator like `default.qubit` or `lightning.qubit`, which are more memory-efficient for pure state simulations, or explore advanced techniques like circuit cutting for very large systems.
Upgrade
Version history
0.45.0latest on PyPI · released May 12, 2026
Audit
Dependencies
numpyrequiredCore mathematical operations; integrated via an interface.
jaxoptionalOptional interface for JAX integration and automatic differentiation.
tensorflowoptionalOptional interface for TensorFlow integration and automatic differentiation.
torchoptionalOptional interface for PyTorch integration and automatic differentiation.
Agent activity
21 hits · last 30 days
node
16
OpenAI (training)
1
Resources
pennylane — pip install pennylane · libregistry