pennylane
Helps your agent build and differentiate quantum circuits and hybrid models. It's useful for variational quantum algorithms and quantum machine learning.
What it does
PennyLane helps build and optimize quantum circuits. It allows combining quantum computation with artificial intelligence models (like PyTorch or JAX) to solve complex problems, such as calculating molecular energies or validating quantum circuits.
When to use it
- ✓To optimize quantum circuits with adjustable parameters.
- ✓To build models that mix quantum and classical (AI) computation.
- ✓To calculate molecular energies or solve quantum optimization problems.
Example of what to ask your AI
“Create a quantum circuit to calculate the energy of the hydrogen molecule and optimize it using the VQE algorithm.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
PennyLane lets you define quantum circuits and then use machine learning tools to tune the parameters of these circuits. It can simulate the circuit on a computer or, if configured, send it to real quantum hardware.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add K-Dense-AI/scientific-agent-skills --skill pennylaneOr download just the file:
curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/pennylane/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
PennyLane
When to use
Use PennyLane to optimize parameterized circuits, build hybrid quantum-classical models, estimate molecular energies, or compare a validated circuit across devices. This skill targets stable PennyLane 0.45.1. The local examples use small synthetic systems; successful optimization does not establish quantum advantage, molecular accuracy, or hardware fidelity.
Installation
Create a dedicated environment; provider plugins and compiler dependencies should be resolved separately from unrelated scientific packages:
uv venv --python 3.13 .venv-pennylane
uv pip install --python .venv-pennylane/bin/python "pennylane==0.45.1"
PennyLane 0.45 requires NumPy 2+. Core installation includes Lightning. For ML, use the tested JAX 0.7.1/JAXlib 0.7.1 pair or PyTorch; do not assume the latest JAX is supported by this PennyLane release. See device setup for optional plugin versions and their verification limits.
Workflow
- Fix the problem convention: feature ordering and label encoding for ML; Hamiltonian sign for optimization; units, charge, multiplicity, basis, active space and mapping for chemistry.
- Build a small analytic
default.qubitcircuit. Keep the quantum function separate from the QNode when reusing it on another backend. - Check a known value and a gradient against an analytic or finite-difference
result before training. Use trainable
pennylane.numpyarrays for Autograd, framework-native tensors for Torch/JAX. - Optimize while recording objective, gradient norm, seeds, ansatz shape and
package versions.
step_and_costreturns the cost before its update; evaluate the objective again for final reporting. - Validate independently: held-out examples and classical baselines for ML; particle number and a sector-appropriate classical reference for VQE; enumerated small instances for QAOA.
- Introduce finite shots/noise, report uncertainty, inspect decomposed resources, then select a current accessible hardware backend and execution budget. Plugin portability does not guarantee identical gates, measurements or gradients.
Quick start: value, gradient and optimization
This self-contained example is executed by the skill's tests.
import pennylane as qml
from pennylane import numpy as np
dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev, interface="autograd", diff_method="backprop")
def energy(theta):
qml.RY(theta, wires=0)
return qml.expval(qml.Z(0))
theta = np.array(0.3, requires_grad=True)
assert np.allclose(energy(theta), np.cos(theta))
assert np.allclose(qml.grad(energy)(theta), -np.sin(theta))
opt = qml.GradientDescentOptimizer(stepsize=0.2)
for _ in range(80):
theta = opt.step(energy, theta)
final_energy = float(energy(theta))
assert final_energy < -0.999
print(f"[OK] final expectation = {final_energy:.6f}")
Load the relevant reference
- Getting started: QNodes, shots, random streams, trainability, batched parameters and simulator selection.
- Quantum circuits: controls, measurement feedback, wire ordering, QFT, transforms and current resource access.
- Quantum ML: executed TorchLayer and JAX training, stable classifier loss, feature scaling and evaluation.
- Quantum chemistry: H2 UCCSD, units, particle sector checks, dipoles, active spaces, geometry and excited-state caveats.
- Devices: simulators, provider contracts, credentials, current target discovery and source-only integration boundaries.
- Optimization: gradient checks, SPSA, QNG, MaxCut sign and exact QUBO-to-Ising conversion.
- Advanced features: templates, noise, parametrized Hamiltonian evolution, Catalyst and error-correction examples.
Failure checks
- Samples/counts require finite shots; states require a supporting simulator.
Use
qml.set_shotson the QNode rather than mutating device shots. - Mid-circuit measurement values are symbolic. Use
qml.cond, not Pythonif m. qml.specsin 0.45.1 returnsCircuitSpecs; access.resources, not obsolete top-level dictionary keys. Record the transform level and account for split tapes.qml.qaoa.maxcutproduces negative cut size. Minimize it directly.
…
FAQ
What is a quantum circuit?
It's a sequence of instructions (quantum gates) that manipulate quantum bits (qubits) to perform a calculation. Think of it like a program for a quantum computer.
What are variational quantum algorithms (VQE/QAOA)?
These are methods that use a quantum circuit with adjustable parameters and a classical computer to find the best solution to a problem, like the minimum energy of a molecule or the solution to an optimization problem.
Can I run this on my computer?
Yes, PennyLane can simulate quantum circuits on your computer. To run on actual quantum hardware, you need to set up access to a specific provider.
Details
Original description by the author
Builds and differentiates PennyLane quantum circuits, hybrid PyTorch or JAX models, molecular VQE and QAOA workflows. Use for variational quantum algorithms, quantum machine learning, simulator validation, and moving validated circuits to provider plugins. For hardware-specific compilation use qiskit or cirq; for open-system dynamics use qutip.
Popularity
- GitHub stars
- 51k
- Ranking position
- #1933
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
13c-metabolic-flux
Estimates metabolic fluxes using carbon-13 isotope tracing data. It is useful for analyzing cellular metabolism and biochemical pathways.
K-Dense-AI/scientific-agent-skills
adaptyv
Designs protein characterization experiments using the Adaptyv API. It helps estimate costs, submit sequences, and monitor lab results.
K-Dense-AI/scientific-agent-skills
aeon
Performs machine learning tasks on time series data. It is useful for classifying, forecasting, detecting anomalies, and finding patterns in sequential data.
K-Dense-AI/scientific-agent-skills
alphagenome
Looks up precomputed genomic effects for genetic variants. It provides scores and explanations to understand the impact of variants on the genome.
K-Dense-AI/scientific-agent-skills
Similar skills
dashboard-builder
Helps your agent create useful monitoring dashboards. It turns data into charts that answer important system questions.
affaan-m/ECC
dev-team
Simulates a collaborative development team where different roles respond to a problem together. It's useful for getting multiple perspectives without manually switching agents.
affaan-m/ECC
ecc-council
Has your agent convene a four-voice council for difficult decisions. It's useful when there are multiple good options and debate is needed before choosing.
affaan-m/ECC