circuits-devices
Build and debug PennyLane QNodes, devices, measurements, shots, drawing, and device-test CLI workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- circuits-devices
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build and debug PennyLane QNodes, devices, measurements, shots, drawing, and device-test CLI workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md3.6 KB
- 参考文档references/troubleshooting.md2.6 KB
- 参考文档references/workflows.md2.6 KB
- 脚本scripts/device_help.sh214 B
- 脚本scripts/qnode_smoke.py520 B
03 SKILL.md 正文
Circuits, QNodes, devices, and measurements
Use this sub-skill when the task asks how to create, execute, inspect, or debug PennyLane circuits. It owns QNodes, device selection, measurements, shots, drawing, mid-circuit measurement routing, and the device-test CLI.
Read first
references/api-reference.md: signatures and core objects forQNode,qnode,device, measurements, drawing, andexecute.references/workflows.md: recipes for QNode creation, finite shots, drawing, and device-test checks.references/troubleshooting.md: device, wire, shot, measurement-shape, and mid-circuit failure modes.scripts/qnode_smoke.py: safe CPU QNode smoke script.scripts/device_help.sh: helper to displaypl-device-test --helpwhen the console script is installed.
Route within this sub-skill
- Basic circuit creation: use
qp.device(...), define a quantum function with operations, return measurement processes, and wrap it with@qp.qnode(dev)orqp.QNode(func, dev). - Device choice: start with
default.qubitfor ordinary pure-state CPU simulation; usedefault.mixedfor noisy/mixed-state workflows,default.cliffordfor Clifford circuits,default.tensorfor tensor-network style simulation,reference.qubitfor reference checks, andnull.qubitfor dry/resource-like runs. - Measurements: use
qp.expval,qp.var,qp.probs,qp.sample,qp.counts,qp.state,qp.density_matrix, entropy/purity/mutual-info functions, and shadows according to the requested return type. - Shots: analytic workflows use exact-style returns; sampling/counts require finite shots. Use
qp.set_shotsor QNode/device update methods when changing shot behavior. - Drawing/inspection: use
qp.draw(qnode)(*args)for text diagrams andqp.draw_mpl(qnode)(*args)for Matplotlib figures. - Plugin/device validation: use
pl-device-test --helpfirst, then choose explicit--device,--shots,--analytic, and--device-kwargsvalues.
Boundaries
- Operations/templates and circuit transforms are owned by
../operators-transforms/SKILL.md. - Gradients/interfaces/training are owned by
../gradients-interfaces/SKILL.md. - Domain modules such as qchem/qcut/resource are owned by
../applications-qchem-resource/SKILL.md. - Import/export, datasets, logging, and debugging snapshots are owned by
../io-data-logging/SKILL.md, although snapshot measurements can be used inside circuits. - Source-checkout test/lint policy is owned by
../repo-development/SKILL.md.
Minimal pattern
import pennylane as qp
angles = qp.numpy.array([0.1, 0.2], requires_grad=True)
dev = qp.device("default.qubit", wires=2)
@qp.qnode(dev)
def circuit(params):
qp.RX(params[0], wires=0)
qp.CNOT(wires=[0, 1])
qp.RY(params[1], wires=1)
return qp.expval(qp.Z(1))
value = circuit(angles)
print(value)
print(qp.draw(circuit)(angles))
Verification cues
A good answer or code change in this area should state the chosen device, wires, shot setting, measurement return shape, interface/diff assumptions if gradients are involved, and a tiny QNode smoke check. For source-checkout changes, native candidates include QNode, device, and measurement tests mirrored under tests/workflow/, tests/devices/, and tests/measurements/.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).