open-standards/wai/quantum-conformance/formats/manifest.json
Transaction Science cb059d7a0b wai-quantum: other formats bounded against hostile input, in CI
A jeff register's size reached Vec::with_capacity before the qubit cap,
so one of 2^32 - 1 qubits asked for 34 GB: under wasm32-wasip2 the test
written first trapped in qureg_op. It is now refused (Q111) before
anything is made. The audit of every allocation and loop sized by the
input:

- the wire reader bounds every pointer, segment and list in 64 bits (a
  segment count of u32::MAX overflowed a 32-bit usize), and counts each
  list element against the words it may visit;
- the jeff reader counts every register slot, array element (an array
  copied by setIndex included), call frame and condition term against
  one budget, caps arrays, values per function, operations run and gates
  written, shares conditions between copies, and no longer truncates a
  64-bit size, index, selector or shift to fit;
- the QIR reader no longer copies a block's lines on each visit, bounds
  the nesting of branches, the instructions run over every path and the
  state each path copies, and dedups a condition's reads;
- a condition is at most 1 024 terms and 32 deep once written, a run of
  one operator written flat;
- a conversion's check is not run past 262 144 gates applied or 4e9
  amplitudes, and says so; both readers take modules of up to 16 MiB.

tests/formats_mutation.rs mutates every QIR and jeff file of the
conformance set from a fixed seed (45 153 inputs: bits flipped, files cut
short and spliced, every length, count, offset and 32-bit field inflated)
and holds each to converting or a refusal with a code of the table,
within 20 s and 1 GiB measured by a counting allocator.
wai-quantum-formats.yml runs it natively and under wasm32-wasip2 (a
release build with overflow checks), the count pinned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 07:16:32 -04:00

856 lines
17 KiB
JSON

