{"id":3736,"library":"pennylane-lightning","title":"PennyLane-Lightning","description":"PennyLane-Lightning provides high-performance C++ quantum simulators that integrate as plugins with the PennyLane quantum machine learning library. The base package includes the `lightning.qubit` device for CPU-based state-vector simulation, with other specialized devices (GPU, Kokkos, Tensor, AMDGPU) available via separate installation packages. It is actively maintained with frequent, typically monthly or bi-monthly, releases.","status":"active","version":"0.44.0","language":"python","source_language":"en","source_url":"https://github.com/PennyLaneAI/pennylane-lightning","tags":["quantum computing","simulator","pennylane","qubit","gpu","high-performance","quantum machine learning"],"install":[{"cmd":"pip install pennylane-lightning","lang":"bash","label":"Base package (lightning.qubit)"}],"dependencies":[{"reason":"Core library; PennyLane-Lightning provides devices for PennyLane.","package":"pennylane","optional":false},{"reason":"Numerical operations and array handling.","package":"numpy","optional":false}],"imports":[{"note":"PennyLane-Lightning devices are loaded via `qml.device` using their string name, not by direct import of a class from the `pennylane_lightning` package itself. Attempting direct import will fail.","wrong":"from pennylane_lightning import LightningQubit","symbol":"qml.device","correct":"import pennylane as qml\ndevice = qml.device(\"lightning.qubit\", wires=4)"}],"quickstart":{"code":"import pennylane as qml\nimport numpy as np\n\n# Create a Lightning Qubit device\ndev = qml.device(\"lightning.qubit\", wires=2)\n\n@qml.qnode(dev)\ndef circuit(x):\n    qml.RX(x[0], wires=0)\n    qml.RY(x[1], wires=1)\n    qml.CNOT(wires=[0, 1])\n    return qml.expval(qml.PauliZ(0))\n\n# Run the circuit\nparams = np.array([0.54, 0.12], requires_grad=True)\nresult = circuit(params)\nprint(f\"Expectation value: {result}\")\n\n# Calculate gradients\ndq = qml.grad(circuit)(params)\nprint(f\"Gradients: {dq}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `lightning.qubit` device and use it within a PennyLane quantum circuit to compute an expectation value and its gradients. Ensure PennyLane is also installed."},"warnings":[{"fix":"Install the specific package for the desired device, e.g., `pip install pennylane-lightning-gpu`.","message":"The `pennylane-lightning` package only provides the `lightning.qubit` CPU device. For GPU-accelerated (`lightning.gpu`), Kokkos-enabled (`lightning.kokkos`), Tensor Network (`lightning.tensor`), or AMDGPU (`lightning.amdgpu`) devices, separate `pennylane-lightning-gpu`, `pennylane-lightning-kokkos`, `pennylane-lightning-tensor`, and `pennylane-lightning-amdgpu` packages must be installed respectively.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Catalyst Runtime version (e.g., v0.11.0 for PennyLane-Lightning v0.41.1) is compatible when using Lightning devices within Catalyst. Refer to the release notes for specific version requirements.","message":"Building Catalyst Lightning plugins requires compatibility with specific Catalyst Runtime versions.","severity":"breaking","affected_versions":"0.41.1 onwards"},{"fix":"Consult the PennyLane-Lightning documentation for detailed hardware, driver, and CUDA/ROCm toolkit installation instructions before attempting to use these devices.","message":"Specialized devices like `lightning.gpu`, `lightning.kokkos`, and `lightning.amdgpu` have specific hardware and driver requirements (e.g., NVIDIA CUDA, AMD ROCm). They will not function without the correct setup.","severity":"gotcha","affected_versions":"All versions supporting these devices"},{"fix":"For very large numbers of qubits, consider using tensor network simulators (`lightning.tensor`), or sampling-based approaches, or distributed computing solutions (e.g., `lightning.kokkos` with MPI).","message":"Like all state-vector simulators, `lightning.qubit`'s memory consumption scales exponentially with the number of qubits. This can quickly become a bottleneck for circuits with a large number of wires.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For optimal MCM performance and full feature set, ensure you are using a recent version (0.43.0+) and explicitly specify the `mcm_method` if required, e.g., `qml.device(\"lightning.qubit\", wires=4, mcm_method=\"device\")`.","message":"Support for mid-circuit measurements (MCMs) and their different execution methods (`mcm_method`) was introduced and refined, potentially impacting performance or available features.","severity":"gotcha","affected_versions":"Prior to 0.43.0 for full support, 0.43.0 introduced `mcm_method=\"device\"` and `\"tree-traversal\"`"}],"env_vars":null,"search_vec":"'activ':55 'amdgpu':47 'avail':48 'base':26,35 'bi':63 'bi-month':62 'c':11 'comput':67 'cpu':34 'cpu-bas':33 'devic':31,43 'frequent':58 'gpu':44,71 'high':9,73 'high-perform':8,72 'includ':28 'instal':51 'integr':15 'kokko':45 'learn':23,77 'librari':24 'lightn':3,6 'lightning.qubit':30 'machin':22,76 'maintain':56 'month':60,64 'packag':27,52 'pennylan':2,5,20,69 'pennylane-lightn':1,4 'perform':10,74 'plugin':17 'provid':7 'quantum':12,21,66,75 'qubit':70 'releas':65 'separ':50 'simul':13,39,68 'special':42 'state':37 'state-vector':36 'tensor':46 'typic':59 'vector':38 'via':49","created_at":"2026-04-11T17:42:31.591709+00:00","updated_at":"2026-04-16T17:58:20.483066+00:00","problems":[{"fix":"Ensure you are using a Python version supported by PennyLane-Lightning (e.g., 3.10 or newer) and that your system's `glibc` library is sufficiently new (e.g., 2.28 or greater for `manylinux_2_28` wheels). Using a virtual environment (like Conda or `venv`) is recommended. If problems persist, consider using cloud environments like Google Colab or qBraid, or compiling PennyLane-Lightning from source if you have specific system constraints.","cause":"This error often occurs when the pre-compiled binaries for `lightning.qubit` (or other Lightning devices like `lightning.gpu`, `lightning.tensor`) are not compatible with your system's `glibc` version (common on older Linux distributions like RHEL 7), or due to an unsupported Python version, or issues within your virtual environment.","error":"ImportError: Pre-compiled binaries for lightning.qubit are not available."},{"fix":"Install the appropriate `custatevec` package for your CUDA version (e.g., `pip install custatevec-cu11` for CUDA 11.x or `custatevec-cu12` for CUDA 12.x). Verify that your NVIDIA CUDA Toolkit is correctly installed and configured, your NVIDIA drivers are up to date, and your GPU meets the minimum compute capability requirement (SM7.0 or newer).","cause":"This error indicates that the `lightning.gpu` device could not be found or properly initialized. This typically happens when the NVIDIA cuQuantum SDK's `custatevec` library is not installed, is not accessible in the system's library path, or if your GPU hardware or CUDA Toolkit version is incompatible.","error":"DeviceError: Device lightning.gpu does not exist. Make sure the required plugin is installed."},{"fix":"Ensure your CUDA Toolkit is at a supported version (e.g., 11.5 or newer, 11.8 preferred, or 12.x for recent `pennylane-lightning` versions). Update your NVIDIA drivers and CUDA SDK if necessary. Crucially, ensure that the `LD_LIBRARY_PATH` environment variable includes the directory where your CUDA runtime libraries (e.g., `libcudart.so`) are located.","cause":"This error, or similar messages like 'Error in PennyLane Lightning: the provided PTX was compiled with an unsupported toolchain,' signifies a mismatch between the CUDA runtime libraries available on your system and the CUDA version `pennylane-lightning-gpu` was compiled against or expects. It often occurs with outdated CUDA versions or incorrect `LD_LIBRARY_PATH` settings.","error":"ImportError: libcudart.so.11.0: cannot open shared object file: No such file or directory"},{"fix":"Ensure both `pennylane` and `pennylane-lightning` are installed from a compatible release, preferably by upgrading both simultaneously using `pip install pennylane pennylane-lightning --upgrade`. If you are building from source, clone and install `pennylane` from a compatible branch or version before installing `pennylane-lightning`.","cause":"This error typically points to a version incompatibility between the main `pennylane` library and the `pennylane-lightning` plugin, or an issue when installing `pennylane-lightning` from source without a matching `pennylane` installation. The internal structure of PennyLane can evolve, leading to missing modules if versions don't align.","error":"ModuleNotFoundError: No module named 'pennylane_lightning.core'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.45.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://pennylane.ai","github":"https://github.com/PennyLaneAI/pennylane-lightning","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pennylane-lightning/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}