interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tools / run_d7_same_bits_chip.sh

57 lines · 3747 bytes Raw Blame History
1#!/bin/bash
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# tools/run_d7_same_bits_chip.sh JOB RUNS OUTDIR -- D7 on the GB10: run one job RUNS times, each a separate
4# process, with no determinism setting, then compare the printed output hashes (tools/d7_same_bits_check.sh).
5#
6# JOB hello build/hello_gpu c = a + b, 2^20 floats (no reduction; the D7 baseline)
7# gemv build/gpu_bf16_gemv_test --reps 1 --no-evict bf16 GEMV 151936 x 2048, the lm_head (per-lane FFMA chain,
8# then a SHFL.DOWN tree across the warp)
9# rmsnorm build/gpu_elementwise_test rmsnorm 4x2048, 1x256, 2x8192 (SHFL.DOWN, BAR.SYNC and
10# shared memory across the CTA); the other ops print no hash
11# dattn build/gpu_decode_attn_test --reps 1 --no-evict decode attention 32 q / 4 kv heads x 128, contexts 1 .. 32768
12# (softmax max/sum reductions, the cross-split combine)
13# Each binary prints "<label> output sha256 <hex>" for the chip output buffer of its first call (tests/out_sha.h).
14#
15# It opens the GPU, so the caller holds the shared lock: flock -w 900 /tmp/aien-gb10.lock <this script> JOB RUNS OUTDIR
16# Writes OUTDIR/JOB/run-NN.log (stdout+stderr of each run, headed by the command, UTC start, and followed by the exit
17# code and UTC end), OUTDIR/JOB/env.txt (git HEAD, binary sha256, driver, the environment check) and
18# OUTDIR/JOB/check.txt (the comparison). Exit 0 only when every run exited 0 and the checker says PASS.
19set -u
20JOB=${1:?usage: run_d7_same_bits_chip.sh JOB RUNS OUTDIR}; RUNS=${2:?RUNS}; OUT=${3:?OUTDIR}
21ROOT=$(cd "$(dirname "$0")/.." && pwd)
22case "$JOB" in
23 hello) CMD=("$ROOT/build/hello_gpu") ;;
24 gemv) CMD=("$ROOT/build/gpu_bf16_gemv_test" --reps 1 --no-evict) ;;
25 rmsnorm) CMD=("$ROOT/build/gpu_elementwise_test") ;;
26 dattn) CMD=("$ROOT/build/gpu_decode_attn_test" --reps 1 --no-evict) ;;
27 *) echo "unknown job $JOB (hello|gemv|rmsnorm|dattn)" >&2; exit 2 ;;
28esac
29[ "$RUNS" -ge 2 ] 2>/dev/null || { echo "RUNS must be >= 2" >&2; exit 2; }
30[ -x "${CMD[0]}" ] || { echo "NOT_RUN: ${CMD[0]} not built" >&2; exit 2; }
31D="$OUT/$JOB"; mkdir -p "$D"
32# No setting: refuse to run when any determinism or CUDA switch is in the environment.
33SWITCHES=$(env | grep -E '^(CUBLAS_|CUDA_|CUDNN_|NVIDIA_TF32|TORCH_|PYTORCH_|OMEGA_.*DETERMIN)' || true)
34{
35 echo "job: $JOB"
36 echo "command: ${CMD[*]}"
37 echo "git HEAD: $(git -C "$ROOT" rev-parse HEAD)"
38 echo "git status (outside evidence/): $(git -C "$ROOT" status --porcelain -- . ':!evidence' | wc -l) changed files"
39 echo "binary sha256: $(sha256sum "${CMD[0]}" | cut -d' ' -f1)"
40 echo "driver: $(nvidia-smi --query-gpu=name,driver_version --format=csv,noheader 2>&1)"
41 echo "kernel: $(uname -r)"
42 echo "determinism/CUDA switches in the environment: ${SWITCHES:-none}"
43} > "$D/env.txt"
44[ -z "$SWITCHES" ] || { echo "NOT_RUN: a switch is set: $SWITCHES" >&2; exit 2; }
45fails=0
46for i in $(seq -w 1 "$RUNS"); do
47 L="$D/run-$i.log"
48 { echo "# command: ${CMD[*]}"; echo "# utc start: $(date -u +%Y-%m-%dT%H:%M:%S.%NZ)"; } > "$L"
49 "${CMD[@]}" >> "$L" 2>&1; rc=$?
50 { echo "# exit: $rc"; echo "# utc end: $(date -u +%Y-%m-%dT%H:%M:%S.%NZ)"; } >> "$L"
51 [ "$rc" -eq 0 ] || fails=$((fails + 1))
52 echo "run $i exit $rc: $(grep -E '(^| )output sha256 [0-9a-f]{64}$' "$L" | tr '\n' ';')"
53done
54"$ROOT/tools/d7_same_bits_check.sh" "$D"/run-*.log > "$D/check.txt"; crc=$?
55cat "$D/check.txt"
56echo "runs failed: $fails of $RUNS"
57[ "$fails" -eq 0 ] && [ "$crc" -eq 0 ]