인터페이스는 현지화되어 있으며, Skill 소개와 설명 문서는 선택한 언어로 AI가 자동 번역합니다. 코드·명령어·경로·전문 용어는 원문을 유지하며 원작자 문서가 우선합니다.
Skills 둘러보기
생산성 및 협업 · SKILL.md

gradients-interfaces

gradients-interfaces

Configure PennyLane gradients, differentiable interfaces, optimizers, TorchLayer, and optional compiler/qjit workflows.

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill 문서

GitHub

name: gradients-interfaces description: "Configure PennyLane gradients, differentiable interfaces, optimizers, TorchLayer, and optional compiler/qjit workflows." metadata: disco-role: operating disable-model-invocation: true license: Apache 2.0

Gradients and interfaces

Use this sub-skill when a task involves differentiating QNodes, choosing diff_method, using Autograd/JAX/Torch/TensorFlow arrays, training hybrid models, converting QNodes to TorchLayer, or troubleshooting gradient/interface behavior.

Read first

Route within this sub-skill

  • Base gradients: use qp.grad, qp.jacobian, qp.value_and_grad, qp.vjp, qp.jvp, and gradient transforms under qp.gradients.
  • Interface selection: set interface="auto", "autograd", "jax", "torch", or legacy "tf" deliberately when auto-detection is ambiguous.
  • Differentiation method: start with diff_method="best"; choose parameter-shift, finite-diff, backprop, adjoint, SPSA, or device-specific methods only when the device/measurement/workflow requires it.
  • Training loops: use PennyLane optimizers for Autograd/NumPy workflows; use native JAX/Torch optimizers for those frameworks.
  • QNN: use qp.qnn.TorchLayer(qnode, weight_shapes, init_method=None) when integrating a QNode into torch.nn.
  • Compilation: qp.qjit routes to Catalyst-backed workflows; do not claim qjit availability until Catalyst runtime is installed and checked.

Boundaries

Minimal Autograd pattern

import pennylane as qp

dev = qp.device("default.qubit", wires=1)

@qp.qnode(dev)
def circuit(theta):
    qp.RX(theta, wires=0)
    return qp.expval(qp.Z(0))

theta = qp.numpy.array(0.2, requires_grad=True)
print(circuit(theta))
print(qp.grad(circuit)(theta))

If qp.grad returns () or warns about no trainable parameters, use a trainable PennyLane NumPy tensor or pass argnums explicitly.

Verification cues

State the array framework, QNode interface, diff_method, measurement type, shot setting, optional dependency status, and a numeric gradient check. For source changes, choose focused tests under tests/gradients/, tests/test_grad.py, interface-marked tests, or tests/qnn/ depending on the changed surface.

저장한 Skills