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-v4.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-v4.sh` 189 lines ยท 13944 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 v4 campaign (ACCEPTANCE-v4.md; PREPARED, NOT FROZEN, NOT RUN). It refuses a real run while the 18 # build identity below holds the placeholder, and afterwards unless the commits and the three binaries' sha256 match. 19 # Qwen3-4B, adapted from run-qwen3-v3.sh: same driver (next-phase-1/run-campaign.sh), receipt builder, v8 rows and 20 # scorer; new tasks (tasks-oq3-v4.json), two declarations (qualification, regression) and extra rows (v4-rows.sh). 21 # Shell + jq only. Run inside the caller's hold, one part per hold. Environment as in ACCEPTANCE-v4 Section 7 22 # (model, tokenizer, binary, KV context, hardware requirement, declared attempt flag), then: 23 # OQ3_PART=1|2|3|4|5 run-qwen3-v4.sh RUN_BASE OUT_DIR SC_COMMIT OMEGA_COMPOSE_COMMIT OMEGA_GPU_COMMIT REFERENCE_BIN MERGE_BIN 24 # Parts (ACCEPTANCE-v4 Section 8): 1 = W1 W2 W3, 2 = W4 W5 U1 U2, 3 = N1 N2, 4 = R1 and the QUALIFICATION score, 25 # 5 = RG2 RG3 RT4 RT6 (regression, scored separately, never part of the verdict). Part k needs part k-1 completed in 26 # the same RUN_BASE with the same binaries, tasks file, declarations and wrapper. 27 # Dry run: OQ3_DRY_TASKS= lifts the pinned paths and writes oq3-v4-DRYRUN-* outputs. A dry run is never a verdict. 29 set -u 30 PART=${OQ3_PART:?OQ3_PART must be 1, 2, 3, 4 or 5} 31 case $PART in 1) LAUNCHES="W1 W2 W3" ;; 2) LAUNCHES="W4 W5 U1 U2" ;; 3) LAUNCHES="N1 N2" ;; 4) LAUNCHES="R1" ;; 5) LAUNCHES="RG2 RG3 RT4 RT6" ;; *) echo "run-qwen3-v4: OQ3_PART must be 1, 2, 3, 4 or 5" >&2; exit 2 ;; esac 32 HERE=$(cd "$(dirname "$0")" && pwd) 33 NP1=$(cd "$HERE/../next-phase-1" && pwd) 34 BASE=${1:?RUN_BASE} OUT=${2:?OUT_DIR} SC=${3:?SC_COMMIT} OMC=${4:?OMEGA_COMPOSE} OMG=${5:?OMEGA_GPU} REFBIN=${6:?REFERENCE_BIN} MERGEBIN=${7:?MERGE_BIN} 35 36 # ---- Build identity (ACCEPTANCE-v4 Section 7), TO FILL AT FREEZE (exact sovereign-core commit, omega.lock commit, binary sha256), 37 # not before. A real run refuses unless the commit arguments and the three binaries sha256 equal these. Placeholder = refuse. 38 PLACEHOLDER="TO BE FILLED at freeze, after all required changes merge and the combined build passes review and checks" 39 FROZEN_SC_COMMIT=$PLACEHOLDER 40 FROZEN_OMEGA_COMMIT=$PLACEHOLDER 41 FROZEN_AIEN_CLI_SHA256=$PLACEHOLDER 42 FROZEN_NP1_REFERENCE_SHA256=$PLACEHOLDER 43 FROZEN_NP1_EDIT_MERGE_SHA256=$PLACEHOLDER 44 45 TASKS=$HERE/tasks-oq3-v4.json TAG=oq3-v4 46 # A dry run skips the pinned-path, placeholder and frozen-build checks but still starts the real driver and daemon on the GPU. 47 if [ -n "${OQ3_DRY_TASKS:-}" ]; then 48 TASKS=$OQ3_DRY_TASKS TAG=oq3-v4-DRYRUN 49 shape='[.tasks[] | [.id, .kind, .max_tokens, .budget_ms, .destination, .seed]]' 50 [ "$(jq -c "$shape" "$TASKS")" = "$(jq -c "$shape" "$HERE/tasks-oq3-v4.json")" ] || 51 { echo "run-qwen3-v4: dry-run tasks must keep the v4 ids, kinds, max_tokens, budgets, destinations and seeds" >&2; exit 2; } 52 else 53 # Real run: the run path is pinned (the prompt embeds the workspace path), the output directory is fresh, 54 # and the build identity must be filled in and must match. 55 PINNED_BASE=/home/drakestapleton/workspace/oq3-v4-runs 56 [ "$BASE" = "$PINNED_BASE" ] || { echo "run-qwen3-v4: RUN_BASE must be $PINNED_BASE" >&2; exit 2; } 57 if [ $PART = 1 ]; then 58 [ ! -e "$BASE" ] || { echo "run-qwen3-v4: $BASE already exists (the v4 run is fresh and happens once)" >&2; exit 2; } 59 [ ! -e "$OUT" ] || [ -z "$(ls -A "$OUT" 2>/dev/null)" ] || { echo "run-qwen3-v4: OUT_DIR must be new or empty" >&2; exit 2; } 60 fi 61 for v in "$FROZEN_SC_COMMIT" "$FROZEN_OMEGA_COMMIT" "$FROZEN_AIEN_CLI_SHA256" "$FROZEN_NP1_REFERENCE_SHA256" "$FROZEN_NP1_EDIT_MERGE_SHA256"; do 62 [ "$v" != "$PLACEHOLDER" ] || { echo "run-qwen3-v4: the build identity is not frozen yet (ACCEPTANCE-v4 Section 7)" >&2; exit 2; } 63 done 64 [ "$SC" = "$FROZEN_SC_COMMIT" ] && [ "$OMC" = "$FROZEN_OMEGA_COMMIT" ] && [ "$OMG" = "$FROZEN_OMEGA_COMMIT" ] || 65 { echo "run-qwen3-v4: SC_COMMIT, OMEGA_COMPOSE_COMMIT and OMEGA_GPU_COMMIT must equal the frozen commits" >&2; exit 2; } 66 fi 67 DECL=$HERE/../scoring/declarations/oq3-v4.decl.json 68 RDECL=$HERE/../scoring/declarations/oq3-v4-regression.decl.json 69 SCORER=$HERE/../scoring/score-rows.sh 70 [ -f "$DECL" ] && [ -f "$RDECL" ] && [ -x "$SCORER" ] && [ -x "$REFBIN" ] && [ -x "$MERGEBIN" ] || { echo "run-qwen3-v4: declaration, scorer, reference binary or merge binary missing" >&2; exit 2; } 71 : "${AIEN_MODEL_PATH:?}" "${AIEN_TOKENIZER_PATH:?}" "${AIEN_BIN:?}" 72 need() { [ "$(printenv "$1")" = "$2" ] || { echo "$1 must be $2 (ACCEPTANCE-v4 Section 7)" >&2; exit 3; }; } 73 need AIEN_KV_CONTEXT_TOKENS 4096 74 need AIEN_REQUIRE_BLACKWELL 1 75 need AIEN_GB10_QWEN3_DECLARED_ATTEMPT 1 76 # The limits are set per launch below; a stale value from the caller is refused, never overridden silently. 77 # AIEN_COMPOSE_BUDGET_MS is the retired single budget (sc#284 refuses it too). 78 for v in AIEN_FORCE_CPU_STUB AIEN_COMPOSE_MAX_TOKENS AIEN_COMPOSE_DOC_MAX_TOKENS AIEN_COMPOSE_EDIT_BUDGET_MS \ 79 AIEN_COMPOSE_DOC_BUDGET_MS AIEN_COMPOSE_BUDGET_MS AIEN_OMEGA_SPIN_US AIEN_OMEGA_CTA_BUDGET; do 80 [ -z "$(printenv $v)" ] || { echo "$v must be unset (ACCEPTANCE-v4 Section 7)" >&2; exit 3; } 81 done 82 MODEL_DIR=$(dirname "$AIEN_MODEL_PATH") 83 chk() { [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$2" ] || { echo "digest mismatch: $1" >&2; exit 3; }; } 84 chk "$AIEN_MODEL_PATH" `d6c42883a895dfef5b0080ed2116a1bcd764f558406b98923d675978a1abf29c` 85 chk "$MODEL_DIR/model-00001-of-00003.safetensors" `75311d91bb08cf0b882913da464a1e722a31fb44db35208663487efb7a3d8ed6` 86 chk "$MODEL_DIR/model-00002-of-00003.safetensors" `0b48adbb1f60e901153d91907ba11ce63bd4b8b584482e730f48808d055dfba1` 87 chk "$MODEL_DIR/model-00003-of-00003.safetensors" `7dd39ccca5e4de123c74c14af44c9bf2eb75df33b4614382af0134528e060d5d` 88 chk "$AIEN_TOKENIZER_PATH" `aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4` 89 chk "$MODEL_DIR/config.json" `5beea1a4a34c62782bfb2f911c606741a3bab8f92d80a118fa053c28af12e8ba` 90 chk "$MODEL_DIR/generation_config.json" `835fffe355c9438e7a25be099b3fccaa98350b83451f9fd2d99512e74f1ade48` 91 chk "$MODEL_DIR/tokenizer_config.json" `a62ff0a2472a0fa1b8eaabcb57c59b58afa42a22831dc141400b6e0cf2b65ce3` 92 if [ -z "${OQ3_DRY_TASKS:-}" ]; then 93 chk "$AIEN_BIN" "$FROZEN_AIEN_CLI_SHA256" 94 chk "$REFBIN" "$FROZEN_NP1_REFERENCE_SHA256" 95 chk "$MERGEBIN" "$FROZEN_NP1_EDIT_MERGE_SHA256" 96 fi 97 RES=$OUT/$TAG-results.jsonl RESR=$OUT/$TAG-regression-results.jsonl 98 if [ $PART = 1 ]; then 99 [ ! -e "$BASE/part1.done" ] && [ ! -e "$RES" ] || { echo "run-qwen3-v4: part 1 already ran here" >&2; exit 2; } 100 mkdir -p "$BASE" "$OUT"; : >"$RES"; : >"$RESR" 101 else 102 prev=$((PART - 1)) 103 [ -f "$BASE/part$prev.done" ] && [ ! -e "$BASE/part$PART.started" ] || { echo "run-qwen3-v4: part $PART needs a completed part $prev and runs once" >&2; exit 2; } 104 : >"$BASE/part$PART.started" 105 fi 106 sha256sum "$AIEN_BIN" "$REFBIN" "$MERGEBIN" "$TASKS" "$DECL" "$HERE/rows-oq3-v3.jq" "$HERE/rows-oq3-v4.jq" "$HERE/v4-rows.sh" "$RDECL" "$0" > "$BASE/identity-part$PART.sha256" 107 if [ $PART != 1 ] && ! cmp -s <(cut -d" " -f1 "$BASE/identity-part1.sha256") <(cut -d" " -f1 "$BASE/identity-part$PART.sha256"); then 108 echo "run-qwen3-v4: part $PART binaries, tasks, declaration, rows or wrapper differ from part 1 (one build per run)" >&2; exit 2 109 fi 110 # The receipt builder looks for tasks-v8.json, rows-v5/v8.jq and the seed folders next to itself. A staging folder of 111 # links to the unchanged next-phase-1 files, with tasks-v8.json replaced by this campaign's tasks file and seed-v4 112 # linked in, lets the unchanged make-receipt.sh and rows-v8.jq be used (ACCEPTANCE-v4 Section 12). 113 STAGE=$BASE/stage 114 # The unchanged make-receipt.sh reads seed/ for any task that has a seed, which only fits edits. A document 115 # whose seed holds a different source file (W4) is staged with seed null for the receipt builder only; the driver still 116 # gets the real seed from the tasks file (NP1_SEED_DIR below), and v4-rows.sh checks the source file itself (row SRC). 117 STAGE_FILTER='(.tasks[] | select(.source != null) | .seed) = null' 118 if [ $PART = 1 ]; then 119 mkdir -p "$STAGE" 120 for f in "$NP1"/*; do 121 n=$(basename "$f"); case $n in tasks-v8.json) continue ;; esac 122 ln -s "$f" "$STAGE/$n" 123 done 124 jq "$STAGE_FILTER" "$TASKS" >"$STAGE/tasks-v8.json" 125 ln -s "$HERE/seed-v4" "$STAGE/seed-v4" 126 fi 127 [ "$(jq "$STAGE_FILTER" "$TASKS")" = "$(cat "$STAGE/tasks-v8.json")" ] || { echo "run-qwen3-v4: staged tasks file differs from the tasks file" >&2; exit 2; } 128 # Product limits (ACCEPTANCE-v4 Section 1), the same for every launch. 129 export AIEN_COMPOSE_EDIT_BUDGET_MS=$(jq -r .limits.edit_budget_ms "$TASKS") AIEN_COMPOSE_DOC_BUDGET_MS=$(jq -r .limits.doc_budget_ms "$TASKS") 130 for id in $LAUNCHES; do 131 # Regression launches (part 4) have their own declaration and result file; they never touch the qualification files. 132 if [ "$(jq -r --arg id "$id" '.tasks[] | select(.id == $id) | .group' "$TASKS")" = regression ]; then LRES=$RESR LDECL=$RDECL; else LRES=$RES LDECL=$DECL; fi 133 t=$(jq -c --arg id "$id" '.tasks[] | select(.id == $id)' "$TASKS") 134 goal=$(jq -r .goal <<<"$t"); max=$(jq -r .max_tokens <<<"$t"); kind=$(jq -r .kind <<<"$t"); seed=$(jq -r '.seed // empty' <<<"$t") 135 seed_dir=; [ -n "$seed" ] && seed_dir=$HERE/$seed 136 # An edit goal (names an existing file) uses the edit cap AIEN_COMPOSE_MAX_TOKENS; every other goal creates a 137 # new file and uses the document cap AIEN_COMPOSE_DOC_MAX_TOKENS. The other cap stays at its product value. 138 if [ "$kind" = edit ]; then ecap=$max dcap=$(jq -r .limits.doc_max_tokens "$TASKS"); else ecap=$(jq -r .limits.edit_max_tokens "$TASKS") dcap=$max; fi 139 NP1_GOAL=$goal AIEN_COMPOSE_MAX_TOKENS=$ecap AIEN_COMPOSE_DOC_MAX_TOKENS=$dcap NP1_SEED_DIR=$seed_dir \ 140 bash "$NP1/run-campaign.sh" "$BASE/$id" >"$BASE/$id.driver.out" 2>&1 141 echo "launch $id driver exit $? (edit cap $ecap, document cap $dcap, budgets $AIEN_COMPOSE_EDIT_BUDGET_MS/$AIEN_COMPOSE_DOC_BUDGET_MS ms${seed:+, seed $seed})" 142 ref= 143 if [ "$kind" = identity ] && [ -d "$BASE/$id/ws" ]; then 144 ws=$(cd "$BASE/$id/ws" && pwd -P) 145 "$REFBIN" "$MODEL_DIR" "$goal" "$ws" "$max" new >"$BASE/$id.reference.json" 2>"$BASE/$id.reference.err" 146 echo "launch $id CPU reference exit $?" 147 ref=$BASE/$id.reference.json 148 fi 149 if [ -f "$BASE/$id/run.json" ]; then 150 v8merge=null 151 if [ "$kind" = edit ] && [ -f "$BASE/$id/s3-report.json" ]; then 152 rf=$BASE/$id.accepted-reply.txt 153 if jq -e '[.proposal_attempts // [] | .[] | select(.outcome == "parsed")] | length > 0' "$BASE/$id/s3-report.json" >/dev/null 2>&1; then 154 jq -j '[.proposal_attempts[] | select(.outcome == "parsed")] | last | .text' "$BASE/$id/s3-report.json" >"$rf" 155 m=$("$MERGEBIN" "$(jq -r .destination <<<"$t")" "$HERE/$seed/$(jq -r .destination <<<"$t")" "$rf" 2>"$BASE/$id.merge.err") 156 if jq . <<<"$m" >/dev/null 2>&1; then v8merge=$(jq -c . <<<"$m"); fi 157 fi 158 echo "launch $id edit re-derivation: $(jq -r 'if . == null then "none" else "ok=\(.ok)" end' <<<"$v8merge")" 159 fi 160 v5env=(); [ "$(jq -r '.destination // empty' <<<"$t")" != "" ] && [ "${id#N}" = "$id" ] && \ 161 v5env=(TASK_ID="$id" TASK_SPEC="$TASKS" TASK_ACCEPTANCE="$HERE/ACCEPTANCE-v4.md") 162 env "${v5env[@]}" V6_ROWS=rows-v8.jq V8_MERGE="$v8merge" V6_TASK="$id" V6_MAX_TOKENS="$max" V6_REFERENCE="$ref" \ 163 SPEC="open-model-qwen3/ACCEPTANCE-v4.md spec_version 4${OQ3_DRY_TASKS:+ DRY RUN}" bash "$STAGE/make-receipt.sh" \ 164 "$BASE/$id" "$OUT" "$SC" "$OMC" "$OMG" 0 "OPEN-MODEL-QWEN3 v4${OQ3_DRY_TASKS:+ DRY RUN} launch $id" >"$BASE/$id.receipt.out" 2>&1 165 rec=$OUT/$(head -1 "$BASE/$id.receipt.out" | sed -n 's/.*receipt \([0-9a-f]*\.json\).*/\1/p') 166 if [ -f "$rec" ]; then 167 bash "$NP1/v8-results.sh" "$id" "$rec" >>"$LRES" 168 bash "$HERE/v4-rows.sh" "$BASE/$id" "$id" "$TASKS" "$OUT" "$(basename "$rec")" >>"$LRES" 169 else bash "$NP1/v8-results.sh" "$id" - "$LDECL" "receipt not written" >>"$LRES"; fi 170 echo "launch $id receipt $(basename "$rec")" 171 else 172 bash "$NP1/v8-results.sh" "$id" - "$LDECL" "launch failed: no run.json" >>"$LRES" 173 echo "launch $id FAILED to launch" 174 fi 175 jq -r --arg id "$id" 'select(.row | startswith($id + "/")) | select(.verdict != "PASS") | " \(.verdict) \(.row)"' "$LRES" 176 done 177 : >"$BASE/part$PART.done" 178 if [ $PART -le 3 ]; then echo "part $PART done ($LAUNCHES); run part $((PART + 1)) in a new hold"; exit 0; fi 179 if [ $PART = 4 ]; then 180 # Qualification verdict: only the qualification declaration and result file (ACCEPTANCE-v4 Section 5). 181 bash "$SCORER" "$DECL" "$RES" >"$OUT/$TAG-score.json"; rc=$? 182 echo "OPEN-MODEL-QWEN3 v4${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)" 183 echo "part 4 done; run part 5 (regression, reported only) in a new hold" 184 exit $rc 185 fi 186 # Part 5: regression rows, scored separately, reported, never part of the qualification verdict. 187 bash "$SCORER" "$RDECL" "$RESR" >"$OUT/$TAG-regression-score.json"; rc=$? 188 echo "OPEN-MODEL-QWEN3 v4${OQ3_DRY_TASKS:+ DRY RUN (not a verdict)} REGRESSION, REPORTED ONLY, NOT PART OF THE VERDICT (score-rows.sh exit $rc): $(jq -r .verdict "$OUT/$TAG-regression-score.json" 2>/dev/null || echo ERROR)" 189 exit 0