Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tools/run_divsqrt_gate.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tools / run_divsqrt_gate.sh` 138 lines ยท 9294 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_divsqrt_gate.sh -- E1 row 7 chip gate: correctly rounded FP32 DIV and 18 # SQRT on the GB10, bit-identical to the CPU semantic (omega_math_div/sqrt and 19 # the AArch64 FDIV/FSQRT, NaN results canonical 0x7fc00000). 20 # 21 # Order: refuse a dirty omega tree or a physics checkout that is dirty or not 22 # at the physics.lock pin; refuse while ~/workspace/.spark-quiet exists, an 23 # est_load process runs or /tmp/aien-gb10.lock is held; run the host tier and 24 # the offline provenance check (Omega's own disassembler); raise the quiet flag; take the GPU 25 # lock; build the chip binary (no libm math, no CUDA symbols); run it to the 26 # end (never killed, never timed out); write a content-addressed receipt 27 # /.json (mode 0444, created exclusively, outside the 28 # tree) plus the log as blobs/.log; drop the flag. 29 # 30 # Run it detached so a closed terminal cannot cut the chip run: 31 # setsid nohup tools/run_divsqrt_gate.sh > /tmp/divsqrt-gate.out 2>&1 < /dev/null & 32 # Shell + coreutils + git + jq + gcc. No Python. 33 set -u 34 HERE=$(cd -P "$(dirname "$0")/.." && pwd) 35 PHYSICS=${PHYSICS_DIR:-$HOME/workspace/hive-worktrees/physics-gate14-`e95e3ed`} 36 EVID=${DIVSQRT_EVIDENCE_DIR:-$HOME/workspace/evidence-out/E1-DIVSQRT} 37 QUIET=$HOME/workspace/.spark-quiet 38 OWNER="lane2 E1 DIV/SQRT chip run" 39 RUN=$(mktemp -d /tmp/divsqrt-run.XXXXXX) 40 FLAG_MINE=0 41 refuse() { echo "REFUSED: $*"; echo "VERDICT NOT_RUN"; exit 1; } 42 cleanup() { if [ "$FLAG_MINE" = 1 ] && grep -q "^$OWNER" "$QUIET" 2>/dev/null; then rm -f "$QUIET"; fi; } 43 trap cleanup EXIT 44 sha() { sha256sum "$1" | cut -d' ' -f1; } 45 46 case "$(realpath -m "$EVID")/" in "$HERE"/*|"$(realpath -m "$PHYSICS")"/*) refuse "evidence dir $EVID is inside a candidate tree";; esac 47 [ -z "$(git -C "$HERE" status --porcelain)" ] || refuse "omega tree $HERE is dirty" 48 OMEGA_COMMIT=$(git -C "$HERE" rev-parse HEAD) || refuse "cannot read omega HEAD" 49 PIN=$(tr -d '[:space:]' < "$HERE/physics.lock") 50 PHYS_COMMIT=$(git -C "$PHYSICS" rev-parse HEAD) || refuse "cannot read physics HEAD at $PHYSICS" 51 [ "$PHYS_COMMIT" = "$PIN" ] || refuse "physics checkout is at $PHYS_COMMIT, physics.lock pins $PIN" 52 [ -z "$(git -C "$PHYSICS" status --porcelain)" ] || refuse "physics checkout $PHYSICS is dirty" 53 [ -e "$QUIET" ] && refuse "quiet flag is up: $(cat "$QUIET")" 54 [ -n "$(pgrep est_load)" ] && refuse "an est_load process is running" 55 fuser /tmp/aien-gb10.lock >/dev/null 2>&1 && refuse "/tmp/aien-gb10.lock is held" 56 57 echo "== host tier" 58 make -s -C "$HERE" build/test_omega_divsqrt_gb10_cpu > "$RUN/host-build.log" 2>&1 || refuse "host build failed" 59 "$HERE/build/test_omega_divsqrt_gb10_cpu" > "$RUN/host.log" 2>&1; HOST_RC=$? 60 tail -1 "$RUN/host.log" 61 echo "== nvdisasm provenance" 62 "$HERE/tools/divsqrt_nvdisasm_check.sh" > "$RUN/nvdisasm.log" 2>&1; NVD_RC=$? 63 grep -E '^\[|^VERDICT|^disassembler' "$RUN/nvdisasm.log" 64 [ "$HOST_RC" = 0 ] && [ "$NVD_RC" = 0 ] || refuse "host tier ($HOST_RC) or nvdisasm check ($NVD_RC) failed; no chip run" 65 KDIG=$("$HERE/build/test_omega_divsqrt_gb10_cpu" --digest) 66 67 START=$(date -u +%Y-%m-%dT%H:%M:%SZ) 68 set -o noclobber 69 echo "$OWNER start=$START expected_end=$(date -u -d '+3 hours' +%Y-%m-%dT%H:%M:%SZ) pid=$$" > "$QUIET" || refuse "could not create the quiet flag" 70 set +o noclobber 71 FLAG_MINE=1 72 exec 9> /tmp/aien-gb10.lock || refuse "cannot open /tmp/aien-gb10.lock" 73 flock -x 9 || refuse "cannot take /tmp/aien-gb10.lock" 74 75 echo "== chip build" 76 NV=$PHYSICS/third_party/nvidia-open-580.173.02 77 BIN=$RUN/test_omega_divsqrt_gb10 78 (cd "$HERE" && gcc -std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -pthread \ 79 -Isrc -I"$PHYSICS/nvrm" -I"$PHYSICS/m16" \ 80 -I"$NV/src/common/sdk/nvidia/inc" -I"$NV/kernel-open/common/inc" \ 81 -I"$NV/kernel-open/nvidia-uvm" -I"$NV/src/nvidia/arch/nvalloc/unix/include" \ 82 -o "$BIN" tests/test_omega_divsqrt_gb10.c src/omega_numeric_divsqrt_gb10.c src/omega_numeric.c \ 83 src/omega_numeric_provenance.c src/omega_blackwell_encoder.c src/omega_blackwell_codegen.c \ 84 src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_om_units.c \ 85 "$PHYSICS/nvrm/nvrm.c" "$PHYSICS/m16/m16_native.c") > "$RUN/chip-build.log" 2>&1 || { cat "$RUN/chip-build.log"; refuse "chip build failed"; } 86 if nm -u "$BIN" | grep -Eq '\b(sqrtf?|expf?|logf?|powf?|fmaf?|sinf?|cosf?|fdiv|divf)\b'; then refuse "libm math symbols in $BIN"; fi 87 if nm -u "$BIN" | grep -Eiq 'cuda|cuInit|cuLaunch|nvrtc|cublas'; then refuse "CUDA symbols in $BIN"; fi 88 BIN_SHA=$(sha "$BIN") 89 90 echo "== chip run (not killed, not timed out)" 91 "$BIN" --chip > "$RUN/chip.log" 2>&1; CHIP_RC=$? 92 END=$(date -u +%Y-%m-%dT%H:%M:%SZ) 93 exec 9>&- 94 grep -E '^RESULT|^VERDICT' "$RUN/chip.log" 95 96 OMEGA_CLEAN_AFTER=$([ -z "$(git -C "$HERE" status --porcelain)" ] && echo true || echo false) 97 PHYS_CLEAN_AFTER=$([ -z "$(git -C "$PHYSICS" status --porcelain)" ] && echo true || echo false) 98 OMEGA_SAME_AFTER=$([ "$(git -C "$HERE" rev-parse HEAD 2>/dev/null)" = "$OMEGA_COMMIT" ] && echo true || echo false) 99 PHYS_SAME_AFTER=$([ "$(git -C "$PHYSICS" rev-parse HEAD 2>/dev/null)" = "$PHYS_COMMIT" ] && echo true || echo false) 100 field() { grep "^RESULT chip $1 " "$RUN/chip.log" | tr ' ' '\n' | sed -n "s/^$2=//p" | head -1; } 101 VERDICT=$(sed -n 's/^VERDICT \([A-Z_]*\).*/\1/p' "$RUN/chip.log" | tail -1) 102 [ -n "$VERDICT" ] || VERDICT=NOT_RUN 103 [ "$CHIP_RC" = 0 ] || [ "$VERDICT" != PASS ] || VERDICT=FAIL 104 [ "$OMEGA_CLEAN_AFTER" = true ] && [ "$PHYS_CLEAN_AFTER" = true ] && [ "$OMEGA_SAME_AFTER" = true ] && [ "$PHYS_SAME_AFTER" = true ] || { [ "$VERDICT" = PASS ] && VERDICT=FAIL; } 105 106 mkdir -p "$EVID/blobs" 107 LOG_SHA=$(sha "$RUN/chip.log") 108 [ -e "$EVID/blobs/$LOG_SHA.log" ] || { cp "$RUN/chip.log" "$EVID/blobs/$LOG_SHA.log" && chmod 0444 "$EVID/blobs/$LOG_SHA.log"; } || { echo "could not store the chip log blob"; echo "VERDICT FAIL"; exit 1; } 109 num() { local v; v=$(field "$1" "$2"); echo "${v:-null}"; } 110 BODY=$(jq -n --arg gate "E1-DIVSQRT" --arg omega "$OMEGA_COMMIT" --arg phys "$PHYS_COMMIT" --arg pin "$PIN" \ 111 --argjson oclean true --argjson pclean true --argjson oafter "$OMEGA_CLEAN_AFTER" --argjson pafter "$PHYS_CLEAN_AFTER" \ 112 --argjson osame "$OMEGA_SAME_AFTER" --argjson psame "$PHYS_SAME_AFTER" \ 113 --arg bin "$BIN_SHA" --arg log "$LOG_SHA" --arg kd "$KDIG" --arg start "$START" --arg end "$END" \ 114 --arg nvd "$(grep '^disassembler' "$RUN/nvdisasm.log")" --arg host "$(tail -1 "$RUN/host.log")" \ 115 --argjson dchk "$(num DIV checked)" --argjson dedge "$(num DIV edge_and_corpus)" \ 116 --argjson dbad "$(num DIV mismatches)" --argjson dmath "$(num DIV mismatches_vs_omega_math)" --argjson dfill "$(num DIV unwritten)" \ 117 --arg dver "$(field DIV verdict)" --arg seed "$(field DIV seed)" \ 118 --argjson schk "$(num SQRT checked)" --argjson sbad "$(num SQRT mismatches)" \ 119 --argjson smath "$(num SQRT mismatches_vs_omega_math)" --argjson sfill "$(num SQRT unwritten)" --arg sver "$(field SQRT verdict)" \ 120 --arg verdict "$VERDICT" --argjson rc "$CHIP_RC" '{ 121 gate: $gate, row: "E1 gap table row 7: GB10 correctly rounded FP32 DIV and SQRT", 122 omega_commit: $omega, omega_tree_clean_before: $oclean, omega_tree_clean_after: $oafter, omega_commit_unchanged_after: $osame, 123 physics_commit: $phys, physics_lock_pin: $pin, physics_tree_clean_before: $pclean, physics_tree_clean_after: $pafter, physics_commit_unchanged_after: $psame, 124 binary_sha256: $bin, chip_log_sha256: $log, kernels: ($kd | split("\n") | map(select(length > 0) | split(" ") | {op: .[0], instructions: (.[1] | tonumber), sha256: .[2]})), 125 nvdisasm_check: $nvd, host_tier: $host, 126 div: {checked: $dchk, edge_and_corpus: $dedge, mismatches_vs_fdiv: $dbad, mismatches_vs_omega_math_div: $dmath, mismatches_unwritten: $dfill, rng_seed: $seed, verdict: $dver}, 127 sqrt: {checked: $schk, exhaustive: ($schk == `4294967296`), mismatches_vs_fsqrt: $sbad, mismatches_vs_omega_math_sqrt: $smath, mismatches_unwritten: $sfill, verdict: $sver}, 128 chip_exit_status: $rc, started_utc: $start, finished_utc: $end, verdict: $verdict }') 129 [ -n "$BODY" ] && printf '%s\n' "$BODY" > "$RUN/receipt.json" && jq -e . "$RUN/receipt.json" >/dev/null || { echo "receipt JSON could not be built"; echo "VERDICT FAIL"; exit 1; } 130 RSHA=$(sha "$RUN/receipt.json") 131 OUT=$EVID/$RSHA.json 132 if [ -e "$OUT" ]; then echo "receipt $OUT already exists (identical content)"; else 133 set -o noclobber; { cat "$RUN/receipt.json" > "$OUT" && chmod 0444 "$OUT"; } || { echo "could not write receipt $OUT"; echo "VERDICT FAIL"; exit 1; }; set +o noclobber; fi 134 cmp -s "$RUN/receipt.json" "$OUT" || { echo "receipt $OUT does not match what was built"; echo "VERDICT FAIL"; exit 1; } 135 echo "RECEIPT $OUT" 136 echo "VERDICT $VERDICT" 137 [ "$VERDICT" = PASS ] || exit 1 138 exit 0