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 / run_gpu_l2d_prefetch_chip.sh

94 lines · 6164 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# run_gpu_l2d_prefetch_chip.sh EVIDENCE_DIR [PHYSICS_DIR] (OWN-30B W-L2d, 2026-10-14; run under flock /tmp/aien-gb10.lock)
18# One variable: the o_proj weight prefetch launch beside the attention (decode graph --prefetch), on GPU-cached weights.
19# Synthetic 2-layer token (no model load). Interleaved A/B: cached base, cached prefetch, cached base, cached prefetch;
20# control: uncached + prefetch (no L2 keep possible: expect no o_proj gain); red: --prefetch-red MUST FAIL;
21# cmdlist chip test (regression of the cmdlist change). Every graph run checks B == C bit for bit + mutants and prints the
22# per-kind TIMELINE and the logits hash. Verdict line last: "GPU_L2D_PREFETCH_CHIP: PASS|FAIL".
23set -u
24HERE="$(cd "$(dirname "$0")/.." && pwd)"
25# Host-only gate. All test generation, child supervision and result decisions
26# live in gate.om. This retained shell entry only verifies and builds the
27# existing native tools. Missing/unqualified compiler dependencies fail closed.
28if [ "${1:-}" = --host-qualification ]; then
29 cd "$HERE" || exit 3
30 sha256sum -c native/prefetch/compiler.sha256 || { echo "PREFETCH_NATIVE_GATE: compiler prerequisite unavailable"; exit 3; }
31 [ -x seed/out/omc ] || exit 3
32 mkdir -p build || exit 3
33 stage="$(mktemp -d "$HERE/build/prefetch-check.XXXXXX")" || exit 3
34 mkdir -p "$stage/native" "$stage/build" || exit 3
35 cp -R native/prefetch "$stage/native/prefetch" || exit 3
36 timeout --kill-after=2 30 seed/out/omc < "$stage/native/prefetch/gate.om" > "$stage/gate.elf" || exit 3
37 chmod 700 "$stage/gate.elf" || exit 3
38 cd "$stage" || exit 3
39 exec "$stage/gate.elf" "$HERE/seed/out/omc"
40fi
41EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}"
42"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock
43# Classification is implemented by native/prefetch/classify.om. Require the
44# explicitly built native classifier before any device work; never fall back
45# to accepting a nonzero child exit. An exclusive directory prevents stale
46# receipts from an earlier run from being paired with a failed new invocation.
47CLASSIFIER="${PREFETCH_CLASSIFIER:?path to compiled native/prefetch/classify.om}"
48CLASSIFIER="$(realpath "$CLASSIFIER")" || exit 2
49[ -x "$CLASSIFIER" ] || { echo "GPU_L2D_PREFETCH_CHIP: INVALID classifier unavailable"; exit 2; }
50EXPECTED="$(cat "$HERE/native/prefetch/classify.sha256")" || exit 2
51[[ "$EXPECTED" =~ ^[0-9a-f]{64}$ ]] || exit 2
52mkdir "$EVID" || { echo "GPU_L2D_PREFETCH_CHIP: INVALID evidence directory must be new"; exit 2; }
53EVID="$(cd "$EVID" && pwd)" || exit 2
54cd "$HERE" || exit 2
55cp "$CLASSIFIER" "$EVID/classifier.elf" || exit 2
56CLASSIFIER="$EVID/classifier.elf"
57ACTUAL="$(sha256sum "$CLASSIFIER")" || exit 2
58[ "${ACTUAL%% *}" = "$EXPECTED" ] || { echo "GPU_L2D_PREFETCH_CHIP: INVALID classifier digest"; exit 2; }
59sha256sum -c native/prefetch/source.sha256 > "$EVID/classifier-source.log" 2>&1 || { echo "GPU_L2D_PREFETCH_CHIP: INVALID classifier source"; exit 2; }
60{ echo "start $(date -u +%FT%TZ) omega=$(git rev-parse HEAD) branch=$(git rev-parse --abbrev-ref HEAD) dirty=$(git status --porcelain | wc -l) physics_commit=$(git -C "$PHYS" rev-parse HEAD)"
61 uname -a; nvidia-smi --query-gpu=name,driver_version --format=csv,noheader 2>/dev/null; free -g | head -2; uptime; } > "$EVID/device.txt"
62make PHYSICS_DIR="$PHYS" -j10 build/gpu_decode_graph_test build/gpu_cmdlist_test > "$EVID/build.log" 2>&1 || { echo "GPU_L2D_PREFETCH_CHIP: INVALID build"; exit 2; }
63D=./build/gpu_decode_graph_test
64sha256sum "$D" build/gpu_cmdlist_test build/libomega_gpu.a > "$EVID/binaries.sha256" || exit 2
65sha256sum "$CLASSIFIER" native/prefetch/classify.om >> "$EVID/binaries.sha256" || exit 2
66fail=0
67run() { local name="$1"; shift
68 timeout --kill-after=10 600 "$D" "$@" --reps "${REPS:-10}" --out "$EVID/receipt-$name.json" > "$EVID/$name.log" 2>&1 || fail=1
69 echo "$name ($*): $(grep -E 'TIMELINE|PER TOKEN|^chip:' "$EVID/$name.log" | tr '\n' ' ')"
70 grep -o '"C0_logits_fnv":"[0-9a-f]\{16\}"' "$EVID/receipt-$name.json" || fail=1; }
71run 1-cached-base --cached-weights
72run 2-cached-prefetch --cached-weights --prefetch
73run 3-cached-base --cached-weights
74run 4-cached-prefetch --cached-weights --prefetch
75run 5-uncached-prefetch --prefetch
76timeout --kill-after=10 600 "$D" --cached-weights --prefetch-red --reps 3 --out "$EVID/receipt-red.json" > "$EVID/red.log" 2>&1; rc=$?
77printf '%s\n' "$rc" > "$EVID/red.exit"
78echo "red (prefetch-red): exit $rc ($(tail -1 "$EVID/red.log"))"
79timeout --kill-after=2 10 "$CLASSIFIER" "$rc" "$EVID/red.log" "$EVID/receipt-red.json" > "$EVID/red-classification.log" 2>&1; classification=$?
80cat "$EVID/red-classification.log"
81if [ "$classification" != 0 ]; then
82 fail=1
83 if [ "$classification" != 1 ]; then
84 echo "GPU_L2D_PREFETCH_CHIP: INVALID prefetch control"
85 exit 2
86 fi
87fi
88timeout --kill-after=10 600 ./build/gpu_cmdlist_test > "$EVID/cmdlist.log" 2>&1 || fail=1; echo "cmdlist: $(tail -1 "$EVID/cmdlist.log")"
89echo "end $(date -u +%FT%TZ)" >> "$EVID/device.txt" || exit 2
90# The directory is exclusive and SHA256SUMS does not exist yet. Glob expansion
91# precedes creation of that output, so it cannot hash itself. Preserve hash and
92# write failures instead of masking them behind grep's successful exit.
93(cd "$EVID" && sha256sum ./* > SHA256SUMS) || { echo "GPU_L2D_PREFETCH_CHIP: INVALID evidence manifest"; exit 2; }
94if [ $fail = 0 ]; then echo "GPU_L2D_PREFETCH_CHIP: PASS"; else echo "GPU_L2D_PREFETCH_CHIP: FAIL"; exit 1; fi