Saltar al contenido
Skillpedia
Machine learning51 mil · #3525

pennylane

Qué hace

PennyLane te ayuda a construir y optimizar circuitos cuánticos. Permite combinar la computación cuántica con modelos de inteligencia artificial (como PyTorch o JAX) para resolver problemas complejos, como calcular energías moleculares o validar circuitos cuánticos.

Cuándo usarla

  • ✓Para optimizar circuitos cuánticos con parámetros ajustables.
  • ✓Para construir modelos que mezclen computación cuántica y clásica (IA).
  • ✓Para calcular energías moleculares o resolver problemas de optimización cuántica.

Link de la skill

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pennylane/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pennylane/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Crea un circuito cuántico para calcular la energía de la molécula de hidrógeno y optimízalo con el algoritmo VQE.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

PennyLane te deja definir circuitos cuánticos y luego usar herramientas de aprendizaje automático para ajustar los parámetros de esos circuitos. Puede simular el circuito en tu ordenador o, si lo configuras, enviarlo a hardware cuántico real.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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

  1. 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.
  2. Build a small analytic default.qubit circuit. Keep the quantum function separate from the QNode when reusing it on another backend.
  3. Check a known value and a gradient against an analytic or finite-difference result before training. Use trainable pennylane.numpy arrays for Autograd, framework-native tensors for Torch/JAX.
  4. Optimize while recording objective, gradient norm, seeds, ansatz shape and package versions. step_and_cost returns the cost before its update; evaluate the objective again for final reporting.
  5. 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.
  6. 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_shots on the QNode rather than mutating device shots.
  • Mid-circuit measurement values are symbolic. Use 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.

…

Preguntas frecuentes

¿Qué es un circuito cuántico?

Es una secuencia de instrucciones (puertas cuánticas) que manipulan bits cuánticos (qubits) para realizar un cálculo. Piensa en ello como un programa para un ordenador cuántico.

¿Qué son los algoritmos cuánticos variacionales (VQE/QAOA)?

Son métodos que usan un circuito cuántico con parámetros ajustables y un ordenador clásico para encontrar la mejor solución a un problema, como la energía mínima de una molécula o la solución de un problema de optimización.

¿Puedo ejecutarlo en mi ordenador?

Sí, PennyLane puede simular circuitos cuánticos en tu ordenador. Para ejecutarlos en hardware cuántico real, necesitas configurar el acceso a un proveedor concreto.

Detalles

Descripción original del autor

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.

repo: K-Dense-AI/scientific-agent-skills

Popularidad

Estrellas en GitHub
51 mil
Posición en el ranking
#3525
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas