#!/usr/bin/env bash # Repeatable model-free regression of one commit on a 16 GiB sm_86 card (RTX 3080 Laptop, WSL2), one PASS/FAIL line # per item and the total time. Run it inside WSL (or: wsl -d Ubuntu -- bash /mnt/c/.../regress_3080.sh ...). # # regress_3080.sh [--repo PATH] [--commit REF|WORKTREE] [--work DIR] [--only a,b] [--skip a,b] [--keep-going-build] # # --repo git repository to take the commit from (default: the repository this script lives in) # --commit commit-ish to test (default HEAD); WORKTREE = the current working tree of --repo, uncommitted changes # included. Anything else is exported with `git archive`, so the result is that commit only. # --work scratch/output directory (default ~/regress3080); the cargo target dir is shared between runs here # --only/--skip comma lists of item names (see ITEMS below) # # Items (in this order): # companions sm86_assets.py check (committed sm_86 set matches the sealed sm_120 PTX; no toolkit needed) # unit-driver cargo test -p leleka-cuda-driver --features cuda-driver,sm86 --lib (non-ignored) # unit-runtime same for leleka-runtime --features sm86 # build-binaries release build of leleka-inference/leleka-daemon/leleka-cli with --features sm86 # smoke: the 18 model-free run_gpu_smokes.sh groups (SMOKE_SM86=1, --release) # probe-arena original_arena_probe (PROBE_CAPACITY, PROBE_BUDGET_GIB) # probe-executor original_executor_probe (PROBE_CAPACITY, PROBE_MAX_T) # probe-00 .. probe-40 original_serve_preflight_probe tests 00 01 10 20 30 40 (40 = synthetic verifier, PROBE_REQUESTS # requests of the MTP drafter + verifier, default 6) # probe-cpu-pool native-cpu-expert cpu_pool_probe (CPU only) # # Environment: CUBLAS12_LIB (dir with libcublas.so.12; default $HOME/cublas-12.9.1.4/x/*/lib), PROBE_* (passed to the probes), # PROBE_BUDGET_GIB defaults to ARENA_BUDGET_GIB=12 for the arena probe, and the preflight default (6) elsewhere. # The two-request check is probe-40. A probe item FAILS if cargo fails or its log has a ` ERR` step line. # Exit status 0 only if every selected item passed. Nothing here reads a model, a capture or a credential, and it never # touches another machine. set -uo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" repo="$(cd "$here/../.." && pwd)" commit=HEAD work="${HOME}/regress3080" only="" skip="" while [[ $# -gt 0 ]]; do case "$1" in --repo) repo="$2"; shift 2 ;; --commit) commit="$2"; shift 2 ;; --work) work="$2"; shift 2 ;; --only) only="$2"; shift 2 ;; --skip) skip="$2"; shift 2 ;; -h|--help) sed -n '2,32p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;; *) echo "unknown argument: $1" >&2; exit 2 ;; esac done [[ -f "$HOME/.cargo/env" ]] && . "$HOME/.cargo/env" command -v cargo >/dev/null || { echo "cargo not found (install rustup via scripts/install-pinned-rustup.sh)" >&2; exit 2; } command -v nvidia-smi >/dev/null || { echo "nvidia-smi not found: no GPU visible" >&2; exit 2; } # ------------------------------------------------------------------ source tree # A Windows `git worktree` checkout seen from WSL has a .git file naming a C:/ path: use that git dir (translated) directly. gitdir_args=(-C "$repo") if [[ -f "$repo/.git" ]]; then wt="$(sed -n 's/^gitdir: *//p' "$repo/.git" | head -1)" if [[ "$wt" =~ ^([A-Za-z]):(.*)$ ]]; then wt="/mnt/${BASH_REMATCH[1],,}${BASH_REMATCH[2]}"; fi [[ -d "$wt" ]] && gitdir_args=(--git-dir="$wt") fi git_() { git -c safe.directory='*' -c core.autocrlf=false -c core.eol=lf "${gitdir_args[@]}" "$@"; } src="$work/src" mkdir -p "$work" if [[ "$commit" == WORKTREE ]]; then sha="WORKTREE-$(date -u +%H%M%S)" mkdir -p "$src" rsync -a --delete --exclude .git --exclude target "$repo/" "$src/" else sha="$(git_ rev-parse --verify "$commit^{commit}")" || { echo "unknown commit $commit" >&2; exit 2; } stage="$(mktemp -d "$work/stage.XXXXXX")" git_ archive "$sha" | tar -x -C "$stage" mkdir -p "$src" # checksum compare: git archive stamps every file with the commit time, so mtimes alone would rebuild everything rsync -a -c --delete "$stage/" "$src/" rm -rf "$stage" fi stamp="$(date -u +%Y%m%dT%H%M%SZ)" run="$work/runs/$stamp-${sha:0:12}" mkdir -p "$run/logs" export CARGO_TARGET_DIR="$work/target" CARGO_TERM_COLOR=never cublas="${CUBLAS12_LIB:-}" if [[ -z "$cublas" ]]; then cublas="$(ls -d "$HOME"/cublas-12*/x/*/lib 2>/dev/null | head -1)"; fi [[ -n "$cublas" ]] && export LD_LIBRARY_PATH="$cublas${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" export LELEKA_CUDA_REAL_GPU=1 { echo "commit=$sha"; echo "ref=$commit"; echo "start_utc=$(date -u +%FT%TZ)"; echo "host=$(hostname)" echo "kernel=$(uname -sr)"; echo "rustc=$(rustc --version)"; echo "libcublas_dir=${cublas:-none}" nvidia-smi --query-gpu=name,driver_version,compute_cap,memory.total,memory.used --format=csv,noheader env | grep -E '^(PROBE_|LELEKA_|SMOKE_)' || true } > "$run/run-info.txt" # ------------------------------------------------------------------ item runner pass=0; fail=0 failed_items=() start_all=$SECONDS selected() { # name -> 0 if selected local n="$1" [[ -n "$only" && ",$only," != *",$n,"* && ",$only," != *",${n%%:*},"* ]] && return 1 [[ -n "$skip" && ( ",$skip," == *",$n,"* || ",$skip," == *",${n%%:*},"* ) ]] && return 1 return 0 } report() { # name ok seconds detail local name="$1" ok="$2" secs="$3" detail="${4:-}" if [[ "$ok" == 1 ]]; then pass=$((pass + 1)); printf 'PASS %-34s %5ss %s\n' "$name" "$secs" "$detail" else fail=$((fail + 1)); failed_items+=("$name"); printf 'FAIL %-34s %5ss %s\n' "$name" "$secs" "$detail"; fi } item() { # name cmd... : runs in $src, log in $run/logs/.log local name="$1"; shift selected "$name" || return 0 local log="$run/logs/${name//[:\/]/_}.log" t0=$SECONDS rc=0 detail="" ( cd "$src" && "$@" ) > "$log" 2>&1 || rc=$? local errs errs="$(grep -E '^(PREFLIGHT|PROBE2?) .* ERR' "$log" | head -2 | tr '\n' ';' | cut -c1-200)" if (( rc == 0 )) && [[ -z "$errs" ]]; then report "$name" 1 $((SECONDS - t0)) "$(grep -E '^test result' "$log" | head -1)" else if [[ -n "$errs" ]]; then detail="$errs" elif grep -q 'panicked' "$log"; then detail="$(grep -A1 'panicked' "$log" | head -2 | tr '\n' ' ' | cut -c1-200)" else detail="exit $rc, see $log"; fi report "$name" 0 $((SECONDS - t0)) "$detail" fi } cargo_test() { # pkg features test-target(lib|--test X) filter... local pkg="$1" feat="$2" target="$3"; shift 3 local args=(test --locked --release -p "$pkg" --features "$feat") if [[ "$target" == lib ]]; then args+=(--lib); else args+=(--test "$target"); fi cargo "${args[@]}" -- --ignored --test-threads=1 --nocapture "$@" } echo "== regress_3080: commit ${sha:0:12} ($commit), run dir $run" nvidia-smi --query-gpu=name,compute_cap,memory.total,memory.used --format=csv,noheader # ------------------------------------------------------------------ items item companions python3 -B scripts/gpu-bringup/sm86_assets.py check item unit-driver cargo test --locked --release -p leleka-cuda-driver --features cuda-driver,sm86 --lib item unit-runtime cargo test --locked --release -p leleka-runtime --features sm86 --lib item build-binaries cargo build --locked --release -p strata-desktop-core --features sm86 --bins # smoke groups: one run of the repo's runner (it orders groups by dependency), reported per group run_smokes=1 [[ -n "$only" && "$only" != *smoke* ]] && run_smokes=0 [[ ",$skip," == *",smoke,"* ]] && run_smokes=0 if (( run_smokes )); then t0=$SECONDS groups_arg=() sel_groups="" if [[ -n "$only" ]]; then for g in ${only//,/ }; do [[ "$g" == smoke:* ]] && sel_groups+="${g#smoke:},"; done; fi [[ -n "$sel_groups" ]] && groups_arg=(--groups "${sel_groups%,}") smokes="$run/smokes" ( cd "$src" && SMOKE_SM86=1 scripts/gpu-bringup/run_gpu_smokes.sh --run --release --run-dir "$smokes" "${groups_arg[@]}" ) > "$run/logs/smokes.log" 2>&1 rc=$? if [[ -f "$smokes/results.tsv" ]]; then for g in $(ls "$smokes/status"); do selected "smoke:$g" || continue st="$(cat "$smokes/status/$g")" n_pass="$(awk -F'\t' -v g="$g" 'NR>1 && $1==g && $4=="PASS"' "$smokes/results.tsv" | wc -l)" n_all="$(awk -F'\t' -v g="$g" 'NR>1 && $1==g' "$smokes/results.tsv" | wc -l)" bad="$(awk -F'\t' -v g="$g" 'NR>1 && $1==g && $4!="PASS" {printf "%s=%s ", $3, $4}' "$smokes/results.tsv" | cut -c1-220)" if [[ "$st" == PASS ]]; then report "smoke:$g" 1 0 "$n_pass/$n_all tests"; else report "smoke:$g" 0 0 "$st $bad"; fi done else report "smoke:all" 0 $((SECONDS - t0)) "runner produced no results (exit $rc), see $run/logs/smokes.log" fi printf ' (smokes took %ss; per-test logs in %s)\n' $((SECONDS - t0)) "$smokes" fi arena_budget="${ARENA_BUDGET_GIB:-12}" item probe-arena env PROBE_BUDGET_GIB="${PROBE_BUDGET_GIB:-$arena_budget}" \ bash -c "$(declare -f cargo_test); cargo_test leleka-cuda-driver cuda-driver,sm86 original_arena_probe" item probe-executor bash -c "$(declare -f cargo_test); cargo_test leleka-cuda-driver cuda-driver,sm86 original_executor_probe" for n in 00 01 10 20 30 40; do item "probe-$n" bash -c "$(declare -f cargo_test); cargo_test leleka-cuda-driver cuda-driver,sm86 original_serve_preflight_probe preflight_${n}_" done item probe-cpu-pool cargo test --locked --release -p leleka-native-cpu-expert --test cpu_pool_probe -- --ignored --nocapture echo "== total: $pass passed, $fail failed, $((SECONDS - start_all))s (logs: $run)" if (( fail > 0 )); then echo "FAILED: ${failed_items[*]}"; exit 1; fi exit 0