program-authoring
Enables construction, inspection, transformation, serialization, and diagram generation for PyQuil Programs, Quil, and Quil-T without executing a quantum job.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- program-authoring
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Enables construction, inspection, transformation, serialization, and diagram generation for PyQuil Programs, Quil, and Quil-T without executing a quantum job.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md9.9 KB
- 参考文档references/quil-t-and-diagrams.md7.0 KB
- 参考文档references/troubleshooting.md8.7 KB
- 参考文档references/workflows.md8.2 KB
- 脚本scripts/build_bell_program.py2.5 KB
03 SKILL.md 正文
Program authoring
Use this route when the task is about writing or understanding Quil rather than
submitting it: Program, standard gates, DECLARE, MEASURE, memory
references, placeholders, custom gates, classical labels/branches, PRAGMA,
Quil-T definitions, out(), parsing, or LaTeX diagrams.
This sub-skill constructs and validates program text locally. It does not compile, submit, simulate, estimate noise, query a processor, or prove that a QPU/QVM/service accepts a program.
Route the task first
| Request | Use |
|---|---|
| Build, parse, compose, parameterize, address, inspect, or serialize Quil | This sub-skill |
Compile, select a QuantumComputer, call QAM/QVM/QPU, or inspect job results |
compile-execute |
| Obtain statevectors, probabilities, expectations, or local numerical dynamics | simulation |
Build NoiseModel, Pauli, Experiment, calibration, or estimation workflows |
noise-experiments |
| Build or inspect topology, ISA, processor connectivity, or gate availability | processor-isa |
Read api-reference.md before relying on a
signature or subtle mutability/serialization rule. Read
workflows.md for end-to-end authoring recipes.
Read quil-t-and-diagrams.md for pulse,
frame, calibration, waveform, or LaTeX work. Read
troubleshooting.md after an exception or
when a program looks valid in Python but its Quil is suspect.
For a deterministic, service-free Bell construction and canonical Quil check,
run scripts/build_bell_program.py. It only
constructs and serializes a Program; it never calls a compiler, QVM, QPU, or
external service:
python scripts/build_bell_program.py --help
python scripts/build_bell_program.py --validate-only
python scripts/build_bell_program.py
Authoring contract
- Import
Programfrompyquil; import gates frompyquil.gates; usepyquil.quilatomforMemoryReference,Parameter, placeholders, labels, frames, and waveform invocations; usepyquil.quilbasefor instruction and definition classes. - Construct from typed instructions where possible.
Program(...),.inst,+=,+, and Quil strings are supported. Keep the sourceProgramwhen a second variant is needed:+and.copy()avoid accidental edits to the original, while.inst,+=,.measure,.declare, and.wrap_in_numshots_loopmutate it. - Declare every memory region intentionally and retain the returned base
MemoryReference. Check offsets yourself, especially for parsed or manually created references whose declaration size is unknown. - Resolve every
QubitPlaceholderandLabelPlaceholderbefore callingout()for submission-shaped Quil. Preferaddress_qubits(program, mapping)when a physical mapping is part of the requirement; it returns a copy. - Treat
program.out()as a local serialization observation. Round-trip withProgram(program.out()).out()when a stable Quil representation is needed; this is parsing/serialization validation, not execution validation. - Use
wrap_in_numshots_loop(shots)only to setprogram.num_shots; it does not add a Quil loop and does not run shots. For an actual Quil loop, usewith_loopwith anINTEGERcounter and explicit labels. - Use
out(calibrations=False)only to omit calibration definitions. It can still contain other Quil-T/global definitions such as frames and waveforms. Useremove_quil_t_instructions()only when a deliberately stripped, non-Quil-T variant is wanted; it is not a general compiler compatibility proof. - For custom gates, validate matrix shape/unitarity, parameter count, and qudit argument count explicitly before composing. For classical branches, declare and populate the condition memory, then resolve generated labels.
- For LaTeX, prefer
to_latex(program)when the required output is source text.display(program)additionally needs IPython pluspdflatex, ImageMagickconvert, and a suitable LaTeX installation; neither function executes the program.
Quick local skeleton
from pyquil import Program
from pyquil.gates import CNOT, H, MEASURE
program = Program()
ro = program.declare("ro", "BIT", 2)
program += [H(0), CNOT(0, 1)]
program += [MEASURE(0, ro[0]), MEASURE(1, ro[1])]
quil_text = program.out()
assert Program(quil_text).out() == quil_text
The expected output is ordinary Quil beginning with DECLARE ro BIT[2], then
H 0, CNOT 0 1, and the two measurements. This confirms construction and
round-trip parsing only. Hand the validated Program to
compile-execute, simulation,
or noise-experiments only when that later
workflow is explicitly requested.
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).