{
"format": "wai.formats-conformance/1",
"about": "Programs in other formats, each with what the engine must do with it: QIR modules (base and adaptive profiles) and jeff modules read, with the program each reads to and the refusals with their codes and places; OpenQASM sources written to each format and read back. jeff/upstream/ holds the jeff project's own structured benchmarks and examples, unchanged (Apache-2.0); the QIR specification's two example programs are its own (MIT).",
"expectations": {
"refused": "reading refuses the module with this code; `line` is the QIR line it names, `at` a phrase of where in a jeff module (a function and an operation)",
"notes": "the codes of every warning and note the reader gives, sorted (none when empty)",
"profile": "the QIR profile it is read under",
"dynamic": "whether the program read measures in the middle, resets or branches",
"qubits": "the qubits of the program read",
"reference": "(beside expect) an OpenQASM program the reading must be the same circuit as, by the equivalence ladder; `how` the check that must decide it",
"exact": "the bit-exact method takes the program read",
"outcomes": "the outcomes 512 shots give (seed 7), every one of them and no other",
"equal_bits": "pairs of bits equal in every outcome",
"round_trip": "written back to its format and read again, the two readings the same by the ladder (or by every outcome's probability, for a program that branches)",
"writes": "converted to each format named, the output read back and held to the program: the same (`how` the check that decides it), under a `profile`, with these `notes`, its bytes' BLAKE3 for QIR, or `refused` with a code (`profile_asked` asks for a profile)"
},
"cases": [
{
"file": "qir/bell_base.ll",
"format": "qir",
"covers": [
"the base profile's own example",
"output records with labels"
],
"reference": "qir/bell.ref.qasm",
"expect": {
"profile": "base",
"notes": [],
"how": "tableau",
"outcomes": [
"00",
"11"
],
"round_trip": true
}
},
{
"file": "qir/every_intrinsic.ll",
"format": "qir",
"covers": [
"every intrinsic the reader takes",
"angles in decimal, with an exponent and in hex",
"__adj forms"
],
"reference": "qir/every_intrinsic.ref.qasm",
"expect": {
"profile": "base",
"notes": [
"Q709"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "qir/clifford_t.ll",
"format": "qir",
"covers": [
"a Clifford+T module on the bit-exact method",
"pi/4 as its exact hex double"
],
"reference": "qir/clifford_t.ref.qasm",
"expect": {
"profile": "base",
"notes": [],
"how": "exact",
"exact": true,
"round_trip": true
}
},
{
"file": "qir/qft3_typed.ll",
"format": "qir",
"covers": [
"QIR 1.0 with typed pointers, from the crate's earlier writer",
"controlled phases as rz and cnot"
],
"reference": "qir/qft3_typed.ref.qasm",
"expect": {
"profile": "base",
"notes": [],
"how": "exact",
"exact": true,
"round_trip": true
}
},
{
"file": "qir/teleport_chain.ll",
"format": "qir",
"covers": [
"the adaptive profile's own example",
"measurements in the middle, resets, forward branches on results"
],
"expect": {
"profile": "adaptive",
"notes": [],
"dynamic": true,
"qubits": 6,
"equal_bits": [
[
4,
5
]
],
"round_trip": true
}
},
{
"file": "qir/computed.ll",
"format": "qir",
"covers": [
"float computation the flags declare, computed on reading",
"i1 logic on results as a condition"
],
"expect": {
"profile": "adaptive",
"notes": [
"Q709"
],
"dynamic": true,
"outcomes": [
"001",
"010",
"100",
"111"
],
"round_trip": true
}
},
{
"file": "qir/no_profile.ll",
"format": "qir",
"covers": [
"a module that names no profile"
],
"expect": {
"profile": "base",
"notes": [
"Q702"
],
"outcomes": [
"0",
"1"
]
}
},
{
"file": "qir/refuse/base_branch.ll",
"format": "qir",
"covers": [
"reading a result under the base profile"
],
"expect": {
"refused": "Q704",
"line": 12
}
},
{
"file": "qir/refuse/base_gate_after_measure.ll",
"format": "qir",
"covers": [
"a gate after a measurement under the base profile"
],
"expect": {
"refused": "Q704",
"line": 11
}
},
{
"file": "qir/refuse/undeclared_float.ll",
"format": "qir",
"covers": [
"float computation without its module flag"
],
"expect": {
"refused": "Q704",
"line": 6
}
},
{
"file": "qir/refuse/loop_undeclared.ll",
"format": "qir",
"covers": [
"a loop without backwards_branching"
],
"expect": {
"refused": "Q704",
"line": 10
}
},
{
"file": "qir/refuse/loop_declared.ll",
"format": "qir",
"covers": [
"a loop, declared"
],
"expect": {
"refused": "Q705",
"line": 10
}
},
{
"file": "qir/refuse/switch_declared.ll",
"format": "qir",
"covers": [
"switch, declared"
],
"expect": {
"refused": "Q705",
"line": 8
}
},
{
"file": "qir/refuse/dynamic_qubits.ll",
"format": "qir",
"covers": [
"dynamic qubit management, declared"
],
"expect": {
"refused": "Q705",
"line": 6
}
},
{
"file": "qir/refuse/stale_read.ll",
"format": "qir",
"covers": [
"a result read, measured again, then branched on"
],
"expect": {
"refused": "Q708",
"line": 9
}
},
{
"file": "qir/refuse/unknown_intrinsic.ll",
"format": "qir",
"covers": [
"an intrinsic the reader does not know"
],
"expect": {
"refused": "Q706",
"line": 8
}
},
{
"file": "qir/refuse/qubit_past_count.ll",
"format": "qir",
"covers": [
"a qubit past required_num_qubits"
],
"expect": {
"refused": "Q707",
"line": 8
}
},
{
"file": "qir/refuse/unknown_profile.ll",
"format": "qir",
"covers": [
"a profile the reader does not take"
],
"expect": {
"refused": "Q703",
"line": 3
}
},
{
"file": "qir/refuse/major_version.ll",
"format": "qir",
"covers": [
"QIR 3"
],
"expect": {
"refused": "Q701"
}
},
{
"file": "qir/refuse/not_llvm.ll",
"format": "qir",
"covers": [
"not LLVM text"
],
"expect": {
"refused": "Q700"
}
},
{
"file": "jeff/controls_after_targets.jeff",
"format": "jeff",
"covers": [
"well-known gates, controls after targets as the schema orders them",
"adjoint and power",
"r1, u and gphase under a control"
],
"reference": "jeff/controls_after_targets.ref.qasm",
"expect": {
"notes": [
"Q709"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "jeff/custom_named.jeff",
"format": "jeff",
"covers": [
"custom gates named as standard gates"
],
"reference": "jeff/custom_named.ref.qasm",
"expect": {
"notes": [
"Q709",
"Q711"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "jeff/pauli_product.jeff",
"format": "jeff",
"covers": [
"a Pauli-product rotation exp(iθP) on three qubits"
],
"reference": "jeff/pauli_product.ref.qasm",
"expect": {
"notes": [
"Q709",
"Q712"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "jeff/refuse/custom_unknown.jeff",
"format": "jeff",
"covers": [
"a custom gate the library does not name"
],
"expect": {
"refused": "Q710",
"at": "operation 1"
}
},
{
"file": "jeff/refuse/custom_wrong_qubits.jeff",
"format": "jeff",
"covers": [
"a library name with the wrong qubits"
],
"expect": {
"refused": "Q710",
"at": "operation 1"
}
},
{
"file": "jeff/refuse/qubit_twice.jeff",
"format": "jeff",
"covers": [
"a qubit used twice"
],
"expect": {
"refused": "Q713",
"at": "operation 2"
}
},
{
"file": "jeff/refuse/old_version.jeff",
"format": "jeff",
"covers": [
"jeff 0.1"
],
"expect": {
"refused": "Q701"
}
},
{
"file": "jeff/refuse/angle_from_measurement.jeff",
"format": "jeff",
"covers": [
"an angle computed from a measured bit"
],
"expect": {
"refused": "Q714",
"at": "operation 4"
}
},
{
"file": "jeff/refuse/truncated.jeff",
"format": "jeff",
"covers": [
"a module cut short"
],
"expect": {
"refused": "Q700"
}
},
{
"file": "jeff/refuse/register_too_large.jeff",
"format": "jeff",
"covers": [
"a register of 2^32 - 1 qubits, refused before it is allocated"
],
"expect": {
"refused": "Q111",
"at": "operation 1"
}
},
{
"file": "jeff/upstream/ghz-linear_3.jeff",
"format": "jeff",
"covers": [
"a for loop over a register's indices, unrolled",
"bits returned as an array"
],
"reference": "jeff/upstream/ghz-linear_3.ref.qasm",
"expect": {
"notes": [
"Q715"
],
"how": "tableau",
"outcomes": [
"000",
"111"
],
"round_trip": true
}
},
{
"file": "jeff/upstream/ghz-star_3.jeff",
"format": "jeff",
"covers": [
"a for loop, unrolled"
],
"reference": "jeff/upstream/ghz-star_3.ref.qasm",
"expect": {
"notes": [
"Q715"
],
"how": "tableau",
"outcomes": [
"000",
"111"
],
"round_trip": true
}
},
{
"file": "jeff/upstream/qft_3.jeff",
"format": "jeff",
"covers": [
"nested loops with an angle carried as loop state",
"bits returned in reverse order"
],
"reference": "jeff/upstream/qft_3.ref.qasm",
"expect": {
"notes": [
"Q715"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "jeff/upstream/grover_3.jeff",
"format": "jeff",
"covers": [
"Grover's search on two qubits, one iteration"
],
"expect": {
"notes": [
"Q715"
],
"outcomes": [
"11"
],
"round_trip": true
}
},
{
"file": "jeff/upstream/teleportation.jeff",
"format": "jeff",
"covers": [
"a switch on a measured bit, written as a condition",
"written to QIR's adaptive profile; jeff writes no branch"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": true,
"outcomes": [
"000",
"010",
"100",
"110"
],
"writes": [
{
"to": "qir",
"profile": "adaptive",
"notes": [
"Q715"
]
},
{
"to": "jeff",
"refused": "Q720"
}
]
}
},
{
"file": "jeff/upstream/iqft_3.jeff",
"format": "jeff",
"covers": [
"a qubit reused after a measurement and a reset",
"switches on measured bits",
"written to QIR's adaptive profile; jeff writes no branch"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": true,
"writes": [
{
"to": "qir",
"profile": "adaptive",
"notes": [
"Q715"
]
},
{
"to": "jeff",
"refused": "Q720"
}
]
}
},
{
"file": "jeff/upstream/iqpe_3.jeff",
"format": "jeff",
"covers": [
"a qubit reused after a measurement and a reset",
"switches on measured bits",
"written to QIR's adaptive profile; jeff writes no branch"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": true,
"writes": [
{
"to": "qir",
"profile": "adaptive",
"notes": [
"Q715"
]
},
{
"to": "jeff",
"refused": "Q720"
}
]
}
},
{
"file": "jeff/upstream/qpe_3.jeff",
"format": "jeff",
"covers": [
"structured loops and registers, read and written back"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": false,
"round_trip": true
}
},
{
"file": "jeff/upstream/multiplexer_3.jeff",
"format": "jeff",
"covers": [
"structured loops and registers, read and written back"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": false,
"round_trip": true
}
},
{
"file": "jeff/upstream/qft-adder-classical_3.jeff",
"format": "jeff",
"covers": [
"structured loops and registers, read and written back"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": false,
"round_trip": true
}
},
{
"file": "jeff/upstream/qft-adder-quantum_3.jeff",
"format": "jeff",
"covers": [
"structured loops and registers, read and written back"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": false,
"round_trip": true
}
},
{
"file": "jeff/upstream/controlled-multiplication-modulo-n_3.jeff",
"format": "jeff",
"covers": [
"structured loops and registers, read and written back"
],
"expect": {
"notes": [
"Q715"
],
"dynamic": false,
"round_trip": true
}
},
{
"file": "jeff/upstream/repeat-until-success_3.jeff",
"format": "jeff",
"covers": [
"a while loop on a measurement"
],
"expect": {
"refused": "Q714",
"at": "operation 10"
}
},
{
"file": "jeff/upstream/example-entangled-qubits.jeff",
"format": "jeff",
"covers": [
"custom gates named as standard gates, a control given after its target"
],
"reference": "jeff/upstream/example-entangled-qubits.ref.qasm",
"expect": {
"notes": [
"Q711"
],
"how": "tableau",
"round_trip": true
}
},
{
"file": "jeff/upstream/example-qubits.jeff",
"format": "jeff",
"covers": [
"an entry point that takes qubits"
],
"reference": "jeff/upstream/example-qubits.ref.qasm",
"expect": {
"notes": [
"Q709",
"Q711",
"Q716"
],
"how": "exact",
"round_trip": true
}
},
{
"file": "jeff/upstream/example-entangled-calls.jeff",
"format": "jeff",
"covers": [
"arithmetic on measured bits"
],
"expect": {
"refused": "Q714",
"at": "operation 29"
}
},
{
"file": "jeff/upstream/example-optimisation.jeff",
"format": "jeff",
"covers": [
"an entry point that takes a classical argument"
],
"expect": {
"refused": "Q714"
}
},
{
"file": "jeff/upstream/example-rewrite.jeff",
"format": "jeff",
"covers": [
"a register's slot extracted twice"
],
"expect": {
"refused": "Q713",
"at": "operation 5"
}
},
{
"file": "jeff/upstream/example-simple.jeff",
"format": "jeff",
"covers": [
"a custom gate the library does not name"
],
"expect": {
"refused": "Q710",
"at": "operation 5"
}
},
{
"file": "qasm/every_gate.qasm",
"format": "qasm",
"covers": [
"every gate of the language, written to each format"
],
"expect": {
"writes": [
{
"to": "qir",
"profile": "base",
"how": "exact",
"blake3": "1ec96352d855778f5a41c09d96fd0d260632663f03213e225255f074e8a4c022"
},
{
"to": "jeff",
"how": "exact"
}
]
}
},
{
"file": "qasm/clifford_t.qasm",
"format": "qasm",
"covers": [
"Clifford+T written as Clifford+T intrinsics"
],
"expect": {
"writes": [
{
"to": "qir",
"profile": "base",
"how": "exact",
"blake3": "967659b446471c62697f49df341972a45f47bef59d3b2fe26bfefc6670f6a50d"
},
{
"to": "jeff",
"how": "exact"
}
]
}
},
{
"file": "qasm/teleport.qasm",
"format": "qasm",
"covers": [
"a branching program under the adaptive profile",
"jeff writes no branch"
],
"expect": {
"dynamic": true,
"outcomes": [
"100",
"101",
"110",
"111"
],
"writes": [
{
"to": "qir",
"profile": "adaptive",
"blake3": "4ac7bea67cb849aac1093b126a2da4a1edc5240176b6d0f42579760713d3c36f"
},
{
"to": "qir",
"profile_asked": "base",
"refused": "Q720"
},
{
"to": "jeff",
"refused": "Q720"
}
]
}
},
{
"file": "qasm/measure_reset.qasm",
"format": "qasm",
"covers": [
"a measurement in the middle and a reset"
],
"expect": {
"dynamic": true,
"outcomes": [
"010",
"111"
],
"writes": [
{
"to": "jeff"
},
{
"to": "qir",
"profile": "adaptive",
"blake3": "fcb9b8d9517b3e76ae4f0a800222ca1624cc59d6a594f51781515d661bd169c2"
}
]
}
},
{
"file": "qasm/timing.qasm",
"format": "qasm",
"covers": [
"timing each format leaves out, and says so"
],
"expect": {
"outcomes": [
"00",
"11"
],
"writes": [
{
"to": "qir",
"profile": "base",
"notes": [
"Q721"
]
},
{
"to": "jeff",
"notes": [
"Q721"
]
}
]
}
}
]
}