pennylane

Optimize quantum circuits with automatic differentiation across simulators and hardware.

33.0k|3.2k|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/K-Dense-AI/claude-scientific-skills --skill pennylane
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pennylane
Source: https://github.com/K-Dense-AI/claude-scientific-skills/tree/main/scientific-skills/pennylane
Command: npx skills add https://github.com/K-Dense-AI/claude-scientific-skills --skill pennylane

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

PennyLane enables building and training differentiable quantum circuits with device-agnostic execution, seamlessly integrating with PyTorch/JAX/TensorFlow for quantum machine learning and chemistry workflows.

Core Features & Use Cases

  • Quantum circuit construction: Create gates and measurements with automatic differentiation.
  • Quantum machine learning: Train quantum neural networks and variational classifiers.
  • Quantum chemistry and chemistry workflows: Build molecular Hamiltonians and run VQE-type optimization.
  • Device management: Run on simulators or hardware backends via plugins.
  • Framework integration: Interoperate with PyTorch, JAX, and TensorFlow for hybrid models.

Quick Start

  1. Install: pip install pennylane
  2. Basic qnode example: import pennylane as qml; dev = qml.device("default.qubit", wires=2); @qml.qnode(dev) def circuit(x): qml.RX(x, 0); return qml.expval(qml.PauliZ(0))

Frequently Asked Questions about pennylane

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build and train quantum circuits with automatic differentiation?

PennyLane enables automatic differentiation of quantum circuits through its qnode decorator, which wraps quantum functions and enables gradient-based optimization across simulators and hardware backends. Define a circuit function, decorate it with @qml.qnode, and compute gradients directly for training variational algorithms.

Can I run quantum circuits on both simulators and hardware devices without rewriting code?

Yes. PennyLane provides device-agnostic execution through its plugin architecture. Switch backends by changing the device parameter—use 'default.qubit' for simulation or specify a hardware plugin—without modifying your circuit code.

How do I integrate quantum machine learning with PyTorch or TensorFlow?

PennyLane's framework integration allows you to embed quantum circuits as differentiable layers in PyTorch, JAX, and TensorFlow models. Combine classical neural networks with quantum subroutines using standard autodiff workflows across the entire hybrid model.

What's the best way to implement variational quantum algorithms like VQE?

PennyLane includes templates and transforms for variational algorithms. Use ansatz templates for circuit structure, compose variational gates, and leverage automatic differentiation to optimize parameters—enabling VQE for quantum chemistry and QAOA for optimization problems.

Do I need prior quantum computing experience to use PennyLane?

PennyLane abstracts quantum mechanics complexity through Pythonic APIs for gate construction and measurement. Basic Python and familiarity with autodiff frameworks (PyTorch, JAX, TensorFlow) are sufficient; quantum concepts are progressive.

Can PennyLane handle quantum chemistry simulations and molecular Hamiltonians?

Yes. PennyLane supports quantum chemistry workflows including molecular Hamiltonian construction and variational quantum eigensolver (VQE) implementations for molecular simulation and ground-state energy calculations.