smoke_inventory.py scans every real #[ignore] attribute, extracts the enabling LELEKA_* flags and values, classifies tests (device / assets / mock) and assigns them to dependency-ordered groups (smoke-groups.json). run_gpu_smokes.sh runs them in order, stops a group at its first failure, skips dependents, continues independent groups, treats a filter that matches nothing as a failure, records nvidia-smi before/after, refuses a busy GPU and never starts a model run without --allow-model-runs plus caller-supplied env. remote_sync.sh mirrors the tree (no --delete, refuses to clobber unpulled sealed files) and builds the three binaries and the test binaries on the host; host_sanity.sh is read-only; record_env.sh captures hardware/software/model digests for the ledger. Tested with stub cargo/nvidia-smi, shellcheck and a Linux container. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
63 lines
3.6 KiB
Bash
Executable File
63 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Record the hardware/software/config facts AGENTS.md requires next to any result. Read-only except OUTDIR.
|
|
#
|
|
# record_env.sh OUTDIR [--toolkit DIR] [--model FILE ...]
|
|
#
|
|
# Writes OUTDIR/env.json, nvidia-smi-q.txt, cpuinfo.txt. --model computes sha256 of each file (slow for tens of GB;
|
|
# the digests are what the performance ledger needs). Model files are only READ.
|
|
# shellcheck disable=SC1091
|
|
set -euo pipefail
|
|
[[ $# -ge 1 ]] || { sed -n '2,8p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//' >&2; exit 2; }
|
|
out="$1"; shift
|
|
toolkit=""; models=()
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--toolkit) toolkit="$2"; shift 2 ;;
|
|
--model) models+=("$2"); shift 2 ;;
|
|
*) echo "unknown $1" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo="$(cd "$here/../.." && pwd)"
|
|
mkdir -p "$out"
|
|
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
|
|
nvidia-smi -q > "$out/nvidia-smi-q.txt" 2>&1 || true
|
|
cat /proc/cpuinfo > "$out/cpuinfo.txt" 2>/dev/null || true
|
|
digests="$(mktemp)"
|
|
for m in ${models[@]+"${models[@]}"}; do printf '%s %s %s\n' "$(sha256sum "$m" | cut -d' ' -f1)" "$(stat -c %s "$m")" "$m" >> "$digests"; done
|
|
REPO="$repo" TOOLKIT="$toolkit" DIGESTS="$digests" python3 - "$out/env.json" <<'PY'
|
|
import json, os, platform, subprocess, sys, datetime
|
|
|
|
def run(*cmd):
|
|
try:
|
|
return subprocess.run(cmd, capture_output=True, text=True, timeout=60).stdout.strip()
|
|
except Exception as error: # noqa: BLE001 - record, never fail the session on a missing tool
|
|
return f"unavailable: {error}"
|
|
|
|
q = lambda f: run("nvidia-smi", f"--query-gpu={f}", "--format=csv,noheader").splitlines()[:1]
|
|
repo = os.environ["REPO"]
|
|
head_file = os.path.join(repo, ".synced-from-head")
|
|
info = {
|
|
"recorded_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds"),
|
|
"host": platform.node(), "kernel": platform.platform(),
|
|
"git_head": open(head_file).read().strip() if os.path.exists(head_file) else run("git", "-C", repo, "rev-parse", "HEAD"),
|
|
"gpu": {k: q(k) for k in ("name", "driver_version", "memory.total", "power.limit", "power.default_limit", "clocks.max.sm",
|
|
"clocks.max.mem", "persistence_mode", "ecc.mode.current", "pcie.link.gen.current", "pcie.link.width.current")},
|
|
"cpu": [l.split(":", 1)[1].strip() for l in open("/proc/cpuinfo") if l.startswith("model name")][:1],
|
|
"cpu_flags_avx": sorted(set(f for f in open("/proc/cpuinfo").read().split() if f.startswith(("avx", "amx"))))[:40],
|
|
"mem_total_kib": [l for l in open("/proc/meminfo") if l.startswith("MemTotal")][0].split()[1],
|
|
"governor": run("sh", "-c", "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null"),
|
|
"rustc": run("rustc", "--version"), "cargo": run("cargo", "--version"),
|
|
"nvcc": run(os.path.join(os.environ["TOOLKIT"], "bin/nvcc"), "--version").splitlines()[-1:] if os.environ["TOOLKIT"] else None,
|
|
"libcuda": run("sh", "-c", "ldconfig -p | grep libcuda.so.1 | head -1"),
|
|
"binaries_sha256": run("sh", "-c", f"cd {repo} && cat target/gpu-bringup/binaries.sha256 2>/dev/null"),
|
|
"model_files": [dict(zip(("sha256", "bytes", "path"), l.split(None, 2))) for l in open(os.environ["DIGESTS"]).read().splitlines()],
|
|
"relevant_env": {k: ("<set>" if any(s in k for s in ("TOKEN", "KEY", "SECRET")) else v)
|
|
for k, v in os.environ.items() if k.startswith(("LELEKA_", "STRATA_", "CUDA_", "RUSTFLAGS", "CARGO_"))},
|
|
"cache_state_note": "fill in by hand per run: cold (page cache dropped / first load) or warm",
|
|
}
|
|
json.dump(info, open(sys.argv[1], "w"), indent=2, sort_keys=True)
|
|
print(f"wrote {sys.argv[1]}")
|
|
PY
|
|
rm -f "$digests"
|