name: wai-quantum Metal member # The fabric's Metal member: the gate kernels in the Metal shading language, # compiled at run time by the operating system's own compiler for the device, # and certified bit-exact against the CPU reference's pinned corpus digests. # # - metal-hw (the macOS runner's GPU): the device tests must find exactly the # declared device, agree with the CPU on the arithmetic probe and on random # states (out-of-range runs included), reproduce all four pinned certificates # (two gatesets, random-v1 and fabric-v1), and catch every kernel mutant; and # the matrix kernel, every product formed by the GPU's SIMD-group matrix # multiply from 8-bit limbs, must do all of the same under its own # implementation id, with its own mutants caught; and so must the # tensor-operation kernel, every product formed by the shading language's # tensor operation from offset-binary 8-bit limbs. # - metal-absent (a container with no Metal): the same build finds no member # and says why, rather than failing; the device tests run over no member with # the declaration `none`. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: pull_request: paths: - 'wai/wai-quantum/**' - 'rust-toolchain.toml' - '.github/workflows/wai-quantum-metal.yml' schedule: - cron: '56 7 * * *' jobs: relevant: name: does this change touch it runs-on: linux-arm64 outputs: run: ${{ steps.gate.outputs.run }} steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - id: gate run: | set -euo pipefail r=$(python3 scripts/pr-touches-paths.py .github/workflows/wai-quantum-metal.yml \ "${{ github.event.pull_request.base.sha }}" \ "${{ github.event.pull_request.head.sha }}") echo "this change touches wai-quantum-metal: $r" echo "run=$r" >> "$GITHUB_OUTPUT" metal-hw: name: member · Metal (macos) needs: relevant if: needs.relevant.outputs.run == 'true' runs-on: macos timeout-minutes: 90 env: WAI_QUANTUM_METAL_EXPECT: gpu-msl-1009 steps: - uses: actions/checkout@v5 # launchd's PATH omits cargo on the macOS host runner. - name: Put cargo on PATH shell: bash run: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - name: The member's unit tests shell: bash working-directory: wai/wai-quantum run: | set -euo pipefail nice -n 10 cargo test --locked --features quantum_fabric_metal --lib -- quantum_fabric_metal:: quantum_fabric::metal:: 2>&1 | tee "$RUNNER_TEMP/unit.log" grep -qE '^test result: ok\. [1-9][0-9]* passed; 0 failed' "$RUNNER_TEMP/unit.log" || { echo "::error::no unit test ran"; exit 1; } - name: The member's device tests shell: bash working-directory: wai/wai-quantum run: | set -euo pipefail report="$RUNNER_TEMP/metal-report.txt"; : > "$report" WAI_QUANTUM_METAL_REPORT="$report" nice -n 10 \ cargo test --locked --release --features quantum_fabric_metal --test metal_member -- --test-threads=1 2>&1 | tee "$RUNNER_TEMP/device.log" grep -qE '^test result: ok\. 9 passed; 0 failed' "$RUNNER_TEMP/device.log" || { echo "::error::not every device test ran and passed"; exit 1; } cat "$report" key="$WAI_QUANTUM_METAL_EXPECT" grep -qx "metal devices: as declared ($key)" "$report" || { echo "::error::the devices found are not the declared ones"; exit 1; } n="$(grep -c "^metal certified: key=$key .* implementation=metal-lanes64/[0-9a-f]\{16\} parity=bit-exact " "$report")" [ "$n" = 4 ] || { echo "::error::$n of 4 certificates were earned"; exit 1; } grep -qx "metal mutants: key=$key killed 6 of 6" "$report" || { echo "::error::a kernel mutant survived"; exit 1; } - name: The matrix kernel, every product by the SIMD-group matrix multiply shell: bash working-directory: wai/wai-quantum run: | set -euo pipefail report="$RUNNER_TEMP/metal-matrix-report.txt"; : > "$report" WAI_QUANTUM_METAL_REPORT="$report" nice -n 10 \ cargo test --locked --release --features quantum_fabric_metal --test metal_matrix -- --test-threads=1 2>&1 | tee "$RUNNER_TEMP/matrix.log" grep -qE '^test result: ok\. 9 passed; 0 failed' "$RUNNER_TEMP/matrix.log" || { echo "::error::not every matrix test ran and passed"; exit 1; } cat "$report" key="$WAI_QUANTUM_METAL_EXPECT" grep -qx "metal matrix devices: as declared ($key)" "$report" || { echo "::error::the devices found are not the declared ones"; exit 1; } grep -q "^metal matrix member: key=$key .* implementation=metal-matrix-limbs8/[0-9a-f]\{16\} " "$report" || { echo "::error::the device ran no matrix member"; exit 1; } n="$(grep -c "^metal matrix certified: key=$key .* implementation=metal-matrix-limbs8/[0-9a-f]\{16\} parity=bit-exact " "$report")" [ "$n" = 4 ] || { echo "::error::$n of 4 matrix certificates were earned"; exit 1; } grep -qx "metal matrix mutants: key=$key killed 7 of 7" "$report" || { echo "::error::a matrix mutant survived"; exit 1; } - name: The tensor-operation kernel, every product by the tensor operation shell: bash working-directory: wai/wai-quantum run: | set -euo pipefail report="$RUNNER_TEMP/metal-tensor-ops-report.txt"; : > "$report" WAI_QUANTUM_METAL_REPORT="$report" nice -n 10 \ cargo test --locked --release --features quantum_fabric_metal --test metal_tensor_ops -- --test-threads=1 2>&1 | tee "$RUNNER_TEMP/tensor-ops.log" grep -qE '^test result: ok\. 9 passed; 0 failed' "$RUNNER_TEMP/tensor-ops.log" || { echo "::error::not every tensor-operation test ran and passed"; exit 1; } cat "$report" key="$WAI_QUANTUM_METAL_EXPECT" grep -qx "metal tensor-ops devices: as declared ($key)" "$report" || { echo "::error::the devices found are not the declared ones"; exit 1; } grep -q "^metal tensor-ops member: key=$key .* implementation=metal-tensor-ops-limbs8/[0-9a-f]\{16\} " "$report" || { echo "::error::the device ran no tensor-operation member"; exit 1; } n="$(grep -c "^metal tensor-ops certified: key=$key .* implementation=metal-tensor-ops-limbs8/[0-9a-f]\{16\} parity=bit-exact " "$report")" [ "$n" = 4 ] || { echo "::error::$n of 4 tensor-operation certificates were earned"; exit 1; } grep -qx "metal tensor-ops mutants: key=$key killed 8 of 8" "$report" || { echo "::error::a tensor-operation mutant survived"; exit 1; } metal-absent: name: member · Metal absent (linux) needs: relevant if: needs.relevant.outputs.run == 'true' runs-on: linux timeout-minutes: 60 env: WAI_QUANTUM_METAL_EXPECT: none steps: - uses: actions/checkout@v5 - name: Install Rust 1.98.0 shell: bash run: | export PATH="$HOME/.cargo/bin:$PATH" command -v rustup >/dev/null 2>&1 || \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.98.0 rustup toolchain install 1.98.0 --profile minimal rustup default 1.98.0 echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - name: No Metal here, and the member says so shell: bash working-directory: wai/wai-quantum run: | set -euo pipefail cargo test --locked --features quantum_fabric_metal --lib -- quantum_fabric_metal:: quantum_fabric::metal:: 2>&1 | tee "$RUNNER_TEMP/unit.log" grep -qE '^test quantum_fabric_metal::tests::off_macos_nothing_is_found_and_discovery_says_why \.\.\. ok$' "$RUNNER_TEMP/unit.log" || { echo "::error::the off-platform discovery test did not run"; exit 1; } report="$RUNNER_TEMP/metal-report.txt"; : > "$report" for t in metal_member metal_matrix metal_tensor_ops; do WAI_QUANTUM_METAL_REPORT="$report" cargo test --locked --features quantum_fabric_metal --test "$t" -- --test-threads=1 2>&1 | tee "$RUNNER_TEMP/$t.log" grep -qE '^test result: ok\. 9 passed; 0 failed' "$RUNNER_TEMP/$t.log" || { echo "::error::$t did not run over no device"; exit 1; } done grep -qx 'metal devices: as declared (none)' "$report" || { echo "::error::the absent case was not established"; exit 1; } grep -qx 'metal matrix devices: as declared (none)' "$report" || { echo "::error::the matrix absent case was not established"; exit 1; } grep -qx 'metal tensor-ops devices: as declared (none)' "$report" || { echo "::error::the tensor-operation absent case was not established"; exit 1; }