Some checks failed
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 6s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Failing after 49s
wai-audit collector and player integration / does this change touch it (push) Has been cancelled
wai-audit collector and player integration / collector · linux (push) Has been cancelled
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (push) Has been cancelled
WAI operation catalogue / does this change touch it (push) Has been cancelled
WAI operation catalogue / the catalogue and every door · linux (push) Has been cancelled
wai-quantum for JavaScript / does this change touch it (push) Has been cancelled
wai-quantum for JavaScript / javascript · linux (push) Has been cancelled
wai-quantum studio and desktop / does this change touch it (push) Has been cancelled
wai-quantum studio and desktop / studio · browser (push) Has been cancelled
wai-quantum studio and desktop / desktop app · macos (push) Has been cancelled
wai-quantum studio and desktop / desktop app · linux (push) Has been cancelled
wai-quantum studio and desktop / desktop app · windows (push) Has been cancelled
wai-sink-android native sink library / does this change touch it (push) Has been cancelled
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (push) Has been cancelled
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (push) Has been cancelled
wai-sink-swift native sink package / does this change touch it (push) Has been cancelled
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (push) Has been cancelled
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Has been cancelled
WAI Studio / does this change touch it (push) Has been cancelled
WAI Studio / the catalogue's actions, the unit tests and the core · linux (push) Has been cancelled
WAI Studio / Studio in Chromium and Firefox · macos (push) Has been cancelled
WAI Studio / Studio in WebKit · linux (push) Has been cancelled
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Failing after 1m22s
wai-quantum command line / does this change touch it (push) Has been cancelled
wai-quantum command line / command line · linux (push) Has been cancelled
wai-quantum command line / command line · macos (push) Has been cancelled
wai-quantum contract / does this change touch it (push) Has been cancelled
wai-quantum contract / API compatibility · linux (push) Has been cancelled
wai-quantum contract / schemas and the committed tool lists · linux (push) Has been cancelled
wai-quantum contract / the policy is linked, and the deprecations page reads (push) Has been cancelled
wai-quantum docs, course and locales / does this change touch it (push) Has been cancelled
wai-quantum docs, course and locales / every command and snippet in the docs · linux (push) Has been cancelled
wai-quantum docs, course and locales / the course and the command line's languages · linux (push) Has been cancelled
wai-quantum docs, course and locales / the Studio's words in every locale · linux (push) Has been cancelled
wai-quantum editors / does this change touch it (push) Has been cancelled
wai-quantum editors / editors · linux (push) Has been cancelled
wai-quantum editors / editors · macos (push) Has been cancelled
wai-quantum resource estimation / does this change touch it (push) Has been cancelled
wai-quantum resource estimation / estimation and calibration · linux, release (push) Has been cancelled
wai-quantum other formats / does this change touch it (push) Has been cancelled
wai-quantum other formats / readers, writers and the set · linux (push) Has been cancelled
wai-quantum other formats / the set under wasm32-wasip2 (wasmtime) (push) Has been cancelled
wai-quantum OpenQASM reader / does this change touch it (push) Has been cancelled
wai-quantum OpenQASM reader / reader and corpus · linux (push) Has been cancelled
wai-quantum OpenQASM reader / corpus under wasm32-wasip2 (wasmtime) (push) Has been cancelled
wai-quantum pulse and dynamics / does this change touch it (push) Has been cancelled
wai-quantum pulse and dynamics / reader, simulator and pulse jobs · linux, release (push) Has been cancelled
wai-quantum pulse and dynamics / the same bits · linux-arm64 (push) Has been cancelled
wai-quantum pulse and dynamics / the same bits · macos (push) Has been cancelled
wai-quantum pulse and dynamics / reader, simulator and pulse jobs under wasm32-wasip2 (wasmtime) (push) Has been cancelled
wai-quantum for Python / does this change touch it (push) Has been cancelled
wai-quantum for Python / python · linux (push) Has been cancelled
wai-quantum for Python / python · macos (push) Has been cancelled
wai-quantum error correction and mitigation / does this change touch it (push) Has been cancelled
wai-quantum error correction and mitigation / codes, decoders, texts and mitigation · linux, release (push) Has been cancelled
wai-quantum extension points / does this change touch it (push) Has been cancelled
wai-quantum extension points / the registry and the example · linux (push) Has been cancelled
wai-quantum extension points / the registry and the example · linux-arm64 (push) Has been cancelled
wai-quantum extension points / the registry under wasm32-wasip2 (wasmtime) (push) Has been cancelled
wai-quantum service / does this change touch it (push) Has been cancelled
wai-quantum service / service · linux (push) Has been cancelled
wai-quantum service / service · macos (push) Has been cancelled
wai-quantum service / service energy · linux packages (push) Has been cancelled
wai-quantum variational and algorithm library / does this change touch it (push) Has been cancelled
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux, release (push) Has been cancelled
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux-arm64, release (push) Has been cancelled
wai-quantum verdicts and repairs / does this change touch it (push) Has been cancelled
wai-quantum verdicts and repairs / verdicts, repairs and the intent set · linux (push) Has been cancelled
wai-quantum verdicts and repairs / the intent set and the verdict under wasm32-wasip2 (wasmtime) (push) Has been cancelled
wai-quantum views in agent hosts / does this change touch it (push) Has been cancelled
wai-quantum views in agent hosts / views · the page and its engine (push) Has been cancelled
wai-quantum views in agent hosts / views · a scripted host (push) Has been cancelled
Re-landed from PR #671 (branch wai/quantum-synth-rz-reference, head
7f48d2673) as one commit on main, under the land-it model; its review was
complete.
The synthesiser took more T gates than the reference implementation on
some rotations: on one of the four angles of arXiv:2506.03094's 10 x 10
Ising program, 84 where pygridsynth 1.0.1 takes 82. Both find the same u at
the same exponent; every unit multiple w^j t of a norm-equation solution is
one too, and the operators differ by T gates. engine::synth::rz now writes
the operator for t, w t, w^2 t and w^3 t and keeps the fewest T gates (the
solver's own on a tie). No rotation takes more T gates; at an equal count
none is farther; at a lower count one can be farther, never past its eps.
The reference's T counts on 1,192 rotations are test data
(tests/data/rz_gridsynth_oracle.csv, from wai/tools/quantum-rz-oracle).
Also: the catalog's pins the synthesiser moves, each to fewer T gates; and
two first uses of the CLI at once make one signing key, not one failure.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
79 lines
3 KiB
Python
79 lines
3 KiB
Python
#!/usr/bin/env python3
|
||
"""gridsynth_oracle.py: the reference T counts that the engine's z-rotation
|
||
synthesiser (wai/wai-quantum/src/engine/synth/rz.rs) is held to.
|
||
|
||
For each angle and precision it runs pygridsynth 1.0.1, the reference
|
||
implementation of the Ross–Selinger algorithm that arXiv:2506.03094 cites, and
|
||
prints one CSV row: the angle and the precision as the doubles both sides use
|
||
(Python's repr, which Rust parses back to the same bits), pygridsynth's
|
||
denominator exponent and its T count. The output is
|
||
wai/wai-quantum/tests/data/rz_gridsynth_oracle.csv. CI does not run this
|
||
script and nothing depends on pygridsynth: the CSV is the oracle's answer,
|
||
committed, and `engine::synth::rz`'s tests read it.
|
||
|
||
python3 -m venv /tmp/pgs && /tmp/pgs/bin/pip install "pygridsynth==1.0.1" mpmath
|
||
/tmp/pgs/bin/python gridsynth_oracle.py > rz_gridsynth_oracle.csv
|
||
|
||
The angles:
|
||
- the four rotation angles of the 10 × 10 Ising program of arXiv:2506.03094
|
||
(Appendix A.10: a fourth-order product formula, Δ = 0.25, J = g = 1), at
|
||
its ε = 5·10⁻⁹ and at every precision below;
|
||
- 128 angles spread over (−π, π) by the golden ratio, θᵢ = −π + 2π·frac(i·φ),
|
||
none within 10⁻⁶ of a multiple of π/4 (those the engine writes exactly);
|
||
at ε = 10⁻¹, 10⁻², 10⁻³, 10⁻⁴, 10⁻⁵, 10⁻⁷, 10⁻⁹, 10⁻¹¹ and 10⁻¹³.
|
||
"""
|
||
import io
|
||
import math
|
||
import multiprocessing
|
||
import contextlib
|
||
import sys
|
||
|
||
import mpmath
|
||
from pygridsynth.gridsynth import gridsynth_gates
|
||
from pygridsynth.gridsynth import gridsynth
|
||
|
||
PRECISIONS = [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-7, 1e-9, 1e-11, 1e-13]
|
||
|
||
|
||
def ising_angles():
|
||
gamma = 1.0 / (4.0 - 4.0 ** (1.0 / 3.0))
|
||
delta = 0.25
|
||
mid = (1.0 - 4.0 * gamma) * delta
|
||
return [("ising zz", gamma * delta), ("ising x", 2.0 * gamma * delta), ("ising zz middle", mid), ("ising x middle", 2.0 * mid)]
|
||
|
||
|
||
def swept_angles(n=128):
|
||
phi = (1.0 + math.sqrt(5.0)) / 2.0
|
||
out = []
|
||
i = 1
|
||
while len(out) < n:
|
||
theta = -math.pi + 2.0 * math.pi * math.fmod(i * phi, 1.0)
|
||
q = theta / (math.pi / 4.0)
|
||
if abs(q - round(q)) > 1e-6:
|
||
out.append((f"sweep {len(out) + 1}", theta))
|
||
i += 1
|
||
return out
|
||
|
||
|
||
def run(job):
|
||
name, theta, eps = job
|
||
mpmath.mp.dps = 128
|
||
with contextlib.redirect_stdout(io.StringIO()):
|
||
u = gridsynth(theta=mpmath.mpf(theta), epsilon=mpmath.mpf(eps))
|
||
gates = gridsynth_gates(theta=mpmath.mpf(theta), epsilon=mpmath.mpf(eps))
|
||
return (name, repr(theta), repr(eps), u.k, gates.count("T"))
|
||
|
||
|
||
def main():
|
||
jobs = [(name, theta, 5e-9) for name, theta in ising_angles()]
|
||
for eps in PRECISIONS:
|
||
jobs += [(name, theta, eps) for name, theta in ising_angles() + swept_angles()]
|
||
with multiprocessing.Pool(int(sys.argv[1]) if len(sys.argv) > 1 else 8) as pool:
|
||
rows = pool.map(run, jobs, chunksize=1)
|
||
print("name,theta,epsilon,k,t_count")
|
||
for row in rows:
|
||
print(",".join(str(x) for x in row))
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|