From 8b05fb2d47fbb395c574cf0f6e9db0be1c048612 Mon Sep 17 00:00:00 2001 From: Hasan Basbunar Date: Mon, 19 Oct 2026 14:57:24 +0200 Subject: [PATCH] flash lane: a GPU outside its ATS mode is said before the lane starts, and nothing downloads for it (issue #54) The flash lane serves its 47.7 GiB N-gram table from a file on NVMe, which the GPU reads through the host page tables: a GB10 in its ATS addressing mode. On the GX10 of issue #54, whose mode reads None, SGLang refused the file backend when it loaded the weights, after the image and 126 GiB of checkpoint had been fetched, and systemd started the lane again every 15 s. flash-ats-check.sh asks nvidia-smi --query-gpu=addressing_mode. HMM or None refuse the lane with the reason, exit code 1. ATS, and anything nvidia-smi does not name (a driver without the field, [N/A], no answer within 10 s), leave the engine to decide, as before: refused, a lane would stay down for good on a misreading. It takes engine-preflight.sh's nvidia-smi settings. Every caller reads it through one function, lanes.sh flash_cannot_start, and only exit code 1 with a reason means it cannot start: a check that is missing or fails in any other way leaves the engine to decide (found in review: any exit code read as "cannot"). - The launcher asks before the table is written or the image runs, ends a start it cannot make with "preflight: qwen38-flash.service cannot start: " and exit code 78, which the unit does not start it again on (RestartPreventExitStatus=78). - install.sh installs the check beside engine-preflight.sh on every box. A new flash install stops at step 1, before its first download, and names the 27B lane: a plain ./install.sh where the box has it, which keeps its target. A box that has the flash lane already, as its main lane or beside the 27B, gets its units only: nothing downloads or starts for it, the rest of the box is updated, and the run ends on why and on what the 27B lane beside it can do now. Found in review: the main lane stopped the whole update at step 1, a prepared lane beside the 27B stopped before it wrote the new launcher, and the end told every box to Load the 27B lane. - prepare-lane.sh (the first Load) and switch-model.sh (a Load of another flash checkpoint, the Library's Download) refuse it before the first byte, and the boot is not pointed at it. The tests run the check against every answer nvidia-smi gives, the shared function against every exit code, the launcher's head as rendered and with the check missing, the installer's step 1 and its end as written, its block for the lane beside the 27B, its summary line, an update whose flash lane cannot start run to its end, the switch's order and the units-only run to its end. The first-Load harness stubs the GPU: its cases asked the host's own. The image and video lanes' suites find the boot lanes' path by its new condition. With only the new script added to the old code, the new cases fail, but those that run the script alone or check that the launcher goes on in ATS, as the old one did. Co-Authored-By: Claude Opus 5.5 --- ARCHITECTURE.md | 6 + docs/flash-lane.md | 27 ++ flash-ats-check.sh | 32 ++ install.sh | 126 ++++++-- lanes.sh | 11 + prepare-lane.sh | 5 +- qwen38-flash-launch.sh.template | 12 + qwen38-flash.service.template | 3 + switch-model.sh | 8 + tests/test_flash_ats_check.py | 353 ++++++++++++++++++++++ tests/test_hints_name_standard_targets.py | 4 +- tests/test_image_lane.py | 10 +- tests/test_install_every_lane.py | 20 +- tests/test_install_units_only_run.py | 80 ++++- tests/test_lane_on_demand.py | 19 +- tests/test_video_lane.py | 6 +- 16 files changed, 674 insertions(+), 48 deletions(-) create mode 100755 flash-ats-check.sh create mode 100644 tests/test_flash_ats_check.py diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 97048fa2..e29423d9 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -102,6 +102,12 @@ launcher in `~/.local/bin`, and the two weight trees (HF cache, PLE dir). the script in place first (run on its own, the image installer would otherwise leave a lane that never starts), one attempt fits in the unit's start timeout, and the script is no input of the engine, so a new one never restarts a healthy engine. +14. The flash lane does not start on a GPU nvidia-smi reports outside its ATS addressing + mode (`flash-ats-check.sh`, issue #54; a mode it does not name leaves the engine to + decide): its launcher asks before the table or the image and ends a start it cannot make + with an exit code its unit does not restart on, nothing downloads for it there (an update + gives it its units only and starts nothing for it, prepare-lane.sh and switch-model.sh + refuse it), and the script is no input of the engine. ## How a change moves through the repo diff --git a/docs/flash-lane.md b/docs/flash-lane.md index 7a7d2221..ec59c17b 100644 --- a/docs/flash-lane.md +++ b/docs/flash-lane.md @@ -29,6 +29,33 @@ file on the local NVMe and the gather kernel reads its rows through GB10's host page tables, which works because this part reports `cudaDevAttrPageableMemoryAccessUsesHostPageTables`. +That attribute holds in the GPU's ATS addressing mode only. Outside it SGLang +refuses the file backend when it loads the weights ("needs a device whose +pageable host memory accesses go through the host page tables"), as on the GB10 +of [issue #54](https://github.com/hasso5703/dgx-spark-qwen38/issues/54), whose +mode reads None. `nvidia-smi --query-gpu=addressing_mode --format=csv,noheader` +names the mode: ATS, HMM or None. The reference box runs in ATS. The box of +issue #54 boots with the same `iommu.passthrough=0` and the same `nvidia_uvm` +settings, so those alone do not decide it. + +Since v1.36.4 the lane asks before it starts (`flash-ats-check.sh`), and a box +in another mode fetches nothing for it: + +- A new flash install stops before its first download, with the reason. An + update gives the flash lane its units only, beside the 27B lane or as the + box's own text lane, starts nothing for it, updates the rest of the box, and + says the lane cannot start here. +- Its first Load, a Load of another flash checkpoint and the Library's Download + (`prepare-lane.sh`, `switch-model.sh`) refuse it before the first byte, and + before the serving lane is stopped. +- The launcher stops its start with the reason, which the cockpit shows as + **cannot start on this GPU**, instead of a new start every 15 s. + +A mode nvidia-smi does not name (an older driver, `[N/A]`), or a check that +cannot run, leaves the engine to decide, as before. Serving the table on a GPU without ATS would take a +host-staging path in SGLang, which +[sglang#40235](https://github.com/sgl-project/sglang/pull/40235) proposes. + Until v1.7 that was a patch this repo vendored and built into a local image. Since v1.8 it is upstream and the image is official: diff --git a/flash-ats-check.sh b/flash-ats-check.sh new file mode 100755 index 00000000..d9f5e439 --- /dev/null +++ b/flash-ats-check.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Can this GPU serve the flash lane's N-gram table from a file on NVMe? (issue #54) +# +# The flash lane serves its 47.7 GiB FP8 N-gram (PLE) table from a sparse file on NVMe +# (--ple-offload-backend file, sglang#37068), and the GPU reads its rows through the host page +# tables. A GB10 does that in its ATS addressing mode. Outside it SGLang refuses the file backend +# when it loads the weights ("needs a device whose pageable host memory accesses go through the +# host page tables"): on the box of issue #54, whose mode reads None, that came after the image and +# the checkpoint had been fetched, and systemd started the lane again every 15 s. nvidia-smi names +# the mode: ATS, HMM or None. The reference box runs in ATS; the box of issue #54 boots with the +# same iommu.passthrough=0 and the same nvidia_uvm settings, so those alone do not decide it. +# +# Prints one line. Exits 1 when nvidia-smi names HMM or None (the line says why), 0 otherwise: ATS, +# and anything else (no nvidia-smi, a driver without the field, [N/A], no answer in time), where +# the engine decides as it did before. QWEN38_PREFLIGHT_SMI and QWEN38_PREFLIGHT_SMI_TIMEOUT_S are +# engine-preflight.sh's (the tests name another nvidia-smi). +# +# usage: flash-ats-check.sh +set -u +SMI="${QWEN38_PREFLIGHT_SMI:-nvidia-smi}" +SMI_TIMEOUT_S="${QWEN38_PREFLIGHT_SMI_TIMEOUT_S:-10}" +mode="" +if out="$(timeout -k 2 "$SMI_TIMEOUT_S" "$SMI" --query-gpu=addressing_mode --format=csv,noheader 2>/dev/null)"; then + mode="$(printf '%s\n' "$out" | head -1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" +fi +case "$mode" in + ATS) echo "addressing mode ATS" ;; + HMM|None) + echo "the GPU's addressing mode is $mode (nvidia-smi --query-gpu=addressing_mode) and the flash lane needs ATS: it reads its 47.7 GiB N-gram table from a file on NVMe through the host page tables (docs/flash-lane.md)" + exit 1 ;; + *) echo "addressing mode not reported by nvidia-smi${mode:+ ($mode)}, the engine decides" ;; +esac diff --git a/install.sh b/install.sh index 6539ca84..e490b816 100755 --- a/install.sh +++ b/install.sh @@ -1448,6 +1448,25 @@ docker info >/dev/null 2>&1 || die "Cannot talk to the docker daemon. Fix: sudo # /proc/meminfo, not `free`: free(1) localizes its row labels (issue #3) TOTAL_GB=$(awk '/^MemTotal/{print int($2/1048576)}' /proc/meminfo) [ "$TOTAL_GB" -ge 110 ] || die "This config needs a ~121 GB unified-memory machine; found ${TOTAL_GB} GB." +# A GPU outside its ATS addressing mode cannot start the flash lane (issue #54), and a flash install +# fetches its image and its checkpoint (223 GB in all). A new flash install stops here, before the +# first byte. A run for a box whose flash lane is installed gives it its units only, which say why at +# every start, starts nothing, and goes on with the rest of the box: stopped here, it kept the +# launcher that started again every 15 s, and a box booting a side lane was never updated again +# (found in review, 2026-10-19). Beside the 27B lane it gets its units only too (step 6). +ATS_CANNOT="" +if [ "$LANE" = "flash" ] && ATS_CANNOT="$(flash_cannot_start)"; then + if [ "$UNITS_ONLY" -eq 0 ] && [ "$INSTALLED_CHOICE" != flash ]; then + # a box serving the 27B keeps its target with a plain run: MODEL_CHOICE=stock moved one serving + # fp8 or an abliterated target to stock, 22 GB to fetch (found in review, 2026-10-19) + if [ "$INSTALLED_CHOICE" = 27b ]; then + die "The flash lane cannot start on this box: $ATS_CANNOT. Its 27B lane can: ./install.sh updates it and keeps its target" + fi + die "The flash lane cannot start on this box: $ATS_CANNOT. The 27B lane can: MODEL_CHOICE=stock ./install.sh" + fi + [ -n "$SECONDARY" ] || echo "NOTE: the flash lane cannot start on this box: $ATS_CANNOT. Its units only, none of its downloads, and this run starts nothing." + UNITS_ONLY=1 +fi # Measured where the weights actually land: HF_CACHE may live on another disk, # and then free space under $HOME says nothing (the error message used to send # people there while measuring here). @@ -1578,7 +1597,8 @@ fi echo "OK (aarch64, ${TOTAL_GB} GB RAM, ${FREE_DISK_GB} GB free)" if [ "$UNITS_ONLY" -eq 1 ]; then - if [ "$LANE" = "flash" ]; then step "2/10 The Flash-Next image: pulled at the lane's first Load (~16 GB to download, 35 GB on disk)" + if [ -n "$ATS_CANNOT" ]; then step "2/10 The Flash-Next image: not pulled, as this GPU cannot start the flash lane" + elif [ "$LANE" = "flash" ]; then step "2/10 The Flash-Next image: pulled at the lane's first Load (~16 GB to download, 35 GB on disk)" else step "2/10 The SGLang image: pulled at the lane's first Load (~15 GB to download)"; fi PULLED_IMAGE="$PULL_TARGET" elif [ "$LANE" = "flash" ]; then @@ -1615,7 +1635,9 @@ if [ "$LANE" = "flash" ]; then pin_tag 27b "$IMAGE"; else pin_tag flash "$FLASH_ unpin_stale "$LANE" "$PULLED_IMAGE" || true if [ "$LANE" = "flash" ]; then unpin_stale 27b "$IMAGE" || true; else unpin_stale flash "$FLASH_IMAGE" || true; fi -if [ "$UNITS_ONLY" -eq 1 ]; then +if [ -n "$ATS_CANNOT" ]; then + step "3/10 The GPU from a container: not asked, as this GPU cannot start the flash lane" +elif [ "$UNITS_ONLY" -eq 1 ]; then step "3/10 The GPU from a container: seen by the run that serves (this lane's image comes later)" else step "3/10 Verifying the container can see the GPU" @@ -1629,7 +1651,8 @@ else fi if [ "$UNITS_ONLY" -eq 1 ]; then - if [ "$LANE" = "flash" ]; then step "4/10 The Flash-Next checkpoint: fetched at the lane's first Load (~136 GB)" + if [ -n "$ATS_CANNOT" ]; then step "4/10 The Flash-Next checkpoint: not fetched, as this GPU cannot start the flash lane" + elif [ "$LANE" = "flash" ]; then step "4/10 The Flash-Next checkpoint: fetched at the lane's first Load (~136 GB)" else step "4/10 The checkpoints (the target and its DFlash2 draft): fetched at the lane's first Load (~24 GB, ~33 for an FP8 target)"; fi elif [ "$LANE" = "flash" ]; then step "4/10 Downloading the Flash-Next checkpoint (~136 GB, one-time, reuses/resumes any local copy)" @@ -1680,7 +1703,7 @@ dl_fetch(){ # $1 repo, $2 revision; an empty repo is a kept custom model (alrea || die "Checkpoint download failed. Causes: no internet, HuggingFace throttling of unauthenticated downloads (set HF_TOKEN=, or re-run: downloads resume), a pinned revision removed (try MODEL_REV=main DRAFT2_REV=main ./install.sh), or a permission error: if your $HF_CACHE contains root-owned files from other tools, fix with: sudo chown -R \$(id -u):\$(id -g) $HF_CACHE" } if [ "$UNITS_ONLY" -eq 1 ]; then - echo "no checkpoint now: the lane's first Load fetches it" + [ -n "$ATS_CANNOT" ] || echo "no checkpoint now: the lane's first Load fetches it" else dl_fetch "$DL_MODEL_REPO" "$MODEL_REV" dl_fetch "$DL_DRAFT2_REPO" "$DRAFT2_REV" @@ -1749,6 +1772,11 @@ bash "$CONFIG_DIR/engine-secrets.sh" || die "could not write the engine's key fi # see engine-preflight.sh), so it is in place before any unit that names it can start. cmp -s "$REPO_DIR/engine-preflight.sh" "$CONFIG_DIR/engine-preflight.sh" \ || install -m 755 "$REPO_DIR/engine-preflight.sh" "$CONFIG_DIR/engine-preflight.sh" +# The flash launcher asks it before every start (a GB10 outside its ATS addressing mode cannot +# serve the lane's N-gram table from a file, issue #54); every box gets it, as a flash lane +# installed on demand starts from its first Load. +cmp -s "$REPO_DIR/flash-ats-check.sh" "$CONFIG_DIR/flash-ats-check.sh" \ + || install -m 755 "$REPO_DIR/flash-ats-check.sh" "$CONFIG_DIR/flash-ats-check.sh" # One patched template per engine file name: the served template always follows # the served model (both fixes: reasoning_effort normalization + mid-conversation # system messages as blocks; see patch-template.py). @@ -1759,7 +1787,7 @@ if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then || die "custom model kept, but no patched template at $TEMPLATE_OUT. Pass MODEL_CHOICE=stock, uncensored, fp8 or uncensored-fp8 to regenerate it." echo "custom target model kept: existing patched template left untouched" elif [ "$UNITS_ONLY" -eq 1 ]; then - echo "the chat template comes from the checkpoint: the lane's first Load writes it (its switch)" + [ -n "$ATS_CANNOT" ] || echo "the chat template comes from the checkpoint: the lane's first Load writes it (its switch)" else python3 "$REPO_DIR/patch-template.py" "$HF_CACHE" "$TEMPLATE_OUT" "$MODEL_REV" "$MODEL_REPO" \ || die "Template patch failed (see message above). If the upstream template changed, please open an issue on this repo." @@ -1834,7 +1862,7 @@ apply_context_configs(){ # cache, the binds) goes over explicitly; what belongs to one lane (its target, revision # and context mode) does not: a MODEL_CHOICE given for this lane must not pick the other # one's. A lane not installed yet gets its default target; one installed keeps its own. -SECOND_LANE=""; SECOND_UNIT=""; SECOND_FRESH=0; SECOND_NEW=0; SECOND_STATE=""; SECOND_UNITS=0 +SECOND_LANE=""; SECOND_UNIT=""; SECOND_FRESH=0; SECOND_NEW=0; SECOND_STATE=""; SECOND_UNITS=0; SECOND_CANNOT="" if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ]; then if [ "$LANE" = "27b" ]; then SECOND_LANE=flash; SECOND_UNIT=qwen38-flash.service; SECOND_WANT="$WANT_FLASH"; SECOND_TARGET=flash @@ -1847,7 +1875,18 @@ if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ]; then # which a run that builds it whole proves (--all-weights proved none of them, 2026-10-15) SECOND_PREPARED=0; text_lane_prepared "$SECOND_LANE" && SECOND_PREPARED=1 SECOND_NEW="$SECOND_FRESH"; [ "$SECOND_PREPARED" -eq 1 ] || SECOND_NEW=1 - step "The ${SECOND_LANE/27b/27B} lane, installed beside the ${LANE/27b/27B} lane (it serves when it is loaded)" + # A GPU outside its ATS addressing mode cannot start the flash lane (issue #54): its units only, + # whose launcher says why at every start, and none of its downloads, prepared or named alike. + # Installed whole, its run stopped before it wrote them, and kept the launcher before (found in + # review, 2026-10-19). + SECOND_CANNOT="" + if [ "$SECOND_LANE" = flash ] && why="$(flash_cannot_start)"; then SECOND_CANNOT="$why"; fi + if [ -n "$SECOND_CANNOT" ]; then + step "The flash lane, installed beside the 27B lane: its units only, as this GPU cannot start it" + echo "why: $SECOND_CANNOT" + else + step "The ${SECOND_LANE/27b/27B} lane, installed beside the ${LANE/27b/27B} lane (it serves when it is loaded)" + fi SECOND_ENV=() [ "$SECOND_FRESH" -eq 1 ] && SECOND_ENV=(MODEL_CHOICE="$SECOND_TARGET") # The other text lane on demand: its units only, unless it is prepared, asked for by name @@ -1857,11 +1896,15 @@ if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ]; then if [ "$ALL_WEIGHTS" -eq 0 ] && [ "$SECOND_NAMED" -eq 0 ] && [ "$SECOND_PREPARED" -eq 0 ]; then SECOND_UNITS=1; SECOND_ENV+=(QWEN38_UNITS_ONLY=1) fi + if [ -n "$SECOND_CANNOT" ] && [ "$SECOND_UNITS" -eq 0 ]; then + SECOND_UNITS=1; SECOND_ENV+=(QWEN38_UNITS_ONLY=1) + fi if env -u MODEL_CHOICE -u MODEL_REV -u CONTEXT_MODE -u RESTART_ENGINE \ QWEN38_SECONDARY="$SECOND_LANE" QWEN38_RECOMMENDED="$RECOMMENDED" PORT="$PORT" HF_CACHE="$HF_CACHE" \ ENGINE_BIND="$ENGINE_BIND" PROXY_BIND="$PROXY_BIND" PROXY_PORT="$PROXY_PORT" \ ${SECOND_ENV[@]+"${SECOND_ENV[@]}"} bash "$REPO_DIR/install.sh"; then SECOND_STATE=installed; [ "$SECOND_UNITS" -eq 1 ] && SECOND_STATE=units + [ -z "$SECOND_CANNOT" ] || SECOND_STATE=cannot else SECOND_STATE=failed echo "NOTE: the ${SECOND_LANE/27b/27B} lane did not install (the lines above say why); the ${LANE/27b/27B} lane goes on." @@ -2772,21 +2815,24 @@ rm -f "$CONFIG_DIR/warmup-claude-code.sh" sudo systemctl daemon-reload if [ -n "$SECONDARY" ]; then # Installed, not enabled and not started: the serving run proves it once it is new. - if [ "$UNITS_ONLY" -eq 1 ]; then + if [ -n "$ATS_CANNOT" ]; then + step "Done: installed as $UNIT_NAME ($MODEL_CHOICE), not enabled at boot: this GPU cannot start it" + elif [ "$UNITS_ONLY" -eq 1 ]; then step "Done: installed as $UNIT_NAME ($MODEL_CHOICE), not enabled at boot, not prepared yet" else step "Done: installed as $UNIT_NAME ($MODEL_CHOICE), not enabled at boot" fi exit 0 fi -if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then +if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then sudo systemctl enable "$UNIT_NAME" text_lane_note "$UNIT_NAME" else # Updated, not switched to. Starting it would stop the lane that is serving, and # the cockpit and the side-lane steps below only run once a text engine has proved # itself, so this path finishes here, on its own, instead of waiting for a boot it - # must not do. + # must not do. A flash lane on a GPU outside its ATS mode takes it too: its start would + # end at once (issue #54), and its boot stays as it was. # The proxy's code and unit were just rewritten above; on the text path it is restarted # once the engine behind it answers, which this path never waits for. Without this it # kept the old keepalive-proxy.py in memory until someone restarted it by hand. @@ -2821,26 +2867,45 @@ else "$REPO_DIR/install-nemotron-super.sh" "$(side_mode nemotron-super "$WITH_NEMOTRON_SUPER")" \ || echo "NOTE: the Nemotron Super lane did not install or update; retry with ./install-nemotron-super.sh --no-smoke" fi - SERVING_LANE="image" + SERVING_LANE="" + [ "$IMAGE_BOOT" -eq 1 ] && SERVING_LANE="image" [ "$VIDEO_BOOT" -eq 1 ] && SERVING_LANE="video" [ "$KOLIBRI_BOOT" -eq 1 ] && SERVING_LANE="Kolibri" [ "$NEMOTRON_BOOT" -eq 1 ] && SERVING_LANE="Nemotron" [ "$NEMOTRON_SUPER_BOOT" -eq 1 ] && SERVING_LANE="Nemotron Super" - step "Done: the text lane is up to date; the $SERVING_LANE lane stays this box's serving lane" - echo " text lane : installed as $UNIT_NAME, not enabled at boot" - # The first target the hint names is the standard one: the project advises the standard - # checkpoints. The abliterated one a lane was installed with comes after it; this line - # named only that one. - case "$MODEL_CHOICE" in - custom) - # a kept custom model has no switch target of its own; the installer is the way back - echo " back to it: MODEL_CHOICE= ./install.sh (this box serves a custom model)" ;; - uncensored) echo " back to it: ./switch-model.sh stock, the standard checkpoint of that lane (a first switch downloads about 22 GB), or ./switch-model.sh uncensored, the abliterated one it was installed with" ;; - uncensored-fp8) echo " back to it: ./switch-model.sh fp8, the standard checkpoint of that lane (a first switch downloads about 31 GB), or ./switch-model.sh uncensored-fp8, the abliterated one it was installed with" ;; - flash-uncensored) echo " back to it: ./switch-model.sh flash, the standard checkpoint of that lane (a first switch downloads about 136 GB), or ./switch-model.sh flash-uncensored, the abliterated one it was installed with" ;; - *) - echo " back to it: Load on that lane in the cockpit's Lanes view, or ./switch-model.sh $MODEL_CHOICE" ;; - esac + if [ -n "$ATS_CANNOT" ]; then + step "Done: this box is up to date, and its flash lane, which this GPU cannot start, was not started" + echo " why : $ATS_CANNOT" + [ -z "$SERVING_LANE" ] || echo " the $SERVING_LANE lane stays this box's serving lane" + # The 27B lane beside it, in the summary's words (lane_line, which this path never reaches): + # one with its units only, whose switch refuses, one that did not install, and a box without + # it or without a cockpit were all told to Load it or to switch to it (found in review, 2026-10-19). + case "$SECOND_STATE" in + installed) if [ "$COCKPIT" -eq 1 ]; then echo " the 27B lane can serve on this GPU: Load it from the cockpit's Lanes view (or ./switch-model.sh stock)" + else echo " the 27B lane can serve on this GPU: ./switch-model.sh stock switches to it"; fi ;; + units) if [ "$COCKPIT" -eq 1 ]; then echo " the 27B lane can serve on this GPU: its first Load from the cockpit's Lanes view builds it and fetches its weights (58 GB)" + else echo " the 27B lane can serve on this GPU: ./prepare-lane.sh 27b builds it (58 GB in all), then ./switch-model.sh stock switches to it"; fi ;; + failed) echo " the 27B lane can serve on this GPU, but it did not install (see its NOTE above): ./install.sh --with-27b installs it whole" ;; + off) if [ -f "$SGL_UNIT_PATH" ]; then echo " the 27B lane can serve on this GPU: left out by --no-27b, so not updated; ./install.sh --with-27b brings it back" + else echo " the 27B lane can serve on this GPU: ./install.sh --with-27b adds it (58 GB)"; fi ;; + esac + else + step "Done: the text lane is up to date; the $SERVING_LANE lane stays this box's serving lane" + echo " text lane : installed as $UNIT_NAME, not enabled at boot" + # The first target the hint names is the standard one: the project advises the standard + # checkpoints. The abliterated one a lane was installed with comes after it; this line + # named only that one. + case "$MODEL_CHOICE" in + custom) + # a kept custom model has no switch target of its own; the installer is the way back + echo " back to it: MODEL_CHOICE= ./install.sh (this box serves a custom model)" ;; + uncensored) echo " back to it: ./switch-model.sh stock, the standard checkpoint of that lane (a first switch downloads about 22 GB), or ./switch-model.sh uncensored, the abliterated one it was installed with" ;; + uncensored-fp8) echo " back to it: ./switch-model.sh fp8, the standard checkpoint of that lane (a first switch downloads about 31 GB), or ./switch-model.sh uncensored-fp8, the abliterated one it was installed with" ;; + flash-uncensored) echo " back to it: ./switch-model.sh flash, the standard checkpoint of that lane (a first switch downloads about 136 GB), or ./switch-model.sh flash-uncensored, the abliterated one it was installed with" ;; + *) + echo " back to it: Load on that lane in the cockpit's Lanes view, or ./switch-model.sh $MODEL_CHOICE" ;; + esac + fi record_install side-boot exit 0 fi @@ -3256,6 +3321,8 @@ except Exception as e: case "$2" in proved) echo " $1: installed and proved it serves; Load it from the cockpit's Lanes view (or ./switch-model.sh $4)" ;; installed) echo " $1: installed and up to date; Load it from the cockpit's Lanes view (or ./switch-model.sh $4)" ;; + # a GPU outside its ATS mode (issue #54): its units only, whose launcher says why at a start + cannot) echo " $1: installed, and it cannot start on this box: $SECOND_CANNOT" ;; units) if [ "$COCKPIT" -eq 1 ]; then echo " $1: installed, ready to load: its first Load from the cockpit's Lanes view builds it and fetches its weights ($5)" else @@ -3267,7 +3334,12 @@ except Exception as e: # it did not install (its room, a download): a lane installed on demand is given its # units only by a plain run, which tried nothing again, and one already there read as # unproved (found in review, 2026-10-15); a run that names it installs it whole - failed) echo " $1: NOT ready, see its NOTE above (it did not install): ./install.sh --with-$3 installs it whole" ;; + # on a GPU outside its ATS mode a run that names it gives it its units only (issue #54) + failed) if [ "$3" = flash ] && [ -n "$SECOND_CANNOT" ]; then + echo " $1: NOT ready, see its NOTE above (it did not install), and this GPU cannot start it: $SECOND_CANNOT" + else + echo " $1: NOT ready, see its NOTE above (it did not install): ./install.sh --with-$3 installs it whole" + fi ;; off) if [ -f "$6" ]; then echo " $1: left out by --no-$3, so not updated; ./install.sh --with-$3 brings it back" else diff --git a/lanes.sh b/lanes.sh index 99406453..e498127d 100644 --- a/lanes.sh +++ b/lanes.sh @@ -202,6 +202,17 @@ pin_tag() { # $1 lane, $2 image: a digest reference present on this box gets i fi } +flash_cannot_start(){ + # Prints why this GPU cannot start the flash lane and returns 0, or returns 1. Only the check's + # status 1 says so (HMM or None, issue #54): any other, a check that is not there or cannot + # run included, is no answer, and the engine decides as before. Read as "cannot", a missing + # check stopped the lane for good, with no reason given (found in review, 2026-10-19). + local why rc=0 + why="$(bash "$REPO_DIR/flash-ats-check.sh" 2>/dev/null)" || rc=$? + [ "$rc" -eq 1 ] && [ -n "$why" ] || return 1 + printf '%s\n' "$why" +} + # The image a text lane's launcher (flash) or unit (27B) runs: the word on the line before its # server command, whatever its form (a digest pin, a tag an operator passed, a local build). engine_image(){ # $1 the launcher or the unit diff --git a/prepare-lane.sh b/prepare-lane.sh index 5bea1a13..c360a4a0 100755 --- a/prepare-lane.sh +++ b/prepare-lane.sh @@ -75,8 +75,11 @@ pins_or_die(){ # the pins install.sh declares, the one place they are, each che } prepare_flash(){ - local launch="$CONFIG_DIR/launch-flash.sh" img model hf ple map target rev + local launch="$CONFIG_DIR/launch-flash.sh" img model hf ple map target rev why [ -f "$launch" ] || die "the flash lane is not installed on this box (no $launch): ./install.sh installs it" + # its image and its checkpoint (223 GB in all) for a lane that cannot start on a GB10 outside + # its ATS addressing mode (issue #54): said before the first byte + if why="$(flash_cannot_start)"; then die "the flash lane cannot start on this box: $why"; fi img="$(engine_image "$launch")"; model="$(arg_of "$launch" --model-path)"; hf="$(mount_of "$launch" /root/.cache/huggingface)" ple="$(mount_of "$launch" /ple)" # a flag where the image should be: a launcher edited by hand left another word there, and its diff --git a/qwen38-flash-launch.sh.template b/qwen38-flash-launch.sh.template index 484a17bc..16c38a8e 100644 --- a/qwen38-flash-launch.sh.template +++ b/qwen38-flash-launch.sh.template @@ -12,6 +12,18 @@ # upstream PR replaced. set -euo pipefail +# The GPU reads that table through the host page tables, which a GB10 does in its ATS addressing +# mode only: outside it the engine refuses it when it loads the weights (issue #54). The start +# stops here instead, before the table is written or the image runs, and says why in the line +# the cockpit reads (dashboard/lifecycle.py). 78 is the unit's RestartPreventExitStatus: no new +# start every 15 s. Only the check's status 1 says so: any other (the check not there, say) +# leaves the engine to decide, as before. +ats_rc=0; why="$(bash __HOME__/.config/qwen38/flash-ats-check.sh)" || ats_rc=$? +if [ "$ats_rc" -eq 1 ] && [ -n "$why" ]; then + echo "preflight: qwen38-flash.service cannot start: $why" + exit 78 +fi + # The 47.7 GiB FP8 N-gram (PLE) table lives in a sparse file on the local NVMe # and the gather kernel reads its rows through the host page tables # (--ple-offload-backend file, sglang#37068). GB10 is the hardware that makes diff --git a/qwen38-flash.service.template b/qwen38-flash.service.template index 7b584d09..c43ef6b2 100644 --- a/qwen38-flash.service.template +++ b/qwen38-flash.service.template @@ -21,6 +21,9 @@ ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-preflight.sh qwen38-flash. ExecStart=/bin/bash __HOME__/.config/qwen38/launch-flash.sh ExecStop=-/usr/bin/docker stop -t 20 qwen38-flash Restart=always +# 78: the launcher found a GPU outside its ATS addressing mode, which no new start changes +# (flash-ats-check.sh, issue #54); the unit stays failed with the reason in its journal +RestartPreventExitStatus=78 # docker kills SGLang with SIGKILL (137) or SIGTERM (143) on a plain stop; that is # a clean stop, not a failure (v1.5.5: the cockpit showed 'failed' after every stop) SuccessExitStatus=137 143 diff --git a/switch-model.sh b/switch-model.sh index abab8d7c..7e8155a5 100755 --- a/switch-model.sh +++ b/switch-model.sh @@ -742,6 +742,14 @@ esac [ -n "${TARGET_REPO:-}" ] && [ -n "${TARGET_REV:-}" ] \ || die "target '$CHOICE' resolved to an empty checkpoint or revision; install.sh is missing its pin" +# A GPU outside its ATS addressing mode cannot start the flash lane (issue #54): no checkpoint is +# fetched for it and the boot is not pointed at it. A cockpit Load that points the boot at it runs +# this before it stops the serving lane (a failed step ends the journey), and so does the Library's +# Download (--fetch). +if [ "$TARGET_LANE" = flash ] && ATS_WHY="$(flash_cannot_start)"; then + die "the flash lane cannot start on this box: $ATS_WHY" +fi + if [ "$TARGET_LANE" = "27b" ]; then [ -f "$SGL_UNIT" ] || die "the 27B stack is not installed on this box (no $SGL_UNIT). Install it once first: MODEL_CHOICE=$CHOICE ./install.sh" TARGET_UNIT="$SGL_UNIT"; TARGET_UNIT_NAME="qwen38-sglang.service" diff --git a/tests/test_flash_ats_check.py b/tests/test_flash_ats_check.py new file mode 100644 index 00000000..bef4b839 --- /dev/null +++ b/tests/test_flash_ats_check.py @@ -0,0 +1,353 @@ +#!/usr/bin/env python3 +"""The flash lane starts only on a GPU in its ATS addressing mode (issue #54, 2026-10-19). + +The flash lane serves its 47.7 GiB N-gram table from a file on NVMe, which the GPU reads through +the host page tables: a GB10 in its ATS addressing mode. On the box of issue #54, whose mode reads +None, SGLang refused the file backend when it loaded the weights, after the image and the +checkpoint had been fetched, and systemd started the lane again every 15 s. flash-ats-check.sh +asks nvidia-smi for the mode and says whether the lane can start. The launcher asks it before the +table is written or the image runs, says why in the line the cockpit reads, and exits with the code +its unit does not restart on. install.sh, the first Load (tests/test_lane_on_demand.py) and +switch-model.sh ask it before the first byte, and an update gives the flash lane its units only, +beside the 27B lane or as the box's own text lane, so the new launcher reaches a box where it was +prepared (tests/test_install_units_only_run.py runs both to their end). Only the check's status 1 +says "cannot": anything else, a mode nvidia-smi does not name or a check that cannot run, leaves +the engine to decide, as before. +""" +import importlib.util +import pathlib +import re +import shutil +import subprocess +import sys +import tempfile +import time +import unittest + +REPO = pathlib.Path(__file__).resolve().parents[1] +CHECK = REPO / "flash-ats-check.sh" +QUERY = "--query-gpu=addressing_mode --format=csv,noheader" +# what nvidia-smi 580.178.04 answered on the reference box (2026-10-19): the mode, and for a field +# it does not know (an older driver) this line and an empty one, with exit code 2 +NO_FIELD = 'Field "addressing_mode" is not a valid field to query.\n\n' + + +def load_lifecycle(): + spec = importlib.util.spec_from_file_location("lifecycle_ats", REPO / "dashboard" / "lifecycle.py") + mod = importlib.util.module_from_spec(spec) + sys.modules["lifecycle_ats"] = mod + spec.loader.exec_module(mod) + return mod + + +class Box(unittest.TestCase): + def setUp(self): + self.t = pathlib.Path(tempfile.mkdtemp(prefix="flash-ats-")) + self.addCleanup(shutil.rmtree, self.t, True) + + def smi(self, out, rc=0, sleep=0): + """An nvidia-smi that answers the one query the check asks, and nothing else.""" + p = self.t / "nvidia-smi" + (self.t / "smi-out").write_text(out) + p.write_text(f'#!/bin/sh\n[ "$*" = "{QUERY}" ] || exit 99\nsleep {sleep}\n' + f'cat "{self.t}/smi-out"\nexit {rc}\n') + p.chmod(0o755) + return str(p) + + def check(self, smi, **env): + r = subprocess.run(["bash", str(CHECK)], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin", "QWEN38_PREFLIGHT_SMI": smi, **env}) + return r.returncode, r.stdout.strip() + + +class TheCheck(Box): + def test_ats_starts(self): + self.assertEqual(self.check(self.smi("ATS\n")), (0, "addressing mode ATS")) + + def test_hmm_and_none_are_refused_with_the_reason(self): + for mode in ("HMM", "None", " None "): + rc, out = self.check(self.smi(mode + "\n")) + self.assertEqual(rc, 1, mode) + self.assertIn(f"addressing mode is {mode.strip()} (nvidia-smi {QUERY.split()[0]}) and the flash lane needs ATS", out) + self.assertIn("docs/flash-lane.md", out) + + def test_what_nvidia_smi_does_not_name_leaves_the_engine_to_decide(self): + """An older driver, a field it cannot read, an empty answer, no nvidia-smi at all: as + before, the engine decides. Refused, a lane would stay down for good on a misreading.""" + for out, rc in (("[N/A]\n", 0), ("[Not Supported]\n", 0), ("\n", 0), (NO_FIELD, 2), ("ATS\n", 2)): + got = self.check(self.smi(out, rc)) + self.assertEqual(got[0], 0, (out, rc)) + self.assertTrue(got[1].startswith("addressing mode not reported by nvidia-smi"), got) + self.assertEqual(self.check(str(self.t / "no-such-smi"))[0], 0) + + def test_an_nvidia_smi_that_does_not_answer_leaves_the_engine_to_decide_in_time(self): + t0 = time.monotonic() + rc, out = self.check(self.smi("None\n", sleep=30), QWEN38_PREFLIGHT_SMI_TIMEOUT_S="1") + self.assertEqual(rc, 0, out) + self.assertLess(time.monotonic() - t0, 10) + + def test_no_variable_skips_it(self): + """QWEN38_FLASH_SKIP_ATS_CHECK was documented and never reached the launcher (review, + 2026-10-19): there is no way around the question, and nothing says there is.""" + rc, _ = self.check(self.smi("None\n"), QWEN38_FLASH_SKIP_ATS_CHECK="1") + self.assertEqual(rc, 1) + for f in ("flash-ats-check.sh", "qwen38-flash-launch.sh.template", "docs/flash-lane.md", "CHANGELOG.md"): + self.assertFalse("SKIP_ATS" in (REPO / f).read_text(), f) + + +class TheSharedQuestion(Box): + """lanes.sh's flash_cannot_start, which install.sh, prepare-lane.sh and switch-model.sh ask: + each read any status but 0 as "cannot", and a check that was not there stopped the lane for + good with no reason (found in review, 2026-10-19).""" + + def ask(self, body): + repo = self.t / "repo" + repo.mkdir(exist_ok=True) + if body is not None: + (repo / "flash-ats-check.sh").write_text(body) + r = subprocess.run(["bash", "-c", f'CONFIG_DIR="{self.t}/cfg"; REPO_DIR="{repo}"; . "{REPO}/lanes.sh"\n' + 'if why="$(flash_cannot_start)"; then echo "CANNOT:$why"; else echo "CAN"; fi'], + capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin"}) + return r.stdout.strip() + + def test_only_status_1_with_a_reason_is_cannot(self): + self.assertEqual(self.ask('echo "the GPU\'s addressing mode is None"; exit 1\n'), + "CANNOT:the GPU's addressing mode is None") + for body in ('echo "addressing mode ATS"\n', 'echo oops; exit 2\n', "exit 1\n", "exit 127\n", None): + self.assertEqual(self.ask(body), "CAN", body) + + +class TheLauncher(Box): + TEMPLATE = (REPO / "qwen38-flash-launch.sh.template").read_text() + + def test_it_asks_before_the_table_is_written_or_the_image_runs(self): + t = self.TEMPLATE + ask = t.index("flash-ats-check.sh") + self.assertLess(ask, t.index("PLE_DIR=__PLE_DIR__")) + self.assertLess(ask, t.index("docker run")) + + def run_head(self, smi): + home = self.t / "home" + cfg = home / ".config" / "qwen38" + cfg.mkdir(parents=True, exist_ok=True) + shutil.copy(CHECK, cfg / "flash-ats-check.sh") + head = self.TEMPLATE[:self.TEMPLATE.index("PLE_DIR=__PLE_DIR__")].replace("__HOME__", str(home)) + (self.t / "launch.sh").write_text(head + "echo REACHED\n") + return subprocess.run(["bash", str(self.t / "launch.sh")], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin", "QWEN38_PREFLIGHT_SMI": smi}) + + def test_a_gpu_that_cannot_start_it_is_said_as_such_and_ends_without_a_restart(self): + """The launcher's head, run as rendered, on a GPU in None: one line the cockpit reads as + "cannot start" with the reason, never as GPU memory held, and the exit code the unit does + not start it again on.""" + r = self.run_head(self.smi("None\n")) + code = int(re.search(r"^RestartPreventExitStatus=(\d+)$", (REPO / "qwen38-flash.service.template").read_text(), re.M).group(1)) + self.assertEqual(r.returncode, code, r.stdout + r.stderr) + self.assertNotIn("REACHED", r.stdout) + lc = load_lifecycle() + said = lc.parse_preflight(r.stdout.splitlines()) + self.assertEqual(said["verdict"], "cannot start", r.stdout) + self.assertIn("addressing mode is None", said["reason"]) + flags = lc.preflight_flags({"state": "failed"}, unit_sub="failed", preflight=said) + self.assertEqual(flags.get("cannot"), said["reason"]) + self.assertNotIn("refused", flags) + + def test_ats_and_a_mode_not_named_go_on(self): + for out in ("ATS\n", "[N/A]\n"): + r = self.run_head(self.smi(out)) + self.assertEqual((r.returncode, r.stdout.strip().splitlines()[-1]), (0, "REACHED"), out) + + def test_a_check_that_cannot_answer_leaves_the_engine_to_decide(self): + """Not there, or ending on another status: a start as before, never exit 78 with an + empty reason the cockpit cannot read (found in review, 2026-10-19).""" + r = self.run_head(self.smi("None\n")) + cfg = self.t / "home" / ".config" / "qwen38" + (cfg / "flash-ats-check.sh").unlink() + r = subprocess.run(["bash", str(self.t / "launch.sh")], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin"}) + self.assertEqual((r.returncode, r.stdout.strip().splitlines()[-1]), (0, "REACHED"), r.stdout + r.stderr) + (cfg / "flash-ats-check.sh").write_text("echo half an answer; exit 2\n") + r = subprocess.run(["bash", str(self.t / "launch.sh")], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin"}) + self.assertEqual((r.returncode, r.stdout.strip().splitlines()[-1]), (0, "REACHED"), r.stdout + r.stderr) + + +class TheInstaller(Box): + TEXT = (REPO / "install.sh").read_text() + + def test_every_box_gets_the_check_as_it_gets_the_engine_preflight(self): + self.assertIn('cmp -s "$REPO_DIR/flash-ats-check.sh" "$CONFIG_DIR/flash-ats-check.sh"', self.TEXT) + self.assertIn('install -m 755 "$REPO_DIR/flash-ats-check.sh" "$CONFIG_DIR/flash-ats-check.sh"', self.TEXT) + + def test_a_flash_install_asks_before_its_first_download(self): + line = 'if [ "$LANE" = "flash" ] && ATS_CANNOT="$(flash_cannot_start)"; then' + self.assertEqual(self.TEXT.count(line), 1) + self.assertLess(self.TEXT.index(line), self.TEXT.index('docker pull "$PULL_TARGET"')) + self.assertLess(self.TEXT.index(line), self.TEXT.index("dl_fetch(){")) + + def step_one(self, mode, installed, secondary="", units_only=0): + """The block of step 1 that asks the GPU, run as written.""" + start = self.TEXT.index('ATS_CANNOT=""\nif [ "$LANE" = "flash" ] && ATS_CANNOT=') + end = self.TEXT.index("\nfi\n", start) + len("\nfi\n") + repo = self.t / "repo" + repo.mkdir(exist_ok=True) + shutil.copy(CHECK, repo / "flash-ats-check.sh") + script = ("set -euo pipefail\ndie(){ echo \"DIE $*\"; exit 1; }\n" + f'CONFIG_DIR="{self.t}/cfg"; REPO_DIR="{repo}"; . "{REPO}/lanes.sh"\n' + f'LANE=flash; INSTALLED_CHOICE="{installed}"; SECONDARY="{secondary}"; UNITS_ONLY={units_only}\n' + + self.TEXT[start:end] + 'echo "UNITS_ONLY=$UNITS_ONLY CANNOT=${ATS_CANNOT:0:30}"\n') + r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin", "QWEN38_PREFLIGHT_SMI": self.smi(mode + "\n")}) + return r.returncode, r.stdout + + def test_step_one_stops_a_new_flash_install_and_lets_an_update_go_on_with_units_only(self): + """A box whose text lane is the flash lane (at boot, or the one a side lane at boot came + from) was stopped here, kept the launcher that starts again every 15 s, and a box booting + a side lane was never updated again (found in review, 2026-10-19).""" + rc, out = self.step_one("None", "flash") + self.assertEqual(rc, 0, out) + self.assertIn("NOTE: the flash lane cannot start on this box: the GPU's addressing mode is None", out) + self.assertIn("this run starts nothing", out) + self.assertIn("UNITS_ONLY=1 CANNOT=the GPU's addressing mode is", out) + for installed in ("", "27b"): + rc, out = self.step_one("None", installed) + self.assertEqual(rc, 1, out) + self.assertIn("DIE The flash lane cannot start on this box: the GPU's addressing mode is None", out) + self.assertIn("The 27B lane can: MODEL_CHOICE=stock ./install.sh", self.step_one("None", "")[1]) + # a box serving the 27B keeps its target with a plain run: MODEL_CHOICE=stock moved one + # serving fp8 or an abliterated target to stock, 22 GB to fetch (found in review, 2026-10-19) + out = self.step_one("None", "27b")[1] + self.assertIn("Its 27B lane can: ./install.sh updates it and keeps its target", out) + self.assertNotIn("MODEL_CHOICE=", out) + rc, out = self.step_one("None", "flash", secondary="flash", units_only=1) + self.assertEqual(rc, 0, out) + self.assertNotIn("NOTE", out) + self.assertIn("UNITS_ONLY=1 CANNOT=the GPU's", out) + for installed in ("flash", "", "27b"): + self.assertEqual(self.step_one("ATS", installed), (0, "UNITS_ONLY=0 CANNOT=\n"), installed) + + def ending(self, second_state, cockpit=1, unit=True): + """The end of the path that starts nothing, on a GPU outside ATS, run as written.""" + start = self.TEXT.index(' if [ -n "$ATS_CANNOT" ]; then\n step "Done: this box is up to date') + end = self.TEXT.index("\n else\n", start) + sgl = self.t / "qwen38-sglang.service" + if unit: + sgl.write_text("[Unit]\n") + elif sgl.exists(): + sgl.unlink() + script = ('step(){ echo "STEP $*"; }\n' + f'ATS_CANNOT="the GPU\'s addressing mode is None"; SERVING_LANE=""; SECOND_STATE="{second_state}"\n' + f'COCKPIT={cockpit}; SGL_UNIT_PATH="{sgl}"\n' + self.TEXT[start:end] + "\n fi\n") + r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30) + self.assertEqual(r.returncode, 0, r.stderr) + return r.stdout + + def test_its_end_says_what_the_27b_lane_beside_it_can_do(self): + """It told every box to Load the 27B lane or to switch to it: one with the 27B's units + only (whose switch refuses, the image is not there), one where it did not install, one + without it or without a cockpit (found in review, 2026-10-19).""" + self.assertIn("Load it from the cockpit's Lanes view (or ./switch-model.sh stock)", self.ending("installed")) + out = self.ending("installed", cockpit=0) + self.assertIn("./switch-model.sh stock switches to it", out) + self.assertNotIn("cockpit", out) + out = self.ending("units") + self.assertIn("its first Load from the cockpit's Lanes view builds it and fetches its weights", out) + self.assertNotIn("switch-model.sh", out) + self.assertIn("./prepare-lane.sh 27b builds it", self.ending("units", cockpit=0)) + out = self.ending("failed") + self.assertIn("it did not install", out) + self.assertIn("./install.sh --with-27b installs it whole", out) + self.assertIn("./install.sh --with-27b brings it back", self.ending("off")) + self.assertIn("./install.sh --with-27b adds it", self.ending("off", unit=False)) + for state in ("installed", "units", "failed", "off"): + out = self.ending(state) + self.assertIn("STEP Done: this box is up to date, and its flash lane, which this GPU cannot start", out) + self.assertNotIn("serves on this GPU", out, state) + + def test_the_box_s_own_flash_lane_is_neither_enabled_nor_started_by_the_run(self): + """Outside ATS the run takes the path that starts nothing (a side lane at boot takes it + too) and says why at its end.""" + t = self.TEXT + self.assertIn('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ]', t) + end = t.index(' if [ -n "$ATS_CANNOT" ]; then\n step "Done: this box is up to date, and its flash lane') + self.assertLess(t.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ]'), end) + self.assertLess(end, t.index('step "9/10')) + + def beside(self, mode, prepared, named=0): + """The block of install.sh that installs the flash lane beside the 27B lane, run as + written, with a nested install.sh that records what it was asked.""" + start = self.TEXT.index(' SECOND_CANNOT=""\n') + end = self.TEXT.index(" else\n SECOND_STATE=off", start) + repo = self.t / "repo" + repo.mkdir(exist_ok=True) + shutil.copy(CHECK, repo / "flash-ats-check.sh") + (repo / "install.sh").write_text(f'env | grep "^QWEN38_" | sort > "{self.t}/asked"\n') + script = ( + "set -euo pipefail\nstep(){ echo \"STEP $*\"; }\n" + f'CONFIG_DIR="{self.t}/cfg"; . "{REPO}/lanes.sh"; SECOND_FRESH=0; SECOND_TARGET=flash\n' + f'REPO_DIR="{repo}"; LANE=27b; SECOND_LANE=flash; SECOND_PREPARED={prepared}; ALL_WEIGHTS=0\n' + f'WITH_FLASH={named}; WITH_27B=0; RECOMMENDED=0; PORT=30000; HF_CACHE=/hf; ENGINE_BIND=127.0.0.1\n' + 'PROXY_BIND=0.0.0.0; PROXY_PORT=30001; SECOND_STATE=""; SECOND_CANNOT=""; SECOND_ENV=()\n' + "if true; then\n" + self.TEXT[start:end] + "fi\n" + 'echo "STATE=$SECOND_STATE"\n') + r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30, + env={"PATH": "/usr/bin:/bin", "QWEN38_PREFLIGHT_SMI": self.smi(mode + "\n")}) + self.assertEqual(r.returncode, 0, r.stdout + r.stderr) + return r.stdout, (self.t / "asked").read_text().split() + + def test_an_update_of_a_box_outside_ats_writes_the_flash_units_and_fetches_nothing(self): + """Issue #54's box: the 27B serves, the flash lane was prepared by its first Load. Run + whole, the flash lane's run stopped at the question before it wrote its new launcher, so + the box kept the one that starts every 15 s (review, 2026-10-19). Prepared, named or + neither, it now gets its units only.""" + for prepared, named in ((1, 0), (0, 1), (0, 0)): + out, asked = self.beside("None", prepared, named) + self.assertIn("QWEN38_UNITS_ONLY=1", asked, (prepared, named)) + self.assertIn("QWEN38_SECONDARY=flash", asked) + self.assertEqual(asked.count("QWEN38_UNITS_ONLY=1"), 1, asked) + self.assertIn("STEP The flash lane, installed beside the 27B lane: its units only, as this GPU cannot start it", out) + self.assertIn("why: the GPU's addressing mode is None", out) + self.assertNotIn("it serves when it is loaded", out) + self.assertIn("STATE=cannot", out) + + def test_a_box_in_ats_installs_a_prepared_flash_lane_whole_as_before(self): + out, asked = self.beside("ATS", 1) + self.assertNotIn("QWEN38_UNITS_ONLY=1", asked) + self.assertIn("STATE=installed", out) + out, asked = self.beside("ATS", 0) + self.assertEqual(asked.count("QWEN38_UNITS_ONLY=1"), 1) + self.assertIn("STATE=units", out) + self.assertIn("(it serves when it is loaded)", out) + self.assertNotIn("cannot start", out) + + def test_its_summary_says_it_cannot_start_here_not_ready_to_load(self): + start = self.TEXT.index(" lane_line(){") + end = self.TEXT.index("\n }\n", start) + len("\n }\n") + script = ("set -u\nCOCKPIT=1\n" + 'SECOND_CANNOT="the GPU\'s addressing mode is None (nvidia-smi) and the flash lane needs ATS"\n' + + self.TEXT[start:end] + 'lane_line "Flash 176B " cannot flash flash "223 GB" /nonexistent\n') + r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30) + self.assertEqual(r.stdout.strip(), "Flash 176B : installed, and it cannot start on this box: " + "the GPU's addressing mode is None (nvidia-smi) and the flash lane needs ATS") + # its units did not install either: --with-flash would only give it its units again + r = subprocess.run(["bash", "-c", script.replace(' cannot flash flash ', ' failed flash flash ')], + capture_output=True, text=True, timeout=30) + self.assertIn("NOT ready, see its NOTE above (it did not install), and this GPU cannot start it", r.stdout) + self.assertNotIn("--with-flash", r.stdout) + + +class TheSwitch(unittest.TestCase): + TEXT = (REPO / "switch-model.sh").read_text() + + def test_a_flash_checkpoint_is_neither_fetched_nor_booted_on_a_gpu_that_cannot_start_it(self): + """A Load of another flash checkpoint, or the Library's Download, fetched 124 to 136 GB + for a lane that cannot start (review, 2026-10-19): the switch asks first.""" + ask = self.TEXT.index('if [ "$TARGET_LANE" = flash ] && ATS_WHY="$(flash_cannot_start)"; then') + self.assertLess(self.TEXT.index('TARGET_LANE=flash ;;'), ask) + for later in ('docker image inspect "$DL_IMAGE"', 'fetching $TARGET_REPO @ $TARGET_REV', + 'sudo systemctl enable "$TARGET_UNIT_NAME"'): + self.assertLess(ask, self.TEXT.index(later), later) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_hints_name_standard_targets.py b/tests/test_hints_name_standard_targets.py index 1a5b3ae2..7bd58c70 100644 --- a/tests/test_hints_name_standard_targets.py +++ b/tests/test_hints_name_standard_targets.py @@ -66,7 +66,9 @@ class TheSwitchBackLine(unittest.TestCase): class TheInstallersLineOnABoxThatBootsImagesOrVideo(unittest.TestCase): - LINES = block(INSTALL, ' case "$MODEL_CHOICE" in\n custom)', " esac") + # the hint ends the run of a box booting a side lane, inside its "else" since a flash lane + # its GPU cannot start ends that run too (issue #54) + LINES = block(INSTALL, ' case "$MODEL_CHOICE" in\n custom)', " esac") def test_an_abliterated_lane_names_its_standard_target_first(self): for choice, standard in (("uncensored", "stock"), ("uncensored-fp8", "fp8"), diff --git a/tests/test_image_lane.py b/tests/test_image_lane.py index 4a42ecc7..46181ffd 100644 --- a/tests/test_image_lane.py +++ b/tests/test_image_lane.py @@ -589,13 +589,13 @@ class AnUpdateKeepsTheImageLaneAsTheBootLane(unittest.TestCase): self.assertIn('[ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]', self.text) def test_the_text_unit_is_not_enabled_on_that_path(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') self.assertIn('sudo systemctl enable "$UNIT_NAME"', self.text[i:i + 220]) # and that is the ONLY enable of the serving unit: an unguarded one would undo it self.assertEqual(self.text.count('sudo systemctl enable "$UNIT_NAME"'), 1) def test_that_path_ends_before_any_text_engine_is_started(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] self.assertNotIn("systemctl start", early) self.assertIn("--no-smoke", early, "the smoke test stops and starts the serving lane") @@ -623,12 +623,12 @@ class TheBootLaneConvergenceHoldsEveryWay(unittest.TestCase): self.assertIn("sudo systemctl disable qwen38-image.service", self.text) def test_the_image_boot_path_restarts_the_proxy_it_rewrote(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] self.assertIn('sudo systemctl restart "$KEEPALIVE_UNIT"', early) def test_the_image_boot_path_respects_a_left_out_image_lane(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] call = early.index('"$REPO_DIR/install-image.sh" "$(side_mode image') self.assertIn('if [ "$WANT_IMAGE" -eq 1 ]', early[:call]) @@ -645,7 +645,7 @@ class TheBootLaneConvergenceHoldsEveryWay(unittest.TestCase): def test_it_never_points_at_a_switch_target_that_does_not_exist(self): """A kept custom model is MODEL_CHOICE=custom, which switch-model.sh rejects.""" - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] # the case names custom before the line that names ./switch-model.sh $MODEL_CHOICE case = early.index('case "$MODEL_CHOICE" in') diff --git a/tests/test_install_every_lane.py b/tests/test_install_every_lane.py index 6dfab085..afcc09f3 100644 --- a/tests/test_install_every_lane.py +++ b/tests/test_install_every_lane.py @@ -521,13 +521,13 @@ class TheWholeBoxNeedsTheFullInstall(unittest.TestCase): class TheParentStartsIt(unittest.TestCase): """The block before step 7 that starts the run for the other lane, against a stub install.sh that prints what it was given.""" - BLOCK = between('SECOND_LANE=""; SECOND_UNIT=""; SECOND_FRESH=0; SECOND_NEW=0; SECOND_STATE=""; SECOND_UNITS=0\n', + BLOCK = between('SECOND_LANE=""; SECOND_UNIT=""; SECOND_FRESH=0; SECOND_NEW=0; SECOND_STATE=""; SECOND_UNITS=0; SECOND_CANNOT=""\n', '\nif [ -n "$SECONDARY" ]; then\n step "7/10') PREPARED = between("text_lane_prepared(){", "\n}\n") + "\n}\n" IMG_FLASH, IMG_27B = "lmsysorg/sglang@sha256:" + "a" * 64, "lmsysorg/sglang:v0.5.21" def parent(self, lane, want, unit_there, child_rc=0, no_service=0, flash_ready=False, all_weights=0, with_flash=0, - ready_27b=False, image_27b=False, with_27b=0, map_waits=False, map_built=False, served=None): + ready_27b=False, image_27b=False, with_27b=0, map_waits=False, map_built=False, served=None, gpu="ATS"): """flash_ready: the image the flash launcher runs is on the box. ready_27b: the image the 27B unit runs (a tag here, as an operator may pass) and its DFlash2 draft are; image_27b: the image alone. served: the checkpoint the launcher or the unit serves is whole in the @@ -575,6 +575,10 @@ class TheParentStartsIt(unittest.TestCase): (units / "qwen38-flash.service").write_text("[Unit]\n") repo = t / "repo" repo.mkdir() + # the question the flash lane asks its GPU (issue #54), on the reference box's GPU unless + # the test says otherwise: the copy's own check, never the host's GPU + (repo / "flash-ats-check.sh").write_text((REPO / "flash-ats-check.sh").read_text()) + stub(t / "bin" / "nvidia-smi", f'echo "{gpu}"') stub(repo / "install.sh", 'echo "CHILD SECONDARY=${QWEN38_SECONDARY:-} MODEL_CHOICE=${MODEL_CHOICE:-unset} ' 'MODEL_REV=${MODEL_REV:-unset} CONTEXT_MODE=${CONTEXT_MODE:-unset} PORT=${PORT:-} ' @@ -595,6 +599,18 @@ class TheParentStartsIt(unittest.TestCase): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) return r.stdout + def test_a_gpu_outside_ats_gives_the_flash_lane_its_units_only_however_it_was_asked_for(self): + # issue #54: prepared, named or with every weight, run whole it stopped at the question + # before it wrote its new launcher (found in review, 2026-10-19) + for kw in ({"flash_ready": True, "map_waits": True, "map_built": True}, {"with_flash": 1}, {"all_weights": 1}): + with self.subTest(**kw): + out = self.parent("27b", 1, unit_there=True, gpu="None", **kw) + self.assertIn("UNITS_ONLY=1", out) + self.assertIn("AFTER FRESH=0 STATE=cannot", out) + out = self.parent("27b", 1, unit_there=True, **kw) + self.assertIn("UNITS_ONLY=unset", out) + self.assertNotIn("STATE=cannot", out) + def test_a_new_flash_lane_gets_its_default_target_and_the_shared_settings_only(self): # on demand: its units only, its first Load from the cockpit prepares it (2026-10-15) out = self.parent("27b", 1, unit_there=False) diff --git a/tests/test_install_units_only_run.py b/tests/test_install_units_only_run.py index d4843bb5..13c4e676 100644 --- a/tests/test_install_units_only_run.py +++ b/tests/test_install_units_only_run.py @@ -21,11 +21,17 @@ import installer_wall as wall # noqa: E402 REPO = pathlib.Path(__file__).resolve().parents[1] DONE = ' step "Done: installed as $UNIT_NAME ($MODEL_CHOICE), not enabled at boot, not prepared yet"\n' +# where the run of a box that starts nothing begins: a side lane at boot, or a flash lane its GPU +# cannot start (issue #54) +NO_START = ' # Updated, not switched to. Starting it would stop the lane that is serving, and\n' -def run_units_only(lane): +def run_units_only(lane, gpu="ATS", main=False): + """The run for the other text lane, or with main=True the run of a box whose own text lane is + the flash lane, installed and enabled at boot, walled where that run takes the path that starts + nothing. gpu: the addressing mode nvidia-smi reports.""" units = wall.units_dir() - script = pathlib.Path(wall.walled(at=DONE, after=True, units=units)) + script = pathlib.Path(wall.walled(at=NO_START if main else DONE, after=not main, units=units)) meminfo = wall._tmp("meminfo-") / "meminfo" meminfo.write_text("MemTotal: 127535272 kB\n") # the reference box's text, read = script.read_text(), "awk '/^MemTotal/{print int($2/1048576)}' /proc/meminfo" @@ -38,26 +44,36 @@ def run_units_only(lane): home = wall._tmp("home-") (home / ".config/qwen38").mkdir(parents=True) (home / ".config/qwen38/api-key").write_text("k\n") + if main: # a flash lane this box already had: its unit and the launcher of v1.36.3 + (pathlib.Path(units) / "qwen38-flash.service").write_text( + f"[Service]\nExecStart=/bin/bash {home}/.config/qwen38/launch-flash.sh\n") + (home / ".config/qwen38/launch-flash.sh").write_text( + "exec /usr/bin/docker run --rm --name qwen38-flash lmsysorg/sglang@sha256:" + "a" * 64 + + " python3 -m sglang.launch_server --model-path RadixArk/Qwen3.8-Flash-Next-NVFP4 --tp-size 1\n") stubs, docker_root = wall._tmp("stubs-"), wall._tmp("docker-root-") calls = stubs / "calls" calls.touch() for name, body in ( - ("nvidia-smi", 'case "$*" in *driver_version*) echo 580.173.02 ;; *memory.total*) echo "[N/A]" ;; *) echo "NVIDIA GB10" ;; esac\n'), + ("nvidia-smi", 'case "$*" in *driver_version*) echo 580.173.02 ;; *memory.total*) echo "[N/A]" ;; ' + f'*addressing_mode*) echo {gpu} ;; *) echo "NVIDIA GB10" ;; esac\n'), ("uname", 'echo aarch64\n'), ("docker", f'case "$1 $2" in "info "*) echo "{docker_root}" ;; "image inspect") exit 1 ;; esac\nexit 0\n'), ("sudo", 'while [ -n "${1:-}" ] && [ "${1#-}" != "$1" ]; do shift; done\n' '[ "$#" -eq 0 ] || [ "$1" = true ] && exit 0\n"$@"\n'), - ("systemctl", 'case "$1" in is-enabled|is-active) exit 1 ;; esac\nexit 0\n'), + ("systemctl", ('[ "$1 $2" = "is-enabled qwen38-flash.service" ] && exit 0\n' if main else "") + + 'case "$1" in is-enabled|is-active) exit 1 ;; esac\nexit 0\n'), # the preflight has to find it, and a lane's run then asks it nothing (the parent # checked the ports): the host's was used, and a host without iproute2 died there, # "ss not found" (a cloud container, 2026-10-18) ("ss", 'exit 0\n')): (stubs / name).write_text(f'#!/bin/bash\necho "{name} $*" >> "{calls}"\n' + body) (stubs / name).chmod(0o755) - env, fenced = wall.fenced_env(home=home, first=str(stubs), QWEN38_SECONDARY=lane, QWEN38_UNITS_ONLY="1", - MODEL_CHOICE="flash" if lane == "flash" else "stock", - HF_CACHE=str(home / "hf"), PORT="30000", PROXY_PORT="30001") - r = subprocess.run([str(script)], capture_output=True, text=True, env=env, cwd=wall.cwd(), timeout=180) + run = {} if main else {"QWEN38_SECONDARY": lane, "QWEN38_UNITS_ONLY": "1", + "MODEL_CHOICE": "flash" if lane == "flash" else "stock"} + env, fenced = wall.fenced_env(home=home, first=str(stubs), HF_CACHE=str(home / "hf"), PORT="30000", + PROXY_PORT="30001", **run) + r = subprocess.run([str(script)] + (["--no-opencode"] if main else []), capture_output=True, text=True, + env=env, cwd=wall.cwd(), timeout=300) return (r.returncode, r.stdout + r.stderr, calls.read_text().splitlines(), wall.reached(fenced), pathlib.Path(units), home) @@ -85,6 +101,28 @@ class TheUnitsOnlyRunToItsEnd(unittest.TestCase): launcher = (home / ".config/qwen38/launch-flash.sh").read_text() self.assertIn('[ -s "', launcher) # the vocabulary waited for, not required self.assertIn("&& TIER+=(--speculative-token-map /out/token-map-", launcher) + # the run an update gives a box outside ATS (issue #54): the launcher asks the GPU's mode + # at every start, from the copy this run installed, and the unit does not start it again + # on the code it then ends with + self.assertIn(f'bash {home}/.config/qwen38/flash-ats-check.sh)"', launcher) + self.assertTrue((home / ".config/qwen38/flash-ats-check.sh").is_file()) + self.assertIn("RestartPreventExitStatus=78", (units / "qwen38-flash.service").read_text()) + + def test_the_flash_lane_on_a_gpu_outside_ats_promises_no_first_load(self): + """Given its units only because this GPU cannot start it (issue #54), the run said its + image and checkpoint came at its first Load, which is refused there (review, 2026-10-19).""" + rc, out, calls, fenced, units, home = run_units_only("flash", gpu="None") + # it ends on its own line, before the wall of a run that is not prepared yet + self.assertEqual(rc, 0, out[-1500:]) + self.assertEqual(fenced, []) + self.assertIn("2/10 The Flash-Next image: not pulled, as this GPU cannot start the flash lane", out) + self.assertIn("3/10 The GPU from a container: not asked, as this GPU cannot start the flash lane", out) + self.assertIn("4/10 The Flash-Next checkpoint: not fetched, as this GPU cannot start the flash lane", out) + self.assertIn("not enabled at boot: this GPU cannot start it", out) + for promise in ("first Load", "not prepared yet", "comes later"): + self.assertNotIn(promise, out) + launcher = (home / ".config/qwen38/launch-flash.sh").read_text() + self.assertIn(f'bash {home}/.config/qwen38/flash-ats-check.sh)"', launcher) def test_the_27b_lane(self): out, units, home = self.check("27b", "qwen38-sglang.service") @@ -93,5 +131,31 @@ class TheUnitsOnlyRunToItsEnd(unittest.TestCase): self.assertIn("checkpoints' configs for the 1m window: set at the lane's first Load", out) +class TheBoxsOwnFlashLaneOnAGpuOutsideAts(unittest.TestCase): + """A box whose text lane is the flash lane, at boot, on a GPU outside its ATS mode (issue #54). + Its update stopped at step 1 and kept the launcher that starts again every 15 s, and a box + booting a side lane with the flash lane as its text lane was never updated again (found in + review, 2026-10-19). Run whole up to the path that starts nothing: its new units are written, + nothing is fetched, enabled or started.""" + + def test_its_update_writes_its_units_and_starts_nothing(self): + rc, out, calls, fenced, units, home = run_units_only("flash", gpu="None", main=True) + self.assertIn(wall.WALL, out, out[-2500:]) + self.assertEqual(rc, 97, out[-2500:]) + self.assertEqual(fenced, []) + self.assertIn("NOTE: the flash lane cannot start on this box: the GPU's addressing mode is None", out) + self.assertIn("this run starts nothing", out) + self.assertIn("2/10 The Flash-Next image: not pulled, as this GPU cannot start the flash lane", out) + self.assertEqual(sorted({" ".join(c.split()[:3]) for c in calls if c.startswith("docker ")} + - {"docker image inspect", "docker info", "docker info --format"}), [], calls) + flash = [c for c in calls if c.startswith(("sudo systemctl", "systemctl")) and "qwen38-flash.service" in c + and any(v in c.split() for v in ("enable", "start", "restart"))] + self.assertEqual(flash, [], "the flash lane enabled or started") + launcher = (home / ".config/qwen38/launch-flash.sh").read_text() + self.assertIn(f'bash {home}/.config/qwen38/flash-ats-check.sh)"', launcher) + self.assertTrue((home / ".config/qwen38/flash-ats-check.sh").is_file()) + self.assertIn("RestartPreventExitStatus=78", (units / "qwen38-flash.service").read_text()) + + if __name__ == "__main__": unittest.main() diff --git a/tests/test_lane_on_demand.py b/tests/test_lane_on_demand.py index 8e19a6ef..33e8dc86 100644 --- a/tests/test_lane_on_demand.py +++ b/tests/test_lane_on_demand.py @@ -340,7 +340,7 @@ class TextBox: self.t = t = pathlib.Path(tempfile.mkdtemp(prefix="prepare-text-")) self.d = d = t / "repo" d.mkdir() - for f in ("lanes.sh", "install.sh"): + for f in ("lanes.sh", "install.sh", "flash-ats-check.sh"): (d / f).write_text((REPO / f).read_text()) self.units = t / "units" self.units.mkdir() @@ -366,6 +366,9 @@ class TextBox: f' "pull "*) touch "{t}/pulled" ;;\n' 'esac\nexit 0\n') self.stub("df", f'printf "Avail\\n{free_gb}G\\n"') + # the reference box's GPU: the flash lane's first Load asks its addressing mode + # (flash-ats-check.sh), and every case here asked the host's own GPU (review, 2026-10-19) + self.stub("nvidia-smi", 'echo ATS') if free_at: # df answers for the disk of the folder it is given, a link followed self.stub("df", 'p="$(readlink -f "${@: -1}")"\ncase "$p" in\n' @@ -460,6 +463,20 @@ class TheFlashPreparation(unittest.TestCase): self.assertEqual(rc, 0, out) self.assertTrue(calls[-1].startswith("docker run --rm --init "), calls[-1]) + def test_a_gpu_outside_its_ats_mode_is_refused_before_anything(self): + # issue #54: on a GB10 outside its ATS mode the engine refused the table at load, after the image + # and 126 GiB of checkpoint had come + b = self.box() + b.stub("nvidia-smi", 'echo None') + rc, out, calls = b.run("flash") + self.assertEqual(rc, 1, out) + self.assertIn("the flash lane cannot start on this box: the GPU's addressing mode is None", out) + self.assertEqual(calls, []) + b.stub("nvidia-smi", 'echo ATS') + rc, out, calls = b.run("flash") + self.assertEqual(rc, 0, out) + self.assertIn("docker pull", heads(calls)) + def test_a_target_of_another_lane_is_refused_before_anything(self): for target in ("stock", "image", "flash-turbo"): with self.subTest(target=target): diff --git a/tests/test_video_lane.py b/tests/test_video_lane.py index 93989714..ed05a9ca 100644 --- a/tests/test_video_lane.py +++ b/tests/test_video_lane.py @@ -578,18 +578,18 @@ class TheBootLaneConvergence(unittest.TestCase): self.assertIn("systemctl is-enabled --quiet qwen38-video.service", self.text) def test_the_text_unit_is_not_enabled_on_that_path(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') self.assertIn('sudo systemctl enable "$UNIT_NAME"', self.text[i:i + 220]) self.assertEqual(self.text.count('sudo systemctl enable "$UNIT_NAME"'), 1) def test_that_path_updates_without_starting_anything(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] self.assertNotIn("systemctl start", early) self.assertIn("--no-smoke", early) def test_that_path_respects_a_left_out_video_lane(self): - i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') + i = self.text.index('if [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ]; then') early = self.text[i:self.text.index("exit 0", i)] call = early.index('"$REPO_DIR/install-video.sh" "$(side_mode video') self.assertIn('if [ "$WANT_VIDEO" -eq 1 ]', early[:call])