open-standards/wai/wai-quantum/docs/qasm-diagnostics.md
Transaction Science 71df7608d4
Some checks failed
wai-audit collector and player integration / does this change touch it (push) Successful in 46s
wai-quantum command line / does this change touch it (push) Successful in 37s
WAI operation catalogue / does this change touch it (push) Successful in 41s
wai-quantum for JavaScript / does this change touch it (push) Successful in 14s
wai-quantum contract / does this change touch it (push) Successful in 1m39s
wai-quantum editors / does this change touch it (push) Successful in 1m36s
wai-quantum docs, course and locales / does this change touch it (push) Successful in 1m41s
wai-quantum resource estimation / does this change touch it (push) Successful in 1m5s
wai-quantum other formats / does this change touch it (push) Successful in 1m5s
wai-quantum OpenQASM reader / does this change touch it (push) Successful in 40s
wai-quantum pulse and dynamics / does this change touch it (push) Successful in 59s
wai-quantum for Python / does this change touch it (push) Successful in 40s
wai-quantum service / does this change touch it (push) Successful in 42s
wai-quantum error correction and mitigation / does this change touch it (push) Successful in 1m16s
wai-quantum extension points / does this change touch it (push) Successful in 1m15s
wai-quantum service / service energy · linux packages (push) Failing after 19s
wai-quantum studio and desktop / does this change touch it (push) Successful in 1m17s
wai-quantum variational and algorithm library / does this change touch it (push) Successful in 1m12s
wai-quantum verdicts and repairs / does this change touch it (push) Successful in 1m11s
wai-quantum views in agent hosts / does this change touch it (push) Successful in 55s
WAI Studio / does this change touch it (push) Successful in 54s
wai-sink-swift native sink package / does this change touch it (push) Successful in 54s
wai-sink-android native sink library / does this change touch it (push) Successful in 49s
wai-quantum pulse and dynamics / the same bits · linux-arm64 (push) Successful in 3m31s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Failing after 6m28s
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux-arm64, release (push) Successful in 2m42s
wai-quantum extension points / the registry and the example · linux-arm64 (push) Successful in 7m2s
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (push) Successful in 5m57s
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 20s
wai-quantum wasmQ / does this change touch it (push) Successful in 14s
wai-audit collector and player integration / collector · linux (push) Successful in 2m0s
wai-quantum contract / the policy is linked, and the deprecations page reads (push) Successful in 11s
WAI operation catalogue / the catalogue and every door · linux (push) Successful in 8m36s
wai-quantum docs, course and locales / the Studio's words in every locale · linux (push) Successful in 18s
wai-quantum for JavaScript / javascript · linux (push) Successful in 5m24s
wai-quantum editors / editors · linux (push) Successful in 3m44s
wai-quantum contract / API compatibility · linux (push) Successful in 5m45s
wai-quantum other formats / the set under wasm32-wasip2 (wasmtime) (push) Successful in 2m32s
wai-quantum docs, course and locales / the course and the command line's languages · linux (push) Successful in 3m43s
wai-quantum OpenQASM reader / corpus under wasm32-wasip2 (wasmtime) (push) Successful in 1m7s
wai-quantum pulse and dynamics / reader, simulator and pulse jobs under wasm32-wasip2 (wasmtime) (push) Successful in 1m13s
wai-quantum other formats / readers, writers and the set · linux (push) Successful in 6m9s
wai-quantum OpenQASM reader / reader and corpus · linux (push) Successful in 3m41s
wai-quantum resource estimation / estimation and calibration · linux, release (push) Successful in 7m15s
wai-quantum contract / schemas and the committed tool lists · linux (push) Successful in 8m50s
wai-quantum pulse and dynamics / reader, simulator and pulse jobs · linux, release (push) Successful in 4m52s
wai-quantum for Python / python · linux (push) Successful in 4m16s
wai-quantum extension points / the registry under wasm32-wasip2 (wasmtime) (push) Successful in 1m17s
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux, release (push) Successful in 3m4s
wai-quantum error correction and mitigation / codes, decoders, texts and mitigation · linux, release (push) Successful in 4m53s
wai-quantum verdicts and repairs / the intent set and the verdict under wasm32-wasip2 (wasmtime) (push) Successful in 1m41s
wai-quantum verdicts and repairs / verdicts, repairs and the intent set · linux (push) Successful in 2m48s
WAI Studio / the catalogue's actions, the unit tests and the core · linux (push) Successful in 1m11s
wai-quantum service / service · linux (push) Failing after 6m47s
wai-quantum studio and desktop / studio · browser (push) Successful in 4m25s
wai-quantum views in agent hosts / views · a scripted host (push) Successful in 4m48s
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (push) Successful in 4m7s
wai-quantum extension points / the registry and the example · linux (push) Successful in 7m48s
wai-quantum command line / command line · macos (push) Successful in 2m41s
wai-quantum views in agent hosts / views · the page and its engine (push) Successful in 7m5s
wai-quantum editors / editors · macos (push) Successful in 1m28s
wai-quantum studio and desktop / desktop app · linux (push) Successful in 10m37s
wai-quantum pulse and dynamics / the same bits · macos (push) Successful in 1m4s
wai-quantum for Python / python · macos (push) Successful in 2m40s
wai-quantum service / service · macos (push) Successful in 6m20s
wai-quantum studio and desktop / desktop app · macos (push) Successful in 3m51s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Failing after 2m2s
WAI Studio / Studio in WebKit · linux (push) Successful in 23m30s
wai-quantum wasmQ / the reference modules rebuild to their modules of record · linux (push) Failing after 38s
wai-quantum wasmQ / profile, engines, reference modules, adversarial, vectors · linux (push) Successful in 3m42s
wai-quantum wasmQ / interpreter and vectors under wasm32-wasip2 (wasmtime) (push) Successful in 4m27s
WAI Studio / Studio in Chromium and Firefox · macos (push) Successful in 8m18s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 8m47s
wai-quantum studio and desktop / desktop app · windows (push) Successful in 10m34s
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (push) Successful in 10m14s
wai-quantum docs, course and locales / every command and snippet in the docs · linux (push) Successful in 50m35s
wai-quantum command line / command line · linux (push) Failing after 1h0m9s
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (push) Successful in 19m9s
wai-quantum wasmQ / profile, engines, reference modules, adversarial, vectors · macos (push) Successful in 1m49s
wai-quantum: the OpenQASM reader reads eight constructs as OpenQASM 3.1 defines them, and the feature matrix says what each path does
Held to the 3.1 specification construct by construct, the reader read these
to another program without a word; each now reads as the specification
says, with a test that failed first (qasm::spec_tests):

