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/aien-sovereign-core-mv/blob/main/docs/campaigns/open-model-qwen3/run-qwen3-v5.sh # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / docs / campaigns / open-model-qwen3 / run-qwen3-v5.sh` 200 lines ยท 15377 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 # OPEN-MODEL-QWEN3 v5 campaign (ACCEPTANCE-v5.md; DRAFT, NOT FROZEN, NOT RUN). It refuses a real run while any pin 18 # in frozen-v5.json holds the placeholder or its status does not say FROZEN, and afterwards unless every pin read 19 # from the checkouts and binaries equals it. Qwen3-4B, derived from run-qwen3-v4.sh: same driver (next-phase-1/run-campaign.sh), receipt builder, v8 rows and 20 # scorer; new tasks (tasks-oq3-v5.json), one declaration (qualification) and extra rows (v5-rows.sh, rows-oq3-v5.jq). 21 # Shell + jq only. Run inside the caller's hold, one part per hold. Environment as in ACCEPTANCE-v5 Section 7 22 # (model, tokenizer, binary, KV context, hardware requirement, checkpoint requirement, declared attempt flag), then: 23 # OQ3_PART=1|2|3|4 run-qwen3-v5.sh RUN_BASE OUT_DIR SC_DIR OMEGA_DIR REFERENCE_BIN MERGE_BIN 24 # SC_DIR is the sovereign-core checkout the binaries were built from, OMEGA_DIR the omega checkout at its omega.lock; 25 # the commits and lock files are read from them (row -PIN). Parts (ACCEPTANCE-v5 Section 8): 1 = D1 D2 D3, 26 # 2 = D4 D5 D6, 3 = E1 E2 N1, 4 = N2 R1 and the QUALIFICATION score. Part k needs part k-1 completed in the same 27 # RUN_BASE with the same binaries, tasks file, declaration, frozen values, row modules and wrapper. 28 # Dry run (gate G6): OQ3_DRY_TASKS= 29 # lifts the pinned paths and the frozen-pin checks and writes oq3-v5-DRYRUN-* outputs. A dry run is never a verdict. 30 # A dry run still starts the real driver and daemon on the GPU. 31 set -u 32 PART=${OQ3_PART:-} 33 case $PART in 1) LAUNCHES="D1 D2 D3" ;; 2) LAUNCHES="D4 D5 D6" ;; 3) LAUNCHES="E1 E2 N1" ;; 4) LAUNCHES="N2 R1" ;; *) echo "run-qwen3-v5: OQ3_PART must be 1, 2, 3 or 4" >&2; exit 2 ;; esac 34 HERE=$(cd "$(dirname "$0")" && pwd) 35 NP1=$(cd "$HERE/../next-phase-1" && pwd) 36 BASE=${1:?RUN_BASE} OUT=${2:?OUT_DIR} SCD=${3:?SC_DIR} OMD=${4:?OMEGA_DIR} REFBIN=${5:?REFERENCE_BIN} MERGEBIN=${6:?MERGE_BIN} 37 FROZEN=$HERE/frozen-v5.json 38 PLACEHOLDER=$(jq -r .placeholder "$FROZEN") 39 40 TASKS=$HERE/tasks-oq3-v5.json TAG=oq3-v5 41 if [ -n "${OQ3_DRY_TASKS:-}" ]; then 42 TASKS=$OQ3_DRY_TASKS TAG=oq3-v5-DRYRUN 43 shape='[.tasks[] | [.id, .kind, .max_tokens, .budget_ms, .destination, .seed]]' 44 [ "$(jq -c "$shape" "$TASKS")" = "$(jq -c "$shape" "$HERE/tasks-oq3-v5.json")" ] || 45 { echo "run-qwen3-v5: dry-run tasks must keep the v5 ids, kinds, max_tokens, budgets, destinations and seeds" >&2; exit 2; } 46 else 47 # Real run: the run path is pinned (the prompt embeds the workspace path), the output directory is fresh, 48 # and every frozen pin must be filled in (the comparison with the recorded pins follows below). 49 PINNED_BASE=/home/drakestapleton/workspace/oq3-v5-runs 50 [ "$BASE" = "$PINNED_BASE" ] || { echo "run-qwen3-v5: RUN_BASE must be $PINNED_BASE" >&2; exit 2; } 51 if [ $PART = 1 ]; then 52 [ ! -e "$BASE" ] || { echo "run-qwen3-v5: $BASE already exists (the v5 run is fresh and happens once)" >&2; exit 2; } 53 [ ! -e "$OUT" ] || [ -z "$(ls -A "$OUT" 2>/dev/null)" ] || { echo "run-qwen3-v5: OUT_DIR must be new or empty" >&2; exit 2; } 54 fi 55 [ "$(jq --arg p "$PLACEHOLDER" '[.pins[] | select(. == $p)] | length' "$FROZEN")" = 0 ] || 56 { echo "run-qwen3-v5: the build pins are not frozen yet (frozen-v5.json, ACCEPTANCE-v5 Section 7)" >&2; exit 2; } 57 # Filled pins are not a freeze: a draft freeze-fill change fills them first. The status line changes only at G8. 58 case "$(jq -r .status "$FROZEN")" in FROZEN*) ;; *) 59 echo "run-qwen3-v5: frozen-v5.json status is not FROZEN (ACCEPTANCE-v5 Section 9, gate G8)" >&2; exit 2 ;; esac 60 fi 61 DECL=$HERE/../scoring/declarations/oq3-v5.decl.json 62 SCORER=$HERE/../scoring/score-rows.sh 63 [ -f "$DECL" ] && [ -x "$SCORER" ] && [ -x "$REFBIN" ] && [ -x "$MERGEBIN" ] || { echo "run-qwen3-v5: declaration, scorer, reference binary or merge binary missing" >&2; exit 2; } 64 : "${AIEN_MODEL_PATH:?}" "${AIEN_TOKENIZER_PATH:?}" "${AIEN_BIN:?}" 65 need() { [ "$(printenv "$1")" = "$2" ] || { echo "$1 must be $2 (ACCEPTANCE-v5 Section 7)" >&2; exit 3; }; } 66 need AIEN_KV_CONTEXT_TOKENS 4096 67 need AIEN_REQUIRE_BLACKWELL 1 68 need AIEN_REQUIRE_CHECKPOINT 1 69 need AIEN_GB10_QWEN3_DECLARED_ATTEMPT 1 70 # The limits are set per launch below; a stale value from the caller is refused, never overridden silently. 71 # AIEN_COMPOSE_BUDGET_MS is the retired single budget (sc#284 refuses it too). AIEN_DEV_FALLBACK is new in v5, and so is 72 # AIEN_COMPOSE_AUTHORIZE_REQUIRES_DESK (the dev-only desk opt-out of sc#342, valid only with AIEN_DEV_FALLBACK=1). 73 for v in AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK AIEN_COMPOSE_AUTHORIZE_REQUIRES_DESK AIEN_COMPOSE_MAX_TOKENS AIEN_COMPOSE_DOC_MAX_TOKENS AIEN_COMPOSE_EDIT_BUDGET_MS \ 74 AIEN_COMPOSE_DOC_BUDGET_MS AIEN_COMPOSE_BUDGET_MS AIEN_OMEGA_SPIN_US AIEN_OMEGA_CTA_BUDGET; do 75 [ -z "$(printenv $v)" ] || { echo "$v must be unset (ACCEPTANCE-v5 Section 7)" >&2; exit 3; } 76 done 77 MODEL_DIR=$(dirname "$AIEN_MODEL_PATH") 78 chk() { [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$2" ] || { echo "digest mismatch: $1" >&2; exit 3; }; } 79 # The model the generation record must bind (row -GR): the index and every shard, re-hashed before each part. 80 chk "$AIEN_MODEL_PATH" "$(jq -r .model.index_sha256 "$FROZEN")" 81 while read -r n h; do chk "$MODEL_DIR/$n" "$h"; done < <(jq -r '.model.shards[] | "\(.[0]) \(.[1])"' "$FROZEN") 82 chk "$AIEN_TOKENIZER_PATH" "$(jq -r .model.tokenizer_sha256 "$FROZEN")" 83 chk "$MODEL_DIR/config.json" `5beea1a4a34c62782bfb2f911c606741a3bab8f92d80a118fa053c28af12e8ba` 84 chk "$MODEL_DIR/generation_config.json" `835fffe355c9438e7a25be099b3fccaa98350b83451f9fd2d99512e74f1ade48` 85 chk "$MODEL_DIR/tokenizer_config.json" `a62ff0a2472a0fa1b8eaabcb57c59b58afa42a22831dc141400b6e0cf2b65ce3` 86 # Build pins, read from the checkouts and the binaries (row -PIN). A real run refuses any difference. 87 SC=$(git -C "$SCD" rev-parse HEAD 2>/dev/null) && OMC=$(git -C "$OMD" rev-parse HEAD 2>/dev/null) || 88 { echo "run-qwen3-v5: SC_DIR and OMEGA_DIR must be git checkouts" >&2; exit 2; } 89 OMG=$OMC 90 [ "$OMC" = "$(tr -d '[:space:]' <"$SCD/omega.lock")" ] || { echo "run-qwen3-v5: OMEGA_DIR HEAD differs from SC_DIR/omega.lock" >&2; exit 2; } 91 PINS=$(jq -n --arg sc "$SC" --arg om "$OMC" --arg ph "$(tr -d '[:space:]' <"$OMD/physics.lock" 2>/dev/null)" \ 92 --arg ao "$(tr -d '[:space:]' <"$OMD/aienos.lock" 2>/dev/null)" --arg cl "$(sha256sum "$SCD/Cargo.lock" | cut -d' ' -f1)" \ 93 --arg cli "$(sha256sum "$AIEN_BIN" | cut -d' ' -f1)" --arg ref "$(sha256sum "$REFBIN" | cut -d' ' -f1)" --arg mrg "$(sha256sum "$MERGEBIN" | cut -d' ' -f1)" \ 94 '{sovereign_core_commit: $sc, omega_lock_commit: $om, physics_lock_commit: $ph, aienos_lock_commit: $ao, cargo_lock_sha256: $cl, 95 aien_cli_sha256: $cli, np1_reference_sha256: $ref, np1_edit_merge_sha256: $mrg}') 96 if [ -z "${OQ3_DRY_TASKS:-}" ]; then 97 [ -z "$(git -C "$SCD" status --porcelain)" ] || { echo "run-qwen3-v5: SC_DIR has uncommitted changes" >&2; exit 2; } 98 [ "$(jq -c --argjson p "$PINS" '.pins == $p' "$FROZEN")" = true ] || 99 { echo "run-qwen3-v5: the recorded build pins differ from frozen-v5.json: $(jq -c --argjson p "$PINS" '.pins as $f | [$f | keys[] | select($f[.] != $p[.])]' "$FROZEN")" >&2; exit 2; } 100 fi 101 RES=$OUT/$TAG-results.jsonl 102 if [ $PART = 1 ]; then 103 [ ! -e "$BASE/part1.done" ] && [ ! -e "$RES" ] || { echo "run-qwen3-v5: part 1 already ran here" >&2; exit 2; } 104 mkdir -p "$BASE" "$OUT"; : >"$RES" 105 else 106 prev=$((PART - 1)) 107 [ -f "$BASE/part$prev.done" ] && [ ! -e "$BASE/part$PART.started" ] || { echo "run-qwen3-v5: part $PART needs a completed part $prev and runs once" >&2; exit 2; } 108 : >"$BASE/part$PART.started" 109 fi 110 sha256sum "$AIEN_BIN" "$REFBIN" "$MERGEBIN" "$TASKS" "$DECL" "$FROZEN" "$HERE/rows-oq3-v3.jq" "$HERE/rows-oq3-v4.jq" "$HERE/rows-oq3-v5.jq" \ 111 "$HERE/v5-rows.sh" "$0" > "$BASE/identity-part$PART.sha256" 112 if [ $PART != 1 ] && ! cmp -s <(cut -d" " -f1 "$BASE/identity-part1.sha256") <(cut -d" " -f1 "$BASE/identity-part$PART.sha256"); then 113 echo "run-qwen3-v5: part $PART binaries, tasks, declaration, frozen values, rows or wrapper differ from part 1 (one build per run)" >&2; exit 2 114 fi 115 printf '%s\n' "$PINS" >"$BASE/pins-part$PART.json" 116 # Memory before the part (row -MEAS), from /proc/meminfo, in kB. 117 MEM=$(awk '/^MemFree:/ {f=$2} /^Cached:/ {c=$2} END {printf "{\"mem_free_kb\":%d,\"cached_kb\":%d}", f, c}' /proc/meminfo) 118 printf '%s\n' "$MEM" >"$BASE/meminfo-part$PART.json" 119 # Launch wall time on CLOCK_BOOTTIME (monotonic, 10 ms ticks), in ms. 120 up_ms() { echo $(( $(tr -d . for any task that has a seed, which only fits edits. A non-edit 127 # task whose seed holds other files (D4: its source file; R1: the notes/ folder its destination needs, Section 2) is 128 # staged with seed null for the receipt builder only; the driver still gets the real seed from the tasks file 129 # (NP1_SEED_DIR below), and v5-rows.sh checks the D4 source file itself (row SRC). 130 STAGE_FILTER='(.tasks[] | select(.kind != "edit") | .seed) = null' 131 if [ $PART = 1 ]; then 132 mkdir -p "$STAGE" 133 for f in "$NP1"/*; do 134 n=$(basename "$f"); case $n in tasks-v8.json) continue ;; esac 135 ln -s "$f" "$STAGE/$n" 136 done 137 jq "$STAGE_FILTER" "$TASKS" >"$STAGE/tasks-v8.json" 138 ln -s "$HERE/seed-v5" "$STAGE/seed-v5" 139 fi 140 [ "$(jq "$STAGE_FILTER" "$TASKS")" = "$(cat "$STAGE/tasks-v8.json")" ] || { echo "run-qwen3-v5: staged tasks file differs from the tasks file" >&2; exit 2; } 141 # Product limits (ACCEPTANCE-v5 Section 2) come from the task's own max_tokens and budget_ms (row -D scores the 142 # same budget_ms); only D6 differs from the product values (Drake 2026-10-09, ACCEPTANCE-v5 Section 2.1). 143 for id in $LAUNCHES; do 144 t=$(jq -c --arg id "$id" '.tasks[] | select(.id == $id)' "$TASKS") 145 goal=$(jq -r .goal <<<"$t"); max=$(jq -r .max_tokens <<<"$t"); bud=$(jq -r .budget_ms <<<"$t"); kind=$(jq -r .kind <<<"$t"); seed=$(jq -r '.seed // empty' <<<"$t") 146 seed_dir=; [ -n "$seed" ] && seed_dir=$HERE/$seed 147 # An edit goal (names an existing file) uses the edit cap AIEN_COMPOSE_MAX_TOKENS and budget AIEN_COMPOSE_EDIT_BUDGET_MS; 148 # every other goal creates a new file and uses the document cap and budget. The other cap and budget stay at their product values. 149 if [ "$kind" = edit ]; then ecap=$max dcap=$(jq -r .limits.doc_max_tokens "$TASKS") ebud=$bud dbud=$(jq -r .limits.doc_budget_ms "$TASKS") 150 else ecap=$(jq -r .limits.edit_max_tokens "$TASKS") dcap=$max ebud=$(jq -r .limits.edit_budget_ms "$TASKS") dbud=$bud; fi 151 export AIEN_COMPOSE_EDIT_BUDGET_MS=$ebud AIEN_COMPOSE_DOC_BUDGET_MS=$dbud 152 t0=$(up_ms) 153 NP1_GOAL=$goal AIEN_COMPOSE_MAX_TOKENS=$ecap AIEN_COMPOSE_DOC_MAX_TOKENS=$dcap NP1_SEED_DIR=$seed_dir \ 154 bash "$NP1/run-campaign.sh" "$BASE/$id" >"$BASE/$id.driver.out" 2>&1 155 drc=$?; t1=$(up_ms) 156 jq -n --arg id "$id" --argjson w $((t1 - t0)) --argjson m "$MEM" --argjson p "$PINS" --argjson rc $drc \ 157 '{launch: $id, wall_ms: $w, wall_clock: "CLOCK_BOOTTIME, 10 ms ticks, around the driver call", driver_exit: $rc, meminfo_before: $m, pins: $p}' >"$BASE/$id.launch-v5.json" 158 echo "launch $id driver exit $drc in $((t1 - t0)) ms (edit cap $ecap, document cap $dcap, budgets $AIEN_COMPOSE_EDIT_BUDGET_MS/$AIEN_COMPOSE_DOC_BUDGET_MS ms${seed:+, seed $seed})" 159 ref= 160 if [ "$kind" = identity ] && [ -d "$BASE/$id/ws" ]; then 161 ws=$(cd "$BASE/$id/ws" && pwd -P) 162 "$REFBIN" "$MODEL_DIR" "$goal" "$ws" "$max" new >"$BASE/$id.reference.json" 2>"$BASE/$id.reference.err" 163 echo "launch $id CPU reference exit $?" 164 ref=$BASE/$id.reference.json 165 fi 166 if [ -f "$BASE/$id/run.json" ]; then 167 v8merge=null 168 if [ "$kind" = edit ] && [ -f "$BASE/$id/s3-report.json" ]; then 169 rf=$BASE/$id.accepted-reply.txt 170 if jq -e '[.proposal_attempts // [] | .[] | select(.outcome == "parsed")] | length > 0' "$BASE/$id/s3-report.json" >/dev/null 2>&1; then 171 jq -j '[.proposal_attempts[] | select(.outcome == "parsed")] | last | .text' "$BASE/$id/s3-report.json" >"$rf" 172 m=$("$MERGEBIN" "$(jq -r .destination <<<"$t")" "$HERE/$seed/$(jq -r .destination <<<"$t")" "$rf" 2>"$BASE/$id.merge.err") 173 if jq . <<<"$m" >/dev/null 2>&1; then v8merge=$(jq -c . <<<"$m"); fi 174 fi 175 echo "launch $id edit re-derivation: $(jq -r 'if . == null then "none" else "ok=\(.ok)" end' <<<"$v8merge")" 176 fi 177 v5env=(); [ "$(jq -r '.destination // empty' <<<"$t")" != "" ] && [ "${id#N}" = "$id" ] && \ 178 v5env=(TASK_ID="$id" TASK_SPEC="$TASKS" TASK_ACCEPTANCE="$HERE/ACCEPTANCE-v5.md") 179 env "${v5env[@]}" V6_ROWS=rows-v9.jq V8_MERGE="$v8merge" V6_TASK="$id" V6_MAX_TOKENS="$max" V6_REFERENCE="$ref" \ 180 SPEC="open-model-qwen3/ACCEPTANCE-v5.md spec_version 5${OQ3_DRY_TASKS:+ DRY RUN}" bash "$STAGE/make-receipt.sh" \ 181 "$BASE/$id" "$OUT" "$SC" "$OMC" "$OMG" 0 "OPEN-MODEL-QWEN3 v5${OQ3_DRY_TASKS:+ DRY RUN} launch $id" >"$BASE/$id.receipt.out" 2>&1 182 rec=$OUT/$(head -1 "$BASE/$id.receipt.out" | sed -n 's/.*receipt \([0-9a-f]*\.json\).*/\1/p') 183 if [ -f "$rec" ]; then 184 bash "$NP1/v8-results.sh" "$id" "$rec" >>"$RES" 185 bash "$HERE/v5-rows.sh" "$BASE/$id" "$id" "$TASKS" "$OUT" "$(basename "$rec")" "$BASE/$id.launch-v5.json" "$FROZEN" >>"$RES" 186 else bash "$NP1/v8-results.sh" "$id" - "$DECL" "receipt not written" >>"$RES"; fi 187 echo "launch $id receipt $(basename "$rec")" 188 else 189 bash "$NP1/v8-results.sh" "$id" - "$DECL" "launch failed: no run.json" >>"$RES" 190 echo "launch $id FAILED to launch" 191 fi 192 jq -r --arg id "$id" 'select(.row | startswith($id + "/")) | select(.verdict != "PASS") | " \(.verdict) \(.row)"' "$RES" 193 done 194 : >"$BASE/part$PART.done" 195 if [ $PART -le 3 ]; then echo "part $PART done ($LAUNCHES); run part $((PART + 1)) in a new hold"; exit 0; fi 196 # Qualification verdict: the declaration and the result file only (ACCEPTANCE-v5 Section 5). Rows a receipt computes 197 # but the declaration does not hold (for N1: N1-B, N1-C, N1-H) are listed by the scorer as extras, never counted. 198 bash "$SCORER" "$DECL" "$RES" >"$OUT/$TAG-score.json"; rc=$? 199 echo "OPEN-MODEL-QWEN3 v5${OQ3_DRY_TASKS:+ DRY RUN (not a verdict)} QUALIFICATION (scoring-v5, score-rows.sh exit $rc): $(jq -r .verdict "$OUT/$TAG-score.json" 2>/dev/null || echo ERROR)" 200 exit $rc