interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / scripts / abi-qualify.sh

169 lines · 8785 bytes Raw Blame History
1#!/usr/bin/env 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# abi-qualify.sh: qualify the omega and AIEN native boundary on this machine, in one command.
18#
19# Builds sovereign-core against the pinned omega, physics and aienos checkouts with
20# AIEN_REQUIRE_NATIVE_LIBS=1 (a stub is refused, never a quiet pass), then runs:
21# conformance aien-abi-conformance unit and C-side tests (synthetic drift cases)
22# identity scripts/test-native-identity.sh (stub, prebuilt and wrong-commit refusals)
23# checkout scripts/test-omega-checkout.sh (a dirty, flag-hidden or stale omega checkout
24# and a wrong prebuilt digest are refused, a clean one builds)
25# compose aien-omega-compose linked: ABI manifest, native identity, callback safety,
26# the compose suite (ignored tests included)
27# gpu-host aien-omega-gpu linked host tests: ABI manifest, native identity, argument
28# refusals (no chip work)
29# chip only with --chip: GB10 parity (aien-omega-gpu parity, aien-inference-abi
30# omega_backend_parity and the crate's linked tests), under the GPU lease
31# The build scripts check the C headers, a compiled layout probe and the archive symbols against
32# the checked-in ABI manifests and the archive digests against native-artifacts.lock, and the
33# identity tests run with AIEN_ABI_QUALIFY=1, so each linked library must report
34# pinned-source + abi pass + digest locked.
35#
36# Usage: scripts/abi-qualify.sh [--chip] [--pins DIR] [--out DIR]
37# --pins DIR pinned checkouts (default target/pins), materialized by scripts/pins.sh --gpu
38# --out DIR logs and evidence.json (default target/abi-qualification)
39# --chip also run the GB10 tests. Needs `quietlock check` to return 0 and
40# /tmp/aien-gb10.lock to be free (taken with flock -n, as omega tools/chip_run.sh
41# does); otherwise the chip part is INCOMPLETE. Never killed, never timed out.
42# Exit: 0 PASS, 1 FAIL (a check failed), 2 INCOMPLETE (something required could not run).
43# Without --chip a PASS covers the host scope only; evidence.json says "scope":"host".
44set -uo pipefail
45ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
46PINS="$ROOT/target/pins"
47OUT="$ROOT/target/abi-qualification"
48CHIP=0
49while [ $# -gt 0 ]; do
50 case "$1" in
51 --chip) CHIP=1 ;;
52 --pins) PINS="${2:?--pins DIR}"; shift ;;
53 --out) OUT="${2:?--out DIR}"; shift ;;
54 *) echo "usage: scripts/abi-qualify.sh [--chip] [--pins DIR] [--out DIR]" >&2; exit 2 ;;
55 esac
56 shift
57done
58mkdir -p "$OUT"
59OUT="$(cd "$OUT" && pwd)"
60cd "$ROOT"
61
62STEPS=()
63fails=0
64incomplete=0
65CHIP_STATE="not-requested"
66CHIP_REASON=""
67note() { echo "abi-qualify: $*"; }
68record() { # record <name> <pass|fail|incomplete> <detail>
69 STEPS+=("{\"name\":\"$1\",\"status\":\"$2\",\"log\":\"$OUT/$1.log\",\"detail\":\"$3\"}")
70 note "$1: $2${3:+ ($3)}"
71 case "$2" in fail) fails=$((fails + 1)) ;; incomplete) incomplete=$((incomplete + 1)) ;; esac
72}
73step() { # step <name> <command...>: pass when the command exits 0
74 local name=$1
75 shift
76 if "$@" >"$OUT/$name.log" 2>&1; then record "$name" pass ""; else record "$name" fail "exit $?"; fi
77}
78# A cargo test step must also have run at least one test and left nothing ignored.
79tests_ran() {
80 local log="$OUT/$1.log"
81 grep -qE '^test result: ok\. [1-9][0-9]* passed' "$log" &&
82 ! grep -qE '^test result:.* [1-9][0-9]* ignored' "$log"
83}
84
85# 1. Pins (omega at omega.lock, physics and aienos at omega's locks).
86if bash scripts/pins.sh --gpu "$PINS" >"$OUT/pins.log" 2>&1 && [ -f "$PINS/env.sh" ]; then
87 record pins pass ""
88 # shellcheck disable=SC1091
89 . "$PINS/env.sh"
90else
91 record pins incomplete "scripts/pins.sh --gpu failed: no pinned omega, nothing native can be qualified"
92fi
93export AIEN_ABI_QUALIFY=1
94
95if [ "${AIEN_REQUIRE_NATIVE_LIBS:-}" = "1" ]; then
96 step conformance cargo test -p aien-abi-conformance
97 step identity bash scripts/test-native-identity.sh
98 step checkout bash scripts/test-omega-checkout.sh
99 step compose cargo test -p aien-omega-compose --test abi_manifest --test callbacks --test compose \
100 -- --include-ignored --test-threads=1 --nocapture
101 tests_ran compose || record compose-ran fail "no linked compose test ran, or some were ignored"
102 step gpu-host cargo test -p aien-omega-gpu -- --test-threads=1 --nocapture
103fi
104
105# 2. What was linked: one identity line per native library, each must qualify.
106IDS=$(cat "$OUT"/compose.log "$OUT"/gpu-host.log 2>/dev/null | sed -n 's/.*AIEN_NATIVE_IDENTITY \({.*}\).*/\1/p' | sort -u)
107for c in librx_compose.a libomega_gpu.a; do
108 if printf '%s\n' "$IDS" | grep -F "\"component\":\"$c\"" | grep -qF '"qualifies":true'; then
109 record "identity-$c" pass ""
110 elif [ "${AIEN_REQUIRE_NATIVE_LIBS:-}" = "1" ]; then
111 record "identity-$c" fail "no qualifying identity reported"
112 else
113 record "identity-$c" incomplete "not built"
114 fi
115done
116
117# 3. GB10 chip tests, only on request, only when the machine is free.
118if [ "$CHIP" = 1 ] && [ "$fails" -eq 0 ] && [ "$incomplete" -eq 0 ]; then
119 if ! command -v quietlock >/dev/null; then
120 CHIP_STATE=incomplete CHIP_REASON="quietlock not installed"
121 elif ! quietlock check >"$OUT/quietlock.log" 2>&1; then
122 CHIP_STATE=incomplete CHIP_REASON="quietlock check is nonzero: a machine hold is up"
123 else
124 exec 9>/tmp/aien-gb10.lock
125 if ! flock -n 9; then
126 CHIP_STATE=incomplete CHIP_REASON="/tmp/aien-gb10.lock is held by another run"
127 else
128 CHIP_STATE=ran
129 step chip-gpu cargo test -p aien-omega-gpu --test parity -- --include-ignored --test-threads=1 --nocapture
130 tests_ran chip-gpu || record chip-gpu-ran fail "chip parity did not run"
131 step chip-inference cargo test -p aien-inference-abi --test omega_backend_parity -- \
132 --include-ignored --skip chip_mixed_matmul_then_elementwise --test-threads=1 --nocapture
133 tests_ran chip-inference || record chip-inference-ran fail "chip backend parity did not run"
134 step chip-inference-linked cargo test -p aien-inference-abi -- --test-threads=1
135 flock -u 9
136 fi
137 exec 9>&-
138 fi
139 [ "$CHIP_STATE" = incomplete ] && record chip incomplete "$CHIP_REASON"
140elif [ "$CHIP" = 1 ]; then
141 CHIP_STATE=incomplete CHIP_REASON="host checks did not pass"
142 record chip incomplete "$CHIP_REASON"
143fi
144
145# 4. Evidence.
146if [ "$fails" -gt 0 ]; then VERDICT=FAIL CODE=1
147elif [ "$incomplete" -gt 0 ]; then VERDICT=INCOMPLETE CODE=2
148else VERDICT=PASS CODE=0; fi
149SCOPE=host
150[ "$CHIP" = 1 ] && SCOPE=host+chip
151j() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g' | tr -d '\n'; }
152rev() { git -C "$1" rev-parse HEAD 2>/dev/null || echo unknown; }
153dirty=false
154[ -n "$(git status --porcelain 2>/dev/null)" ] && dirty=true
155{
156 printf '{\n"verdict":"%s",\n"scope":"%s",\n"date":"%s",\n' "$VERDICT" "$SCOPE" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
157 printf '"host":"%s",\n"target":"%s",\n' "$(j "$(uname -srm)")" "$(rustc -vV | sed -n 's/^host: //p')"
158 printf '"rustc":"%s",\n"cc":"%s",\n"nm":"%s",\n' "$(j "$(rustc -V)")" "$(j "$(${CC:-cc} --version | head -1)")" "$(j "$(nm --version | head -1)")"
159 printf '"flags":{"RUSTFLAGS":"%s","CFLAGS":"%s","CC":"%s","AIEN_REQUIRE_NATIVE_LIBS":"%s"},\n' \
160 "$(j "${RUSTFLAGS:-}")" "$(j "${CFLAGS:-}")" "$(j "${CC:-cc}")" "${AIEN_REQUIRE_NATIVE_LIBS:-}"
161 printf '"commits":{"sovereign_core":"%s","sovereign_core_dirty":%s,"omega_lock":"%s","omega":"%s","physics":"%s","aienos":"%s"},\n' \
162 "$(rev "$ROOT")" "$dirty" "$(tr -d '[:space:]' <omega.lock)" "$(rev "$PINS/omega")" "$(rev "$PINS/physics")" "$(rev "$PINS/aienos")"
163 printf '"native_artifacts_lock_sha256":"%s",\n' "$(sha256sum native-artifacts.lock | cut -d' ' -f1)"
164 printf '"identities":[%s],\n' "$(printf '%s\n' "$IDS" | grep . | paste -sd, -)"
165 printf '"chip":{"state":"%s","reason":"%s"},\n' "$CHIP_STATE" "$(j "$CHIP_REASON")"
166 printf '"steps":[\n%s\n]\n}\n' "$(printf '%s\n' "${STEPS[@]}" | paste -sd, -)"
167} >"$OUT/evidence.json"
168note "$VERDICT (scope $SCOPE): evidence $OUT/evidence.json"
169exit "$CODE"