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
omega-mv / tools / run_gpu_attention_chip.sh
| 1 | #!/bin/sh |
| 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/run_gpu_attention_chip.sh [OUT_ROOT] |
| 18 | # FB-1 cut 5 chip gate: gqa_attention (f32 KV) and paged_attention (+ batch, bf16 KV) |
| 19 | # for the TinyLlama (32q/4kv) and Llama-3.2-1B (32q/8kv) head shapes at context |
| 20 | # 1, 17, 256 and 2048, each against the host oracle (the ReferenceCpuBackend math), |
| 21 | # then against every mutant kernel (NO_MAX, KV_HEAD, SLOT, NO_RESCALE, Q_ROW, OUT_ROW), with a |
| 22 | # negative control and a cache-hit repeat. Sealed receipt folder |
| 23 | # OUT_ROOT/FB1-CUT5-<sha>/ (default ~/workspace/evidence-out): |
| 24 | # receipt.json machine-readable verdict per case run.log test output |
| 25 | # sweep.json head-scaling sweep (q/kv heads x ctx) sweep.log its output |
| 26 | # timing.json cut 4b timing gate (median < 3 ms) timing.log its output |
| 27 | # device.txt kernel, driver, omega and physics shas build.log compiler output |
| 28 | # sim.log the same battery through the host IR simulator, run first |
| 29 | # copies of the three source files the verdict depends on, SHA256SUMS over all |
| 30 | # Run it through the heavy queue only (lanes.sh queue --heavy); never kill it. |
| 31 | set -u |
| 32 | cd "$(dirname "$0")/.." || exit 2 |
| 33 | P=${PHYSICS_DIR:-../physics} |
| 34 | SHA=$(git rev-parse --short HEAD) |
| 35 | OUT=${1:-$HOME/workspace/evidence-out}/FB1-CUT5-$SHA |
| 36 | mkdir -p "$OUT" |
| 37 | if ! make PHYSICS_DIR="$P" build/gpu_attention_test > "$OUT/build.log" 2>&1; then |
| 38 | echo "FB1-CUT5 BUILD FAIL (see $OUT/build.log)"; exit 1 |
| 39 | fi |
| 40 | { |
| 41 | uname -a |
| 42 | nvidia-smi --query-gpu=name,driver_version --format=csv,noheader 2>/dev/null || echo "nvidia-smi: unavailable" |
| 43 | echo "omega $(git rev-parse HEAD) ($(git status --porcelain | wc -l) uncommitted paths)" |
| 44 | echo "physics $(git -C "$P" rev-parse HEAD)" |
| 45 | date -u +%FT%TZ |
| 46 | } > "$OUT/device.txt" |
| 47 | # host simulator first: a kernel that is wrong on the host never gets chip time |
| 48 | ./build/gpu_attention_test --sim > "$OUT/sim.log" 2>&1 |
| 49 | sim_rc=$? |
| 50 | if [ "$sim_rc" -ne 0 ]; then |
| 51 | echo "FB1-CUT5 SIMULATOR FAIL rc=$sim_rc (see $OUT/sim.log)"; exit 1 |
| 52 | fi |
| 53 | ./build/gpu_attention_test --out "$OUT/receipt.json" > "$OUT/run.log" 2>&1 |
| 54 | rc=$? |
| 55 | # head-scaling sweep (attention hardening cut) and the cut 4b timing gate, same session rules |
| 56 | ./build/gpu_attention_test --sweep --out "$OUT/sweep.json" > "$OUT/sweep.log" 2>&1 |
| 57 | sweep_rc=$? |
| 58 | ./build/gpu_attention_test --timing --out "$OUT/timing.json" > "$OUT/timing.log" 2>&1 |
| 59 | timing_rc=$? |
| 60 | [ "$rc" -eq 0 ] && rc=$sweep_rc |
| 61 | [ "$rc" -eq 0 ] && rc=$timing_rc |
| 62 | cp src/omega_gpu_attention_api.c src/omega_gpu_attention_api.h tests/gpu_attention_test.c "$OUT/" |
| 63 | (cd "$OUT" && sha256sum -- * > SHA256SUMS) |
| 64 | tail -1 "$OUT/run.log"; tail -1 "$OUT/sweep.log"; tail -1 "$OUT/timing.log" |
| 65 | echo "FB1-CUT5 chip gate rc=$rc (sweep rc=$sweep_rc timing rc=$timing_rc) receipt=$OUT/receipt.json sweep=$OUT/sweep.json" |
| 66 | exit $rc |