본문으로 건너뛰기
Skillpedia
머신러닝51k · #3525

pennylane

하는 일

PennyLane은 양자 회로를 만들고 최적화하도록 돕습니다. 양자 계산을 PyTorch나 JAX 같은 인공지능 모델과 결합해, 분자 에너지 계산이나 양자 회로 검증 같은 복잡한 문제를 해결할 수 있게 합니다.

사용하는 경우

  • ✓조정 가능한 매개변수를 가진 양자 회로를 최적화할 때.
  • ✓양자 계산과 고전(AI) 계산을 섞은 모델을 만들 때.
  • ✓분자 에너지를 계산하거나 양자 최적화 문제를 풀 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pennylane/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“수소 분자의 에너지를 계산하는 양자 회로를 만들고, VQE 알고리즘으로 최적화해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

PennyLane은 양자 회로를 정의하도록 하고, 머신러닝 도구로 회로의 매개변수를 조정할 수 있게 합니다. 회로를 컴퓨터에서 시뮬레이션하거나, 설정하면 실제 양자 하드웨어로 보낼 수도 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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.

…

자주 묻는 질문

양자 회로란 무엇인가요?

양자 비트(큐비트)를 조작해 계산을 수행하는 명령의 순서(양자 게이트)입니다. 양자 컴퓨터를 위한 프로그램과 같다고 생각하면 됩니다.

VQE/QAOA 같은 변분 양자 알고리즘이란 무엇인가요?

조정 가능한 매개변수를 가진 양자 회로와 고전 컴퓨터를 함께 사용해 문제의 최선의 해를 찾는 방법입니다. 예를 들어 분자의 최소 에너지나 최적화 문제의 해를 찾습니다.

제 컴퓨터에서 실행할 수 있나요?

네, PennyLane은 컴퓨터에서 양자 회로를 시뮬레이션할 수 있습니다. 실제 양자 하드웨어에서 실행하려면 특정 제공자에 대한 접근을 설정해야 합니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
51k
순위
#3525
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