wai-quantum: a gate under many controls stays one operation on the state vector, the bit-exact method states what its lowering did, and the error-correction reader takes C_XYZ, E and PAULI_CHANNEL_1 #675
Loading…
Reference in a new issue
No description provided.
Delete branch "wai/quantum-reader-scaling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#662 has landed; this branch has merged main. The comparison below is rerun at the review's fixes, with the same counts.
The engine fixes the cross-simulator corpus exposed.
A gate under many controls stays one operation
ctrl(k) @was written in standard gates by a Gray-code phase polynomial whose length doubles with each control. Now:qasm::read_wholekeeps such a gate as one op (Op::is_whole), under up to 255 controls;Program::loweredwrites it in standard gates, and gives exactly whatqasm::readgives of the same text (one lowering,qasm/controls.rs, behind both).readandparseare unchanged.StateVector::run_ops,Controlled), visiting only the2^(n − c)amplitudes its controls leave on. Its amplitudes move by double rounding, within the method's bound;"options": {"controls": "standard"}gives the old bits.exactruns standard gates by default and gives the hash it gave;"options": {"controls": "whole"}holds the gate whole under its controls (the circuit2 op-log takes controls), nearer the ideal state and with another hash. The first pass of this branch made the whole form the default; the review commit (062f37182) made it opt-in, since the brief asks for bit-identical results on this method.gatesin a result and inlint_qasmstill counts standard gates, anddynamic_stepscounts steps the same way, so a receipt's provenance carries the count it carried;operations(new, optional) says what a method holding gates whole ran. A state-vector job's expectation values move with its amplitudes, and a provenance'splan.workand an estimate'sworkfollow what the method ran.MAX_OPSwithQ208/Q210as before.What stays bit-identical, and where it was checked
inv @ ctrl @,ctrl @ cu,ctrl(2) @ swap,ctrl(2) @ rzz, a controlledgphase, a 6-qubit Grover, and plain ones), the corpus branch's engine computed: the reader's standard gates, the bit-exactstate_hash, a compile, the QIR and jeff exports, the resource estimate's counts, and the result'sgates. All 24 rows were identical on x86_64 (an Intel Mac) and on aarch64 (Linux), and they are this branch'sBEFOREtable (engine/catalog/whole_tests.rs)."controls": "standard",gatesonexactand on the state vector (whole) alike, compile, QIR, jeff and the estimate from both the standard and the whole reading.the_bit_exact_method_keeps_its_bits_unless_askedholds a 9-qubit Grover's default hash toread's, and the whole form to another. It passes on x86_64 (macOS) and aarch64 (Linux).the_state_vector_of_a_whole_gate_is_its_expansion_s_within_rounding, and in the comparison every state-vector row against the exact reference (below).the_walk_under_controls_gives_the_scan_s_bits, every base gate, both gatesets.--features full(14 targets:bit_identity, the conformance corpora,qasm3_conformance,frame_reference, and the rest), every feature subset the workflows check under-D warnings, the debug test build, the command line's tests andsmoke.sh, on Linux aarch64; the library's 1208 tests on x86_64 too.exactcarriesaccuracy.global_phase(andbelow_table,moved_angleswhen there is one), so its JSON and receipt hold them; bits and hash do not change. The committed tool lists (local-mcp.json,service-mcp.json) and the agent docs are regenerated.Three behaviours that were silent
exactstates the phase its lowering drops (accuracy.global_phase, exactly, in 2^33rds of a turn): method statevector's state of the program that ran ise^(i·radians)times its amplitudes. The language's own state can differ from both (itsUise^(iθ/2)times the matrix both take asu, and the reader drops an uncontrolledgphase). The corpus now holds the method to the reference's state with that phase, nothing fitted.accuracy.below_table) and the plan'swhynow say so, and an angle moved to a non-zero dyadic one is stated too (accuracy.moved_angles).mpsis no longer refused on an estimate at the bond it asks for: it runs under a meter of the bonds it holds and stops withJ011, saying where, if those pass one job's work. The meter counts each two-site update, each move of the orthogonality center and each one-qubit gate, and holds the budget inside a gate that crosses the chain; the estimate walks the same steps, so it bounds the meter. The 30-qubit QFT of a basis state atmax_bond256 runs (mps_qft_n30_bond256), at bond 1. Its plan saysmetered, itsworkwhat the meter allows.autokeeps to the estimate.Three instructions the error-correction reader refused
C_XYZandC_ZYX;E(CORRELATED_ERROR), a flip on a carrier qubit handed to its Pauli targets; andPAULI_CHANNEL_1, as the independent flips with its law. A channel with no such flips (PAULI_CHANNEL_1(0.1, 0.1, 0)) is refused with its line, and the corpus lists that refusal as one it must give.The review's fixes
Every finding of the review but the error-correction decode bound (another change holds it) is fixed, each with a test that failed on the code before its fix:
Q208) orMAX_OPS(Q210) before writing any (ctrl(41) @ zon 42 qubits,ctrl(39) @ t, a 42-qubit Grover iteration,ctrl(24) @ p(0), a loop ofctrl(16) @ p(0): refused at once, where each hung). A method's plan makes only the circuit it reads. The whole gate's phases are read exactly there, soctrl(16) @ p(1e-7)is not taken for the identity.Q208/Q210and noJ011; both refusals past 16 controls name"options": {"controls": "whole"}.options.controlsis read: another value, or"whole"on a job that runs standard gates, isJ003, and the schema, methods list, API description, README and both MCP servers name it. Gates held whole may take 2,000,000 qubits in all (Q210).lint'sdynamic_stepscounts standard steps besidegates;operationsis an engine member a registered method may not write.WorkBound), so the plan still bounds it; the pinned mps job's digest moves with its plan'swork. A metered plan saysmetered, itsworkwhat the meter allows, and a metered job does not set the service's measured rate. Tests now run the meter at bonds the chain fills, stop a job withJ011mid-run and for its shots, and price an update at the bond it spans.accuracy.global_phaseis stated against method statevector's state; the language'sUand an uncontrolledgphasediffer from it, and the note says so.below_tableandmoved_anglessay they count the lowering's phase gates, at 1e-14 of a turn.PAULI_CHANNEL_1takes every channel independent flips give, rates above 1/2 and parities of zero among them; text qubit 4294967295 (the carrier's index) and a correlated error with no index left are refused on their lines;C_XYZ/C_ZYXrefuse arguments.E's targets go through the sametouchas every target, so a qubit bound there covers it, plus the one carrier qubitloweradds. The QEC page and the conformance set (a circuit, its model and a refusal) hold the new forms.service-mcp.json,local-mcp.jsonandllms-full.txtregenerated; the feature matrix, refusal table and service README say what changed.The comparison, rerun
reproduce.sh --tier fullon this branch's engine, on both hosts (results/, each file naming its trees):conformance-macos-arm64.jsonconformance-linux-x86_64.jsonAgainst #662's runs (1638 and 1637 pass):
color_d3,qec_correlatedandqec_pauli_channelnow run and match the other engine mechanism by mechanism (largest difference 6.9e-18 against a bound of 2.6e-13 on the colour code), and their detection rates follow the model;qec_refused_channel_with_no_independent_formis refused, as listed. Every bit-exact state is held to OpenQASM's with the phase its result states (184 rows on Linux, largest ratio 0.14 of the bound).mps_qft_n30_bond256runs onwai.mps, exact (error 7e-19). The added not-run rows are the other engine's: its 900 s limit onrotations_wide_n20on Linux this time, and no model of the refused channel. The CI tier and the self-test (every fault caught) pass on macOS arm64 too.Timings, before and after, on one host
Apple M3 Ultra (macOS 27.2, 32 logical CPUs), the same harness (
tools/perf.py), the corpus branch's build then this branch's, one straight after the other, five runs each, median (results/before-after-macos-arm64.json). The host was shared: one-minute load 29 to 89 during the before build and 65 to 134 during the after build, so the after build ran under more load on every row.grover_n10wai.statevectorgrover_n14wai.statevectorgrover_n16wai.statevectorgrover_n20wai.statevectorQ208grover_n14wai.exact(default)grover_n14wai.exact_whole(asked)grover_n16wai.exact_whole(asked)grover_n20wai.exact_whole(asked)Q208Every case without such a gate (QFT, rotation brickworks, tableaus, error-correction sampling, matrix product states) runs the same ops before and after; their times moved by the host's load, both ways. The other engines' rows are in the file, as data.
Notes for review
wai-quantum/srcchanges fire every wai-quantum workflow.🤖 Generated with Claude Code
Review of the first pass: - The bit-exact method's bits are the rounding of each gate it applies, so a gate held whole gives other bits than its standard gates. A job on exact now runs standard gates by default, and gives the hash it always gave; it holds such a gate whole only when asked, "options": {"controls": "whole"}. catalog::runs_whole takes the request, and the planner's bit-exact circuit is the one the method runs. - A result's and lint's `gates` count standard gates however the method ran them, as they always have, so a receipt's provenance is unchanged; `operations` (new, optional) says what a method holding gates whole ran. The schemas say so. - The comparison's driver follows the job path: whole on the state vector, standard on exact unless asked. - The tests hold the default bit-exact hash to the one before the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>