- ctrl @ U(θ, φ, λ): OpenQASM 3's U is e^{iθ/2} times OpenQASM 2's
  matrix (gates.rst), a phase a control sees. It read as controlled
  OpenQASM 2 U, a phase θ/2 short on the control; it is now
  cu(θ, φ, λ, θ/2). ctrl @ u3 and ctrl @ u2 carry e^{−i(φ+λ)/2}
  (standard_library.rst). stdgates.inc's own definitions written into a
  program are now its gates under ctrl @ (its x so written read as cx then
  sdg on the control, overlap 0.71). Uncontrolled, nothing changes.
- A gate a program defines under a built-in name ran the built-in gate and
  dropped the definition; the program's own gate now runs, noted with the
  new warning Q213, unless it is the built-in gate exactly (global phase
  included; up to one in OpenQASM 2), when the built-in gate stands in as
  before. `gate U` and `gate gphase` are refused (Q106).
- A mutable array argument given a slice or a row lost the subroutine's
  writes (subroutines.rst's own example); they are written back. A write
  to a readonly array argument was read; it is refused (new code Q131).
- angle[n] / angle[n] was a float ratio; it is the uint[n] quotient of
  their bits. A float cast to angle[n] exactly halfway rounded away from
  zero; it rounds to even.
- pow(r) @ of a gate written in U with global phases that cancel (the
  libraries' x and rx) was refused; it is the gate's principal power.

The conformance case qasm3/lang/ctrl_user.qasm held ctrl @ U(0.1, 0.2, 0.3)
to cu(0.1, 0.2, 0.3, 0), the first of these; its reference is now
cu(..., 0.05). The jeff reader writes jeff's controlled u, OpenQASM 2's U,
as cu(θ, φ, λ, 0). lang_tests' controlled-U and user-gate cases are held to
the specification's U. docs/qasm-feature-matrix.md gives every construct
with what the reader and the bit-exact path each do, the eight above
before and after, and what is refused and why; the CLI's committed docs
follow. wai-quantum-lang.yml requires the new tests by name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-10 14:23:24 -05:00

170 lines
21 KiB
Markdown

# OpenQASM reader: diagnostic codes
Every refusal and warning the reader gives (`wai_quantum::qasm`), and every
construct it lowers, carries or keeps verbatim, has a code. A refusal or a
warning reads, on every surface:
```text
line 3: unknown gate foo [Q103]
```
and, as data (`wai-quantum lint --json`, the MCP servers' `lint_qasm`, the
job service, the Studio), carries its `code`, its `outcome`, its `message`
and where it stands: `line`, `column` and `length`, in characters.
**Stability.** A code never changes meaning once released. A construct that
comes to be supported gets a new code for what now happens to it; the old
code keeps its row, marked retired, so a code in an old log or receipt still
means what it meant then. New codes are only ever added.
**Outcomes.**
- `refused`: the program is not read, and nothing runs.
- `lowered`: read and lowered exactly to the engine's gates and steps.
- `carried`: kept in the program as written (its timing, its outputs),
changing nothing a method computes unless the method says it uses it.
- `preserved`: kept verbatim for export, never executed.
- `warned`: read, with something the person should know; the job's result
lists it under `diagnostics`.
What is asked of a program (the request, the method, an intent, a repair,
the host) has codes of its own, `J…`: [job-refusals.md](job-refusals.md).
The verdict ([verdicts.md](verdicts.md)) carries a refusal's codes, and the
repair (`wai-quantum repair`, `repair_qasm`) makes the fixes that are
mechanical on the lines a diagnostic flags.
The table is also served as data: `wai_quantum::qasm::diag::codes()` in Rust,
`wai-quantum diagnostics [--json]` on the command line, the `qasm_diagnostics`
tool of both MCP servers, and `engine_diagnostic_codes()` in the browser
engine. A test holds this page to the code's table.
| Code | Outcome | Meaning |
|---|---|---|
| `Q001` | refused | A character that is not part of the language. |
| `Q002` | refused | A number that does not read: a malformed literal, or one too large to hold. |
| `Q003` | refused | A string, a block comment, a bracket or a calibration block that is not closed. |
| `Q004` | refused | Something else was expected here: a `;`, a name, an expression or a statement (the message says which). |
| `Q005` | refused | A statement in a place the language does not allow it: `else` with no `if`, `case` outside `switch`, a declaration inside a gate. |
| `Q006` | refused | A program nested deeper than the reader takes: statements, parentheses, operators, brackets and types more than 64 levels deep in its text (a run of one precedence, `a + b + c`, and an `else if` chain each count one, however long), an array of more than 7 dimensions, or more than 256 levels in all through the gates and subroutines it calls; refused, never read by a recursion that could run out of stack. |
| `Q010` | warned | An `OPENQASM` version other than 2.x or 3.x: the program is read as OpenQASM 3. |
| `Q011` | warned | An `include` of a file other than the standard libraries (`stdgates.inc`, `qelib1.inc`): its definitions are not read, so a gate it defines is unknown. |
| `Q012` | lowered | `include "stdgates.inc"` or `"qelib1.inc"`: the standard gates, `U`, `gphase` and OpenQASM 2's names are built in. |
| `Q013` | warned | A `pragma` or annotation the reader does not act on: kept, not applied. |
| `Q100` | refused | The program declares no qubits. |
| `Q101` | refused | A name declared twice in one scope, or given to two kinds of thing (a register and an integer). |
| `Q102` | refused | A name that is not declared: a register, a variable, an alias or a subroutine. |
| `Q103` | refused | A gate that is neither in the standard library nor defined in the program. |
| `Q104` | refused | A gate or subroutine given the wrong number of parameters, qubits or arguments. |
| `Q105` | refused | A declaration only the top level may make (qubits, a gate, a subroutine, an `extern`) inside a block. |
| `Q106` | refused | A word of the language, or a built-in constant (`pi`, `tau`, `euler`), used as a name. |
| `Q107` | refused | An index or slice outside its register or array. |
| `Q108` | refused | Registers of different lengths in one statement that applies to whole registers. |
| `Q109` | refused | One qubit named twice in one gate. |
| `Q110` | refused | A value of the wrong type here: a float where an integer is needed, a complex gate parameter, a qubit where a value is needed. |
| `Q111` | refused | More qubits than the reader takes (65 536). |
| `Q112` | refused | An integer outside its type's range (a negative `uint`, a value too wide for `int[n]`), or integer arithmetic that overflows. |
| `Q113` | refused | Division, or a remainder, by zero. |
| `Q114` | refused | An `input` given no value, or a value given for an input the program does not declare. |
| `Q115` | refused | An `input` of a type the reader takes no value for: only `int` and `uint` inputs are given values. |
| `Q116` | refused | A value that depends on a measurement used where the reader needs it on reading: a gate parameter, an index, a size, a loop's range. |
| `Q117` | refused | A gate parameter that is not a finite number. |
| `Q118` | refused | Integers divided with a remainder where a real number is wanted: OpenQASM 3 truncates `1/2` to 0 and OpenQASM 2 reads it as 0.5, so write `1.0/2`. |
| `Q119` | refused | `^` between integers in a program that does not say `OPENQASM 3`: OpenQASM 3 reads it as exclusive or, OpenQASM 2 as a power; write `**` for a power. |
| `Q120` | warned | `^` between real numbers, read as a power as OpenQASM 2 reads it; OpenQASM 3 writes `**`. |
| `Q121` | warned | A value rounded to its declared width, as the language defines (`angle[n]` to n bits of a turn, `float[32]` and `float[16]` to single and half precision); the message gives the amount. |
| `Q122` | refused | A type width the reader does not hold: a float other than `float[16]`, `float[32]` and `float[64]`, an integer or an angle wider than 64 bits. |
| `Q123` | refused | A cast the language does not allow, or one whose value does not fit. |
| `Q124` | refused | Physical qubits (`$0`) in a program that also declares qubits. |
| `Q125` | refused | A call of an `extern` function, whose body is outside the program. |
| `Q126` | refused | A call of an `opaque` gate, or of a gate with only a calibration: its matrix is not known. |
| `Q127` | refused | An assignment to a constant, an input or a loop variable. |
| `Q128` | refused | A measurement where a value is needed that is not a bit (measurement gives bits, into a bit register). |
| `Q129` | refused | A parameter (`input float`, `input angle`) a gradient cannot follow to the gates: under a modifier, in a classical variable, a condition, an index, a size, a loop's range, a subroutine or `gphase`, or one whose type rounds it (`angle[n]`, `float[32]`); a gradient follows a parameter through arithmetic, the built-in functions and gate definitions into a gate's arguments. |
| `Q130` | refused | A program whose reading would hold more memory than the reader takes: a classical value (an array, a bit register) of more than 64 MiB, each element counted at its width, or more than 512 MiB in all of its values, gates, steps, measurements and timing; refused before it is made. |
| `Q131` | refused | A write to a `readonly` array argument inside a subroutine: the argument is a reference to the caller's array, which a `readonly` one may not change. |
| `Q200` | lowered | A `gate` the program defines, inlined at each call with its parameters bound. |
| `Q201` | lowered | `ctrl @` and `negctrl @` on any gate, lowered exactly to standard gates (a negative control is a control between two `x`). |
| `Q202` | lowered | `inv @` on any gate, user gates included: each gate's exact inverse, in reverse order. |
| `Q203` | lowered | `pow(k) @` with an integer `k`: angles scaled, or the gate repeated; a negative `k` repeats the inverse. |
| `Q204` | lowered | `pow(r) @` with a fractional `r` where an exact gate exists: the principal power (`pow(1/2) @ x` is `sx`, `pow(r) @ rz(θ)` is `rz(rθ)` for \|θ\| < 2π). |
| `Q205` | refused | `pow(r) @` with a fractional `r` where no exact gate exists here: a user gate, `u`, `cu`, or a rotation by 2π or more. |
| `Q206` | lowered | `gphase(θ)`: a global phase, which no measurement sees, dropped; under controls it is a phase on the controls. |
| `Q207` | refused | A control modifier that adds no control: `ctrl(0) @`. |
| `Q208` | refused | Modifiers that add more controls than the reader lowers (16 written in standard gates, 255 on a gate a method holds whole). |
| `Q209` | refused | Gate definitions or subroutine calls nested deeper than 32. |
| `Q210` | refused | A program that expands to more gates than the reader holds (2 000 000), or that holds gates whole on more qubits than that in all. |
| `Q211` | refused | A modifier on something that is not a gate. |
| `Q212` | refused | A statement a gate's body may not hold: a gate holds gate calls, `gphase`, `barrier`, loops and conditions known on reading. |
| `Q213` | warned | A `gate` the program defines under a name the reader also has built in (a gate of the standard libraries, or another the reader knows), whose definition is not that gate exactly, global phase included: the program's own definition is the gate it runs. |
| `Q300` | lowered | An `if`, `while` or `switch` whose condition is known on reading: decided then. |
| `Q301` | lowered | A condition on measured bits (`c[0]`, `c == 3`, `c >= 2`, `&&`, `\|\|`, `!`), compiled to steps that branch on them. |
| `Q302` | refused | A condition that reads neither measured bits nor values known on reading. |
| `Q303` | refused | A bit register of more than one bit used as a condition: compare it with a number, as `c == 3`. |
| `Q304` | refused | A comparison with a number that does not fit in the bits compared. |
| `Q305` | refused | A negated operand compared with `==` or `!=` (`!c == 1`): write `c != 1`. |
| `Q306` | refused | Classical arithmetic on measured bits at run time, beyond a condition, or a comparison between two measured values: the program's steps branch on bits and hold no other run-time values. |
| `Q307` | refused | A condition that reads more than 64 bits. |
| `Q308` | lowered | `for` over a range, a set or an array: unrolled, once per value. |
| `Q309` | lowered | `while` whose condition is known on reading: unrolled until it fails. |
| `Q310` | refused | A `while` whose condition reads measured bits and that declares no bound: add `@wai.max_iterations N` before it. |
| `Q311` | warned | A `while` on measured bits run at most its declared bound (`@wai.max_iterations N`): a run that still meets its condition after N iterations stops looping there. |
| `Q312` | refused | A program that does not finish unrolling within the reader's bound (20 000 000 statements and loop iterations), or that runs out a caller's budget of reading (`qasm::within_steps`: statements, gates and a generator's loop passes, shared by every program read under it). |
| `Q313` | refused | A range with a zero step, or that does not read as `[start:end]` or `[start:step:end]`. |
| `Q314` | refused | `break` or `continue` outside a loop, or `return` outside a subroutine. |
| `Q315` | refused | A `return` with a value under a condition on measured bits. |
| `Q316` | lowered | `break`, `continue`, `return` and `end`: under a condition on measured bits, a jump forward in the steps. |
| `Q317` | lowered | `switch`: decided on reading, or a chain of conditions on measured bits. |
| `Q318` | lowered | A `def` subroutine, inlined at each call: classical arguments by value, qubits by reference, its `return` value given back. |
| `Q319` | refused | A bit given anything but a measurement at run time: bits are written by measurement (a declaration may give them 0). |
| `Q320` | refused | A measurement whose result goes nowhere: `measure q;` while bit registers are declared (write `c = measure q;`). |
| `Q321` | refused | Qubits measured into a different number of bits. |
| `Q322` | lowered | A bit declared inside a block or a subroutine: a bit of its own, which the steps read and the results do not show. |
| `Q323` | refused | A program past a bound its reader holds it to as it reads it: qubits, bits, steps, the bits its calls of externs take and give, or the work of reading it (a reader of programs from others, as the hybrid profile reads them). |
| `Q324` | refused | A measurement with no target bit (`measure q;`) in a program that calls externs: its outcome is the bits it declares, so each measurement names the bit it writes (write `c = measure q;`). |
| `Q400` | warned | The method applies no durations: the program's delays, boxes and stretches change nothing it computes, and the result says so. |
| `Q401` | carried | `delay[d]` on qubits, carried in the program's timing. |
| `Q402` | carried | `box` (with or without a duration), carried in the timing around the gates it holds. |
| `Q403` | carried | `stretch`: a duration a scheduler would solve, carried by name. |
| `Q404` | carried | `barrier`, carried in the timing; it changes no gate. |
| `Q405` | refused | `durationof(…)`: it needs gate durations, which the program does not give the reader. |
| `Q406` | refused | A duration that does not read: no unit, negative, or not known on reading. |
| `Q407` | carried | A gate's duration (`x[20ns] q;`), carried in the timing, not applied. |
| `Q450` | preserved | `defcal`: kept verbatim for export, never executed; the gate's matrix comes from its `gate` definition or the standard library. |
| `Q451` | preserved | `cal { … }`: kept verbatim for export, never executed. |
| `Q452` | preserved | `defcalgrammar`: kept verbatim for export. |
| `Q453` | lowered | In a pulse run, a `cal` or `defcal` body read as OpenPulse and lowered to the schedule on frames (plays, delays, phase and frequency changes, captures and barriers) that the pulse simulator integrates. |
| `Q454` | refused | In a pulse run, a `defcalgrammar` other than `"openpulse"`: the pulse reader reads OpenPulse alone. |
| `Q455` | refused | A statement in a calibration that the pulse reader does not take: classical control, a frame's attributes or `get_phase`, an `extern` function, a frame made inside a `defcal`, a nested calibration, or a `defcal` over qubit arguments (the message names it and what to write instead). |
| `Q456` | refused | A waveform that does not read: a template the reader does not know, arguments of the wrong number or kind, a length or a width that is not positive, a sample that is not a number, or more samples than it holds. |
| `Q457` | refused | A frame or a port that does not read: a play, a delay or a phase or frequency change on a name that is not a frame, `newframe` on a name that is not a port, a frequency that is not a number, or a port that reaches no qubit. |
| `Q458` | refused | A duration in a calibration that is not a whole, non-negative number of samples at the sample period (`dt`), or a schedule longer than the reader holds. |
| `Q459` | refused | In a pulse run, a gate or a measurement on physical qubits that no `defcal` calibrates for those qubits and those parameters. |
| `Q460` | refused | In a pulse run, a statement outside the calibrations that the pulse reader does not take: declared qubits (a pulse program names physical qubits, `$0`), a modifier, `reset`, classical control, a subroutine, or a measurement into something other than a bit. |
| `Q461` | refused | A capture that does not read: not on a frame of an acquisition port, without a duration or a waveform, or its result put somewhere other than a bit. |
| `Q462` | warned | A play on a measurement port: scheduled and timed, its effect on the readout not simulated (a capture reads the qubit's state). |
| `Q500` | refused | An angle that is not a dyadic multiple of 2π (2πm/2^k, k ≤ 32): the bit-exact method refuses it, never rounds it; the methods in double precision take it. |
| `Q501` | refused | More than 255 qubits for the bit-exact circuit. |
| `Q502` | refused | A program that measures a qubit and then acts on it, resets one after its first gate, or acts on measured bits: the bit-exact circuit takes programs whose measurements all come at the end. |
| `Q600` | carried | An `output` declaration, carried into the result: its bits (their places in each outcome) or its value. |
| `Q601` | refused | An `output` that is not a bit and whose value depends on a measurement at the end. |
| `Q700` | refused | A file that does not read in the format named: QIR that is not LLVM text with one entry point, or jeff that is not a Cap'n Proto message of the jeff schema (a pointer outside the message, a struct or list of the wrong shape, more than the reader takes); the message says what and where. |
| `Q701` | refused | A format version the reader does not take: QIR whose `qir_major_version` is not 1 or 2, or jeff other than 0.2 and 0.3. |
| `Q702` | warned | A QIR module that leaves out what its profile requires (the `qir_profiles` attribute, the version flags, `required_num_qubits`, `required_num_results`, the `entry_point` attribute of its only function): read from what it holds, and said so. |
| `Q703` | refused | A QIR profile the reader does not take: `qir_profiles` names neither `base_profile` nor `adaptive_profile`. |
| `Q704` | refused | What the module's own QIR profile forbids: under the base profile a branch, a classical instruction, reading a result, or a gate or reset on a qubit after its measurement; under the adaptive profile an optional capability its module flags do not declare (computation on integers or floats of a type, IR-defined functions, loops, `switch`, several returns, dynamic qubits or results, arrays). |
| `Q705` | refused | A QIR capability the module may use that this reader does not take: loops, `switch`, `phi`, IR-defined functions, dynamic allocation of qubits or results, arrays, controlled forms that take their controls in an array, or a classical value computed from a measurement anywhere but a branch's condition. |
| `Q706` | refused | An instruction or function the reader does not know: a quantum intrinsic outside the gates it reads (`docs/formats.md` lists them), a runtime function it does not take, an LLVM instruction no profile lists, or a function a module declares and does not define. |
| `Q707` | refused | A QIR operand that does not read: a qubit or result that is not a constant index, an index past `required_num_qubits` or `required_num_results`, or an angle that is not a finite number known on reading. |
| `Q708` | refused | A value whose meaning the program's text cannot keep: in QIR a result read, measured again and only then branched on; in jeff a qubit the two sides of a branch on a measurement leave in different places. |
| `Q709` | warned | Rotations at angles that are not dyadic multiples of 2π, read at their exact doubles: the double-precision methods take them; the bit-exact method refuses them (Q500). |
| `Q710` | refused | A jeff custom gate the reader does not know: its name is not a gate of the standard library (in any case), or its qubits or parameters are not that gate's. |
| `Q711` | warned | A jeff custom gate named as a gate of the standard library (`H`, `CX`, `Rx`, in any case) with that gate's qubits and parameters: read as that gate, by its name alone. |
| `Q712` | lowered | A jeff Pauli-product rotation, `exp(iθP)` as its schema defines it, lowered exactly to basis changes, a parity ladder and one `rz`. |
| `Q713` | refused | A jeff value used where it cannot be: a qubit or register used twice, a value used before it is defined or never defined, a cycle, or a value of the wrong type or count for its operation. |
| `Q714` | refused | A jeff value the reader needs on reading and cannot know: a gate angle, a loop's bounds or a `while` condition from a measurement, a register's size or index, a `switch` on a value that is neither known nor a measured bit, or integer arithmetic on a measured bit beyond not, and, or, xor, eq and select. |
| `Q715` | lowered | jeff's structured control flow: a `for` or `while` decided on reading unrolled, a `switch` on a known value decided, a `switch` on a measured bit written as `if … else`, and a call of a function the module defines inlined. |
| `Q716` | warned | A jeff entry point that takes qubits: they are the program's first qubits, starting in \|0⟩, and the qubits it returns are not measured. |
| `Q720` | refused | A program the format written cannot hold as it is: under QIR's base profile a measurement in the middle, a reset after a gate or a condition (write the adaptive profile), a loop in QIR, or in jeff a branch on a measured bit. |
| `Q721` | warned | What the format read or written has no place for, left out and said so: delays, boxes, barriers and gate durations, calibrations, `output` declarations, and classical values recorded as output. |
See `qasm-feature-matrix.md` for each construct of OpenQASM 3.1 and its code. The codes from `Q700` are those of the readers and writers of other formats (QIR and jeff, `formats.md`).