plan (PLAN_REVISION 2): Config { tile_bits, run_max, skip_identity } with
PER_GATE (what compile makes) and TILED (tiles of up to 1024 amplitudes, runs
of up to 1024 gates, capped at 2^30 / 2^n, 16 at 26 qubits); Step::Tile
{ first, count, size }; compile_with, schedule, execute_from,
PlannedGate::{new, is_identity}. A tile run is a maximal run of consecutive
gates that act inside a tile: diagonal gates on any target, others with their
target's bit below the tile size. Only exact identities are skipped (circuit/1's
P(19..=32) is 2^30 - 1 and stays). The CPU executor mirrors the tile kernel's
index arithmetic tile by tile; lanes::exact_row is shared with apply_words.
Tests: every configuration (10 of them) equals the native simulator over
random-v1 (300) and fabric-v1 and certifies with the four lanes32 pins; long
random circuits and full-range random words tile exactly as they run gate by
gate; fabric-v1 covers every tile path; malformed programs are refused;
a_rounded_product_is_never_negated runs under every configuration.
wgsl: TILE_SHADER = lanes32.wgsl followed by lanes32_tile.wgsl (entry point
apply_tile, workgroup 256, one workgroup per tile, the tile size, gate range
and grid in a 32-byte uniform run record, gates in a 48-byte read-only storage
record), tile_implementation_id() = wgsl-lanes32-tile/de6fb388454a0144 (pinned),
tile records, tile_grid (x at most 8), TILE_MUTANTS T1 (barrier between gates
removed, detector Race over race_witness), T2 (the report's minimum dropped,
Range) and T3 (tbit < size -> <=, Malformed over malformed_tile_run).
Deviation from the plan's kernel text: no workgroup memory. naga 30.0.1
decorates every array type with ArrayStride and struct members with Offset,
and spirv-val (SPIRV-Tools 2026.4) rejects explicit layouts on Workgroup
variables (VUID-StandaloneSpirv-None-10684); per the plan the kernel was
restructured instead: each workgroup updates its own tile in place in the state
planes, with storageBarrier() between gates. The uniformity argument is
unchanged (one barrier, at the top level of the loop over the run's gates).
The min of the report is taken once per gate so that T2's text occurs once; a
tile outside the state reports bit 2; a record outside the gate buffer reads
as malformed.
Checker: SHADER and TILE_SHADER each under their own rules (entry points and
workgroup sizes, bindings, no workgroup memory, bool/u32 only, literal shifts,
atomics, barrier kind and placement at the top level of the body or of a
top-level for loop with no break, continue or return), translation to MSL,
SPIR-V and HLSL, mutants; lanes32_tile.spv for spirv-val; --tile-shader.
Member: WebGpuMember::tiled() compiles TILE_SHADER, probes it, plans with
TILED and reports the tile implementation; per-gate stays the default and the
fallback. Runs interleave gate and tile dispatches per submission (a second
uniform ring for run records, a storage buffer for the runs' gates), within
SUBMIT_BUDGET. Device tests: g8 kills T1-T3 on the tile member; new g12 runs
2,000 full-range cases tiled vs per-gate vs the CPU, the four pinned
certificates under the tile implementation, forced geometries, the conformance
vectors, five repeated runs, and prints per-gate vs tiled timing. The member
script requires 13 tests and both implementations' certificates and mutants.
Browser: QuantumWebGpu.tiled(); the worker certifies and runs the vectors on
the tile member too; browser_webgpu.mjs requires "tiles certified bit-exact 4
of 4" and fabric/expected.json pins tile_implementation.
CI: checks validate lanes32_tile.spv and package lanes32_tile.wgsl; the
browser job checks the tile pin and greps the tile certificates; the wasip2 job
requires the new tests by name, and its timeout is 90 minutes (the planner test
runs several minutes alone in a debug wasm build).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
126 lines
5.8 KiB
HTML
126 lines
5.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>WAI — the fabric's WebGPU member</title>
|
|
<style>
|
|
:root { --bg:#06080c; --bg2:#0d1117; --border:#1e2736; --text:#e6edf5; --text2:#8b99ad; --text3:#4a5568; --g:#00e5a0; --w:#f0b429; --r:#ff6b6b; --mono:'JetBrains Mono','SF Mono',Menlo,monospace; }
|
|
* { box-sizing:border-box; margin:0; padding:0; }
|
|
body { background:var(--bg); color:var(--text); font-family:var(--mono); padding:24px 16px; }
|
|
h1 { font-size:15px; letter-spacing:.04em; margin-bottom:4px; } h1 em { font-style:normal; color:var(--g); }
|
|
.sub { font-size:11px; color:var(--text2); margin-bottom:14px; max-width:880px; line-height:1.5; }
|
|
code { color:var(--w); }
|
|
#status { font-size:12px; margin-bottom:10px; color:var(--text2); }
|
|
#log { list-style:none; font-size:11px; line-height:1.6; max-width:1100px; background:var(--bg2); border:1px solid var(--border); border-radius:10px; padding:10px 14px; overflow-wrap:anywhere; }
|
|
#log li.ok::before { content:"pass "; color:var(--g); }
|
|
#log li.bad::before { content:"FAIL "; color:var(--r); }
|
|
#log li.info::before { content:" "; white-space:pre; }
|
|
#log li.info { color:var(--text2); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>WAI <em>wai.quantum.fabric</em> — the WebGPU member in this page</h1>
|
|
<p class="sub">
|
|
The gate kernel of <code>wai.quantum.circuit</code> and <code>wai.quantum.circuit2</code>, written in
|
|
WGSL with unsigned 32-bit arithmetic only, is compiled here by this page's own WebGPU and run in a
|
|
worker. The adapter's arithmetic is probed against the CPU's first; the kernel is then certified
|
|
against the CPU reference on two corpora per gateset. A bit-exact member reproduces the reference's
|
|
pinned corpus digests (<code>quantum-conformance/fabric/expected.json</code>); every vector of the
|
|
quantum corpus must reproduce its statevector hash, and every reject file must be refused with its class.
|
|
The same adapter then runs the tile implementation (runs of gates applied tile by tile, one dispatch
|
|
per run), certified against the same digests.
|
|
</p>
|
|
<div id="status">starting</div>
|
|
<ol id="log"></ol>
|
|
<script type="module">
|
|
// Results for a driver: every message the workers posted, and whether both finished.
|
|
const state = (window.quantumWebGpu = { messages: [], done: false });
|
|
const log = document.getElementById("log");
|
|
const status = document.getElementById("status");
|
|
const params = new URLSearchParams(location.search);
|
|
|
|
function line(kind, text) {
|
|
const li = document.createElement("li");
|
|
li.className = kind;
|
|
li.textContent = text;
|
|
log.appendChild(li);
|
|
}
|
|
|
|
function show(m) {
|
|
switch (m.type) {
|
|
case "member":
|
|
line("info", `member ${m.id} (class ${m.class}, key ${m.key}) on the ${m.limits === "offered" ? "limits the adapter offers" : "WebGPU default limits"}: up to ${m.max_qubits} qubits; implementation ${m.implementation}`);
|
|
line("info", `detail: ${m.detail}`);
|
|
break;
|
|
case "certificate":
|
|
if (m.error) line("bad", `certificate ${m.label}: ${m.error}`);
|
|
else line(m.got.parity === "bit-exact" && m.got.corpus_hex === m.pin ? "ok" : "bad",
|
|
`certificate ${m.label}: ${m.got.parity}, ${m.got.cases} cases, corpus ${m.got.corpus_hex}${m.got.corpus_hex === m.pin ? " (the pin)" : `, pinned ${m.pin}`}`);
|
|
break;
|
|
case "vector":
|
|
line(m.got === m.want ? "ok" : "bad", `${m.tile ? "tile " : ""}${m.label}: ${m.error ? `refused: ${m.error}` : `statevector ${m.got}${m.got === m.want ? "" : `, manifest ${m.want}`}`}`);
|
|
break;
|
|
case "tiled":
|
|
if (m.error) line("bad", `tile member: ${m.error}`);
|
|
else line("info", `tile member ${m.id}: implementation ${m.implementation}`);
|
|
break;
|
|
case "reject": {
|
|
const ok = !!m.error && m.error.startsWith(`WQC parse (${m.want}): `);
|
|
line(ok ? "ok" : "bad", `${m.label} refused as ${m.want}${ok ? "" : `: ${m.error ? `refused as ${m.error}` : "accepted"}`}`);
|
|
break;
|
|
}
|
|
case "wide": {
|
|
const ok = !!m.error && m.error.startsWith(`simulate (${m.want}): `);
|
|
line(ok ? "ok" : "bad", `${m.n} qubits on a member holding ${m.max_qubits}: ${m.error ? `refused, ${m.error}` : "accepted"}`);
|
|
break;
|
|
}
|
|
case "no-adapter":
|
|
line("info", `no adapter: ${m.why}`);
|
|
break;
|
|
case "done":
|
|
break;
|
|
default:
|
|
line("bad", `${m.type}: ${m.why || m.error || JSON.stringify(m)}`);
|
|
}
|
|
}
|
|
|
|
// One worker to the end; its messages, recorded and shown.
|
|
function runWorker(query) {
|
|
return new Promise((resolve) => {
|
|
const worker = new Worker(`quantum_webgpu_worker.js?${query}`, { type: "module" });
|
|
worker.onmessage = (e) => {
|
|
state.messages.push(e.data);
|
|
show(e.data);
|
|
if (e.data.type === "done") {
|
|
worker.terminate();
|
|
resolve(e.data);
|
|
}
|
|
};
|
|
const fail = (why) => {
|
|
const m = { type: "error", error: why };
|
|
state.messages.push(m);
|
|
show(m);
|
|
worker.terminate();
|
|
resolve(m);
|
|
};
|
|
worker.onerror = (e) => fail(`worker: ${e.message || "failed to load"}`);
|
|
worker.onmessageerror = () => fail("worker: a message could not be read");
|
|
});
|
|
}
|
|
|
|
const corpus = params.get("corpus");
|
|
const base = corpus ? `corpus=${encodeURIComponent(corpus)}` : "";
|
|
status.textContent = "the member on the limits the adapter offers";
|
|
await runWorker(base);
|
|
// The too-wide check on the WebGPU default limits, unless the page was offered no adapter.
|
|
if (state.messages.some((m) => m.type === "member")) {
|
|
status.textContent = "the same adapter on the WebGPU default limits";
|
|
await runWorker([base, "limits=webgpu-defaults"].filter(Boolean).join("&"));
|
|
}
|
|
const failed = log.querySelectorAll("li.bad").length;
|
|
status.textContent = failed ? `done: ${failed} failed` : "done";
|
|
state.done = true;
|
|
</script>
|
|
</body>
|
|
</html>
|