quantum_fabric_tensor_engine (opt-in): the gate's sixteen products per pair as exact limb convolutions in one bf16 matrix multiply per tile of 512 pairs, accumulated in fp32, on a tensor processor's matrix engine. Each 32-bit value is four 8-bit limbs (bf16 holds each exactly), every limb product is at most 2^16 and every coefficient a sum of at most four, so fp32 holds every partial sum exactly in any order: the argument holds for any engine that multiplies bf16 and accumulates in fp32. The host checks every coefficient is an integer below 2^24, assembles the products in 64 bits and applies the fixed-point arithmetic, as the neural-processor member's host does. The probe uses its own weight layout, sixteen independent pairs a multiply. The kernel (tensor_engine_helper.py) runs as a long-lived helper under the Python WAI_QUANTUM_TENSOR_ENGINE_PYTHON names; today its target is the kernel toolchain's simulator (Apache-2.0), so every certificate's provenance is simulator:<versions>. Four mutants: the three host constants, and Radix9, nine-bit limbs the engine's bf16 inputs cannot hold, which the engine gets wrong. Measured on the simulator: tensor_engine_member 9/9 in 340 s (66020 probe pairs, all four pinned certificates, circuits to 20 qubits, 4 of 4 mutants killed). Workflow: the simulator on the container runner, and the absent case on linux-arm64, where the HIP and npu-cores absent legs move too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
160 lines
8.3 KiB
YAML
160 lines
8.3 KiB
YAML
name: wai-quantum npu-cores member
|
|
|
|
# The fabric's npu-cores member: the gate's fixed-point arithmetic on one
|
|
# compute core of a neural processor's tile array, programmed directly. The
|
|
# member builds the core's program with the tile array's open toolchain
|
|
# (Apache-2.0 with the LLVM exception, pinned below) and its host side with
|
|
# the system's C++ compiler against the device runtime, both at run time.
|
|
#
|
|
# - npu-cores-hw (framework-128gb, its neural processor): 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) on
|
|
# silicon, and catch every kernel mutant, each its own program.
|
|
# - npu-cores-absent (a container with no such device): 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:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'wai/wai-quantum/**'
|
|
- 'rust-toolchain.toml'
|
|
- '.github/workflows/wai-quantum-npu-cores.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'wai/wai-quantum/**'
|
|
- 'rust-toolchain.toml'
|
|
- '.github/workflows/wai-quantum-npu-cores.yml'
|
|
|
|
env:
|
|
# The tile array's toolchain: the compiler and its core back end, the
|
|
# build the compiler's release pins (its utils/peano-requirements.txt).
|
|
TOOLCHAIN_VERSION: 1.4.3
|
|
CORE_COMPILER: llvm-aie==22.0.0.2026090701+3e93bf7b
|
|
|
|
jobs:
|
|
# Does this pull request's own diff touch the paths below? This forge matches a
|
|
# workflow's `paths:` against the push, so a merge of main into a branch fires the
|
|
# workflow whatever the pull request changes; every job here waits on this answer.
|
|
# A push to main, a schedule, or anything the script cannot determine answers
|
|
# `true` (scripts/pr-touches-paths.py).
|
|
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-npu-cores.yml \
|
|
"${{ github.event.pull_request.base.sha }}" \
|
|
"${{ github.event.pull_request.head.sha }}")
|
|
echo "this change touches wai-quantum-npu-cores: $r"
|
|
echo "run=$r" >> "$GITHUB_OUTPUT"
|
|
|
|
npu-cores-hw:
|
|
name: member · npu-cores, neural processor (framework-128gb silicon)
|
|
needs: relevant
|
|
if: needs.relevant.outputs.run == 'true'
|
|
runs-on: linux-amd
|
|
timeout-minutes: 90
|
|
env:
|
|
CARGO_PROFILE_DEV_DEBUG: '0'
|
|
CARGO_BUILD_JOBS: '12'
|
|
steps:
|
|
- name: Fetch the source
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
want="${{ github.event.pull_request.head.sha || github.sha }}"
|
|
rm -rf src && mkdir src && cd src
|
|
git init -q
|
|
# Fetch the commit itself, not the ref. The host names its own route to
|
|
# the forge (WAI_FORGE_URL).
|
|
git fetch -q --depth 1 "${WAI_FORGE_URL:-http://100.64.224.0:3400}/Transaction-Science/open-standards.git" "$want"
|
|
git checkout -q FETCH_HEAD
|
|
got="$(git rev-parse HEAD)"
|
|
[ "$got" = "$want" ] || { echo "::error::fetched $got, not $want"; exit 1; }
|
|
- name: The toolchain (cached)
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
venv="$HOME/aie-$TOOLCHAIN_VERSION"
|
|
if ! "$venv/bin/python" -I -c 'import aie.iron' 2>/dev/null; then
|
|
rm -rf "$venv"
|
|
python3 -m venv "$venv"
|
|
tag="$(python3 -c 'import sys; print(f"cp{sys.version_info.major}{sys.version_info.minor}")')"
|
|
"$venv/bin/pip" install -q "https://github.com/Xilinx/mlir-aie/releases/download/v$TOOLCHAIN_VERSION/mlir_aie-$TOOLCHAIN_VERSION-$tag-$tag-manylinux_2_35_x86_64.whl" # allow-name: the toolchain's release URL
|
|
"$venv/bin/pip" install -q -f https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly "$CORE_COMPILER" # allow-name: the core compiler's release index
|
|
"$venv/bin/pip" install -q "numpy>=2.5.2,<3.0" rich ml_dtypes cloudpickle aiofiles
|
|
"$venv/bin/pip" install -q -f https://llvm.github.io/eudsl "eudsl-python-extras==0.1.0.20260801.905+68a0d7a" --config-settings=EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX=aie
|
|
fi
|
|
echo "WAI_QUANTUM_NPU_CORES_PYTHON=$venv/bin/python" >> "$GITHUB_ENV"
|
|
- name: The member's unit tests
|
|
shell: bash
|
|
working-directory: src/wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
CARGO_TARGET_DIR="$HOME/hw-target/wai-quantum-npu-cores" nice -n 10 cargo test --locked --features quantum_fabric_npu_cores --lib -- quantum_fabric_npu_cores:: quantum_fabric::npu_cores:: 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: src/wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
export WAI_QUANTUM_NPU_CORES_CACHE="$HOME/npu-cores-cache"
|
|
# The device this host has, declared here (or by the runner).
|
|
key="${WAI_QUANTUM_AMD_NPU_CORES_EXPECT:-npu-cores-1022-17f0}"
|
|
report="$RUNNER_TEMP/npu-cores-report.txt"; : > "$report"
|
|
WAI_QUANTUM_NPU_CORES_EXPECT="$key" WAI_QUANTUM_NPU_CORES_REPORT="$report" CARGO_TARGET_DIR="$HOME/hw-target/wai-quantum-npu-cores" nice -n 10 \
|
|
cargo test --locked --release --features quantum_fabric_npu_cores --test npu_cores_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"
|
|
grep -qx "npu-cores devices: as declared ($key)" "$report" || { echo "::error::the device found is not the declared one"; exit 1; }
|
|
grep -q "^npu-cores member: key=$key .*; silicon;" "$report" || { echo "::error::the member does not say it ran on silicon"; exit 1; }
|
|
n="$(grep -c "^npu-cores certified: key=$key .* parity=bit-exact " "$report")"
|
|
[ "$n" = 4 ] || { echo "::error::$n of 4 certificates were earned"; exit 1; }
|
|
grep -qx "npu-cores mutants: key=$key killed 3 of 3" "$report" || { echo "::error::a kernel mutant survived"; exit 1; }
|
|
|
|
npu-cores-absent:
|
|
name: member · npu-cores absent (linux-arm64)
|
|
needs: relevant
|
|
if: needs.relevant.outputs.run == 'true'
|
|
runs-on: linux-arm64
|
|
timeout-minutes: 60
|
|
env:
|
|
WAI_QUANTUM_NPU_CORES_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 neural processor here, and the member says so
|
|
shell: bash
|
|
working-directory: wai/wai-quantum
|
|
run: |
|
|
set -euo pipefail
|
|
report="$RUNNER_TEMP/npu-cores-report.txt"; : > "$report"
|
|
cargo test --locked --features quantum_fabric_npu_cores --lib -- quantum_fabric_npu_cores:: quantum_fabric::npu_cores:: 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; }
|
|
WAI_QUANTUM_NPU_CORES_REPORT="$report" cargo test --locked --features quantum_fabric_npu_cores --test npu_cores_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; }
|
|
grep -qx 'npu-cores devices: as declared (none)' "$report" || { echo "::error::the absent case was not established"; exit 1; }
|