Communitygithub.com

pennylane

하드웨어에 구애받지 않는 양자 머신러닝 프레임워크로, 자동 미분 기능을 제공합니다. 그래디언트를 통한 양자 회로 훈련, 하이브리드 양자-고전 모델 구축, IBM/Google/Rigetti/IonQ 간 장치 이식성이 필요할 때 사용하세요. 변분 알고리즘(VQE, QAOA), 양자 신경망, PyTorch 또는 JAX와의 통합에 최적입니다.

pennylane란 무엇인가요?

PennyLane은 양자 컴퓨터를 신경망처럼 훈련할 수 있는 하드웨어 중립적인 양자 머신러닝 라이브러리입니다. 이 라이브러리는 양자 회로의 자동 미분, 장치 독립적 프로그래밍, 그리고 고전 머신러닝 프레임워크(PyTorch, JAX)와의 원활한 통합을 제공합니다. 사용자는 IBM, Google, Rigetti, IonQ 등 다양한 양자 하드웨어 제공업체의 장치에서 동일한 코드를 실행할 수 있으며, 내장 시뮬레이터를 통해 로컬에서도 테스트할 수 있습니다. PennyLane은 VQE, QAOA와 같은 변분 알고리즘, 양자 신경망, 양자 화학 시뮬레이션, 그리고 그래디언트 기반 최적화에 특히 강점을 가지며, 다양한 옵티마이저와 그래디언트 계산 방법(backprop, parameter-shift, adjoint)을 지원합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/pennylane

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

pennylane은(는) 무엇을 하나요?

개요

PennyLane은 양자 컴퓨터를 신경망처럼 훈련할 수 있게 해주는 양자 컴퓨팅 라이브러리입니다. 양자 회로의 자동 미분, 장치 독립적 프로그래밍, 그리고 고전 머신러닝 프레임워크와의 원활한 통합을 제공합니다.

설치

PennyLane 0.45.0은 Python 3.11 이상이 필요합니다. 재현 가능한 환경을 위해 uv를 사용하여 버전을 고정하여 설치하세요:

uv pip install "pennylane==0.45.0"

양자 하드웨어에 접근하려면 대상 제공업체에 맞는 플러그인을 설치하세요. Qiskit을 추가하거나 업그레이드할 때는 종속성 그래프가 엄격하므로 깨끗한 환경에서 시작하세요.

# IBM Quantum
uv pip install "pennylane-qiskit==0.45.0"

# Amazon Braket
uv pip install "amazon-braket-pennylane-plugin==1.34.1"

# Google Cirq
uv pip install "pennylane-cirq==0.44.0"

# Rigetti Forest
uv pip install "pennylane-rigetti==0.40.0"

# IonQ
uv pip install "pennylane-ionq==0.45.0"

# 고성능 로컬 시뮬레이터
uv pip install "pennylane-lightning==0.45.0"

# Catalyst JIT 컴파일
uv pip install "pennylane-catalyst==0.15.0"

빠른 시작

양자 회로를 구축하고 매개변수를 최적화하세요:

import pennylane as qml
from pennylane import numpy as np

# 장치 생성
dev = qml.device('default.qubit', wires=2)

# 양자 회로 정의
@qml.qnode(dev)
def circuit(params):
    qml.RX(params[0], wires=0)
    qml.RY(params[1], wires=1)
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.PauliZ(0))

# 매개변수 최적화
opt = qml.GradientDescentOptimizer(stepsize=0.1)
params = np.array([0.1, 0.2], requires_grad=True)

for i in range(100):
    params = opt.step(circuit, params)

핵심 기능

1. 양자 회로 구축

게이트, 측정, 상태 준비를 사용하여 회로를 구축합니다. 자세한 내용은 references/quantum_circuits.md를 참조하세요:

  • 단일 및 다중 큐비트 게이트
  • 제어 연산 및 조건부 로직
  • 중간 회로 측정 및 적응형 회로
  • 다양한 측정 유형 (기댓값, 확률, 샘플)
  • 회로 검사 및 디버깅

