| Filename | Latest commit message | Latest commit date |
|---|---|---|
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]> |
||
| .. | ||
| jeff | ||
| qasm | ||
| qir | ||
| bundle.json | ||
| manifest.json | ||
| README.md | ||
Other formats: conformance
Programs in QIR and jeff, each with what the engine's readers and writers
(wai_quantum::engine::formats, docs)
must do with it: read it to the program a reference gives, give the outcomes
it must give, write it back to its own format and read it again unchanged,
or refuse it with a code and its place. OpenQASM sources are written to each
format and read back.
| Path | What |
|---|---|
qir/ |
QIR modules: the specification's two example programs (the base profile's Bell pair and the adaptive profile's teleport chain, MIT, as the specification publishes its code), every intrinsic the reader takes, a Clifford+T module, a QIR 1 module with typed pointers from the crate's earlier writer, computation the module flags declare, and a module that names no profile. *.ref.qasm are the references, written by hand. |
qir/refuse/ |
A module for each thing a profile forbids, each capability declared and not taken, a stale read, an unknown intrinsic, a qubit past its count, an unknown profile, QIR 3, and text that is not LLVM: each with its code and line. |
jeff/ |
jeff modules built field by field from the schema (not by the writer): well-known gates with their controls after their targets, custom gates named as standard gates, a Pauli-product rotation; refuse/ the refusals. A unit test (engine::formats::tests::the_conformance_set_holds_these_modules) makes them and holds the files to them. |
jeff/upstream/ |
The jeff project's own structured benchmarks (GHZ, QFT, QPE, Grover, teleportation, iterative QFT and QPE, multiplexer, QFT adders, a controlled modular multiplier: loops over registers, switches on measured bits, several segments) and its examples, unchanged (Apache-2.0), from the jeff repository at commit 97f73829caa2de0b6fbf925d1f97f9eb10c158ad; the examples renamed by what they show. *.ref.qasm are references written by hand from each benchmark's source. Those the readers cannot hold exactly are refused with their codes. |
qasm/ |
OpenQASM sources written to QIR and jeff and read back: every gate of the language, Clifford+T, a branching program, a measurement in the middle with a reset, and timing neither format holds. The QIR written is pinned by its BLAKE3, the same bytes natively and under wasm32-wasip2. |
manifest.json |
Each case: its file, its format, what it covers, its reference, and its expectations (the manifest's expectations says what each kind means). |
bundle.json |
The manifest's cases with each file inline (text, or base64 for jeff), for builds that read no files. |
Native
cd wai/wai-quantum
cargo test --release --features full --test formats_conformance
cargo test --release --features full --lib engine::formats
Two tests: every case against its expectations, and the bundle held equal to the files. After changing a file or the manifest, write the bundle:
WAI_FORMATS_BUNDLE_WRITE=1 cargo test --release --features full --test formats_conformance the_bundle_is_the_corpus
and after changing the hand-built jeff modules,
WAI_FORMATS_VECTORS_WRITE=1 cargo test --release --features full --lib the_conformance_set_holds_these_modules.
The same files are the seed of the hostile-input test: every QIR and jeff file mutated (bits flipped, cut short, spliced with another, and every length, count, offset and 32-bit field inflated), 45 153 inputs from a fixed seed, each converted or refused with a code within 20 s and 1 GiB:
cargo test --release --features full --test formats_mutation -- --nocapture
WASI (the edge)
CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \
cargo test --target wasm32-wasip2 --features full --test formats_conformance
The cases come from the bundle compiled into the test. The hostile-input test runs there too, as a release build with overflow checks on:
CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS=true CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \
cargo test --release --target wasm32-wasip2 --features full --test formats_mutation
CI: wai-quantum-formats.yml (the readers' and writers' unit tests, and the
set natively and under wasm32-wasip2).