interplane.Get Omega
Read in your language

gpu-head-to-head

aien-dev/gpu-head-to-head

Brought by drakestapleton

branch main Branches Tags History

gpu-head-to-head / q35-9b / tools / build-weight-oracles.sh

26 lines · 1433 bytes Raw Blame History
1#!/bin/sh
2# Verification-only. Requires an existing pinned container and Omega kernel object.
3set -eu
4[ "$#" -eq 2 ] || { echo 'usage: build-weight-oracles.sh NEW_OUT_DIR OMEGA_KERNEL_OBJECT' >&2; exit 2; }
5SRC=$(cd "$(dirname "$0")" && pwd)
6OUT=$(realpath -m "$1")
7OBJECT=$(realpath "$2")
8IMAGE=nvcr.io/nvidia/vllm@sha256:557747337846eecf34486866f3d992383c6f8af869fdb0e365b5093fcaee02c2
9docker image inspect "$IMAGE" > /dev/null
10mkdir "$OUT" # Refuse to replace earlier evidence or binaries.
11cc --version > "$OUT/host-compiler.txt"
12sha256sum "$OBJECT" "$SRC/weight-numeric-glue.c" "$SRC/torch-cpu-exp.cpp" > "$OUT/sources.sha256"
13cc -std=gnu11 -O2 -Wall -Wextra -Werror -o "$OUT/weight-numeric-glue" "$SRC/weight-numeric-glue.c" "$OBJECT" -lm
14docker 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
26sha256sum "$OUT/weight-numeric-glue" "$OUT/torch-cpu-exp" > "$OUT/binaries.sha256"