gpu-head-to-head
aien-dev/gpu-head-to-head
Brought by drakestapleton
gpu-head-to-head / q35-9b / tools / build-weight-oracles.sh
| 1 | #!/bin/sh |
| 2 | # Verification-only. Requires an existing pinned container and Omega kernel object. |
| 3 | set -eu |
| 4 | [ "$#" -eq 2 ] || { echo 'usage: build-weight-oracles.sh NEW_OUT_DIR OMEGA_KERNEL_OBJECT' >&2; exit 2; } |
| 5 | SRC=$(cd "$(dirname "$0")" && pwd) |
| 6 | OUT=$(realpath -m "$1") |
| 7 | OBJECT=$(realpath "$2") |
| 8 | IMAGE=nvcr.io/nvidia/vllm@sha256:557747337846eecf34486866f3d992383c6f8af869fdb0e365b5093fcaee02c2 |
| 9 | docker image inspect "$IMAGE" > /dev/null |
| 10 | mkdir "$OUT" # Refuse to replace earlier evidence or binaries. |
| 11 | cc --version > "$OUT/host-compiler.txt" |
| 12 | sha256sum "$OBJECT" "$SRC/weight-numeric-glue.c" "$SRC/torch-cpu-exp.cpp" > "$OUT/sources.sha256" |
| 13 | cc -std=gnu11 -O2 -Wall -Wextra -Werror -o "$OUT/weight-numeric-glue" "$SRC/weight-numeric-glue.c" "$OBJECT" -lm |
| 14 | docker run --rm --pull=never --runtime runc --network none --read-only \ |
| 15 | -e NVIDIA_VISIBLE_DEVICES=void --tmpfs /tmp -v "$SRC:/src:ro" -v "$OUT:/out" \ |
| 16 | --entrypoint /bin/sh "$IMAGE" -c ' |
| 17 | set -eu |
| 18 | T=/usr/local/lib/python3.12/dist-packages/torch |
| 19 | /usr/bin/g++ --version |
| 20 | head -9 "$T/version.py" |
| 21 | /usr/bin/g++ -std=c++20 -O2 -Wall -Wextra -Werror \ |
| 22 | -isystem "$T/include" -isystem "$T/include/torch/csrc/api/include" \ |
| 23 | /src/torch-cpu-exp.cpp -L"$T/lib" -Wl,-rpath,"$T/lib" -ltorch_cpu -lc10 -o /out/torch-cpu-exp |
| 24 | ldd /out/torch-cpu-exp |
| 25 | ' > "$OUT/container-build.txt" 2>&1 |
| 26 | sha256sum "$OUT/weight-numeric-glue" "$OUT/torch-cpu-exp" > "$OUT/binaries.sha256" |