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

90 lines · 5867 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# Qwen3-8B correctness smoke (docs/campaigns/open-model-qwen3/SMOKE-8B-v1.md, sc#384).
18# smoke_qwen3_8b.sh verify sha256 of config.json and the five shards only
19# smoke_qwen3_8b.sh cpu verify, then the CPU reference leg; records the golden ids
20# (refuses to overwrite an existing golden file)
21# smoke_qwen3_8b.sh gb10 verify, then the GB10 leg against the golden ids.
22# OWNS THE CHIP: only after the whole-system runs have finished.
23# Env: MODEL_DIR (default ~/models/qwen3-8b), OUT (default $PWD/smoke-8b-out).
24set -uo pipefail
25REPO=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
26MODEL_DIR=${MODEL_DIR:-$HOME/models/qwen3-8b}
27OUT=${OUT:-$PWD/smoke-8b-out}
28GOLDEN=$REPO/docs/campaigns/open-model-qwen3/SMOKE-8B-v1.golden.json
29# Values recorded in docs/campaigns/open-model-qwen3/EVAL-qwen3-8b.md (Section 1, branch d1/qwen3-8b-eval).
30read -r -d '' SUMS <<'EOS'
31f7c4eadfbbf522470667b797a3c89be2524832d2d599797248dc304fff447c30 config.json
3231d6a825ae35f11fb85b195b4c42c146c051e446433125a215336abdf95cbf5f model-00001-of-00005.safetensors
335991236cea6fe21f3d43cab0f0e84448734fbbe0789816202989f2ddc9d18282 model-00002-of-00005.safetensors
34c5185c4794be2d8a9784d5753c9922db38df478ce11f9ed0b415b7304d896836 model-00003-of-00005.safetensors
35b5ee7de71fbf17db3d5704e0c8f2bc7d005ca9e1d7ca2aeb19827b0cfcaa917a model-00004-of-00005.safetensors
3620c2d6366ab85c90786ccdd829cd2b9e7d30ef3b2ebbb998280e7e4014b542ff model-00005-of-00005.safetensors
37EOS
38fail() { echo "SMOKE-8B FAIL: $*" >&2; exit 1; }
39verify() {
40 [ -d "$MODEL_DIR" ] || fail "no model directory $MODEL_DIR"
41 ( cd "$MODEL_DIR" && printf '%s\n' "$SUMS" | sha256sum -c --quiet - ) || fail "sha256 mismatch in $MODEL_DIR"
42 echo "sha256 ok: config.json and 5 shards"
43}
44build() { # $1 = cpu|gb10
45 if [ "$1" = gb10 ]; then
46 # The pinned GPU engine, as scripts/whole_system_e2e.sh G1 does (env.sh: native libs required, no dev fallback).
47 local pins=$OUT/pins
48 bash "$REPO/scripts/pins.sh" --gpu "$pins" >"$OUT/pins.txt" 2>&1 || fail "pins.sh --gpu failed, see $OUT/pins.txt"
49 ( cd "$REPO" && . "$pins/env.sh" && CARGO_TARGET_DIR="$OUT/target-gb10" \
50 cargo build --release -p aien-runtime --example qwen3_8b_smoke ) >"$OUT/build-gb10.log" 2>&1 || fail "build failed, see $OUT/build-gb10.log"
51 grep -q -E "building the (CPU )?stub|developer override" "$OUT/build-gb10.log" && fail "stub engine build"
52 BIN=$OUT/target-gb10/release/examples/qwen3_8b_smoke
53 else
54 ( cd "$REPO" && CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$OUT/target-cpu}" \
55 cargo build --release -p aien-runtime --example qwen3_8b_smoke ) >"$OUT/build-cpu.log" 2>&1 || fail "build failed, see $OUT/build-cpu.log"
56 BIN=${CARGO_TARGET_DIR:-$OUT/target-cpu}/release/examples/qwen3_8b_smoke
57 fi
58 [ -x "$BIN" ] || fail "no binary at $BIN"
59}
60mkdir -p "$OUT"
61case "${1:-}" in
62 verify) verify ;;
63 cpu)
64 verify; build cpu
65 [ -e "$GOLDEN" ] && fail "golden file exists ($GOLDEN); delete it deliberately to re-record"
66 T0=$(date +%s)
67 "$BIN" "$MODEL_DIR" cpu >"$OUT/cpu.raw" 2>"$OUT/cpu.err" || fail "cpu leg exit $?, see $OUT/cpu.err"
68 grep "^{" "$OUT/cpu.raw" >"$OUT/cpu.json" || fail "no JSON result line in $OUT/cpu.raw"
69 echo "cpu leg wall seconds: $(( $(date +%s) - T0 ))"
70 jq -e '(.leg=="cpu") and (.prompts|length==2) and (all(.prompts[]; .output_ids|length>0)) and (.prompts[1].output_ids|length>=16) and (.fallback_count==0)' "$OUT/cpu.json" >/dev/null || fail "cpu result not well formed"
71 jq '{golden_for:"SMOKE-8B-v1", source:"CPU reference leg", prompts:[.prompts[]|{name,prompt_sha256,prompt_ids,output_ids,reply}]}' "$OUT/cpu.json" >"$GOLDEN"
72 echo "golden output_ids: $(jq -c '[.prompts[].output_ids]' "$GOLDEN")"
73 echo "CPU leg done: golden recorded in $GOLDEN (not a chip verdict)"
74 ;;
75 gb10)
76 verify
77 [ -s "$GOLDEN" ] || fail "no golden file $GOLDEN (run the cpu leg first)"
78 command -v quietlock >/dev/null && { quietlock check || fail "quiet flag held: another run owns the machine"; }
79 pgrep -f whole_system_e2e.sh >/dev/null && fail "a whole-system run is live; the chip is not free"
80 build gb10
81 env -u AIEN_DEV_FALLBACK -u AIEN_OMEGA_CTA_BUDGET -u AIEN_OMEGA_SPIN_US AIEN_GPU_BACKEND=omega AIEN_REQUIRE_BLACKWELL=1 \
82 "$BIN" "$MODEL_DIR" gb10 >"$OUT/gb10.raw" 2>"$OUT/gb10.err" || fail "gb10 leg exit $?, see $OUT/gb10.err"
83 grep "^{" "$OUT/gb10.raw" >"$OUT/gb10.json" || fail "no JSON result line in $OUT/gb10.raw (engine notes on stdout are kept there)"
84 jq -e '.leg=="gb10"' "$OUT/gb10.json" >/dev/null || fail "gb10 result not well formed"
85 [ "$(jq -c '[.prompts[]|[.name,.prompt_ids,.output_ids]]' "$OUT/gb10.json")" = "$(jq -c '[.prompts[]|[.name,.prompt_ids,.output_ids]]' "$GOLDEN")" ] || fail "prompt or output ids differ from the CPU golden (both prompts must be equal)"
86 [ "$(jq .fallback_count "$OUT/gb10.json")" = 0 ] || fail "fallback_count is $(jq .fallback_count "$OUT/gb10.json"), not 0"
87 echo "SMOKE-8B PASS (GB10 token ids equal the CPU golden, fallback_count 0)"
88 ;;
89 *) echo "usage: $0 verify|cpu|gb10" >&2; exit 2 ;;
90esac