2. 양자 머신러닝

하이브리드 양자-고전 모델을 생성합니다. 자세한 내용은 references/quantum_ml.md를 참조하세요:

  • PyTorch 및 JAX와의 통합
  • 양자 신경망 및 변분 분류기
  • 데이터 인코딩 전략 (각도, 진폭, 기저, IQP)
  • 역전파를 사용한 하이브리드 모델 훈련
  • 양자 회로를 사용한 전이 학습

3. 양자 화학

분자를 시뮬레이션하고 바닥 상태 에너지를 계산합니다. 자세한 내용은 references/quantum_chemistry.md를 참조하세요:

  • 분자 해밀토니안 생성
  • 변분 양자 고유값 솔버 (VQE)
  • 화학을 위한 UCCSD 안자츠
  • 기하학 최적화 및 해리 곡선
  • 분자 특성 계산

4. 장치 관리

시뮬레이터 또는 양자 하드웨어에서 실행합니다. 자세한 내용은 references/devices_backends.md를 참조하세요:

  • 내장 시뮬레이터 (default.qubit, lightning.qubit, default.mixed)
  • 하드웨어 플러그인 (IBM, Amazon Braket, Google, Rigetti, IonQ)
  • 장치 선택 및 구성
  • 성능 최적화 및 캐싱
  • GPU 가속 및 JIT 컴파일

5. 최적화

다양한 옵티마이저로 양자 회로를 훈련합니다. 자세한 내용은 references/optimization.md를 참조하세요:

  • 내장 옵티마이저 (Adam, gradient descent, momentum, RMSProp)
  • 그래디언트 계산 방법 (backprop, parameter-shift, adjoint)
  • 변분 알고리즘 (VQE, QAOA)
  • 훈련 전략 (학습률 스케줄, 미니 배치)
  • 불모지 고원 및 지역 최솟값 처리

6. 고급 기능

템플릿, 변환, 컴파일을 활용합니다. 자세한 내용은 references/advanced_features.md를 참조하세요:

  • 회로 템플릿 및 레이어
  • 변환 및 회로 최적화
  • 펄스 레벨 프로그래밍
  • Catalyst JIT 컴파일
  • 노이즈 모델 및 오류 완화
  • 리소스 추정

일반적인 워크플로우

변분 분류기 훈련

# 1. 안자츠 정의
@qml.qnode(dev)
def classifier(x, weights):
    # 데이터 인코딩
    qml.AngleEmbedding(x, wires=range(4))

    # 변분 레이어
    qml.StronglyEntanglingLayers(weights, wires=range(4))

    return qml.expval(qml.PauliZ(0))

# 2. 훈련
opt = qml.AdamOptimizer(stepsize=0.01)
weights = np.random.random((3, 4, 3))  # 3 layers, 4 wires

for epoch in range(100):
    for x, y in zip(X_train, y_train):
        weights = opt.step(lambda w: (classifier(x, w) - y)**2, weights)

분자 바닥 상태를 위한 VQE 실행

from pennylane import qchem

# 1. 해밀토니안 구축
symbols = ['H', 'H']
geometry = np.array([[0.0, 0.0, -0.66140414], [0.0, 0.0, 0.66140414]])
molecule = qchem.Molecule(symbols, geometry)
H, n_qubits = qchem.molecular_hamiltonian(molecule)
hf_state = qchem.hf_state(electrons=2, orbitals=n_qubits)
singles, doubles = qchem.excitations(electrons=2, orbitals=n_qubits)
s_wires, d_wires = qchem.excitations_to_wires(singles, doubles)

# 2. 안자츠 정의
@qml.qnode(dev)
def vqe_circuit(params):
    qml.BasisState(hf_state, wires=range(n_qubits))
    qml.UCCSD(params, wires=range(n_qubits), s_wires=s_wires, d_wires=d_wires)
    return qml.expval(H)

