interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / probe_gpu_open.sh

64 lines · 3561 bytes Raw Blame History
1#!/bin/bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# tools/probe_gpu_open.sh OUT_DIR [N]
18# FB-1 cut 4b flake investigation: does the FIRST chip call of a fresh process fail
19# in the device-open path (seen twice: cut 1b run 2, cut 3c attempt 1)? Each sample
20# is a fresh process (build/gpu_session_probe). Variants, N samples each, in order:
21# baseline one probe at a time, idle gap 200 ms between processes
22# back_to_back the next probe starts the instant the previous one exits (the sighting:
23# "another chip job had just used the chip")
24# overlap a holder keeps a device open (hold 300 ms) while the probe opens its own
25# after_latch NOT RUN (would need a deliberate stall; never leave the chip uncertain)
26# Negative control first: the probe must report a failure when it cannot open the
27# control nodes (file-descriptor limit 4 -> open() fails; limit 3 stops the dynamic loader itself, exit 127, which proves nothing), with the stage named.
28# Run through the heavy queue only (lanes.sh queue --heavy); never kill it.
29set -u
30OUT=${1:?out dir}; N=${2:-30}
31cd "$(dirname "$0")/.." || exit 2
32P=${PHYSICS_DIR:-../physics}
33mkdir -p "$OUT"
34make PHYSICS_DIR="$P" build/gpu_session_probe > "$OUT/build.log" 2>&1 || { echo "PROBE BUILD FAIL"; exit 1; }
35PR=./build/gpu_session_probe
36LOG="$OUT/probe.log"; : > "$LOG"
37{ uname -a; nvidia-smi --query-gpu=name,driver_version --format=csv,noheader 2>/dev/null; echo "omega $(git rev-parse HEAD) physics $(git -C "$P" rev-parse HEAD)"; date -u +%FT%TZ; } > "$OUT/device.txt"
38echo "## negative_control (fd limit 4: the loader runs, /dev/nvidiactl cannot be opened)" | tee -a "$LOG"
39( ulimit -n 4; $PR --label negative_control ) 2>&1 | tee -a "$LOG"
40neg_rc=${PIPESTATUS[0]}
41echo "negative_control exit=$neg_rc (must be non-zero with a named stage)" | tee -a "$LOG"
42fails=0; total=0
43run_variant() { # name
44 local name=$1 f=0
45 echo "## $name N=$N" | tee -a "$LOG"
46 for i in $(seq 1 "$N"); do
47 if [ "$name" = overlap ]; then $PR --label holder --hold-ms 300 >> "$LOG" 2>&1 & sleep 0.05; fi
48 $PR --label "$name#$i" 2>&1 | tee -a "$LOG" | grep -q 'rc=OK' || f=$((f+1))
49 [ "$name" = overlap ] && wait
50 [ "$name" = baseline ] && sleep 0.2
51 done
52 echo "$name: failures $f / $N" | tee -a "$LOG"
53 fails=$((fails+f)); total=$((total+N))
54}
55run_variant baseline
56run_variant back_to_back
57run_variant overlap
58grep -c 'rc=OK' "$LOG" > "$OUT/ok_count.txt"
59grep 'rc=' "$LOG" | grep -v 'rc=OK' | grep -v negative_control > "$OUT/failures.txt"
60echo "end $(date -u +%FT%TZ)" >> "$OUT/device.txt"
61cp tests/gpu_session_probe.c src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c tools/probe_gpu_open.sh "$OUT/"
62(cd "$OUT" && sha256sum -- * > SHA256SUMS)
63echo "PROBE_GPU_OPEN: negative_control_exit=$neg_rc first_call_failures=$fails/$total (details $OUT/failures.txt)"
64[ "$neg_rc" != 0 ] || { echo "PROBE_GPU_OPEN: INSTRUMENT FAIL (negative control passed)"; exit 3; }