Files
leleka/tools/chain-probe/build.sh
T

26 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# Build the chain-kernels probes in WSL (never on the server).
# tools/chain-probe/build.sh [OUTDIR] default OUTDIR=$HOME/chain-bin; also compiles chain_window.cu to OUTDIR/ptx/chain_window.ptx
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
out="${1:-$HOME/chain-bin}"
nvcc="${NVCC:-$HOME/cuda-toolkits/13.2.2/bin/nvcc}"
mkdir -p "$out/ptx"
cd "$here"
"$nvcc" -O3 -std=c++17 -lineinfo -gencode arch=compute_120,code=sm_120 mb_pdl.cu -lcuda -o "$out/mb_pdl"
"$nvcc" -O2 -std=c++17 chain_probe.cpp -lcuda -o "$out/chain_probe"
# the sealed PTX the probe compares against, and the new one compiled with the recipe of its sources (precise math)
cd "$root"
for f in original_verify mtp_original_full_fused_gr mtp_original_full_attention mtp_original_full_head_iq mtp_original_full_shared native_head_sampler mtp_original_full_verify chain_window; do
if [ "$f" = chain_window ]; then
"$nvcc" -ptx -std=c++17 -O3 -arch=sm_120 --fmad=true --ftz=false -Iengine/strata/include crates/cuda-driver/src/$f.cu -o "$out/ptx/$f.ptx"
else
cp crates/cuda-driver/src/$f.ptx "$out/ptx/$f.ptx"
fi
done
"$nvcc" -ptx -std=c++17 -O3 -arch=sm_120 --fmad=true --ftz=false -I"$root/engine/strata/include" "$here/qsa_prof.cu" -o "$out/ptx/qsa_prof.ptx"
"$nvcc" -ptx -std=c++17 -O3 -arch=sm_120 --fmad=true --ftz=false -I"$root/engine/strata/include" "$here/gr_prof.cu" -o "$out/ptx/gr_prof.ptx"
ls -la "$out" "$out/ptx"
sha256sum "$out"/chain_probe "$out"/mb_pdl "$out"/ptx/* > "$out/SHA256SUMS"