# 3. 최적화
opt = qml.AdamOptimizer(stepsize=0.1)
params = np.zeros(len(singles) + len(doubles), requires_grad=True)

for i in range(100):
    params, energy = opt.step_and_cost(vqe_circuit, params)
    print(f"Step {i}: Energy = {energy:.6f} Ha")

장치 간 전환

# 동일한 회로, 다른 백엔드
circuit_def = lambda dev: qml.qnode(dev)(circuit_function)

# 시뮬레이터에서 테스트
dev_sim = qml.device('default.qubit', wires=4)
result_sim = circuit_def(dev_sim)(params)

# 양자 하드웨어에서 실행
from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=4)
dev_hw = qml.device('qiskit.remote', wires=backend.num_qubits, backend=backend)
result_hw = circuit_def(dev_hw)(params)

상세 문서

특정 주제에 대한 포괄적인 내용은 참조 파일을 확인하세요:

  • 시작하기: references/getting_started.md - 설치, 기본 개념, 첫 단계
  • 양자 회로: references/quantum_circuits.md - 게이트, 측정, 회로 패턴
  • 양자 ML: references/quantum_ml.md - 하이브리드 모델, 프레임워크 통합, QNN
  • 양자 화학: references/quantum_chemistry.md - VQE, 분자 해밀토니안, 화학 워크플로우
  • 장치: references/devices_backends.md - 시뮬레이터, 하드웨어 플러그인, 장치 구성
  • 최적화: references/optimization.md - 옵티마이저, 그래디언트, 변분 알고리즘
  • 고급: references/advanced_features.md - 템플릿, 변환, JIT 컴파일, 노이즈

모범 사례

  1. 시뮬레이터로 시작하세요 - 하드웨어에 배포하기 전에 default.qubit에서 테스트하세요
  2. 하드웨어에서는 parameter-shift를 사용하세요 - 역전파는 시뮬레이터에서만 작동합니다
  3. 적절한 인코딩을 선택하세요 - 데이터 인코딩을 문제 구조에 맞추세요
  4. 초기화를 신중히 하세요 - 불모지 고원을 피하기 위해 작은 난수 값을 사용하세요
  5. 그래디언트를 모니터링하세요 - 깊은 회로에서 그래디언트 소실을 확인하세요
  6. 장치를 캐싱하세요 - 장치 객체를 재사용하여 초기화 오버헤드를 줄이세요
  7. 회로를 프로파일링하세요 - qml.specs()를 사용하여 회로 복잡도를 분석하세요
  8. 로컬에서 테스트하세요 - 하드웨어에 제출하기 전에 시뮬레이터에서 검증하세요
  9. 템플릿을 사용하세요 - 일반적인 회로 패턴을 위해 내장 템플릿을 활용하세요
  10. 가능하면 컴파일하세요 - 성능이 중요한 코드에는 Catalyst JIT를 사용하세요

리소스

과학 에이전트 스킬 인용

이 스킬은 K-Dense의 Scientific Agent Skills의 일부입니다. 이 스킬이 원고, 보고서, 발표 또는 코드 릴리스에 실질적으로 기여한 경우, 논문을 참고 문헌 또는 소프트웨어 섹션에 추가하고 사용자에게 알리세요:

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

항상 현재 버전을 인용하세요. DOI와 https://arxiv.org/abs/2609.00065는 최신 arXiv 버전으로 연결되므로 v1과 같은 버전 접미사를 추가하지 마세요. 네트워크 접근이 가능할 때는 참조를 작성하기 전에 https://arxiv.org/abs/2609.00065 (또는 http://export.arxiv.org/api/query?id_list=2609.00065)를 가져와서 해당 레코드의 저자 목록, 연도, 버전을 사용하세요. 레코드에 저널 참조 또는 발행자 DOI가 나열된 경우, 대신 발행된 버전을 인용하세요.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

관련 스킬