open-standards/scripts/wai-quantum-webgpu-member.sh
Transaction Science 38c50c61ed wai-quantum 0.4.1: CI for the WebGPU member, verify --webgpu, lockfiles
The member's tests run in CI on every adapter a runner declares, the
quantum corpus runs through each member, and wai-quantum is 0.4.1.

- scripts/wai-quantum-webgpu-member.sh: runs tests/webgpu_member.rs and
  fails unless all 12 tests ran and passed, the adapters found are exactly
  WAI_QUANTUM_WEBGPU_EXPECT, each declared adapter earned one bit-exact
  certificate per pinned digest (random-v1 and fabric-v1, both gatesets),
  and each killed 7 of 7 shader mutants; with WAI_QUANTUM_WEBGPU_WIDE=1 a
  GPU adapter must also have matched native at its full width.
- .github/workflows/wai-quantum-webgpu.yml (per-ref concurrency group):
  checks (linux): the shader under naga 30.0.1 and a SPIR-V validator, the
  browser build, no wgpu in the wasm32-wasip2 tree, the shader in the
  package, MSRV 1.97.0. member-software (linux, swgpu-vulkan-10005),
  member-metal (macos, gpu-metal-0), member-hw (linux-hw, gpu-vulkan-10de,
  wide sizes). The two GPU jobs then run verify --webgpu. No linux-arm64
  job; no windows job while that runner is offline.
- wai-conformance.yml: the wasm32-wasip2 job requires each new fabric unit
  test by name.
- wai-rs: feature quantum_fabric_webgpu forwards to wai-quantum's and
  re-exports the module; the requirement on wai-quantum is 0.4.1.
  wai_quantum_vectors verify <dir> --webgpu runs the whole check once per
  member, each state computed by the member, and holds each accept file to
  the native simulator's result (the 255-qubit files are refused as
  too-many-qubits by both). No member: exit 2; without the feature, the
  flag is an error.
- wai-quantum 0.4.1 with a CHANGELOG entry for the API of the last three
  commits. Lockfiles: the version line in all six that resolve
  wai-quantum (quantum-wgsl-check included); wai-rs also gains the wgpu
  tree through its new feature, at the versions wai-quantum's lock holds.

Local: on Metal the script passes; it fails with a wrong EXPECT, with the
feature dropped from its cargo test, with M1 as the shader, and with one
pin changed. verify --webgpu passes on Metal. cargo publish --dry-run and
cargo package --list pass. The runs on linux, macos and linux-hw are
pending CI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 22:32:43 -04:00

49 lines
2.8 KiB
Shell
Executable file

#!/usr/bin/env bash
#
# wai-quantum-webgpu-member.sh
#
# Runs the WebGPU member's device tests and fails unless (1) all of them ran and
# passed, (2) the adapters found are exactly WAI_QUANTUM_WEBGPU_EXPECT, (3) each
# declared adapter earned one bit-exact certificate per pinned corpus digest, and
# (4) each declared adapter killed every shader mutant. These checks are what make
# a filtered, skipped or adapter-less run fail instead of pass.
#
# WAI_QUANTUM_WEBGPU_EXPECT=<key[,key...]|none> [WAI_QUANTUM_WEBGPU_WIDE=1] \
# scripts/wai-quantum-webgpu-member.sh
set -euo pipefail
: "${WAI_QUANTUM_WEBGPU_EXPECT:?declare the adapter keys this runner must have, or none}"
cd "$(dirname "$0")/../wai/wai-quantum"
dir="${RUNNER_TEMP:-$(mktemp -d)}"
log="$dir/webgpu-member.log"
export WAI_QUANTUM_WEBGPU_REPORT="$dir/webgpu-member.report"
: > "$WAI_QUANTUM_WEBGPU_REPORT"
cargo test --locked --features quantum_fabric_webgpu --test webgpu_member \
-- --nocapture --test-threads=1 2>&1 | tee "$log"
grep -q "test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out" "$log" \
|| { echo "::error::the member's 12 tests did not all run and pass"; exit 1; }
grep -qxF "webgpu adapters: as declared ($WAI_QUANTUM_WEBGPU_EXPECT)" "$WAI_QUANTUM_WEBGPU_REPORT" \
|| { echo "::error::the adapters found are not the declared set"; exit 1; }
[ "$WAI_QUANTUM_WEBGPU_EXPECT" = none ] && exit 0
pins=(
"wai.quantum.circuit/apply random-v1 d18454c639acfd9c7b66450f4ded1aac4ab46cc10a7bedbcf4958a96e204fb36"
"wai.quantum.circuit2/apply random-v1 3dbde276c1095bf827faec71d5980e050f8a55a5ba7d97cd3bbdaec3f43a13b2"
"wai.quantum.circuit/apply fabric-v1 41c726a0ac80f7defef92e15ecf893bdb7a3076b5e7f670fa0b7142e5c033df7"
"wai.quantum.circuit2/apply fabric-v1 9a84b55af68f1a8b07390b234cf562dd8d85cef3185a697ab85690c8790a7809"
)
for key in $(tr ',' '\n' <<<"$WAI_QUANTUM_WEBGPU_EXPECT" | sort -u); do
want=$(tr ',' '\n' <<<"$WAI_QUANTUM_WEBGPU_EXPECT" | grep -cxF "$key")
for p in "${pins[@]}"; do
set -- $p
n=$(grep -cE "^webgpu certified: key=$key member=local/[a-z]+-[a-z0-9]+-[0-9a-f]{12} kernel=$1 corpus=$2 implementation=wgsl-lanes32/[0-9a-f]{16} parity=bit-exact cases=[0-9]+ digest=$3$" "$WAI_QUANTUM_WEBGPU_REPORT" || true)
[ "$n" -eq "$want" ] || { echo "::error::$key: $n bit-exact $2 certificates for $1, $want expected"; exit 1; }
done
n=$(grep -cxF "webgpu mutants: key=$key killed 7 of 7" "$WAI_QUANTUM_WEBGPU_REPORT" || true)
[ "$n" -eq "$want" ] || { echo "::error::$key: a mutant survived, or the mutant test did not run"; exit 1; }
if [ "${WAI_QUANTUM_WEBGPU_WIDE:-0}" = 1 ] && [ "${key%%-*}" = gpu ]; then
grep -qE "^webgpu wide: key=$key n=2[56] matches native$" "$WAI_QUANTUM_WEBGPU_REPORT" \
|| { echo "::error::$key: no wide run at the member's full size"; exit 1; }
fi
done