Stage 6 of the WebGPU member plan (energy, and placement that can choose the GPU). - quantum_fabric: the member-neutral RunMeter trait (no meter ships in the crate); a reading reaches a result only when check_label accepts it, every start is matched by one stop, and a refused run's reading is discarded. EnergyCalibration turns metered runs into a KernelEntry figure (nJ per pair-update, rounded up, the runs' class with the rounding folded into its uncertainty), or no figure at all; detect_local_metered gives the CPU reference its figure. place_for places one run by a caller's picojoule model when every candidate has a prediction, else as place. Fabric runs a circuit on the placed member, falls back down the placement order on TooWide, OutOfRange, Memory, Timeout or Device, and seals the receipt with the member that produced the result, the refusals beside it. - quantum_fabric_webgpu: simulate_metered brackets a run from its first submission to its last readback (device work only; detail says so), member_metered certifies and calibrates in one pass, the member is a Runner for its own implementation, and WebGpuError maps onto MemberError. - Tests: CPU-side tests with synthetic meters, figures, models and refusing members; device test g13 (metered runs, a metered calibration, and the fabric falling back from a member held to three qubits); the member script expects 14 tests and a fabric line per declared adapter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
60 lines
3.7 KiB
Shell
Executable file
60 lines
3.7 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 14 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 under
|
|
# each implementation (the per-gate kernel, wgsl-lanes32/, and tile runs,
|
|
# wgsl-lanes32-tile/), (4) each declared adapter killed every shader mutant of
|
|
# both, and (5) each declared adapter ran metered and on the fabric, falling back
|
|
# and producing as placed. 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. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out" "$log" \
|
|
|| { echo "::error::the member's 14 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
|
|
for implementation in wgsl-lanes32 wgsl-lanes32-tile; do
|
|
n=$(grep -cE "^webgpu certified: key=$key member=local/[a-z]+-[a-z0-9]+-[0-9a-f]{12} kernel=$1 corpus=$2 implementation=$implementation/[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 under $implementation, $want expected"; exit 1; }
|
|
done
|
|
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; }
|
|
n=$(grep -cxF "webgpu tile mutants: key=$key killed 3 of 3" "$WAI_QUANTUM_WEBGPU_REPORT" || true)
|
|
[ "$n" -eq "$want" ] || { echo "::error::$key: a tile mutant survived, or the mutant test did not run"; exit 1; }
|
|
n=$(grep -cxF "webgpu fabric: key=$key ok" "$WAI_QUANTUM_WEBGPU_REPORT" || true)
|
|
[ "$n" -eq "$want" ] || { echo "::error::$key: the metered and fabric test did not run for it"; 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; }
|
|
grep -qE "^webgpu tile wide: key=$key n=2[56] matches native$" "$WAI_QUANTUM_WEBGPU_REPORT" \
|
|
|| { echo "::error::$key: no wide tile run at the member's full size"; exit 1; }
|
|
fi
|
|
done
|