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 / e1_host_rerun.sh
| 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 | # e1_host_rerun.sh -- the E1 host tier (no GPU) on the checked-out commit, as one record. |
| 18 | # |
| 19 | # tools/e1_host_rerun.sh run OUTDIR [PHYSICS_DIR] run the six host lines, logs + summary into OUTDIR |
| 20 | # tools/e1_host_rerun.sh record OUTDIR EVIDENCE_DIR turn OUTDIR into a content-named record |
| 21 | # |
| 22 | # The six lines are the host tier of the E1 chip campaign (forge jobs E1S-*), run |
| 23 | # again on a different commit (the squash merge of the qualified candidate) so a |
| 24 | # host-class file that differs between the two commits is covered by evidence rather |
| 25 | # than by assertion. The record (schema AIEN_E1_HOST_RERUN_V1) names the commit, the |
| 26 | # tracked-tree cleanliness before and after, the six verdicts and the SHA-256 of each |
| 27 | # line's log; it is written as EVIDENCE_DIR/<sha256 of file>.json next to the logs as |
| 28 | # EVIDENCE_DIR/blobs/<sha256>.log. tools/e1_combine.sh requires every line PASS. |
| 29 | # Shell + coreutils + make + gcc + jq + tools/json_canon.c. No Python. |
| 30 | set -u |
| 31 | HERE=$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) |
| 32 | LINES="GB10-COMPILE NUMERIC-HOST PROGRAM TRANSC MANIFEST HOSTALL" |
| 33 | |
| 34 | run_all() { |
| 35 | local L=$1 PHYS=${2:-${PHYSICS_DIR:-}} NV name s r |
| 36 | [ -n "$PHYS" ] && [ -d "$PHYS/nvrm" ] || { echo "run: need PHYSICS_DIR (a checkout of aien-dev/physics at physics.lock)" >&2; exit 2; } |
| 37 | NV=$PHYS/third_party/nvidia-open-580.173.02 |
| 38 | mkdir -p "$L"; cd "$HERE" || exit 2 |
| 39 | echo "HEAD $(git rev-parse HEAD) dirty_tracked=$(git status --porcelain --untracked-files=no | wc -l) start $(date -u +%FT%TZ)" > "$L/summary.txt" |
| 40 | run() { name=$1; shift; s=$(date +%s); if bash -c "$*" > "$L/$name.log" 2>&1; then r=PASS; else r="FAIL(rc=$?)"; fi; echo "$name: $r ($(( $(date +%s) - s ))s)" >> "$L/summary.txt"; } |
| 41 | run GB10-COMPILE "D=\$(mktemp -d /tmp/e1r-compile.XXXXXX); rc=0; for v in -DE1N_NONE -DOMEGA_C3_PROTECT_OFF; do for f in tests/test_omega_c3_ab_gb10.c src/omega_numeric_gb10.c src/omega_numeric_reduce_gb10.c src/omega_numeric_ldst_gb10.c src/omega_numeric_divsqrt_gb10.c; do gcc -std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -fno-fast-math -pthread -Isrc -I$PHYS/nvrm -I$PHYS/m16 -I$NV/src/common/sdk/nvidia/inc -I$NV/kernel-open/common/inc -I$NV/kernel-open/nvidia-uvm -I$NV/src/nvidia/arch/nvalloc/unix/include \$v -c \$f -o \$D/x.o || { echo COMPILE_FAIL \$v \$f; rc=1; }; done; done; rm -rf \$D; test \$rc = 0 && echo GB10_COMPILE_OK; exit \$rc" |
| 42 | run NUMERIC-HOST "make -k PHYSICS_DIR=$PHYS test-numeric-cpu test-numeric-transc-gb10-host test-divsqrt-host test-divsqrt-nvdisasm test-numeric-reduce-cpu test-numeric-reduce-nvdisasm test-ldst-host test-ldst-nvdisasm" |
| 43 | run PROGRAM "make -k PHYSICS_DIR=$PHYS test-program-fp32 test-program-realize test-program-id test-visor-core" |
| 44 | run TRANSC "make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-numeric-transc test-numeric-transc-digest test-numeric-transc-full" |
| 45 | run MANIFEST "bash tests/test_chip_run_transc_manifest.sh && bash tests/test_chip_run.sh" |
| 46 | run HOSTALL "make PHYSICS_DIR=$PHYS build/test_omega_numeric_transc_gb10_cpu && for o in SIN COS ERF GELU RSQRT; do ./build/test_omega_numeric_transc_gb10_cpu --host-all \$o || exit 1; done" |
| 47 | echo "end $(date -u +%FT%TZ) dirty_tracked_after=$(git status --porcelain --untracked-files=no | wc -l)" >> "$L/summary.txt" |
| 48 | echo DONE >> "$L/summary.txt" |
| 49 | cat "$L/summary.txt" |
| 50 | } |
| 51 | |
| 52 | record() { |
| 53 | local L=$1 EV=$2 JC commit before after start end l v lines= logs= s body d |
| 54 | [ -f "$L/summary.txt" ] && [ "$(tail -n1 "$L/summary.txt")" = DONE ] || { echo "record: $L/summary.txt is not finished (no DONE line)" >&2; exit 1; } |
| 55 | JC=$(mktemp -d "${TMPDIR:-/tmp}/e1hr.XXXXXX"); trap "rm -rf '$JC'" EXIT |
| 56 | "$HERE/seed/out/omc" < "$HERE/tools/json_canon.om" > "$JC/json_canon" && chmod +x "$JC/json_canon" || exit 1 |
| 57 | read -r _ commit before _ start < <(head -n1 "$L/summary.txt") |
| 58 | before=${before#dirty_tracked=}; end=$(grep -E '^end ' "$L/summary.txt" | awk '{print $2}'); after=$(grep -E '^end ' "$L/summary.txt" | sed 's/.*dirty_tracked_after=//') |
| 59 | [[ $commit =~ ^[0-9a-f]{40}$ ]] || { echo "record: bad HEAD line" >&2; exit 1; } |
| 60 | mkdir -p "$EV/blobs" |
| 61 | for l in $LINES; do |
| 62 | v=$(grep -E "^$l: " "$L/summary.txt" | sed -E "s/^$l: ([^ ]+) .*/\1/"); [ -n "$v" ] || { echo "record: no line $l" >&2; exit 1; } |
| 63 | [ -f "$L/$l.log" ] || { echo "record: no log for $l" >&2; exit 1; } |
| 64 | s=$(sha256sum -- "$L/$l.log" | cut -c1-64) |
| 65 | if [ -e "$EV/blobs/$s.log" ]; then cmp -s "$L/$l.log" "$EV/blobs/$s.log" || { echo "record: blob collision $s" >&2; exit 1; }; else cp -- "$L/$l.log" "$EV/blobs/$s.log"; chmod 0444 "$EV/blobs/$s.log"; fi |
| 66 | lines+="\"$l\":\"$v\","; logs+="\"$l\":\"$s\"," |
| 67 | done |
| 68 | body="{\"schema\":\"AIEN_E1_HOST_RERUN_V1\",\"omega_commit\":\"$commit\",\"tracked_tree_clean_before\":$([ "$before" = 0 ] && echo true || echo false),\"tracked_tree_clean_after\":$([ "$after" = 0 ] && echo true || echo false),\"started_utc\":\"$start\",\"finished_utc\":\"$end\",\"lines\":{${lines%,}},\"log_sha256\":{${logs%,}},\"summary_sha256\":\"$(sha256sum -- "$L/summary.txt" | cut -c1-64)\",\"digest_meaning\":\"file name is the SHA-256 of this file; integrity only, not authenticity\"}" |
| 69 | printf '%s' "$body" | "$JC/json_canon" --pretty > "$JC/rec.json" || exit 1 |
| 70 | d=$(sha256sum -- "$JC/rec.json" | cut -c1-64) |
| 71 | [ -e "$EV/$d.json" ] && { echo "record: $EV/$d.json already exists" >&2; exit 1; } |
| 72 | cp -- "$JC/rec.json" "$EV/$d.json" && chmod 0444 "$EV/$d.json" && cp -- "$L/summary.txt" "$EV/blobs/$(sha256sum -- "$L/summary.txt" | cut -c1-64).txt" |
| 73 | echo "E1 HOST RERUN RECORD: $EV/$d.json"; jq -c .lines "$EV/$d.json" |
| 74 | } |
| 75 | |
| 76 | case ${1:-} in |
| 77 | run) [ $# -ge 2 ] || { sed -n '4,5p' "$0" >&2; exit 2; }; run_all "$2" "${3:-}";; |
| 78 | record) [ $# -eq 3 ] || { sed -n '4,5p' "$0" >&2; exit 2; }; record "$2" "$3";; |
| 79 | *) sed -n '4,5p' "$0" >&2; exit 2;; |
| 80 | esac |