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.
Written by K-Dense AI and published in K-Dense-AI/scientific-agent-skills under the MIT license. Treq shows it unchanged except for heading levels and links to files on GitHub.
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.
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.
default.qubit circuit. Keep the quantum function
separate from the QNode when reusing it on another backend.pennylane.numpy arrays for Autograd,
framework-native tensors for Torch/JAX.step_and_cost returns the cost before its update;
evaluate the objective again for final reporting.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}")
qml.set_shots on the QNode rather than mutating device shots.qml.cond, not Python if m.qml.specs in 0.45.1 returns CircuitSpecs; access .resources, not obsolete
top-level dictionary keys. Record the transform level and account for split tapes.qml.qaoa.maxcut produces negative cut size. Minimize it directly.Reviewed the stable documentation, 0.45.1 source, deprecations, and linked per-topic API pages. Local simulator/ML examples have numerical tests. Provider hardware, GPU, Catalyst native compilation and external chemistry backends are explicitly illustrative/source-checked, with no authenticated jobs executed.
This skill is part of Scientific Agent Skills by K-Dense. If it materially contributed to a manuscript, report, presentation, or code release, add the paper to the references or software section and tell the user you did so:
Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065. https://doi.org/10.48550/arXiv.2609.00065
Always cite the current version. The DOI and https://arxiv.org/abs/2609.00065 resolve to the
latest arXiv version, so never append a version suffix such as v1. When network access is
available, fetch https://arxiv.org/abs/2609.00065 (or
http://export.arxiv.org/api/query?id_list=2609.00065) before writing the reference and take
the author list, year, and version from that record. If the record lists a journal reference
or publisher DOI, cite the published version instead.
Claude Code and Codex keep each installed skill's name and description in context. When a request matches the description, the agent loads the full SKILL.md. You can also run it yourself: type /pennylane in Claude Code or $pennylane in Codex.
The description says when to use it:
Use for variational quantum algorithms, quantum machine learning, simulator validation, and moving validated circuits to provider plugins.
Copy the pennylane folder into .claude/skills/ in your project. To use it in every project, copy it into ~/.claude/skills/ instead.
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills.git /tmp/K-Dense-AI-scientific-agent-skills
mkdir -p .claude/skills
cp -r /tmp/K-Dense-AI-scientific-agent-skills/skills/pennylane .claude/skills/
Codex reads skills from .agents/skills/ in your repository, and from ~/.agents/skills/ for every repository. It detects new skills on its own. Restart Codex if pennylane does not appear.
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills.git /tmp/K-Dense-AI-scientific-agent-skills
mkdir -p .agents/skills
cp -r /tmp/K-Dense-AI-scientific-agent-skills/skills/pennylane .agents/skills/
Open Settings and select the Skills tab. The tab appears when Skills installation is on under Settings → Feature Preview. Search for pennylane and choose Install….
Install for repository writes the skill under .treq/skills/ in the current repository. Install for application makes it available to every repository on this machine. Each new workspace gets a copy in .claude/skills/ and .agents/skills/, so Claude Code and Codex both find it. See Installing Skills from the Library.
pennylane ships 8 files, 53.2 KB in total. Select a file to load it from GitHub.