mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
FLASH_UNSLOTH_DEFAULT="flash-unsloth-iq3" (decision 1376), its sizes and measures in the pages, the cockpit's base.js. conformity.py knows the lane's target (FLASH_UNSLOTH_TARGET, read from the folder of the unit's -m, its comments left out) and its old default UD-Q4_K_XL (v1.49.0). install.sh hands the lane's installer FLASH_UNSLOTH_TARGET when conformity.py classes the unit's UD-Q4_K_XL as an old default, names the handed target in the clients' entry, records a given one (--chose) and refuses an unknown one; switch-model.sh records the target as chosen, as Kolibri's; the cockpit names the setting. Tests: the move, what stays, the entry, the box rendered with the lane, the oc artifact's fake unit on a Q4 GGUF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4143 lines
277 KiB
Bash
Executable File
4143 lines
277 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Qwen3.8 serving stack on DGX Spark (GB10): 27B (SGLang+DFlash2) or Flash-Next
|
|
# 176B (SGLang+NEXTN, PLE table mmap-served from NVMe). Systemd, hardened.
|
|
# Idempotent: safe to re-run at any time (uses local caches when present).
|
|
# Everything is PINNED to versions validated on this hardware; override with env
|
|
# vars if you want to try newer builds (see --help). Since v1.14 BOTH lanes serve
|
|
# an OFFICIAL SGLang image with nothing added and this script builds nothing by default: the
|
|
# flash lane crossed over in v1.8, the 27B lane followed once the two reasons it
|
|
# had stayed behind were measured rather than restated (see the IMAGE pin below).
|
|
# The flash lane's old overlay files stay in flash-sglang/ as the record of what
|
|
# upstream replaced; nothing builds them since v1.18.7 (see OVERLAY_FLASH below).
|
|
set -euo pipefail
|
|
trap 'printf "\n\033[1;31mInstall failed at line %s (command: %s).\033[0m\nRe-running ./install.sh is safe: completed steps are skipped.\n" "$LINENO" "$BASH_COMMAND" >&2' ERR
|
|
|
|
# die() is the first thing this file defines, not something down at the steps:
|
|
# the refusal below is the first thing that can reject an invocation, and
|
|
# calling a function the shell has not seen yet printed "command not found" and
|
|
# exited through the ERR trap, losing the message that names the problem
|
|
# (tests/test_install_preflight.py pins that failure mode on the port checks).
|
|
die() { printf '\n\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; }
|
|
|
|
# One spelling of the home, without a trailing slash: a home given as "/home/nvidia/" in /etc/passwd
|
|
# (on a second ASUS Ascent GX10) put a "//" in every path built on it, while systemd hands the cockpit the
|
|
# same home without the slash. The cockpit's exact-argv sudoers, rendered from a login shell, then
|
|
# matched none of the cockpit's own switches, and every Load that installs a unit asked for a password
|
|
# (found on a second ASUS Ascent GX10, 2026-10-22).
|
|
while [ -n "${HOME:-}" ] && [ "$HOME" != / ] && [ "${HOME%/}" != "$HOME" ]; do HOME="${HOME%/}"; done; export HOME
|
|
# The PATH one slash at a time too: a login from such a home put "/home/nvidia//.local/bin" on it, which
|
|
# this script compares with the folders it builds on the home and writes into units (v1.38.1).
|
|
PATH="$(printf '%s' "$PATH" | tr -s /)"; export PATH
|
|
|
|
# ── The first wall: this installer does not run as root ──────────────────────
|
|
# Everything it writes is addressed from $HOME, and the units it renders carry
|
|
# those paths plus User=$(id -un). Put sudo in front and $HOME is /root: the
|
|
# config dir becomes /root/.config/qwen38 with a BRAND NEW API key, the engine
|
|
# unit points --api-key at that file, and every client reading
|
|
# ~/.config/qwen38/api-key gets 401 from an engine that is otherwise perfectly
|
|
# healthy. Nothing fails loudly, which is what makes it expensive: on the
|
|
# reference box, 2026-09-13, `curl .../get.sh | sudo bash` installed, started,
|
|
# served, and answered a key nobody had; it took a read of the sudo audit log
|
|
# to see why. This installer calls sudo itself, for the privileged steps and
|
|
# for nothing else, so there is never a reason to put sudo in front of it.
|
|
# (id -u rather than $EUID: the refusal is testable that way, and a PATH that
|
|
# can lie about id could edit this file anyway.)
|
|
if [ "$(id -u)" = "0" ]; then
|
|
if [ -n "${SUDO_USER:-}" ]; then
|
|
# || true, and it is load bearing: getent exits 2 on an unknown user, and
|
|
# under set -e + pipefail that killed this very refusal through the ERR
|
|
# trap, printing "Install failed at line ..." instead of the message. A
|
|
# refusal that cannot survive its own lookup is not a refusal.
|
|
SUDO_HOME="$(getent passwd "$SUDO_USER" 2>/dev/null | cut -d: -f6 || true)"
|
|
die "do not put sudo in front of this installer.
|
|
|
|
you ran : sudo ... (your login is $SUDO_USER)
|
|
run instead : curl -fsSL https://get.alzeo.ai | bash
|
|
or locally : ./install.sh (it calls sudo itself, for the steps that need it)
|
|
|
|
Under sudo, HOME is /root: the API key, the chat template and the compile cache
|
|
land in /root/.config/qwen38 and the units point there. The engine then installs,
|
|
starts and serves normally with a key nobody has, and every client reading
|
|
${SUDO_HOME:-/home/$SUDO_USER}/.config/qwen38/api-key gets 401 from it."
|
|
fi
|
|
[ "${ALLOW_ROOT:-0}" = "1" ] || die "this installer runs as the user who will use the box, not as root.
|
|
|
|
Everything it writes is addressed from \$HOME (~/.config/qwen38), and the units it
|
|
renders carry that path plus User=$(id -un). As root that is /root, which is not
|
|
where your clients, your cockpit or your opencode config look.
|
|
|
|
log in as that user and run it there
|
|
or, if this box genuinely has no other user: ALLOW_ROOT=1 ./install.sh"
|
|
fi
|
|
|
|
# Remember which knobs the operator set explicitly on THIS invocation, before
|
|
# the defaults below fill them in: an explicit env var beats the installed
|
|
# unit, which beats the defaults (see the convergence block further down).
|
|
_ENV_MODEL_CHOICE="${MODEL_CHOICE:-}"; _ENV_MODEL_REV="${MODEL_REV:-}"
|
|
_ENV_PORT="${PORT:-}"; _ENV_HF_CACHE="${HF_CACHE:-}"
|
|
_ENV_CONTEXT_MODE="${CONTEXT_MODE:-}"; _ENV_PROXY_PORT="${PROXY_PORT:-}"
|
|
_ENV_ENGINE_BIND="${ENGINE_BIND:-}"; _ENV_PROXY_BIND="${PROXY_BIND:-}"
|
|
_ENV_PLE_DIR="${PLE_DIR:-}"; FLASH_TIER_ENV="${FLASH_TIER:-}"
|
|
_ENV_SPEC_TOKEN_MAP_SIZE="${SPEC_TOKEN_MAP_SIZE:-}"; _ENV_FLASH_REPLAYSSM_SPEC="${FLASH_REPLAYSSM_SPEC:-}"
|
|
_ENV_DRAFT2_REPO="${DRAFT2_REPO:-}"; _ENV_DRAFT2_REV="${DRAFT2_REV:-}"
|
|
_ENV_DRAFT2_QUANT="${DRAFT2_QUANT:-}"; _ENV_DRAFT2_TOKENS="${DRAFT2_TOKENS:-}"
|
|
# FLASH_LOCAL_CONTEXT, the Qwen3.8 Flash-Next FP4-Local lane's window, is set by its own installer and a Load: this run
|
|
# sizes the clients from the lane's unit before it renders that unit again, so a window chosen here would have reached
|
|
# the unit and not the clients (second review of v1.45.2). Not read, the unit rendered again serves the window it served:
|
|
# it changes only when its checkpoint is not in the cache (a pin moved), and that unit starts no engine before the Load
|
|
# that fetches the checkpoint and sets the clients for its window (flash-local-files.sh, switch-model.sh).
|
|
if [ -n "${FLASH_LOCAL_CONTEXT+set}" ]; then
|
|
printf 'NOTE: FLASH_LOCAL_CONTEXT is not read by ./install.sh: run FLASH_LOCAL_CONTEXT=%s ./install-flash-local.sh --units-only,\n then Load the lane (docs/flash-local-lane.md). This run keeps the window chosen before.\n' "$FLASH_LOCAL_CONTEXT"
|
|
unset FLASH_LOCAL_CONTEXT
|
|
fi
|
|
# FLASH_LOCAL_EFFORT, that lane's default reasoning effort (v1.46.4), is its own installer's to set too: this run writes
|
|
# the opencode config before it runs that installer, so a level chosen here would have reached the lane's template and
|
|
# not the clients' list of its levels before the run after. Not read, the lane keeps the level chosen before.
|
|
if [ -n "${FLASH_LOCAL_EFFORT+set}" ]; then
|
|
printf 'NOTE: FLASH_LOCAL_EFFORT is not read by ./install.sh: run FLASH_LOCAL_EFFORT=%s ./install-flash-local.sh --units-only,\n then Load the lane (docs/flash-local-lane.md). This run keeps the level chosen before.\n' "$FLASH_LOCAL_EFFORT"
|
|
unset FLASH_LOCAL_EFFORT
|
|
fi
|
|
# FLASH_UNSLOTH_CONTEXT, the Qwen3.8 Flash-Next Unsloth GGUF lane's window (262,144 tokens for each of 2 requests, or
|
|
# 1,048,576 for one; decisions 1316 and 1318, 2026-11-12), is its own installer's to set, for FLASH_LOCAL_CONTEXT's
|
|
# reason: this run sizes the clients from the lane's unit before it renders that unit again. Not read, the unit rendered
|
|
# again serves the window chosen before (its installer keeps the choice), and a Load sets the clients for it
|
|
# (switch-model.sh).
|
|
if [ -n "${FLASH_UNSLOTH_CONTEXT+set}" ]; then
|
|
printf 'NOTE: FLASH_UNSLOTH_CONTEXT is not read by ./install.sh: run FLASH_UNSLOTH_CONTEXT=%s ./install-flash-unsloth.sh --units-only,\n then Load the lane (docs/flash-unsloth-lane.md). This run keeps the window chosen before.\n' "$FLASH_UNSLOTH_CONTEXT"
|
|
unset FLASH_UNSLOTH_CONTEXT
|
|
fi
|
|
# the side lanes' checkpoints, which their installers read from the environment (2026-10-17)
|
|
_ENV_KOLIBRI_VARIANT="${KOLIBRI_VARIANT:-}"; _ENV_IMAGE_MODEL="${IMAGE_MODEL:-}"; _ENV_VIDEO_VARIANT="${VIDEO_VARIANT:-}"
|
|
_ENV_FLASH_UNSLOTH_TARGET="${FLASH_UNSLOTH_TARGET:-}"
|
|
# A run installs the text lane that does not serve as well, beside the one it serves: it
|
|
# starts this script again for that lane, with QWEN38_SECONDARY naming it (27b or flash).
|
|
# That run converges on that lane's own installed choices, installs its unit without
|
|
# enabling it, starts nothing, and leaves the proxy, the boot lane, opencode, the cockpit
|
|
# and the side lanes to the run that started it.
|
|
SECONDARY="${QWEN38_SECONDARY:-}"
|
|
case "$SECONDARY" in
|
|
""|27b|flash) ;;
|
|
*) echo "ERROR: QWEN38_SECONDARY names a text lane, 27b or flash (got: $SECONDARY)" >&2; exit 1 ;;
|
|
esac
|
|
# The other text lane installed on demand beside the lane that serves (the run that serves asks
|
|
# for it when that lane is not prepared): its unit (and the flash lane's launcher) only, with no
|
|
# image, no checkpoint, no template, no draft vocabulary, and no room taken for them. Its first
|
|
# Load from the cockpit prepares it (prepare-lane.sh), checking the room for what it fetches,
|
|
# and that Load's switch writes its template (and the 27B's 1M configs).
|
|
UNITS_ONLY=0
|
|
if [ "${QWEN38_UNITS_ONLY:-0}" = 1 ]; then
|
|
case "$SECONDARY" in
|
|
flash|27b) UNITS_ONLY=1 ;;
|
|
*) echo "ERROR: QWEN38_UNITS_ONLY is for the text lane installed beside another (QWEN38_SECONDARY=flash or 27b)" >&2; exit 1 ;;
|
|
esac
|
|
fi
|
|
|
|
# ── Pinned, validated versions (override via env if you know what you do) ──
|
|
# The 27B lane's image, and since v1.14 it is the official release, served
|
|
# directly with no overlay built on top of it. Until v1.13 this lane built its
|
|
# own image (the 2026-08-15 base plus eight sha256-verified files) for two
|
|
# reasons, and both were retired by measurement on 2026-09-17 rather than by
|
|
# assumption:
|
|
# - DFlash2 itself, merged upstream 2026-08-19 (sglang#35371) together with
|
|
# the quantized target lm_head the candidate selector projects through
|
|
# (sglang#35496). Both are in v0.5.19: diffed file by file against the
|
|
# overlay, not one function of it is missing upstream, and upstream carries
|
|
# about ten this box never had.
|
|
# - The mrope fix (sglang#34446, "the fused Qwen3.5 RoPE kernel discards mrope
|
|
# height and width", merged 2026-08-30), whose failure mode is silent image
|
|
# corruption. v0.5.19 is built after it: checked in the image, its
|
|
# fused_qk_rmsnorm_rope_gate.py carries mrope_axis_map, same as the overlay.
|
|
# The sm_121 objection that kept this lane off the release is retired too, and it
|
|
# was never a departure: v0.5.19 reports arch_list up to sm_120 and ships
|
|
# sgl_kernel variants for sm90 and sm100 only, but SO DOES the image this lane
|
|
# served before it, byte for byte (15301320 and 14711496). GB10 loads the sm100
|
|
# cubin either way.
|
|
# Measured on the box, same flags, same probes, 2026-09-17: greedy median 71.4
|
|
# against 69.8 tok/s, acceptance 4.29 against 4.09, conc-check 40/40 serial and
|
|
# 160/160 at concurrency 8 on both, needle retrieval exact at 300,108 prompt
|
|
# tokens on both (514 s against 493 s, the one point where the release is
|
|
# behind). The KV pool needs the fraction moved from 0.70 to 0.76 to match, for
|
|
# the reason written at CONTEXT_MODE below.
|
|
# v1.23.0 moved the lane from v0.5.19 to v0.5.21 (2026-10-01), the release the cookbook's
|
|
# DGX Spark recipe now names (lmsysorg/sglang:latest), for sglang#37818: on v0.5.19 a DFlash
|
|
# verify that crosses a 256-token Mamba tracking boundary saved no checkpoint, so a turn
|
|
# that reused a generated answer from the prefix cache resumed from a stale linear state
|
|
# (largest log-probability shift among the first token's five likeliest candidates, against
|
|
# a full recompute: 3.25 nats, median of 16 documents; 0.54 on v0.5.21).
|
|
# Measured on the box, same flags, same probes, 2026-10-09: prefill log-probabilities
|
|
# identical bit for bit (30 texts of 1,024 tokens), GSM8K 248 and 247 of 250, needle exact
|
|
# at 299,901 tokens, conc-check 40/40 and 160/160 on both, pool 872,414 to 878,687 on three
|
|
# boots (854,123 to 888,628 on four v0.5.19 boots). v0.5.21 refuses --cuda-graph-max-bs
|
|
# as ambiguous; the units say --cuda-graph-max-bs-decode, which v0.5.19 resolves to the
|
|
# same settings, so IMAGE= with the v0.5.19 digest still rolls back (booted that way on
|
|
# the box: the 18 production checks pass). cuBLAS and PyTorch are the same in both.
|
|
# v1.39.0 moves the lane from v0.5.21 to v0.5.22 (2026-10-23), which lmsysorg/sglang:latest, the
|
|
# cookbook's DGX Spark image for this model, names since 2026-10-16: it carries sglang#41872 (a
|
|
# scheduler stall at admission v0.5.21 has, sglang#41841) and #41737 (DFlash2's greedy selector
|
|
# took a neighbouring row's candidates when a row of scores was all NaN). Measured on the box,
|
|
# both images started from this unit's own command line, in the order v0.5.21, v0.5.22, v0.5.22,
|
|
# v0.5.21, same client and probes: decoding at 1 stream 38.8, 38.5 and 38.8 tok/s against 31.8,
|
|
# 31.8 and 36.7 (inter-token 10.9 ms against 13.8 to 17.9), at 4 streams 81.7 and 81.6 against
|
|
# 77.5, 77.8 and 74.7; the draft's accepted length 5.05 on both boots against 3.96 and 4.59;
|
|
# GSM8K 244 against 246 of 250; needle exact at 120,196 and 299,901 tokens on both;
|
|
# conc-check 40/40 and 160/160 on both; pool 869,920 and 874,145 against 872,921 and 898,513;
|
|
# a 30-minute agent session up to 518,252 tokens with no error. Prefill log-probabilities are
|
|
# deterministic on each and differ between them (0.20 nats a token on average over 30 texts),
|
|
# with no bias: mean NLL 1.786 against 1.802. torch 2.14.1, FlashInfer 0.7.1; cuBLAS 13.1 and
|
|
# CUDA 13.0 unchanged. IMAGE= with the v0.5.21 digest rolls back: the unit's flags are the same.
|
|
IMAGE="${IMAGE:-lmsysorg/sglang@sha256:e3a4f06001a29542fc4a8638536d9ffc5eb9c9942b08603c09b19a56eae4a1ae}" # = lmsysorg/sglang:v0.5.22, 2026-10-16
|
|
# Target model choice: "stock" (validated censored base, default) or "uncensored"
|
|
# (huihui-ai abliteration re-quantized with the identical RadixArk modelopt
|
|
# NVFP4 recipe: same architecture, chat template, MTP + vision, ~22 GB).
|
|
STOCK_REPO="RadixArk/Qwen3.8-27B-NVFP4"
|
|
STOCK_REV="52d1adc5f38aa5ebf099c29ed7025ba34cfbb854"
|
|
# Qwen's own FP8 release: the quality reference of the 27B lane. Weights are 30.9 GB
|
|
# against 21.9 GB for NVFP4, which SGLang takes out of the KV pool: measured on the
|
|
# reference box, the same 1m unit reports 863,398 tokens on NVFP4 and 771,139 on
|
|
# FP8, so about 92,000 fewer (an earlier note here extrapolated 200,000 from
|
|
# 20,000 tokens per GB; the measurement is the number to trust).
|
|
# Decode is bandwidth bound on GB10, so it is also slower. No flag changes: SGLang reads
|
|
# the scheme from the checkpoint's own config.
|
|
FP8_REPO="Qwen/Qwen3.8-27B-FP8"
|
|
FP8_REV="017b9c7af6b5689d5dd426a76e0bc077eb5ca20a"
|
|
# The abliterated weights in Qwen's own FP8 format: same packager as the NVFP4
|
|
# uncensored target above, same fp8 e4m3 scheme as Qwen's official release (which this
|
|
# repo already serves), and lm_head is left out of the quantization, which is what keeps
|
|
# an FP8 checkpoint loadable by SGLang. Verified against the official FP8: 66 weight
|
|
# files, not one hash in common, so the abliteration is real and not a rename.
|
|
UNCFP8_REPO="edp1096/Huihui-Qwen3.8-27B-abliterated-FP8"
|
|
UNCFP8_REV="603028a116e50e57baeda318eff6181be4ce5876"
|
|
UNC_REPO="edp1096/Huihui-RadixArk-Qwen3.8-27B-abliterated-NVFP4"
|
|
UNC_REV="21565d389fe573a32c1c425e0c7ade204ddb2263"
|
|
# Arete 27B, Nous Research's fine-tune of Qwen3.8-27B (Apache-2.0), in atakans's NVFP4
|
|
# (ModelOpt 0.48.0, NVIDIA's recipe for the 27B: the same architecture, chat template and
|
|
# serving flags, no MTP layer, 21.1 GB). Measured on the reference box on 2026-11-14 under this
|
|
# lane's unit, against Nous's BF16 and veladan's NVFP4: KLD 0.030 to the BF16, GSM8K 0.992,
|
|
# MMLU 0.880, HumanEval 0.963, 69 to 72 tok/s alone, the needle exact at 120,000 and 300,000.
|
|
# It declares no KV cache: its switch writes the lane's fp8 declaration into its config
|
|
# (patch-kv.py says why that and not --kv-cache-dtype), and it serves as stock does.
|
|
ARETE_REPO="atakans/Arete-27B-NVFP4"
|
|
ARETE_REV="50235efb8aaa20e7d9338ad9d64f9451da784f91"
|
|
# Third target: Qwen3.8-Flash-Next (176B hybrid MoE, 6B active) in NVFP4 on
|
|
# SGLang (same engine as the 27B pair), single box. The official image cannot
|
|
# fit it on a GB10 as shipped; the locally built two-file overlay mmaps the 51B
|
|
# N-gram (PLE) table from NVMe and unblocks QSA decode on sm_121 (see
|
|
# flash-sglang/ATTRIBUTION.md). Same service surface: port, API key, keepalive
|
|
# proxy, opencode wiring, and (v1.5) working prefix caching, vision and the
|
|
# Anthropic endpoint. Serving flags validated on the reference box 2026-08-28.
|
|
FLASH_REPO="RadixArk/Qwen3.8-Flash-Next-NVFP4"
|
|
FLASH_REV="7b719225242aacd3dbd3f9407468c2ee9a9d2594"
|
|
# Fifth checkpoint of the flash lane: NVIDIA's own ModelOpt MIXED_PRECISION
|
|
# export of the same model (NVFP4 routed experts, FP8 N-gram table, FP8
|
|
# block-scaled MTP experts). On one box its smaller fp8 draft leaves a much
|
|
# larger KV pool than the RadixArk export at the same pins (upstream measured
|
|
# 174k tokens against 93k with MTP). It needs the mixed-precision loader of
|
|
# sglang#38121, which the image below has and the older qwen38flashnext tag
|
|
# does not, and it must NOT be passed --quantization (it resolves to
|
|
# modelopt_mixed on its own) while --moe-runner-backend has to be pinned to
|
|
# flashinfer_cutlass, because the mixed-precision auto-default picks
|
|
# flashinfer_trtllm on GB10 and the NVFP4 MoE method rejects it at autotune.
|
|
FLASH_NVDA_REPO="nvidia/Qwen3.8-Flash-Next-NVFP4"
|
|
FLASH_NVDA_REV="fc694b54fb0174e0913e6adf86691ef85a4ead47"
|
|
# Sixth checkpoint of the flash lane: the abliterated build of the same model, in
|
|
# the same tree. Chosen on evidence rather than on popularity: of the abliterated
|
|
# Flash-Next exports published for this architecture, this one has 206 shards
|
|
# with the same names as RadixArk's and 205 of them byte-identical in size, plus
|
|
# the same index, the same hf_quant_config and the same chat template, so it is
|
|
# an abliteration OF the export this lane already serves and every serving flag
|
|
# transfers unchanged. It declares library_name sglang, keeps the MTP head and
|
|
# stays multimodal. The alternative with more downloads
|
|
# (orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4) was rejected here: 18 shards,
|
|
# 170.9 GiB, no hf_quant_config and a separate model-mtp.safetensors, so a
|
|
# different packaging and a different loader path, none of it validated on this
|
|
# recipe. The Mia/Keys splice was rejected for a harder reason: it is built on
|
|
# the vLLM tree (architecture Qwen3_8FlashNextForConditionalGeneration,
|
|
# model_type qwen3_8_flash_next) and SGLang registers only
|
|
# Qwen4ExpForConditionalGeneration, with zero mentions of the other name
|
|
# anywhere in the image, so it cannot be served here at all.
|
|
FLASH_UNC_REPO="dealignai/Qwen3.8-Flash-Next-ABLITERATED-NVFP4"
|
|
FLASH_UNC_REV="be794b990578ef3031eccf9f28e675a289a09ee9"
|
|
# The flash lane's image. Since v1.8 this is the image the cookbook points DGX
|
|
# Spark at: the qwen4-main-squashed build, which carries the file-backed PLE
|
|
# table backend (sglang#37068, replacing this repo's mmap overlay), the merged
|
|
# KDA QSA sm_121 decode kernel (sglang#36845, replacing the vendored copy), the
|
|
# router fix for the GB10 MTP output collapse (sglang#36811 via #38308/#38290,
|
|
# which is the root cause of the wall of "!" the proxy learned to detect in
|
|
# v1.6), and the mixed-precision loader (sglang#38121).
|
|
FLASH_IMAGE="${FLASH_IMAGE:-lmsysorg/sglang@sha256:3e79541d1e2a6818979c4aa9ca1fa63d6961d7bc50120867953ea6baaf1d8f62}" # = lmsysorg/sglang:nightly-cu134-20261011-53295c6, measured 2026-10-12 on this box against 6caf0ff, same target and tier: logprobs bit-identical on 30 fixed texts (NLL 1.6229 both), GSM8K 247 vs 248 of 250, needle 120k/200k 2/2 with identical replies, greedy decode median 46.6/49.6 vs 44.3/46.9 tok/s, serving c4 output 61.0 vs 58.0 tok/s with a tighter p99, pool +1.9% (boot noise), every client green (SDK, Node, Bun, LiteLLM, 4 agents; one isolated Hermes truncation retested 3/3). The previous pin was 6caf0ff (nightly-cu134-20260928, 2026-09-28); an update untags it like any retired pin (unpin_stale below), so a docker image prune reclaims it.
|
|
# Backing store for the flash target's file-backed 47.7 GiB PLE table. The
|
|
# server rewrites it on every boot (~10 min from a fresh sparse file, ~55 min
|
|
# over a populated one), so the launcher deletes the previous file first.
|
|
PLE_DIR="${PLE_DIR:-$HOME/flashnext-ple}"
|
|
# Resident-set budget for the table's mapping (SGLANG_QWEN4_PLE_FILE_RSS_BUDGET_GB,
|
|
# upstream default 8 GiB, 0 disables). A row fault maps in a whole page-cache
|
|
# folio, so the mapping's RSS climbs towards 47.7 GiB while a token reads a few
|
|
# KB of it; on unified memory that is the same pool the KV cache is sized from,
|
|
# which is why upstream trims it. This is the knob behind the pool lottery this
|
|
# repo pinned --max-total-tokens for in v1.6.2.
|
|
PLE_RSS_BUDGET_GB="${PLE_RSS_BUDGET_GB:-8}"
|
|
MODEL_CHOICE="${MODEL_CHOICE:-stock}"
|
|
case "$MODEL_CHOICE" in
|
|
stock) MODEL_REPO="$STOCK_REPO"; MODEL_REV="${MODEL_REV:-$STOCK_REV}" ;;
|
|
uncensored) MODEL_REPO="$UNC_REPO"; MODEL_REV="${MODEL_REV:-$UNC_REV}" ;;
|
|
fp8) MODEL_REPO="$FP8_REPO"; MODEL_REV="${MODEL_REV:-$FP8_REV}" ;;
|
|
uncensored-fp8) MODEL_REPO="$UNCFP8_REPO"; MODEL_REV="${MODEL_REV:-$UNCFP8_REV}" ;;
|
|
arete) MODEL_REPO="$ARETE_REPO"; MODEL_REV="${MODEL_REV:-$ARETE_REV}" ;;
|
|
flash) MODEL_REPO="$FLASH_REPO"; MODEL_REV="${MODEL_REV:-$FLASH_REV}" ;;
|
|
flash-nvda) MODEL_REPO="$FLASH_NVDA_REPO"; MODEL_REV="${MODEL_REV:-$FLASH_NVDA_REV}" ;;
|
|
flash-uncensored) MODEL_REPO="$FLASH_UNC_REPO"; MODEL_REV="${MODEL_REV:-$FLASH_UNC_REV}" ;;
|
|
*) printf 'ERROR: MODEL_CHOICE must be "stock", "uncensored", "fp8", "uncensored-fp8", "arete", "flash", "flash-nvda" or "flash-uncensored" (got: %s)\n' "$MODEL_CHOICE" >&2; exit 1 ;;
|
|
esac
|
|
# Which flags the flash lane's checkpoint wants. The RadixArk export is plain
|
|
# NVFP4 and says so; NVIDIA's is a mixed-precision export that resolves its own
|
|
# scheme and needs the MoE runner pinned (see FLASH_NVDA_REPO above).
|
|
# Both the target's scheme and the DRAFT's belong to the checkpoint, not to the
|
|
# serving tier. RadixArk and its abliteration quantized only the routed experts,
|
|
# so their 31 in-checkpoint MTP tensors are BF16 and the draft must be told not
|
|
# to quantize them; NVIDIA's export ships FP8 block-scaled MTP experts and its
|
|
# verified cell passes no draft quantization at all, so forcing "unquant" there
|
|
# would load an fp8 head as if it were dense.
|
|
#
|
|
# A FUNCTION, and called again after the convergence block below, because that
|
|
# block can change MODEL_CHOICE (a plain ./install.sh on a flash box converges
|
|
# from the default "stock" to "flash"). Computed once, it kept the empty value
|
|
# the default had chosen and the rendered launcher lost --quantization
|
|
# modelopt_fp4 entirely: the engine then resolved its MoE runner to
|
|
# flashinfer_trtllm and died ten minutes into the boot with "Unsupported
|
|
# moe_runner_backend for NVFP4 MoE" (2026-09-08, on the reference box).
|
|
resolve_flash_checkpoint_args() {
|
|
case "$MODEL_CHOICE" in
|
|
flash|flash-uncensored)
|
|
FLASH_QUANT_ARGS="--quantization modelopt_fp4 --speculative-draft-model-quantization unquant " ;;
|
|
flash-nvda)
|
|
FLASH_QUANT_ARGS="--moe-runner-backend flashinfer_cutlass " ;;
|
|
*)
|
|
FLASH_QUANT_ARGS="" ;;
|
|
esac
|
|
}
|
|
resolve_flash_checkpoint_args
|
|
# Lane implied by the target model: the 27B pair and Flash-Next each have
|
|
# their own unit and serving image (both SGLang since v1.5), same port,
|
|
# never enabled together.
|
|
LANE=27b; UNIT_NAME="qwen38-sglang.service"
|
|
case "$MODEL_CHOICE" in
|
|
flash|flash-nvda|flash-uncensored) LANE=flash; UNIT_NAME="qwen38-flash.service" ;;
|
|
esac
|
|
# Serving tier of the flash lane. Every mamba state slot costs 0.206 GiB of the
|
|
# same pool the KV cache comes out of (measured here), and the hybrid GDN/QSA
|
|
# model reserves 5 slots per running request with extra_buffer, 4 with
|
|
# extra_buffer_lazy, so concurrency and the longest servable prompt trade against
|
|
# each other one for one:
|
|
# context 4 requests, 20 slots, MTP: KV pool 295,936 tokens, so a full
|
|
# 262,144-token prompt fits.
|
|
# concurrency 8 requests, 40 slots, 2 states per path, MTP: the default since
|
|
# 2026-09-30, measured on this box (~/flashtest-palier8,
|
|
# ~/flashtest-nightly2809): pool 477,056 tokens, so a full 262K
|
|
# prompt fits at 8 requests, bench median 46.9 tok/s single
|
|
# stream (vs 46.2 without the per-path cap), canaries 4/4,
|
|
# needle 120k/200k 2/2, prefix cache 99.9% on a repeated prefix.
|
|
# The per-path cap halves the state each speculative path holds,
|
|
# which is what makes 8 requests fit in 40 slots.
|
|
# throughput 24 requests, 96 lazy slots, no speculation: the cookbook's
|
|
# high-throughput cell, 83 tok/s of output at 24 upstream and a
|
|
# ~286k pool, at 15.9 tok/s single stream.
|
|
FLASH_TIER="${FLASH_TIER:-concurrency}"
|
|
# MTP verify intermediates on a fixed ring instead of per-request state slots
|
|
# (the cookbook's EAGLE row on SM120/SM121). Measured on this box 2026-09-12,
|
|
# context tier, same target: pool 463,936 -> 557,312 (+20%, above the previous
|
|
# boot range), decode neutral (42.4 vs 43.1 greedy median, mixed per-probe
|
|
# directions inside the documented uptime drift), canaries 4/4, no corruption.
|
|
# Refused with the throughput tier, which runs no speculation. On unless
|
|
# asked: measured +20% pool on this box, decode neutral, canaries 4/4.
|
|
FLASH_REPLAYSSM_SPEC="${FLASH_REPLAYSSM_SPEC:-1}"
|
|
# Also a function, and for the same reason: the convergence block can adopt the
|
|
# tier the installed launcher is already serving.
|
|
resolve_flash_tier_args() {
|
|
case "$FLASH_TIER" in
|
|
context)
|
|
FLASH_TIER_ARGS="--max-running-requests 4 --max-mamba-cache-size 20 --mamba-radix-cache-strategy extra_buffer --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4" ;;
|
|
concurrency)
|
|
FLASH_TIER_ARGS="--max-running-requests 8 --max-mamba-cache-size 40 --mamba-max-states-per-path 2 --mamba-radix-cache-strategy extra_buffer --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4" ;;
|
|
throughput)
|
|
FLASH_TIER_ARGS="--max-running-requests 24 --max-mamba-cache-size 96 --mamba-radix-cache-strategy extra_buffer_lazy" ;;
|
|
*) printf 'ERROR: FLASH_TIER must be "context", "concurrency" or "throughput" (got: %s)\n' "$FLASH_TIER" >&2; exit 1 ;;
|
|
esac
|
|
case "$FLASH_REPLAYSSM_SPEC" in
|
|
0|"") ;;
|
|
1)
|
|
# No speculation on throughput, so nowhere to apply it: say so and skip,
|
|
# instead of failing a convergent throughput reinstall on the new default.
|
|
case "$FLASH_TIER" in
|
|
throughput) echo "NOTE: FLASH_REPLAYSSM_SPEC=1 has no speculation to apply to on the throughput tier; ignored" ;;
|
|
*) FLASH_TIER_ARGS="$FLASH_TIER_ARGS --enable-linear-replayssm-spec" ;;
|
|
esac ;;
|
|
*) printf 'ERROR: FLASH_REPLAYSSM_SPEC must be 0 or 1 (got: %s)\n' "$FLASH_REPLAYSSM_SPEC" >&2; exit 1 ;;
|
|
esac
|
|
}
|
|
resolve_flash_tier_args
|
|
# The cookbook's verified value for both single-Spark cells. Lower it if your box
|
|
# runs co-tenants: the pools are sized from what the host has free at profiling.
|
|
FLASH_MEM_FRACTION="${FLASH_MEM_FRACTION:-0.85}"
|
|
# Reduced draft vocabulary, in token ids (0 = off). A speculative step's draft
|
|
# reads the model's lm_head in full, and at 248,320 x 2560 in BF16 that is
|
|
# 1.18 GiB read three times per MTP-3 engine step. SGLang can hand the draft a
|
|
# sliced head instead (--speculative-token-map): the target still verifies over
|
|
# the whole vocabulary, so this cannot change what the model is allowed to say.
|
|
# build-token-map.py writes the list; install.sh builds it inside the serving
|
|
# image, where the tokenizer version matches the served model by construction.
|
|
# The size is a measured choice, not a guess: see BENCHMARKS.md.
|
|
SPEC_TOKEN_MAP_SIZE="${SPEC_TOKEN_MAP_SIZE:-65536}"
|
|
# The file name carries the size, so a box that changes SPEC_TOKEN_MAP_SIZE
|
|
# builds a new map instead of serving the old one under a new intent. Defined
|
|
# here and not earlier on purpose: the first version of this line sat above the
|
|
# size it interpolates, and ${...:-0} turned that ordering bug into a silently
|
|
# mis-named file rather than an error.
|
|
TOKEN_MAP_NAME="token-map-${SPEC_TOKEN_MAP_SIZE}.pt"
|
|
# The DSpark drafter. Served up to v1.1; DFlash2 replaced it in v1.2 and no
|
|
# serving path has referenced it since, so it is no longer downloaded (it cost
|
|
# 6 GB and a few minutes on every 27B install). The pin stays so the cockpit's
|
|
# registry can still recognise a copy left on disk, and `git checkout v1.1 &&
|
|
# ./install.sh` fetches it through that release's own installer.
|
|
# RadixArk published a v2 of this draft on 2026-08-28 claiming +26% acceptance
|
|
# over v1 (3.43 aggregate over 64,675 prompts on their own card), which would
|
|
# put it level with DFlash2 on paper. Measured here on 2026-09-18, same box,
|
|
# same unit, only the drafter swapped (b9a5dbdf, DSPARK, gamma auto-inferred):
|
|
# greedy median 48.7 tok/s against DFlash2's 72.0, acceptance 3.49 against 4.29,
|
|
# conc-check clean on both. It does leave a larger pool (953,442 against
|
|
# 889,131) because its verify window is 8 rather than 16, and that does not come
|
|
# close to paying for a third of the throughput. The lane stays on DFlash2.
|
|
# shellcheck disable=SC2034 # read externally: dashboard/registry.py pairs DRAFT_REV
|
|
# with this repo id to classify a leftover DSpark copy, and uninstall.sh lists it.
|
|
DRAFT_REPO="RadixArk/Qwen3.8-27B-DSpark"
|
|
DRAFT_REV="${DRAFT_REV:-85ef153be924f17ce4bf62726954eeaa4a73e854}"
|
|
# The DFlash2 drafter the 27B lane serves. Since v1.9 this is maurienne-ai's
|
|
# calibrated NVFP4 build of the z-lab draft (3.53 GB BF16 -> 1.37 GB of VRAM,
|
|
# same acceptance once calibrated), served 16 tokens deep instead of 8.
|
|
# Measured on the reference box, same target, same flags otherwise:
|
|
# bench.sh greedy median 50 -> 65.3 tok/s (+30%), bench-matrix code 41 -> 40,
|
|
# tech-FR 26 -> 32, reasoning-FR 43.5 -> 49.5, prose unchanged, pool 357,706
|
|
# tokens, 0 corruption markers, 4 concurrent streams clean. The drafters are
|
|
# lossless by construction (the target verifies every drafted token), and the
|
|
# depth was swept, not guessed (D8 -> D16 alone is +19% pooled throughput).
|
|
# Rollback to the BF16 draft: DRAFT2_REPO=z-lab/Qwen3.8-27B-DFlash2
|
|
# DRAFT2_REV=50307d4c4cde6860d4eee73e2547cd786fe8e8a4 DRAFT2_QUANT=unquant
|
|
# DRAFT2_TOKENS=8 ./install.sh (then restart the unit).
|
|
DRAFT2_REPO="${DRAFT2_REPO:-maurienne-ai/Qwen3.8-27B-DFlash2-NVFP4-RTNcal}"
|
|
DRAFT2_REV="${DRAFT2_REV:-bd7a934213c47a9e7ef69eef36bb3325f47fd1f1}"
|
|
DRAFT2_QUANT="${DRAFT2_QUANT:-modelopt_fp4}"
|
|
DRAFT2_TOKENS="${DRAFT2_TOKENS:-16}"
|
|
# Context mode: "1m" (1,010,000 via YaRN static scaling, mem-fraction 0.76,
|
|
# plus the keepalive proxy for agent clients) or "native" (262144). Since
|
|
# v1.12.1 an unset CONTEXT_MODE means 1m on the 27B lane: it is the preset the
|
|
# reference box has served daily since 2026-08-22, and a stack whose headline
|
|
# window has to be asked for by name ships it off for almost everybody.
|
|
# Empty here means "not chosen yet". The default is resolved further down,
|
|
# once the lane, the flags and the installed unit are all known, because the
|
|
# two paths that cannot serve 1m (the flash lane and --no-service) have to
|
|
# fall back to native in silence rather than refuse a default nobody typed.
|
|
# The fraction is 0.76 since v1.14, and the number is the image's, not a taste.
|
|
# The official image sizes its static budget more conservatively than the
|
|
# locally built one this lane served before: at an identical 0.70 it came up
|
|
# with a 770,118-token pool against 906,524, while leaving 29.89 GB of GPU
|
|
# memory unused against 19.38. It was never short of memory, it just did not
|
|
# claim it. 0.76 hands the pool back (902,398 measured, inside the boot-to-boot
|
|
# spread this box shows on one image: 906,524 then 910,203) and still leaves a
|
|
# wider margin than the old pin did, 21.30 GiB against 19.38.
|
|
# What bounds this number is the unified pool, NOT the container: --memory 100g
|
|
# is a host-RSS cap and the cgroup does not see the engine's own GPU memory (plain
|
|
# cudaMalloc on GB10), while managed and pinned memory are charged to it.
|
|
# Measured 2026-09-18 at 0.76 under a 5,623-token generation, the container held
|
|
# 7.15 GiB of its 100 GiB the whole way. Read the GPU-side headroom instead
|
|
# (available_gpu_mem after graph capture), which is what every number here is.
|
|
CONTEXT_MODE="${CONTEXT_MODE:-}"
|
|
case "$CONTEXT_MODE" in
|
|
native|1m|"") ;;
|
|
*) printf 'ERROR: CONTEXT_MODE must be "native" or "1m" (got: %s)\n' "$CONTEXT_MODE" >&2; exit 1 ;;
|
|
esac
|
|
if [ "$LANE" = "flash" ] && [ "$CONTEXT_MODE" = "1m" ]; then
|
|
printf 'ERROR: CONTEXT_MODE=1m is a 27B mode. Flash-Next serves its full native 262144 window\n' >&2
|
|
printf ' by default; a validated long-context mode for it may come in a later release.\n' >&2
|
|
exit 1
|
|
fi
|
|
# What actually gets served. Until v1.7 both lanes served a locally built image:
|
|
# the pinned official base plus sha256-verified overlay files, because no
|
|
# official image carried DFLASH2 or ran Flash-Next on one GB10. Both are
|
|
# upstream now, so both lanes serve the pinned official image directly and
|
|
# build nothing. The flash lane crossed over in v1.8; the 27B lane followed in
|
|
# v1.14, once the two things holding it back were measured rather than assumed
|
|
# (see the IMAGE pin above).
|
|
#
|
|
# OVERLAY_FLASH=1 used to rebuild the flash lane's old overlay image (v1.5 to v1.7)
|
|
# as its rollback, and serve it with the launcher of v1.8, which does not fit it:
|
|
# the overlay's model code keeps the 47.7 GiB PLE table in pinned host RAM unless
|
|
# SGLANG_QWEN4_PLE_MMAP_DIR is set, the launcher sets no such thing and passes
|
|
# --ple-offload-backend file (sglang#37068, newer than the overlay's base) instead,
|
|
# and it has none of the attention backends and sizes the overlay was validated
|
|
# with. Nothing had booted that pairing since v1.8 (found in review, 2026-09-24).
|
|
# The overlay, its launcher and its pins shipped together in v1.7.2, which is the
|
|
# rollback that holds together.
|
|
if [ "${OVERLAY_FLASH:-${OVERLAY:-0}}" = "1" ]; then
|
|
die "OVERLAY_FLASH=1 is retired: this release's flash launcher does not fit the overlay image, and the pair cannot boot. The overlay path shipped whole in v1.7.2 (git checkout v1.7.2 && ./install.sh); this release serves the official image (unset OVERLAY_FLASH)."
|
|
fi
|
|
# Every line below sits at column 0 and refers only to names defined above it,
|
|
# because run.sh and switch-model.sh read these assignments out of this file and
|
|
# eval them with nothing else bound.
|
|
SERVE_IMAGE="${SERVE_IMAGE:-$IMAGE}"
|
|
FLASH_SERVE_IMAGE="${FLASH_SERVE_IMAGE:-$FLASH_IMAGE}"
|
|
# opencode, the client this repo configures and serves in the cockpit's Agent tab, is
|
|
# pinned like everything else. Four things the repo does were read out of this
|
|
# version's own binary and checked against its behaviour: the compaction threshold
|
|
# oc-fit-limits.py sizes the limits for, the hidden 32,000-token output cap the oc
|
|
# launcher lifts (182,000 sent with the variable, 32,000 without, measured on a fake
|
|
# endpoint), the overflow phrases the proxy answers with so a refusal triggers a
|
|
# compaction (21 of 21 present), and --yolo / OPENCODE_PERMISSION for the Agent tab.
|
|
# 1.18.32 passed all of it against the 1.18.27 the repo was measured on (2026-09-23),
|
|
# 1.18.35 against 1.18.32 (2026-10-10), which also masks the provider keys `opencode debug
|
|
# config` prints, where 1.18.32 printed this box's key in clear, 1.19.4 against 1.18.35
|
|
# (2026-10-22), which runs on Bun 1.4.4 and its fixes for Brotli, TLS and HTTP, and 1.19.5
|
|
# against 1.19.4 (2026-10-30), which lets a terminal's ticket stand for the password only on the
|
|
# route the server dispatches the request to, no longer on a pattern of its path.
|
|
# Left alone, two boxes installed a week apart run two versions (up to 1.18, opencode also
|
|
# installed its own patch releases). The sha256 is GitHub's own digest of the release asset
|
|
# opencode-linux-arm64.tar.gz. OPENCODE_PIN=0 keeps whatever opencode you have.
|
|
_ENV_OPENCODE_VERSION="${OPENCODE_VERSION:-}"
|
|
_ENV_OPENCODE_SHA256="${OPENCODE_SHA256:-}"
|
|
OPENCODE_VERSION="${OPENCODE_VERSION:-1.19.5}"
|
|
OPENCODE_SHA256="${OPENCODE_SHA256:-fae5be262d693b7c5e562856cc473e59e741772936db0c0600ac0d5ed5bd088b}"
|
|
OPENCODE_PIN="${OPENCODE_PIN:-1}"
|
|
PORT="${PORT:-30000}"
|
|
HF_CACHE="${HF_CACHE:-$HOME/.cache/huggingface}"
|
|
CONFIG_DIR="$HOME/.config/qwen38"
|
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
|
|
# shellcheck source=lanes.sh
|
|
. "$REPO_DIR/lanes.sh"
|
|
# The box's memory class (boxmem.py), read before any choice: 128, or 64 for the 64 GB DGX Spark
|
|
# NVIDIA's partners ship from 2026-10-23, which gets the 27B in a unit sized for it, Bolt and the
|
|
# speech lane, and no lane that does not fit it. A box below both is refused at step 1.
|
|
MEM_CLASS="$(QWEN38_MEMINFO="${QWEN38_MEMINFO:-/proc/meminfo}" box_mem_class 2>/dev/null)" || MEM_CLASS=none
|
|
# and the same class for what this run calls: conformity.py, the lanes' installers, the run for the
|
|
# other text lane
|
|
case "$MEM_CLASS" in 64|128) export QWEN38_MEMORY_CLASS="$MEM_CLASS" ;; esac
|
|
|
|
NO_START=0
|
|
NO_SERVICE=0
|
|
NO_OPENCODE=0
|
|
WITH_OPENCODE=0
|
|
NO_COCKPIT=0
|
|
WITH_COCKPIT=0
|
|
WITH_IMAGE=0
|
|
NO_IMAGE=0
|
|
WITH_VIDEO=0
|
|
NO_VIDEO=0
|
|
WITH_FLASH=0
|
|
NO_FLASH=0
|
|
WITH_27B=0
|
|
NO_27B=0
|
|
WITH_KOLIBRI=0
|
|
NO_KOLIBRI=0
|
|
WITH_NEMOTRON=0
|
|
NO_NEMOTRON=0
|
|
WITH_NEMOTRON_SUPER=0
|
|
NO_NEMOTRON_SUPER=0
|
|
WITH_FLASH_LOCAL=0
|
|
NO_FLASH_LOCAL=0
|
|
WITH_ORNITH_122B=0
|
|
NO_ORNITH_122B=0
|
|
WITH_FLASH_UNSLOTH=0
|
|
NO_FLASH_UNSLOTH=0
|
|
ALL_WEIGHTS=0
|
|
PLAN_ONLY=0
|
|
# --recommended (v1.36.0): every setting the list before step 1 compares, but the site's (the
|
|
# port, the HF cache, the PLE folder), moves to the recommended value, the operator's choices
|
|
# too, and the lanes, opencode and the cockpit an earlier --no-* left out come back: what a new
|
|
# box gets (Hasan, 2026-10-17). The run for the other text lane and the side lanes' installers
|
|
# read it as QWEN38_RECOMMENDED.
|
|
RECOMMENDED="${QWEN38_RECOMMENDED:-0}"
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--plan) PLAN_ONLY=1 ;;
|
|
--recommended) RECOMMENDED=1 ;;
|
|
--no-start) NO_START=1 ;;
|
|
--no-service) NO_SERVICE=1 ;;
|
|
--no-opencode) NO_OPENCODE=1 ;;
|
|
--with-opencode) WITH_OPENCODE=1 ;;
|
|
--no-cockpit) NO_COCKPIT=1 ;;
|
|
--with-cockpit) WITH_COCKPIT=1 ;;
|
|
--with-image) WITH_IMAGE=1 ;;
|
|
--no-image) NO_IMAGE=1 ;;
|
|
--with-video) WITH_VIDEO=1 ;;
|
|
--no-video) NO_VIDEO=1 ;;
|
|
--with-flash) WITH_FLASH=1 ;;
|
|
--no-flash) NO_FLASH=1 ;;
|
|
--with-27b) WITH_27B=1 ;;
|
|
--no-27b) NO_27B=1 ;;
|
|
--with-kolibri) WITH_KOLIBRI=1 ;;
|
|
--no-kolibri) NO_KOLIBRI=1 ;;
|
|
--with-nemotron) WITH_NEMOTRON=1 ;;
|
|
--no-nemotron) NO_NEMOTRON=1 ;;
|
|
--with-nemotron-super) WITH_NEMOTRON_SUPER=1 ;;
|
|
--no-nemotron-super) NO_NEMOTRON_SUPER=1 ;;
|
|
--with-flash-local) WITH_FLASH_LOCAL=1 ;;
|
|
--no-flash-local) NO_FLASH_LOCAL=1 ;;
|
|
--with-ornith-122b) WITH_ORNITH_122B=1 ;;
|
|
--no-ornith-122b) NO_ORNITH_122B=1 ;;
|
|
--with-flash-unsloth) WITH_FLASH_UNSLOTH=1 ;;
|
|
--no-flash-unsloth) NO_FLASH_UNSLOTH=1 ;;
|
|
--all-weights) ALL_WEIGHTS=1 ;;
|
|
--with-claude-warmup)
|
|
echo "NOTE: --with-claude-warmup was removed in v1.3 (the repo's client story moved to opencode)."
|
|
echo " The flag is ignored; an installed warmup drop-in from an earlier version is cleaned up." ;;
|
|
-h|--help)
|
|
cat <<'HLP'
|
|
Usage: ./install.sh [--no-start] [--no-service] [--no-opencode | --with-opencode]
|
|
[--no-cockpit | --with-cockpit] [--no-image | --with-image]
|
|
[--no-video | --with-video] [--no-flash | --with-flash]
|
|
[--no-27b | --with-27b] [--no-kolibri | --with-kolibri]
|
|
[--no-nemotron | --with-nemotron]
|
|
[--no-nemotron-super | --with-nemotron-super]
|
|
[--no-flash-local | --with-flash-local]
|
|
[--no-ornith-122b | --with-ornith-122b]
|
|
[--no-flash-unsloth | --with-flash-unsloth]
|
|
[--all-weights] [--plan] [--recommended]
|
|
|
|
Run it as yourself. Never with sudo in front: it calls sudo itself for the
|
|
privileged steps, and under sudo every path it writes moves to /root (see the
|
|
refusal at the top of this file).
|
|
|
|
A plain run installs the box: the text lane MODEL_CHOICE names (the 27B by
|
|
default), which serves, the keepalive proxy with its typed decision endpoint,
|
|
the opencode wiring, the cockpit and its Agent view, and every other lane on
|
|
demand: a run puts in its units, and the first Load of each from the cockpit
|
|
prepares it as the user, with no sudo, and fetches its weights. That is the
|
|
other text lane (the flash beside the 27B, its image, checkpoint and PLE table,
|
|
223 GB; or the 27B beside a serving flash, its image, draft and checkpoint,
|
|
58), the image lane (46), the video lane (174), the Kolibri lane (Aleph
|
|
Alpha's Kolibri-1, on vLLM, 102), the Nemotron lane (NVIDIA's Nemotron 3.5
|
|
Bolt, on vLLM, 51), the Nemotron Super lane (NVIDIA's Nemotron 3.5 Super VL
|
|
on vLLM, in the Nemotron lane's image: 77 beside it, else 102), the Flash
|
|
FP4-Local lane (NVIDIA's FP4 build of the flash model, on vLLM, 121; 33 more
|
|
when the HF cache is on another disk than the home directory's, for the copy
|
|
of its n-gram table), the Ornith 122B lane (Ornith AI's Ornith 1.5 122B,
|
|
on vLLM, in the Qwen3.8 Flash-Next FP4-Local lane's image: 78 beside it, else 96)
|
|
and the Qwen3.8 Flash-Next Unsloth GGUF lane (Unsloth's GGUF of the flash
|
|
model, on llama.cpp, 90). The lane that serves proves it serves before the run ends; on a new box the 27B takes 58 GB
|
|
of disk, about 39 GB of
|
|
downloads (about 6 to 7 minutes at 100 MB/s). A lane installed whole (--all-weights, --with-<lane>)
|
|
that does not fit on the disk is left out and named at the end, with the
|
|
command that adds it later. When it finishes it prints the
|
|
cockpit URL, and from there you start, stop, switch, watch and benchmark
|
|
without a terminal.
|
|
|
|
--no-start install everything but don't start the service now
|
|
--no-service no systemd, no sudo: just prepare one text lane (image,
|
|
checkpoints, key, template), then run it in the
|
|
foreground anytime with ./run.sh (Ctrl+C stops it).
|
|
A 128 GB DGX Spark: a 64 GB one refuses it, as
|
|
./run.sh runs a 128 GB box's memory settings
|
|
--no-opencode skip the opencode integration (no generated config, no
|
|
oc launcher, and switch-model.sh leaves your opencode
|
|
default model alone). Remembered by later runs, each of
|
|
which says so.
|
|
--with-opencode re-enable it after a --no-opencode
|
|
--no-cockpit skip the web cockpit and its Agent view (no dashboard
|
|
unit, no sudoers allowlist). Remembered by later runs,
|
|
each of which says so.
|
|
--with-cockpit re-enable it after a --no-cockpit
|
|
--no-image leave the Qwen-Image 2.1 lane out of this run (46 GB).
|
|
Not remembered: pass it on each run to keep the lane
|
|
out; a lane already installed stays in place, not
|
|
updated by that run (./install-image.sh --uninstall
|
|
removes it)
|
|
--with-image install it whole now, runtime and weights, and prove it
|
|
--no-video leave the MiniMax-H3 video lane out of this run (174 GB),
|
|
the same way (./install-video.sh --uninstall)
|
|
--with-video install it whole now and prove it
|
|
--no-flash leave the Qwen3.8 Flash-Next lane out of this run when it is not
|
|
the one serving (223 GB), the same way
|
|
--with-flash install it whole now beside the lane that serves
|
|
--no-27b leave the 27B lane out of this run when it is not the
|
|
one serving (58 GB), the same way
|
|
--with-27b install it whole now beside the lane that serves
|
|
--no-kolibri leave the Kolibri-1 lane out of this run (vLLM, 102 GB),
|
|
the same way (./install-kolibri.sh --uninstall removes it)
|
|
--with-kolibri install it whole now and prove it
|
|
--no-nemotron leave the Nemotron 3.5 Bolt lane (vLLM, 51 GB) out of this
|
|
run, the same way (./install-nemotron.sh --uninstall)
|
|
--with-nemotron install it whole now and prove it
|
|
--no-nemotron-super leave the Nemotron 3.5 Super VL lane (vLLM, 102 GB) out of
|
|
this run, the same way (./install-nemotron-super.sh --uninstall)
|
|
--with-nemotron-super install it whole now and prove it
|
|
--no-flash-local leave the Qwen3.8 Flash-Next FP4-Local lane (vLLM, 121 GB) out of this
|
|
run, the same way (./install-flash-local.sh --uninstall)
|
|
--with-flash-local install it whole now and prove it
|
|
--no-ornith-122b leave the Ornith 1.5 122B lane (vLLM, 96 GB) out of this
|
|
run, the same way (./install-ornith-122b.sh --uninstall)
|
|
--with-ornith-122b install it whole now and prove it
|
|
--no-flash-unsloth leave the Qwen3.8 Flash-Next Unsloth GGUF lane (llama.cpp, 90 GB)
|
|
out of this run, the same way (./install-flash-unsloth.sh --uninstall)
|
|
--with-flash-unsloth install it whole now and prove it
|
|
--all-weights install every lane whole now (the flash beside the 27B,
|
|
the image, video, Kolibri, both Nemotron, the Flash
|
|
FP4-Local, the Ornith and the Unsloth GGUF lanes), runtime
|
|
and weights, about 1047 GB of disk (1080 with the cache on
|
|
another disk), and prove each new one
|
|
(without it, each is prepared at its first Load from
|
|
the cockpit; --with-<lane> does the same for that one
|
|
lane)
|
|
--plan list this box against what this release recommends (what
|
|
a run moves, what stays yours, the site's settings), then
|
|
stop before anything changes: run the same command
|
|
without --plan to apply it
|
|
--recommended what a new box gets: every setting the list compares
|
|
moves to the recommended value, your choices too (each
|
|
lane's target, the drafter, the context mode, the binds,
|
|
the flash tier, the side lanes' checkpoints), and
|
|
opencode and the cockpit an earlier --no-opencode or
|
|
--no-cockpit left out come back (a lane comes back with
|
|
any run that does not pass its --no-<lane>); the port,
|
|
the HF cache and the PLE folder stay (--plan
|
|
--recommended lists what it moves)
|
|
|
|
Re-running over an existing install keeps the operator's choices: the target
|
|
model (any of the eight), the context mode (native/1m), the flash serving tier,
|
|
the port, the HF cache location and the opencode on/off choice are read from
|
|
the installed unit or launcher (or the marker file) unless the env var or flag
|
|
is passed explicitly, or --recommended. A value only an older release's default put there, which
|
|
nothing records as chosen, moves to today's default (since v1.36.0); the list
|
|
printed before step 1 says which, and --plan prints it alone.
|
|
|
|
Env overrides (defaults are pinned to the versions validated on the reference
|
|
box, the 27B image on 2026-10-23):
|
|
IMAGE=lmsysorg/sglang:v0.5.22 the moving tag of the pinned digest, instead
|
|
of the digest itself (this run only: IMAGE
|
|
is not remembered, pass it on every run)
|
|
MODEL_REV=main use the latest target revision
|
|
DRAFT2_REV=main latest DFlash2 draft revision
|
|
DRAFT2_REPO=z-lab/Qwen3.8-27B-DFlash2 DRAFT2_REV=50307d4c4cde6860d4eee73e2547cd786fe8e8a4 DRAFT2_QUANT=unquant DRAFT2_TOKENS=8
|
|
roll the 27B lane back to the BF16 draft
|
|
at depth 8 (the default since v1.9 is the
|
|
calibrated NVFP4 draft at depth 16)
|
|
MODEL_CHOICE=uncensored serve the huihui-abliterated model
|
|
(edp1096 NVFP4) instead of the stock base
|
|
MODEL_CHOICE=fp8 serve Qwen's own FP8 release (30.9 GB, slower
|
|
decode; its 1M pool measured 881,895 tokens
|
|
against 887,797 for NVFP4, 2026-09-18)
|
|
MODEL_CHOICE=uncensored-fp8 the huihui abliteration in that same FP8 format
|
|
MODEL_CHOICE=arete serve Arete 27B, Nous Research's fine-tune of
|
|
the 27B, in atakans's NVFP4 (21.1 GB)
|
|
MODEL_CHOICE=flash serve Qwen3.8-Flash-Next (176B hybrid MoE,
|
|
NVFP4, SGLang engine, ~136 GB download; the
|
|
47.7 GiB N-gram table is served from a file
|
|
on NVMe, with prefix caching and vision)
|
|
MODEL_CHOICE=flash-uncensored the abliterated build of the same tree
|
|
(~136 GB): 205 of its 206 shards are
|
|
byte-identical in size to the stock export,
|
|
so every serving flag is the same one
|
|
MODEL_CHOICE=flash-nvda the same model from NVIDIA's own mixed-
|
|
precision export (~133 GB download), served
|
|
with no --quantization and a pinned MoE
|
|
runner; measured here as a tie with stock
|
|
SPEC_TOKEN_MAP_SIZE=0 flash: serve without the reduced draft
|
|
vocabulary (it is worth 14 to 25% of decode
|
|
and cannot change what the model may say)
|
|
FLASH_TIER=concurrency flash only: 8 concurrent requests with the
|
|
MTP head instead of 4 (a full 262K prompt
|
|
still fits their measured pool); "throughput"
|
|
is 24 without speculation
|
|
FLASH_REPLAYSSM_SPEC=0 flash only: keep MTP verify intermediates
|
|
in per-request state slots instead of the
|
|
fixed ring (measured +20% pool on this box,
|
|
decode neutral, canaries 4/4)
|
|
FLASH_MEM_FRACTION=0.85 flash only: static memory fraction
|
|
PLE_RSS_BUDGET_GB=8 flash only: resident-set budget of the
|
|
N-gram table's mapping (0 disables the trim)
|
|
PLE_DIR=~/flashnext-ple flash only: where the 47.7 GiB backing file
|
|
of the N-gram table lives
|
|
CONTEXT_MODE=native the 262144 window instead of the 1,010,000
|
|
one. Since v1.12.1 a 27B install serves 1m
|
|
by default (YaRN static scaling, README,
|
|
"The 1M context mode"); the flash lane and
|
|
--no-service are native either way, and a
|
|
re-run keeps what the box chose
|
|
PROXY_PORT=30001 keepalive proxy port (default: PORT+1)
|
|
SERVE_IMAGE=ref serving image for the 27B lane
|
|
FLASH_SERVE_IMAGE=ref serving image for the Flash-Next lane
|
|
HF_CACHE=/path HuggingFace cache location (~24 GB for a 27B
|
|
target and its draft, ~136 GB for flash)
|
|
PORT=30000 serving port
|
|
HLP
|
|
exit 0 ;;
|
|
*) printf 'Unknown flag: %s (see --help)\n' "$arg" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
[ "$PLAN_ONLY" -eq 0 ] || [ "$NO_SERVICE" -eq 0 ] \
|
|
|| die "--plan lists what a run does to the box's services; --no-service writes none."
|
|
case "$RECOMMENDED" in 0|1) ;; *) die "QWEN38_RECOMMENDED takes 0 or 1 (got: $RECOMMENDED)" ;; esac
|
|
case "$_ENV_FLASH_UNSLOTH_TARGET" in
|
|
""|flash-unsloth|flash-unsloth-iq3) ;;
|
|
*) die "FLASH_UNSLOTH_TARGET takes flash-unsloth (UD-Q4_K_XL) or flash-unsloth-iq3 (UD-IQ3_XXS), got: $_ENV_FLASH_UNSLOTH_TARGET" ;;
|
|
esac
|
|
# A terminal opened before its account joined the docker group has none of the group's rights: the
|
|
# run goes on with them from here, where it has printed and exported nothing yet (lanes.sh). An
|
|
# account outside the group is added at step 1, after every refusal that comes before it.
|
|
docker_session bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
|
|
# Started again by that step 1 (lanes.sh docker_grant): what this run prints up to it is on the
|
|
# screen already, from the run that added the account. The runs this one starts print as usual.
|
|
DOCKER_SAID=""
|
|
if [ "${QWEN38_DOCKER_RELAUNCHED:-}" = granted ]; then
|
|
DOCKER_SAID=1; export QWEN38_DOCKER_RELAUNCHED="shown"
|
|
exec 3>&1 1>/dev/null
|
|
fi
|
|
export QWEN38_RECOMMENDED="$RECOMMENDED" # the side lanes' installers this run calls read it
|
|
|
|
# ── Converge on the operator's installed choices ──
|
|
# Re-running the installer (or the get.sh one-liner) must never silently reset
|
|
# a choice that is already serving: the target model (any of the eight targets),
|
|
# the port, and the HF cache location are read from the installed units and
|
|
# kept, unless the corresponding env var was passed explicitly on this
|
|
# invocation. Everything else (image digest, checkpoint revisions, launch
|
|
# flags) always follows the repo: that is what an upgrade is.
|
|
#
|
|
# A value an older release installed by default is not a choice, and until v1.36.0 it was
|
|
# kept as one, for good: the engine on every interface (before v1.17.0), the native window
|
|
# (before v1.12.1), the flash context tier (before v1.19.0), the BF16 draft at depth 8 (before
|
|
# v1.9.0). A unit cannot say which is which; conformity.py can (2026-10-17). Such a value stays
|
|
# when installed.json records it as the operator's choice, or, on a box no run of v1.36.0 or
|
|
# later recorded, when the box is younger than the release that moved the default (the mtime
|
|
# of its API key, written once at the first install) or its age cannot be told. Otherwise it
|
|
# moves to today's default, said with the variable that keeps it. Anything conformity.py
|
|
# cannot answer keeps the value, as every update did before.
|
|
MOVED_TAG=""
|
|
old_default_moves() { # $1 the setting, $2 the value the unit serves; succeeds when it moves
|
|
local v
|
|
v="$(python3 "$REPO_DIR/conformity.py" verdict --config-dir "$CONFIG_DIR" "$1" "$2" || true)"
|
|
case "$v" in
|
|
"converge "*) MOVED_TAG="${v#converge }"; return 0 ;;
|
|
esac
|
|
return 1
|
|
}
|
|
KEEP_MODEL_VERBATIM=0
|
|
SGL_UNIT_PATH="/etc/systemd/system/qwen38-sglang.service"
|
|
FLASH_UNIT_PATH="/etc/systemd/system/qwen38-flash.service"
|
|
KOLIBRI_UNIT_PATH="/etc/systemd/system/qwen38-kolibri.service"
|
|
NEMOTRON_UNIT_PATH="/etc/systemd/system/qwen38-nemotron.service"
|
|
NEMOTRON_SUPER_UNIT_PATH="/etc/systemd/system/qwen38-nemotron-super.service"
|
|
FLASH_LOCAL_UNIT_PATH="/etc/systemd/system/qwen38-flash-local.service"
|
|
ORNITH_122B_UNIT_PATH="/etc/systemd/system/qwen38-ornith-122b.service"
|
|
FLASH_UNSLOTH_UNIT_PATH="/etc/systemd/system/qwen38-flash-unsloth.service"
|
|
for _p in "$SGL_UNIT_PATH" "$FLASH_UNIT_PATH"; do
|
|
if [ -f "$_p" ] && [ ! -r "$_p" ]; then
|
|
echo "NOTE: an installed unit ($_p) exists but is not readable (pre-v1.2.3 installs used mode 600),"
|
|
echo " so its choices cannot be preserved automatically. If you had a custom PORT= or"
|
|
echo " MODEL_CHOICE=, pass them explicitly on this command."
|
|
fi
|
|
done
|
|
# Which interface the engine and the proxy answer on.
|
|
#
|
|
# THE ENGINE IS LOCALHOST-ONLY SINCE v1.17, and that is a changed default. It listened on
|
|
# every interface before, and the measurement that decided it: seven days of journal on
|
|
# the reference box, 581,479 requests to the engine, every single one from 127.0.0.1,
|
|
# while the machine was reached from a laptop and a phone on the cockpit port alone. An
|
|
# open port nobody uses would be an ordinary waste; this one is the port SGLang dies on
|
|
# rather than refuses (sglang#40076 and sglang#31597, both unfixed upstream, both refused
|
|
# at the proxy since v1.15.0). Leaving it open leaves a door beside the one with the lock.
|
|
#
|
|
# Nothing is lost by closing it, which is why the default could move at all: the proxy on
|
|
# PORT+1 is a full pass-through, every route the engine serves and the same OpenAI and
|
|
# Anthropic dialects, plus the guards. A client that pointed at :30000 from another
|
|
# machine points at :30001 and gets more, not less. ENGINE_BIND=0.0.0.0 restores the old
|
|
# behaviour for a box that wants it.
|
|
#
|
|
# The proxy's own default does NOT move: it is the door clients are told to use, the
|
|
# README has said so since v1.5, and it is the one that refuses what the engine cannot.
|
|
ENGINE_BIND="${ENGINE_BIND:-127.0.0.1}"
|
|
PROXY_BIND="${PROXY_BIND:-0.0.0.0}"
|
|
# Loopback or every interface, nothing between: the box reaches both ports itself on
|
|
# 127.0.0.1 (the proxy's UPSTREAM, the health checks and the smoke test, opencode's
|
|
# base_url, the cockpit), so a bind that leaves loopback out breaks all of them. The
|
|
# old check took any digits and dots, 300.1.1.1 and ... included (found in review,
|
|
# 2026-09-24). Called again once the installed binds are read back.
|
|
check_binds() {
|
|
local b
|
|
for b in "ENGINE_BIND=$ENGINE_BIND" "PROXY_BIND=$PROXY_BIND"; do
|
|
case "${b#*=}" in
|
|
127.0.0.1|0.0.0.0) ;;
|
|
*) printf 'ERROR: %s=%s: this box reaches that port itself on 127.0.0.1 (the proxy, the health checks, opencode), so it binds 127.0.0.1 (this machine only) or 0.0.0.0 (every interface: narrow it with a firewall)\n' "${b%%=*}" "${b#*=}" >&2
|
|
exit 1 ;;
|
|
esac
|
|
done
|
|
}
|
|
check_binds
|
|
|
|
# Which choice is installed? The flash unit wins only when it is the enabled
|
|
# one; a box can hold both unit files but only one engine serves the port.
|
|
# On the (hand-made) both-enabled state, the 27B unit is followed and a note
|
|
# is printed: predictable beats clever here.
|
|
INSTALLED_CHOICE=""
|
|
SGL_READABLE=0; FLASH_READABLE=0
|
|
[ -f "$SGL_UNIT_PATH" ] && [ -r "$SGL_UNIT_PATH" ] && SGL_READABLE=1
|
|
[ -f "$FLASH_UNIT_PATH" ] && [ -r "$FLASH_UNIT_PATH" ] && FLASH_READABLE=1
|
|
FLASH_ENABLED=0; SGL_ENABLED=0
|
|
systemctl is-enabled --quiet qwen38-flash.service 2>/dev/null && FLASH_ENABLED=1
|
|
systemctl is-enabled --quiet qwen38-sglang.service 2>/dev/null && SGL_ENABLED=1
|
|
# The image lane is a lane too, and when it is the one enabled at boot it was switched to
|
|
# on purpose. A plain re-run must keep that, the same promise it keeps for the target, the
|
|
# context mode and the port: without this it fell through to "27b" below, enabled the 27B
|
|
# unit beside the image one, and left two engines set to start at the next reboot, with
|
|
# only the order systemd happened to pull them in deciding which one came up.
|
|
IMAGE_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-image.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
# An explicit MODEL_CHOICE asks for a text lane: honour it, and the image lane leaves
|
|
# the boot below, where the text unit is enabled. Keeping the image lane here would
|
|
# answer "install flash" with "flash updated, not served", and exit 0.
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the image lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the image lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
IMAGE_BOOT=1
|
|
echo "The image lane is this box's boot lane: this run brings the text lane up to date"
|
|
echo "without making it the boot lane again. Switch back to text from the cockpit when you want it."
|
|
fi
|
|
fi
|
|
# The video lane is a lane too, under the same promise: a plain re-run on a box
|
|
# booting video must not enable a text unit beside it.
|
|
VIDEO_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-video.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
# An explicit MODEL_CHOICE asks for a text lane: honour it, and the video lane
|
|
# leaves the boot below, where the text unit is enabled.
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the video lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the video lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
VIDEO_BOOT=1
|
|
echo "The video lane is this box's boot lane: this run brings the text lane up to date"
|
|
echo "without making it the boot lane again. Switch back to text from the cockpit when you want it."
|
|
fi
|
|
fi
|
|
# The Kolibri lane is a lane of its own too (vLLM, its own unit and installer), under the
|
|
# same promise: a plain re-run on a box booting Kolibri must not enable a SGLang unit beside it.
|
|
KOLIBRI_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-kolibri.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Kolibri-1 lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the Kolibri-1 lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
KOLIBRI_BOOT=1
|
|
echo "The Kolibri-1 lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
# The Nemotron lane is one too (vLLM, its own unit and installer), under the same promise.
|
|
NEMOTRON_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-nemotron.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Nemotron 3.5 Bolt lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ] && [ "$MEM_CLASS" != 64 ]; then
|
|
echo "--recommended on a box booting the Nemotron 3.5 Bolt lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
# (a new 64 GB box serves Bolt itself, so --recommended keeps it there)
|
|
NEMOTRON_BOOT=1
|
|
echo "The Nemotron 3.5 Bolt lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
# And the Nemotron Super lane, under the same promise.
|
|
NEMOTRON_SUPER_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-nemotron-super.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Nemotron 3.5 Super VL lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the Nemotron 3.5 Super VL lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
NEMOTRON_SUPER_BOOT=1
|
|
echo "The Nemotron 3.5 Super VL lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
# And the Qwen3.8 Flash-Next FP4-Local lane, under the same promise.
|
|
FLASH_LOCAL_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-flash-local.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Qwen3.8 Flash-Next FP4-Local lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the Qwen3.8 Flash-Next FP4-Local lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
FLASH_LOCAL_BOOT=1
|
|
echo "The Qwen3.8 Flash-Next FP4-Local lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
# And the Ornith 1.5 122B lane, under the same promise.
|
|
ORNITH_122B_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-ornith-122b.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Ornith 1.5 122B lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the Ornith 1.5 122B lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
ORNITH_122B_BOOT=1
|
|
echo "The Ornith 1.5 122B lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
# And the Qwen3.8 Flash-Next Unsloth GGUF lane, under the same promise.
|
|
FLASH_UNSLOTH_BOOT=0
|
|
if [ -z "$SECONDARY" ] && systemctl is-enabled --quiet qwen38-flash-unsloth.service 2>/dev/null \
|
|
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
|
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the Qwen3.8 Flash-Next Unsloth GGUF lane: making that text lane the boot lane again."
|
|
elif [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended on a box booting the Qwen3.8 Flash-Next Unsloth GGUF lane: the 27B lane becomes the boot lane again, as on a new box."
|
|
else
|
|
FLASH_UNSLOTH_BOOT=1
|
|
echo "The Qwen3.8 Flash-Next Unsloth GGUF lane is this box's boot lane: this run brings the other lanes up to date"
|
|
echo "without making one of them the boot lane again. Switch from the cockpit when you want another."
|
|
fi
|
|
fi
|
|
SIDE_BOOT=$((IMAGE_BOOT + VIDEO_BOOT + KOLIBRI_BOOT + NEMOTRON_BOOT + NEMOTRON_SUPER_BOOT + FLASH_LOCAL_BOOT + ORNITH_122B_BOOT + FLASH_UNSLOTH_BOOT))
|
|
# Which text lane to bring up to date on that path. Both text units can be on disk with
|
|
# neither enabled, since a switch to a side lane disables both, so enablement cannot say which
|
|
# one was in use; switch-model.sh writes it down instead (lanes.sh: one record since v1.30, the
|
|
# links of a box switched before are read once), and without it the 27B lane is the fallback,
|
|
# the same one the code below picks when nothing is enabled.
|
|
text_lane_migrate
|
|
TEXT_LANE_LAST="$(text_lane_last)"
|
|
if [ "$FLASH_READABLE" -eq 1 ] && [ "$FLASH_ENABLED" -eq 1 ] && [ "$SGL_ENABLED" -eq 1 ]; then
|
|
echo "NOTE: both qwen38-sglang and qwen38-flash are enabled (only one can serve the port)."
|
|
echo " Following the 27B unit; run ./switch-model.sh to resolve this cleanly."
|
|
fi
|
|
if [ "$FLASH_READABLE" -eq 1 ] && [ "$FLASH_ENABLED" -eq 1 ] && [ "$SGL_ENABLED" -eq 0 ]; then
|
|
INSTALLED_CHOICE=flash
|
|
elif [ "$SIDE_BOOT" -gt 0 ] && [ "$TEXT_LANE_LAST" = "qwen38-flash.service" ] && [ "$FLASH_READABLE" -eq 1 ]; then
|
|
INSTALLED_CHOICE=flash # the text lane this box used before it switched to a side lane
|
|
elif [ "$SGL_READABLE" -eq 1 ]; then
|
|
INSTALLED_CHOICE=27b
|
|
elif [ "$FLASH_READABLE" -eq 1 ]; then
|
|
# flash unit present but not enabled and no sglang unit: still the only choice
|
|
INSTALLED_CHOICE=flash
|
|
fi
|
|
# The secondary run converges on its own lane's unit, whichever one is enabled: the
|
|
# lane its parent serves is, and the detection above follows that one. A lane not
|
|
# installed yet converges on nothing, and takes the target its parent passes.
|
|
if [ -n "$SECONDARY" ]; then
|
|
INSTALLED_CHOICE=""
|
|
if [ "$SECONDARY" = flash ] && [ "$FLASH_READABLE" -eq 1 ]; then INSTALLED_CHOICE=flash; fi
|
|
if [ "$SECONDARY" = 27b ] && [ "$SGL_READABLE" -eq 1 ]; then INSTALLED_CHOICE=27b; fi
|
|
fi
|
|
if [ "$INSTALLED_CHOICE" = "flash" ]; then
|
|
# Converge on the installed flash launch script (the unit only points at it;
|
|
# the engine flags and mounts live in $CONFIG_DIR/launch-flash.sh).
|
|
FLASH_LAUNCH="$CONFIG_DIR/launch-flash.sh"
|
|
CUR_REV=""; CUR_PORT=""; CUR_HF=""
|
|
if [ -r "$FLASH_LAUNCH" ]; then
|
|
CUR_REV="$(grep -oE -- '--revision [^ ]+' "$FLASH_LAUNCH" | head -1 | cut -d' ' -f2 || true)"
|
|
if grep -q 'sglang.launch_server' "$FLASH_LAUNCH"; then
|
|
# v1.5+ shape (SGLang, host networking): --port IS the host port.
|
|
CUR_PORT="$(grep -oE -- '--port [0-9]+' "$FLASH_LAUNCH" | head -1 | tr -dc '0-9' || true)"
|
|
CUR_HF="$(unit_hf_cache "$FLASH_LAUNCH")"
|
|
else
|
|
# v1.4 shape (vLLM, bridge networking): the host port is the -p mapping;
|
|
# its in-container --port 8000 must NOT be read as a host port. The
|
|
# upgrade regenerates the launcher on the new engine, keeping only
|
|
# port/HF/model choices.
|
|
CUR_PORT="$(grep -oE -- '-p [0-9]+:8000' "$FLASH_LAUNCH" | head -1 | grep -oE '^-p [0-9]+' | tr -dc '0-9' || true)"
|
|
CUR_HF="$(grep -oE -- '-v [^ :]+:/hf' "$FLASH_LAUNCH" | head -1 | sed -e 's/^-v //' -e 's|:/hf$||' | tr -s / || true)"
|
|
echo "NOTE: the installed flash lane is the v1.4 vLLM engine; this upgrade moves it to SGLang"
|
|
echo " (working prefix caching; see CHANGELOG v1.5). Port/cache/model choices are kept."
|
|
fi
|
|
# one slash at a time, as unit_hf_cache reads the cache (lanes.sh): a "//" kept as a choice forever
|
|
CUR_PLE="$(grep -oE -- '-v [^ :]+:/ple' "$FLASH_LAUNCH" | head -1 | sed -e 's/^-v //' -e 's|:/ple$||' | tr -s / || true)"
|
|
CUR_MODEL="$(grep -oE -- '--model-path [^ ]+' "$FLASH_LAUNCH" | head -1 | cut -d' ' -f2 || true)"
|
|
# The tier lives in the launcher as the concurrency it pins, so a re-run
|
|
# without FLASH_TIER keeps the tier the box is serving.
|
|
if [ -z "${FLASH_TIER_ENV:-}" ] && [ "$RECOMMENDED" -eq 0 ]; then
|
|
for t in context concurrency throughput; do
|
|
case "$t" in
|
|
context) mrr=4 ;;
|
|
concurrency) mrr=8 ;;
|
|
throughput) mrr=24 ;;
|
|
esac
|
|
if grep -q -- "--max-running-requests $mrr" "$FLASH_LAUNCH" 2>/dev/null; then
|
|
if [ "$t" != "$FLASH_TIER" ] && old_default_moves FLASH_TIER "$t"; then
|
|
echo "Moving the flash tier from $t to $FLASH_TIER, the default since $MOVED_TAG: $t is what installs before it"
|
|
echo " got, not a choice this box recorded. To keep it: FLASH_TIER=$t ./install.sh"
|
|
else
|
|
FLASH_TIER="$t"
|
|
echo "Keeping the installed flash tier: $t. Set FLASH_TIER on the command line to change it."
|
|
fi
|
|
fi
|
|
done
|
|
resolve_flash_tier_args
|
|
fi
|
|
# The two speculative-path knobs a box can turn off, read back like the tier: set to
|
|
# 0 on one run, both came back on at the next (found in review, 2026-09-24). A
|
|
# launcher that does not speculate carries neither whatever they were, and one
|
|
# rendered before a knob existed says nothing of it: those keep the defaults. The
|
|
# markers are comments of the template, since v1.8 and since v1.10.2.
|
|
if grep -q -- '--speculative-algorithm' "$FLASH_LAUNCH"; then
|
|
if [ -z "$_ENV_SPEC_TOKEN_MAP_SIZE" ] && [ "$RECOMMENDED" -eq 0 ] && grep -q 'Engine since v1.8' "$FLASH_LAUNCH"; then
|
|
CUR_MAP="$(grep -oE -- '--speculative-token-map /out/token-map-[0-9]+\.pt' "$FLASH_LAUNCH" | head -1 | sed -E 's/.*token-map-([0-9]+)\.pt/\1/' || true)"
|
|
if [ "${CUR_MAP:-0}" != "$SPEC_TOKEN_MAP_SIZE" ]; then
|
|
SPEC_TOKEN_MAP_SIZE="${CUR_MAP:-0}"; TOKEN_MAP_NAME="token-map-${SPEC_TOKEN_MAP_SIZE}.pt"
|
|
echo "Keeping the installed reduced draft vocabulary: SPEC_TOKEN_MAP_SIZE=$SPEC_TOKEN_MAP_SIZE. Pass SPEC_TOKEN_MAP_SIZE= to change."
|
|
fi
|
|
fi
|
|
if [ -z "$_ENV_FLASH_REPLAYSSM_SPEC" ] && [ "$RECOMMENDED" -eq 0 ] && [ "$FLASH_REPLAYSSM_SPEC" = "1" ] \
|
|
&& grep -q 'No --allow-auto-truncate' "$FLASH_LAUNCH" \
|
|
&& ! grep -q -- '--enable-linear-replayssm-spec' "$FLASH_LAUNCH"; then
|
|
FLASH_REPLAYSSM_SPEC=0; resolve_flash_tier_args
|
|
echo "Keeping the installed MTP verify state: FLASH_REPLAYSSM_SPEC=0. Pass FLASH_REPLAYSSM_SPEC=1 to change."
|
|
fi
|
|
fi
|
|
if [ -z "${_ENV_PLE_DIR:-}" ] && [ -n "$CUR_PLE" ] && [ "$CUR_PLE" != "$PLE_DIR" ]; then
|
|
PLE_DIR="$CUR_PLE"
|
|
echo "Keeping the installed PLE table location: $PLE_DIR. Pass PLE_DIR= to change."
|
|
fi
|
|
fi
|
|
# Under --recommended the 27B lane serves, as on a new box, and the run for the flash lane
|
|
# beside it takes that lane's default target.
|
|
if [ -z "$_ENV_MODEL_CHOICE" ] && [ "$LANE" != "flash" ] && { [ "$RECOMMENDED" -eq 0 ] || [ -n "$SECONDARY" ]; }; then
|
|
MODEL_CHOICE=flash; MODEL_REPO="$FLASH_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$FLASH_REV}"
|
|
if [ "$RECOMMENDED" -eq 0 ] && [ -n "${CUR_MODEL:-}" ] && [ "$CUR_MODEL" = "$FLASH_NVDA_REPO" ]; then
|
|
MODEL_CHOICE=flash-nvda; MODEL_REPO="$FLASH_NVDA_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$FLASH_NVDA_REV}"
|
|
elif [ "$RECOMMENDED" -eq 0 ] && [ -n "${CUR_MODEL:-}" ] && [ "$CUR_MODEL" = "$FLASH_UNC_REPO" ]; then
|
|
MODEL_CHOICE=flash-uncensored; MODEL_REPO="$FLASH_UNC_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$FLASH_UNC_REV}"
|
|
fi
|
|
LANE=flash; UNIT_NAME="qwen38-flash.service"
|
|
if [ "$RECOMMENDED" -eq 1 ]; then
|
|
echo "--recommended: the flash lane takes its default target, $MODEL_CHOICE ($MODEL_REPO)."
|
|
else
|
|
echo "Keeping the installed target model: $MODEL_CHOICE ($MODEL_REPO). Pass MODEL_CHOICE= to change."
|
|
fi
|
|
fi
|
|
elif [ "$INSTALLED_CHOICE" = "27b" ]; then
|
|
UNIT_PATH="$SGL_UNIT_PATH"
|
|
CUR_MODEL="$(grep -oE -- '--model-path [^ ]+' "$UNIT_PATH" | head -1 | cut -d' ' -f2 || true)"
|
|
# The target's --revision (never matches --speculative-draft-model-revision:
|
|
# that flag has a single dash before "revision")
|
|
CUR_REV="$(grep -oE -- '--revision [^ ]+' "$UNIT_PATH" | head -1 | cut -d' ' -f2 || true)"
|
|
CUR_PORT="$(grep -oE -- '--port [0-9]+' "$UNIT_PATH" | head -1 | tr -dc '0-9' || true)"
|
|
CUR_HF="$(unit_hf_cache "$UNIT_PATH")"
|
|
if [ -z "$_ENV_MODEL_CHOICE" ] && [ "$RECOMMENDED" -eq 0 ] && [ -n "$CUR_MODEL" ] && [ "$CUR_MODEL" != "$MODEL_REPO" ]; then
|
|
case "$CUR_MODEL" in
|
|
"$STOCK_REPO") MODEL_CHOICE=stock; MODEL_REPO="$STOCK_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$STOCK_REV}" ;;
|
|
"$UNC_REPO") MODEL_CHOICE=uncensored; MODEL_REPO="$UNC_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$UNC_REV}" ;;
|
|
"$FP8_REPO") MODEL_CHOICE=fp8; MODEL_REPO="$FP8_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$FP8_REV}" ;;
|
|
"$UNCFP8_REPO") MODEL_CHOICE=uncensored-fp8; MODEL_REPO="$UNCFP8_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$UNCFP8_REV}" ;;
|
|
"$ARETE_REPO") MODEL_CHOICE=arete; MODEL_REPO="$ARETE_REPO"; MODEL_REV="${_ENV_MODEL_REV:-$ARETE_REV}" ;;
|
|
*) KEEP_MODEL_VERBATIM=1; MODEL_CHOICE=custom; MODEL_REPO="$CUR_MODEL" ;;
|
|
esac
|
|
LANE=27b; UNIT_NAME="qwen38-sglang.service"
|
|
if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then
|
|
echo "NOTE: keeping the custom --model-path already installed ($CUR_MODEL)."
|
|
echo " Its download and template steps are skipped (it is already serving from cache)."
|
|
echo " Pass MODEL_CHOICE=stock, uncensored, fp8, uncensored-fp8 or arete to override."
|
|
else
|
|
echo "Keeping the installed target model: $MODEL_CHOICE ($MODEL_REPO). Pass MODEL_CHOICE= to change."
|
|
fi
|
|
fi
|
|
# Same promise for the drafter: a box rolled back to the BF16 draft via the
|
|
# env override keeps it across plain re-runs, the way MODEL_CHOICE is kept. Each of the
|
|
# four follows the unit unless it is passed: with any one of them passed, all four fell
|
|
# back to the defaults, so DRAFT2_TOKENS=8 on a box serving the BF16 draft moved it to the
|
|
# NVFP4 one without a word (found in review, 2026-09-24). The revision and the
|
|
# quantization belong to the repo, so they follow the unit only with its repo.
|
|
CUR_DRAFT="$(grep -oE -- '--speculative-draft-model-path [^ ]+' "$UNIT_PATH" | head -1 | cut -d' ' -f2 || true)"
|
|
CUR_DRAFT_REV="$(grep -oE -- '--speculative-draft-model-revision [^ ]+' "$UNIT_PATH" | head -1 | cut -d' ' -f2 || true)"
|
|
CUR_DRAFT_QUANT="$(grep -oE -- '--speculative-draft-model-quantization [^ ]+' "$UNIT_PATH" | head -1 | cut -d' ' -f2 || true)"
|
|
CUR_DRAFT_TOKENS="$(grep -oE -- '--speculative-num-draft-tokens [0-9]+' "$UNIT_PATH" | head -1 | tr -dc '0-9' || true)"
|
|
if [ -z "$_ENV_DRAFT2_REPO" ] && [ "$RECOMMENDED" -eq 0 ] && [ -n "$CUR_DRAFT" ] && [ "$CUR_DRAFT" != "$DRAFT2_REPO" ]; then
|
|
DEF_DRAFT2="DRAFT2_REPO=$DRAFT2_REPO DRAFT2_REV=$DRAFT2_REV DRAFT2_QUANT=$DRAFT2_QUANT DRAFT2_TOKENS=$DRAFT2_TOKENS"
|
|
# The BF16 draft at depth 8 was the default of v1.2.3 to v1.8.6 and is the documented
|
|
# rollback since; a box that only ever updated kept it and never got v1.9's draft (found
|
|
# in review, 2026-09-24). Whichever it is on this box decides (old_default_moves), unless
|
|
# one of the drafter pins is passed: that run is about the drafter, and it says how.
|
|
if [ -z "$_ENV_DRAFT2_REV$_ENV_DRAFT2_QUANT$_ENV_DRAFT2_TOKENS" ] \
|
|
&& old_default_moves DRAFT2 "$CUR_DRAFT ($CUR_DRAFT_QUANT, D=$CUR_DRAFT_TOKENS)"; then
|
|
echo "Moving the 27B drafter from $CUR_DRAFT (D=$CUR_DRAFT_TOKENS, $CUR_DRAFT_QUANT) to $DRAFT2_REPO (D=$DRAFT2_TOKENS,"
|
|
echo " $DRAFT2_QUANT), the default since $MOVED_TAG and measured +30% on the reference box (lossless): the BF16"
|
|
echo " draft is what installs before it got, not a choice this box recorded. To keep it:"
|
|
echo " DRAFT2_REPO=$CUR_DRAFT DRAFT2_REV=$CUR_DRAFT_REV DRAFT2_QUANT=$CUR_DRAFT_QUANT DRAFT2_TOKENS=$CUR_DRAFT_TOKENS ./install.sh"
|
|
else
|
|
DRAFT2_REPO="$CUR_DRAFT"
|
|
[ -z "$_ENV_DRAFT2_REV" ] && [ -n "$CUR_DRAFT_REV" ] && DRAFT2_REV="$CUR_DRAFT_REV"
|
|
[ -z "$_ENV_DRAFT2_QUANT" ] && [ -n "$CUR_DRAFT_QUANT" ] && DRAFT2_QUANT="$CUR_DRAFT_QUANT"
|
|
[ -z "$_ENV_DRAFT2_TOKENS" ] && [ -n "$CUR_DRAFT_TOKENS" ] && DRAFT2_TOKENS="$CUR_DRAFT_TOKENS"
|
|
echo "Keeping the installed drafter: $DRAFT2_REPO (D=$DRAFT2_TOKENS, $DRAFT2_QUANT). Pass DRAFT2_REPO= to change."
|
|
if [ "$CUR_DRAFT" = "z-lab/Qwen3.8-27B-DFlash2" ]; then
|
|
echo "NOTE: that is the BF16 draft installs used before v1.9. The default since v1.9 drafts from a"
|
|
echo " calibrated NVFP4 head, measured +30% there on the reference box (lossless). To move to it:"
|
|
echo " $DEF_DRAFT2 ./install.sh"
|
|
fi
|
|
fi
|
|
elif [ -z "$_ENV_DRAFT2_TOKENS" ] && [ "$RECOMMENDED" -eq 0 ] && [ -n "$CUR_DRAFT_TOKENS" ] && [ "$CUR_DRAFT_TOKENS" != "$DRAFT2_TOKENS" ]; then
|
|
DRAFT2_TOKENS="$CUR_DRAFT_TOKENS"
|
|
echo "Keeping the installed draft depth: D=$DRAFT2_TOKENS. Pass DRAFT2_TOKENS= to change."
|
|
fi
|
|
fi
|
|
if [ -n "$INSTALLED_CHOICE" ]; then
|
|
if [ -z "$_ENV_PORT" ] && [ -n "${CUR_PORT:-}" ] && [ "$CUR_PORT" != "$PORT" ]; then
|
|
PORT="$CUR_PORT"
|
|
echo "Keeping the installed port: :$PORT. Pass PORT= to change."
|
|
fi
|
|
if [ -z "$_ENV_HF_CACHE" ] && [ -n "${CUR_HF:-}" ] && [ "$CUR_HF" != "$HF_CACHE" ]; then
|
|
HF_CACHE="$CUR_HF"
|
|
echo "Keeping the installed HF cache location: $HF_CACHE. Pass HF_CACHE= to change."
|
|
fi
|
|
# The same promise the context mode gets, for the same reason: a box hardened to
|
|
# localhost must not be reopened by a plain update. An installed choice wins over a
|
|
# default, both ways. The other promise, that a box running the engine on the network
|
|
# keeps it across updates (v1.17.0), holds since v1.36.0 for a choice only: the 0.0.0.0
|
|
# every install got before v1.17.0 moves to 127.0.0.1 (old_default_moves above).
|
|
if [ -z "${_ENV_ENGINE_BIND:-}" ] && [ "$RECOMMENDED" -eq 1 ]; then
|
|
export ENGINE_BIND # the vLLM side lanes follow the text lane's bind (vllm-lane.sh), as when it moves
|
|
elif [ -z "${_ENV_ENGINE_BIND:-}" ]; then
|
|
# Read where the engine's --host really is: the 27B unit, or the flash launcher (its
|
|
# unit only points at the script). This read $UNIT_PATH, which only the 27B branch
|
|
# sets, so every re-run of a flash box printed "UNIT_PATH: unbound variable" and put
|
|
# the engine back on 127.0.0.1 over the box's own choice (found in review, 2026-09-24).
|
|
if [ "$INSTALLED_CHOICE" = "flash" ]; then BIND_FROM="$FLASH_LAUNCH"; else BIND_FROM="$UNIT_PATH"; fi
|
|
CUR_BIND="$(grep -oE -- '--host [0-9.]+' "$BIND_FROM" 2>/dev/null | head -1 | cut -d' ' -f2 || true)"
|
|
if [ -n "$CUR_BIND" ] && [ "$CUR_BIND" != "$ENGINE_BIND" ]; then
|
|
if old_default_moves ENGINE_BIND "$CUR_BIND"; then
|
|
echo "Moving the engine bind from $CUR_BIND to $ENGINE_BIND, the default since $MOVED_TAG: $CUR_BIND is what"
|
|
echo " installs before it got, not a choice this box recorded. A client on another machine uses the"
|
|
echo " proxy, which serves every route of the engine. To keep it: ENGINE_BIND=$CUR_BIND ./install.sh"
|
|
# the side lanes this run updates read their own unit's bind before the text lane's
|
|
# (vllm-lane.sh), and theirs came from it: they move with it
|
|
export ENGINE_BIND
|
|
else
|
|
ENGINE_BIND="$CUR_BIND"
|
|
echo "Keeping the installed engine bind: $ENGINE_BIND. Pass ENGINE_BIND= to change."
|
|
fi
|
|
fi
|
|
fi
|
|
# The unit name, not $KEEPALIVE_UNIT: that variable is set 700 lines below this block.
|
|
if [ -z "${_ENV_PROXY_BIND:-}" ] && [ "$RECOMMENDED" -eq 0 ] && [ -r "/etc/systemd/system/qwen38-keepalive.service" ]; then
|
|
CUR_PBIND="$(grep -oE -- 'PROXY_BIND=[0-9.]+' "/etc/systemd/system/qwen38-keepalive.service" | head -1 | cut -d= -f2 || true)"
|
|
if [ -n "$CUR_PBIND" ] && [ "$CUR_PBIND" != "$PROXY_BIND" ]; then
|
|
PROXY_BIND="$CUR_PBIND"
|
|
echo "Keeping the installed proxy bind: $PROXY_BIND. Pass PROXY_BIND= to change."
|
|
fi
|
|
fi
|
|
check_binds
|
|
if [ "$INSTALLED_CHOICE" = "27b" ] && [ "$LANE" != "flash" ] && [ -z "$_ENV_CONTEXT_MODE" ] && [ "$MEM_CLASS" = 64 ]; then
|
|
# A 64 GB box serves the native window whatever its unit says and whatever the old default
|
|
# was: this convergence moved it to the 1m one, said so, and the 64 GB check below then refused
|
|
# a CONTEXT_MODE nobody passed (found in review, 2026-10-23). The default below says which.
|
|
if grep -q -- '--context-length 1010000' "$SGL_UNIT_PATH" 2>/dev/null; then
|
|
echo "The installed 1m window needs a 128 GB DGX Spark: this 64 GB box goes back to the native one."
|
|
fi
|
|
elif [ "$INSTALLED_CHOICE" = "27b" ] && [ "$LANE" != "flash" ] && [ -z "$_ENV_CONTEXT_MODE" ] && [ "$RECOMMENDED" -eq 0 ]; then
|
|
if grep -q -- '--context-length 1010000' "$SGL_UNIT_PATH"; then
|
|
CONTEXT_MODE=1m
|
|
echo "Keeping the installed context mode: 1m. Pass CONTEXT_MODE=native to change."
|
|
elif [ -z "$CONTEXT_MODE" ]; then
|
|
# The other direction, and since v1.12.1 it has to exist: with 1m as the
|
|
# default, a plain re-run on a box installed native would patch YaRN into
|
|
# its cached configs and move its memory fraction, which is not what an
|
|
# update means. An installed choice wins over a default, both ways; native
|
|
# as the default every install got before v1.12.1 is not one (since v1.36.0).
|
|
if [ "$NO_SERVICE" -eq 0 ] && old_default_moves CONTEXT_MODE native; then
|
|
echo "Moving the 27B lane from the native 262144 window to the 1m one, the default since $MOVED_TAG: native"
|
|
echo " is what installs before it got, not a choice this box recorded. Its next boot takes about"
|
|
echo " 9 minutes. To keep it: CONTEXT_MODE=native ./install.sh"
|
|
else
|
|
CONTEXT_MODE=native
|
|
echo "Keeping the installed context mode: native. Pass CONTEXT_MODE=1m to change."
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
# (die() is defined at the top of this file, above the root wall that is now the
|
|
# first refusal to call it. It moved out of the steps in v1.10.2 because of the
|
|
# port refusals below: a function defined under a call that fires printed
|
|
# "command not found" and lost the message. tests/test_install_preflight.py
|
|
# pins that, tests/test_install_root_refusal.py pins the wall.)
|
|
|
|
# PORT feeds the arithmetic below, so it is validated before it is used.
|
|
[[ "$PORT" =~ ^[0-9]+$ ]] || die "PORT must be a number (got '$PORT')"
|
|
if [ -z "$_ENV_PROXY_PORT" ] && [ -r "/etc/systemd/system/qwen38-keepalive.service" ]; then
|
|
CUR_PROXY="$(grep -oE 'keepalive-proxy\.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service | head -1 | tr -dc '0-9' || true)"
|
|
[ -n "${CUR_PROXY:-}" ] && PROXY_PORT="$CUR_PROXY"
|
|
fi
|
|
PROXY_PORT="${PROXY_PORT:-$((PORT+1))}"
|
|
|
|
# A non-number dies here with its name on it, and the engine and its proxy may
|
|
# never share one (each check would see "its" port free, then both services
|
|
# would fight over the same socket at runtime).
|
|
[[ "$PROXY_PORT" =~ ^[0-9]+$ ]] || die "PROXY_PORT must be a number (got '$PROXY_PORT')"
|
|
[ "$PORT" != "$PROXY_PORT" ] || die "PORT and PROXY_PORT are both $PORT: the engine and its keepalive proxy cannot share a port"
|
|
|
|
if [ "$NO_SERVICE" -eq 1 ] && [ "$NO_START" -eq 1 ]; then
|
|
printf -- '--no-start controls the systemd service; with --no-service there is no service (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_OPENCODE" -eq 1 ] && [ "$WITH_OPENCODE" -eq 1 ]; then
|
|
printf -- '--no-opencode and --with-opencode contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
# The opencode on/off choice persists like the other choices: a marker file in
|
|
# CONFIG_DIR, written by --no-opencode, removed by --with-opencode. The switch
|
|
# script and the cockpit read the same marker.
|
|
OC_OFF_MARK="$CONFIG_DIR/opencode.off"
|
|
OPENCODE=1
|
|
if [ "$NO_OPENCODE" -eq 1 ]; then
|
|
OPENCODE=0
|
|
elif [ "$RECOMMENDED" -eq 1 ] && [ -f "$OC_OFF_MARK" ]; then
|
|
echo "--recommended: the opencode integration comes back (your earlier --no-opencode), as on a new box."
|
|
elif [ "$WITH_OPENCODE" -eq 0 ] && [ -f "$OC_OFF_MARK" ]; then
|
|
OPENCODE=0
|
|
echo "Keeping the opencode integration off (your earlier --no-opencode). Pass --with-opencode to re-enable."
|
|
fi
|
|
# Before anything is pulled or downloaded: this was refused at step 7, after the image,
|
|
# the checkpoints and the engine's configs (found in review, 2026-09-24).
|
|
if [ "$OPENCODE" -eq 1 ] && [ -n "$_ENV_OPENCODE_VERSION" ] && [ -z "$_ENV_OPENCODE_SHA256" ]; then
|
|
die "OPENCODE_VERSION=$OPENCODE_VERSION needs OPENCODE_SHA256 too (GitHub's digest of opencode-linux-arm64.tar.gz for that release): a version with no checksum is not a pin"
|
|
fi
|
|
# A secondary run installs the lane it was started for, and nothing else.
|
|
if [ -n "$SECONDARY" ] && [ "$LANE" != "$SECONDARY" ]; then
|
|
die "internal error: a run for the $SECONDARY lane resolved the $LANE lane (MODEL_CHOICE=$MODEL_CHOICE). Please open an issue with this line."
|
|
fi
|
|
# The same refusal as the one near the top, once the lane is final: without
|
|
# MODEL_CHOICE that one reads LANE before the convergence has moved it to the
|
|
# installed flash lane, and step 6 then patched YaRN into the flash checkpoint's
|
|
# config.json in the shared HF cache (found in review, 2026-09-24).
|
|
if [ "$LANE" = "flash" ] && [ "$CONTEXT_MODE" = "1m" ]; then
|
|
printf 'ERROR: CONTEXT_MODE=1m is a 27B mode, and this box serves the flash lane. Flash-Next serves\n' >&2
|
|
printf ' its full native 262144 window. Drop CONTEXT_MODE, or pass a 27B MODEL_CHOICE with it.\n' >&2
|
|
exit 1
|
|
fi
|
|
# The default context mode, resolved here because everything it depends on (the
|
|
# lane, --no-service, and what the installed unit already says) is only known
|
|
# now. An explicit CONTEXT_MODE still refuses the combinations it cannot serve,
|
|
# a few lines below; a default must never refuse anything.
|
|
# A 64 GB box serves neither the flash lane (its checkpoint alone is 135.3 GB) nor the 1M window,
|
|
# whose KV pool is more memory than the box has.
|
|
if [ "$MEM_CLASS" = 64 ]; then
|
|
# run.sh serves the native unit's settings, the ones the 64 GB unit exists to change (found in
|
|
# review, 2026-10-23): a 64 GB box gets the 27B as a service, its unit sized for it
|
|
[ "$NO_SERVICE" -eq 0 ] || die "--no-service prepares ./run.sh, which runs the 27B with the memory settings of a 128 GB DGX Spark, and this box is a 64 GB one. Drop --no-service: the service's unit is sized for this box."
|
|
[ "$LANE" != flash ] || die "The flash lane needs a 128 GB DGX Spark (its checkpoint alone is 135.3 GB), and this box is a 64 GB one. MODEL_CHOICE=stock ./install.sh serves the 27B, sized for it."
|
|
# custom is a 27B unit serving a model of its own, whose size boxmem.py cannot know: kept, as on
|
|
# any box (it read as an FP8 target, and the box could not be updated, found in review, 2026-10-23)
|
|
[ "$MODEL_CHOICE" = custom ] || target_fits "$MODEL_CHOICE" || die "MODEL_CHOICE=$MODEL_CHOICE (Qwen's FP8 weights, 30.9 GB) leaves the 27B's KV pool too little on a 64 GB DGX Spark: MODEL_CHOICE=stock, uncensored or arete (NVFP4) serve here."
|
|
[ "$CONTEXT_MODE" != 1m ] || die "CONTEXT_MODE=1m needs a 128 GB DGX Spark (the 1M window's KV pool alone is more memory than this box has), and this box is a 64 GB one. Drop CONTEXT_MODE: the 27B serves its native 262144 window here."
|
|
fi
|
|
if [ -z "$CONTEXT_MODE" ]; then
|
|
if [ "$LANE" = "flash" ]; then
|
|
CONTEXT_MODE=native
|
|
elif [ "$MEM_CLASS" = 64 ]; then
|
|
CONTEXT_MODE=native
|
|
echo "Context mode: native (262144 tokens), the one a 64 GB DGX Spark holds."
|
|
elif [ "$NO_SERVICE" -eq 1 ]; then
|
|
CONTEXT_MODE=native
|
|
echo "--no-service installs the native 262144 window (1m needs the keepalive proxy service)."
|
|
else
|
|
CONTEXT_MODE=1m
|
|
echo "Context mode: 1m (1,010,000 tokens). Pass CONTEXT_MODE=native for the 262144 window."
|
|
fi
|
|
fi
|
|
|
|
if [ "$NO_COCKPIT" -eq 1 ] && [ "$WITH_COCKPIT" -eq 1 ]; then
|
|
printf -- '--no-cockpit and --with-cockpit contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
# The same for the image lane: both were taken, and --no-image won silently at the end of
|
|
# the install (found in review, 2026-09-24).
|
|
if [ "$NO_IMAGE" -eq 1 ] && [ "$WITH_IMAGE" -eq 1 ]; then
|
|
printf -- '--no-image and --with-image contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
# The same for the video lane and the two text lanes.
|
|
if [ "$NO_VIDEO" -eq 1 ] && [ "$WITH_VIDEO" -eq 1 ]; then
|
|
printf -- '--no-video and --with-video contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_FLASH" -eq 1 ] && [ "$WITH_FLASH" -eq 1 ]; then
|
|
printf -- '--no-flash and --with-flash contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_27B" -eq 1 ] && [ "$WITH_27B" -eq 1 ]; then
|
|
printf -- '--no-27b and --with-27b contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_KOLIBRI" -eq 1 ] && [ "$WITH_KOLIBRI" -eq 1 ]; then
|
|
printf -- '--no-kolibri and --with-kolibri contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_NEMOTRON" -eq 1 ] && [ "$WITH_NEMOTRON" -eq 1 ]; then
|
|
printf -- '--no-nemotron and --with-nemotron contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_NEMOTRON_SUPER" -eq 1 ] && [ "$WITH_NEMOTRON_SUPER" -eq 1 ]; then
|
|
printf -- '--no-nemotron-super and --with-nemotron-super contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_FLASH_LOCAL" -eq 1 ] && [ "$WITH_FLASH_LOCAL" -eq 1 ]; then
|
|
printf -- '--no-flash-local and --with-flash-local contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_ORNITH_122B" -eq 1 ] && [ "$WITH_ORNITH_122B" -eq 1 ]; then
|
|
printf -- '--no-ornith-122b and --with-ornith-122b contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_FLASH_UNSLOTH" -eq 1 ] && [ "$WITH_FLASH_UNSLOTH" -eq 1 ]; then
|
|
printf -- '--no-flash-unsloth and --with-flash-unsloth contradict each other (drop one flag)\n' >&2; exit 1
|
|
fi
|
|
|
|
# --no-start and --no-service both return before the image step, so the flag would be
|
|
# accepted and silently do nothing. Say so here rather than at the end of a long install.
|
|
if [ "$WITH_IMAGE" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-image needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-image.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_VIDEO" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-video needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-video.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_KOLIBRI" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-kolibri needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-kolibri.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_NEMOTRON" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-nemotron needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-nemotron.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_NEMOTRON_SUPER" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-nemotron-super needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-nemotron-super.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_FLASH_LOCAL" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-flash-local needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-flash-local.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_ORNITH_122B" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-ornith-122b needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-ornith-122b.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [ "$WITH_FLASH_UNSLOTH" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--with-flash-unsloth needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
|
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-flash-unsloth.sh on its own.\n' >&2
|
|
exit 1
|
|
fi
|
|
# the same for the whole box: --no-service did none of it, --no-start the other text lane alone
|
|
# (found in review, 2026-10-15)
|
|
if [ "$ALL_WEIGHTS" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
|
printf -- '--all-weights needs the full install: it installs every lane whole and proves each it builds.\n' >&2
|
|
printf -- 'Run ./install.sh --all-weights without --no-start/--no-service.\n' >&2
|
|
exit 1
|
|
fi
|
|
# Since v1.12 the cockpit is part of a plain install: the one-liner has to leave
|
|
# a box you can open and drive, not a box plus a second command to find in a
|
|
# README. The choice persists exactly like the opencode one, in a marker file,
|
|
# so --no-cockpit is not quietly undone by the next upgrade.
|
|
CK_OFF_MARK="$CONFIG_DIR/cockpit.off"
|
|
COCKPIT=1
|
|
if [ "$NO_COCKPIT" -eq 1 ]; then
|
|
COCKPIT=0
|
|
if [ "$PLAN_ONLY" -eq 0 ]; then
|
|
mkdir -p "$CONFIG_DIR"
|
|
[ -f "$CK_OFF_MARK" ] || printf 'disabled with ./install.sh --no-cockpit on %s\n' "$(date -u +%Y-%m-%dT%H:%MZ)" > "$CK_OFF_MARK"
|
|
fi
|
|
elif [ "$WITH_COCKPIT" -eq 1 ]; then
|
|
[ "$PLAN_ONLY" -eq 1 ] || rm -f "$CK_OFF_MARK"
|
|
elif [ "$RECOMMENDED" -eq 1 ] && [ -f "$CK_OFF_MARK" ]; then
|
|
[ "$PLAN_ONLY" -eq 1 ] || rm -f "$CK_OFF_MARK"
|
|
echo "--recommended: the cockpit comes back (your earlier --no-cockpit), as on a new box."
|
|
elif [ -f "$CK_OFF_MARK" ]; then
|
|
COCKPIT=0
|
|
echo "Keeping the cockpit off (your earlier --no-cockpit). Pass --with-cockpit to re-enable."
|
|
fi
|
|
# --no-service means no systemd at all, and the cockpit is a systemd unit.
|
|
[ "$NO_SERVICE" -eq 1 ] && COCKPIT=0
|
|
# Since v1.20 a plain run installs every lane: the text lane MODEL_CHOICE names serves,
|
|
# the other text lane is installed beside it, ready to load, and so are the side lanes.
|
|
# --no-<lane> leaves one out of the run that passes it, and of that run only. It was kept in a
|
|
# marker file that left the lane out of every update after it, behind and said only in a line of
|
|
# the log (Hasan, 2026-10-22: "Personne ne doit rester silencieusement derrière"). A marker an
|
|
# older release wrote brings its lane back once, said, and is removed. A lane already on the box
|
|
# that a run leaves out stays where it is, not updated by that run; the text lane a box booting a
|
|
# side lane served last gets this release's units and none of its downloads while it is left out
|
|
# or not prepared (issue #57, below: LEFT_OUT).
|
|
lane_title(){ # $1 a lane, by its flag's name: the name a run says
|
|
case "$1" in
|
|
27b) echo "Qwen3.8 27B" ;; flash) echo "Qwen3.8 Flash-Next" ;; image) echo "image (Qwen-Image 2.1)" ;;
|
|
video) echo "video (MiniMax-H3)" ;; kolibri) echo "Kolibri-1" ;; nemotron) echo "Nemotron 3.5 Bolt" ;;
|
|
nemotron-super) echo "Nemotron 3.5 Super VL" ;; flash-local) echo "Qwen3.8 Flash-Next FP4-Local" ;;
|
|
ornith-122b) echo "Ornith 1.5 122B" ;; flash-unsloth) echo "Qwen3.8 Flash-Next Unsloth GGUF" ;; *) echo "$1" ;;
|
|
esac
|
|
}
|
|
lane_wanted(){ # $1 lane (image, video, flash, 27b), $2 --no-$1 given, $3 --with-$1 given: sets WANT
|
|
local mark="$CONFIG_DIR/$1.off"
|
|
WANT=1
|
|
# A lane a 64 GB box cannot hold is left out of it whatever was asked, and said once below.
|
|
if [ "$MEM_CLASS" = 64 ] && ! lane_fits "$1"; then
|
|
[ "$3" -eq 0 ] || die "The $(lane_title "$1") lane needs a 128 GB DGX Spark, and this box is a 64 GB one. Drop --with-$1."
|
|
# an older release's --no-$1 is no choice about a lane this box cannot hold: it goes, unsaid,
|
|
# where it stayed for good, and uninstall.sh --list called the lane left out (review, 2026-10-23)
|
|
[ "$PLAN_ONLY" -eq 1 ] || rm -f "$mark"
|
|
WANT=0; TOO_BIG+=("$1"); return 0
|
|
fi
|
|
if [ "$2" -eq 1 ]; then
|
|
WANT=0
|
|
! serves_anyway "$1" || serves_said "$1"
|
|
elif [ -f "$mark" ] && [ "$3" -eq 0 ]; then
|
|
echo "Your earlier --no-$1 is no longer remembered ($(head -1 "$mark" 2>/dev/null || echo 'its marker')): a --no-$1 counts for the run that passes it only now, so the $(lane_title "$1") lane is back in this run. Pass --no-$1 on each run to keep it out."
|
|
fi
|
|
[ "$PLAN_ONLY" -eq 1 ] || rm -f "$mark"
|
|
}
|
|
# The text lane this run serves is brought up to date whatever its flag says: ./install.sh --help
|
|
# leaves a lane out "when it is not the one serving". It said "Leaving the flash lane out" over the
|
|
# run that updated it (issue #57). True, and said, when $1 is that lane.
|
|
serves_anyway(){ [ "$1" = "$LANE" ] && [ "$SIDE_BOOT" -eq 0 ]; } # $1 a lane left out
|
|
# Said of it, without "brought up to date": on a GPU outside its ATS mode the flash lane that serves
|
|
# gets its units only, and the run then says so (issue #54; both said, found in review, 2026-10-21).
|
|
serves_said(){ echo "The ${1/27b/27B} lane is the one this run serves: --no-$1 leaves nothing out of it."; }
|
|
WANT_IMAGE=0; WANT_VIDEO=0; WANT_FLASH=0; WANT_27B=0; WANT_KOLIBRI=0; WANT_NEMOTRON=0; WANT_NEMOTRON_SUPER=0; WANT_FLASH_LOCAL=0; WANT_ORNITH_122B=0; WANT_FLASH_UNSLOTH=0
|
|
TOO_BIG=()
|
|
if [ -z "$SECONDARY" ]; then
|
|
lane_wanted image "$NO_IMAGE" "$WITH_IMAGE"; WANT_IMAGE="$WANT"
|
|
lane_wanted video "$NO_VIDEO" "$WITH_VIDEO"; WANT_VIDEO="$WANT"
|
|
lane_wanted flash "$NO_FLASH" "$WITH_FLASH"; WANT_FLASH="$WANT"
|
|
lane_wanted 27b "$NO_27B" "$WITH_27B"; WANT_27B="$WANT"
|
|
lane_wanted kolibri "$NO_KOLIBRI" "$WITH_KOLIBRI"; WANT_KOLIBRI="$WANT"
|
|
lane_wanted nemotron "$NO_NEMOTRON" "$WITH_NEMOTRON"; WANT_NEMOTRON="$WANT"
|
|
lane_wanted nemotron-super "$NO_NEMOTRON_SUPER" "$WITH_NEMOTRON_SUPER"; WANT_NEMOTRON_SUPER="$WANT"
|
|
lane_wanted flash-local "$NO_FLASH_LOCAL" "$WITH_FLASH_LOCAL"; WANT_FLASH_LOCAL="$WANT"
|
|
lane_wanted ornith-122b "$NO_ORNITH_122B" "$WITH_ORNITH_122B"; WANT_ORNITH_122B="$WANT"
|
|
lane_wanted flash-unsloth "$NO_FLASH_UNSLOTH" "$WITH_FLASH_UNSLOTH"; WANT_FLASH_UNSLOTH="$WANT"
|
|
fi
|
|
# The Unsloth GGUF lane's target: its installer keeps the one its unit serves, and UD-Q4_K_XL (flash-unsloth) is what
|
|
# v1.48 installed by default. Such a unit moves to the default since v1.49.0, UD-IQ3_XXS (decision 1376), as an old
|
|
# default does (old_default_moves above), handed to the installer as FLASH_UNSLOTH_TARGET; one given on the command
|
|
# line, or ./install.sh --recommended (the installer's default whatever the unit names), decides instead.
|
|
if [ "$WANT_FLASH_UNSLOTH" -eq 1 ] && [ -z "$_ENV_FLASH_UNSLOTH_TARGET" ] && [ "$RECOMMENDED" -eq 0 ]; then
|
|
_fu_cur="$(flash_unsloth_target "$FLASH_UNSLOTH_UNIT_PATH" "$REPO_DIR/install-flash-unsloth.sh")"
|
|
_fu_def="$(sed -n 's/^FLASH_UNSLOTH_DEFAULT="\([a-z0-9-]*\)"$/\1/p' "$REPO_DIR/install-flash-unsloth.sh" 2>/dev/null || true)"
|
|
if [ -n "$_fu_cur" ] && [ -n "$_fu_def" ] && [ "$_fu_cur" != "$_fu_def" ] && old_default_moves FLASH_UNSLOTH_TARGET "$_fu_cur"; then
|
|
echo "Moving the Unsloth GGUF lane from $_fu_cur to $_fu_def, the default since $MOVED_TAG: $_fu_cur is what installs"
|
|
echo " before it got, not a choice this box recorded. To keep it: FLASH_UNSLOTH_TARGET=$_fu_cur ./install.sh"
|
|
export FLASH_UNSLOTH_TARGET="$_fu_def"
|
|
fi
|
|
unset _fu_cur _fu_def
|
|
fi
|
|
too_big(){ local l; for l in ${TOO_BIG[@]+"${TOO_BIG[@]}"}; do [ "$l" = "$1" ] && return 0; done; return 1; } # $1 a lane
|
|
if [ "${#TOO_BIG[@]}" -gt 0 ]; then
|
|
# the lanes that fit, as boxmem.py decides them, rather than a second list of them here (review,
|
|
# 2026-10-23); the speech lane is installed by its own script
|
|
_fit=(); _speech=""
|
|
for _l in $(fitting_lanes); do
|
|
if [ "$_l" = speech ]; then _speech=", and the speech lane (./install-speech.sh)"; else _fit+=("$(lane_title "$_l")"); fi
|
|
done
|
|
_fits=""; for _i in "${!_fit[@]}"; do
|
|
if [ "$_i" -eq 0 ]; then _fits="${_fit[$_i]}"; elif [ "$_i" -eq $((${#_fit[@]} - 1)) ]; then _fits+=" and ${_fit[$_i]}"; else _fits+=", ${_fit[$_i]}"; fi
|
|
done
|
|
_big=""; for _l in "${TOO_BIG[@]}"; do _big+="${_big:+, }$(lane_title "$_l")"; done
|
|
echo "This box is a 64 GB DGX Spark: the lanes that fit it are the $_fits here$_speech. Left out, as they need a 128 GB one: $_big."
|
|
unset _big _l _fit _fits _speech _i
|
|
fi
|
|
|
|
# The image, video, Kolibri and Nemotron lanes are installed on demand: a run puts in their units
|
|
# (--units-only, what needs root), and the cockpit's first Load of each builds its runtime
|
|
# as the user (--prepare) and fetches its weights (its switch). A lane already prepared
|
|
# (its runtime on the box, as on every box installed before this) is updated whole, as
|
|
# before; --all-weights, or a lane asked for by name (--with-<lane>), is installed whole now
|
|
# and proved when it is new. A lane counts as on the box once its runtime is begun: its venv
|
|
# for the image and video lanes, the image its unit names for Kolibri (tagged once built), and for
|
|
# a Nemotron lane that image with its own checkpoint (the image is the two lanes').
|
|
# The venv alone, not the note of its wheel: a lane installed whole before that note existed
|
|
# (v1.24.0 for the image lane, v1.25.0 for the video lane) has none and was given its units
|
|
# only, its runtime left as it was (found in review, 2026-10-15); a first Load that stopped
|
|
# on the way is finished by the update. The cockpit reads the note, which the installer writes
|
|
# once the whole runtime is in, to build what a Load needs first (dashboard/cockpit.py).
|
|
side_lane_dir(){ # $1 image|video: the folder its unit runs in
|
|
local unit="/etc/systemd/system/qwen38-$1.service" dir
|
|
dir="$({ grep -m1 -E '^WorkingDirectory=' "$unit" 2>/dev/null || true; } | cut -d= -f2-)"
|
|
echo "${dir:-$HOME/.local/share/qwen38-$1}"
|
|
}
|
|
side_kolibri_image(){
|
|
local img
|
|
img="$({ grep -m1 -oE 'qwen38-kolibri:[^ ]+' "$KOLIBRI_UNIT_PATH" 2>/dev/null || true; })"
|
|
[ -n "$img" ] && docker image inspect "$img" >/dev/null 2>&1
|
|
}
|
|
# A Nemotron lane is begun once its own first Load began: its image, and its own checkpoint in the
|
|
# cache its unit mounts. The two lanes run one image (install-nemotron-super.sh says why), built by
|
|
# either one's first Load, and the image alone called the other lane begun too: the next update
|
|
# installed that one whole, 77 GB of Super VL fetched on a box that had only loaded Bolt (found in
|
|
# review, 2026-10-16).
|
|
side_nemotron_begun(){ # $1 the lane's unit
|
|
local img repo hf
|
|
img="$({ grep -m1 -oE 'qwen38-nemotron:[^ ]+' "$1" 2>/dev/null || true; })"
|
|
{ [ -n "$img" ] && docker image inspect "$img" >/dev/null 2>&1; } || return 1
|
|
repo="$({ grep -m1 -oE '[^ ]+ --revision [0-9a-f]{40}' "$1" 2>/dev/null || true; } | cut -d' ' -f1)"
|
|
hf="$(unit_hf_cache "$1")"
|
|
[ -n "$repo" ] && [ -n "$hf" ] && [ -d "$hf/hub/models--${repo//\//--}" ]
|
|
}
|
|
# The Qwen3.8 Flash-Next FP4-Local lane is begun once its first Load began, as a Nemotron lane is: the image its
|
|
# unit names (pulled by digest, the one digest in the unit) and its checkpoint in the cache the
|
|
# unit mounts. The Ornith lane the same way: the two run one image, so the image alone says
|
|
# nothing of either (the Nemotron lanes' lesson above).
|
|
side_pulled_begun(){ # $1 the lane's unit
|
|
local img repo hf
|
|
img="$({ grep -m1 -oE '[^ ]+@sha256:[0-9a-f]{64}' "$1" 2>/dev/null || true; })"
|
|
{ [ -n "$img" ] && docker image inspect "$img" >/dev/null 2>&1; } || return 1
|
|
repo="$({ grep -m1 -oE '[^ ]+ --revision [0-9a-f]{40}' "$1" 2>/dev/null || true; } | cut -d' ' -f1)"
|
|
hf="$(unit_hf_cache "$1")"
|
|
[ -n "$repo" ] && [ -n "$hf" ] && [ -d "$hf/hub/models--${repo//\//--}" ]
|
|
}
|
|
# The Qwen3.8 Flash-Next Unsloth GGUF lane the same way: the image its unit names and its GGUF repository's folder in
|
|
# the cache the unit mounts, which the unit names by its snapshot's path (llama-server takes files, not a repository
|
|
# and a revision): the first path, its model's, the line that names it naming its draft's too.
|
|
side_gguf_begun(){ # $1 the lane's unit
|
|
local img dir hf
|
|
img="$({ grep -m1 -oE '[^ ]+@sha256:[0-9a-f]{64}' "$1" 2>/dev/null || true; })"
|
|
{ [ -n "$img" ] && docker image inspect "$img" >/dev/null 2>&1; } || return 1
|
|
dir="$({ grep -m1 -oE 'hub/models--[^/ ]+/snapshots/[0-9a-f]{40}/' "$1" 2>/dev/null || true; } | head -n1 | cut -d/ -f2)"
|
|
hf="$(unit_hf_cache "$1")"
|
|
[ -n "$dir" ] && [ -n "$hf" ] && [ -d "$hf/hub/$dir" ]
|
|
}
|
|
side_begun(){ # $1 lane (image, video, kolibri, nemotron, nemotron-super, flash-local, ornith-122b, flash-unsloth)
|
|
case "$1" in
|
|
image|video) [ -x "$(side_lane_dir "$1")/venv/bin/python" ] ;;
|
|
kolibri) side_kolibri_image ;;
|
|
nemotron) side_nemotron_begun "$NEMOTRON_UNIT_PATH" ;;
|
|
nemotron-super) side_nemotron_begun "$NEMOTRON_SUPER_UNIT_PATH" ;;
|
|
flash-local) side_pulled_begun "$FLASH_LOCAL_UNIT_PATH" ;;
|
|
ornith-122b) side_pulled_begun "$ORNITH_122B_UNIT_PATH" ;;
|
|
flash-unsloth) side_gguf_begun "$FLASH_UNSLOTH_UNIT_PATH" ;;
|
|
*) return 1 ;;
|
|
esac
|
|
}
|
|
# The other text lane is on demand too: text_lane_prepared (lanes.sh) says when it is prepared.
|
|
side_mode(){ # $1 lane, $2 --with-<lane> given: the installer's option for this run
|
|
if [ "$ALL_WEIGHTS" -eq 1 ] || [ "$2" -eq 1 ] || side_begun "$1"; then echo --no-smoke; else echo --units-only; fi
|
|
}
|
|
|
|
if [ "$NO_SERVICE" -eq 1 ] && [ "$CONTEXT_MODE" = "1m" ]; then
|
|
if [ -z "$_ENV_CONTEXT_MODE" ]; then
|
|
# The 1m came from the installed unit, not from the operator: say so. The refusal
|
|
# named a CONTEXT_MODE nobody had set (found in review, 2026-09-24). It stays a
|
|
# refusal: a native --no-service install restores the configs that unit reads, and it
|
|
# would crash at its next start.
|
|
printf -- 'The installed 27B unit serves the 1M window, and --no-service installs the native 262144 one for\n./run.sh: the checkpoint configs would no longer match that unit, which would crash at its next start.\nDrop --no-service to update the service (it keeps 1m), or pass CONTEXT_MODE=native to move this box\nto native (then run a plain ./install.sh, so the unit follows).\n' >&2; exit 1
|
|
fi
|
|
printf -- 'CONTEXT_MODE=1m needs the systemd path (keepalive proxy service); ./run.sh serves the native config only.\nEither drop --no-service, or pass CONTEXT_MODE=native explicitly.\n' >&2; exit 1
|
|
fi
|
|
if [ "$NO_SERVICE" -eq 1 ] && [ "$LANE" = "flash" ]; then
|
|
printf -- 'The flash targets are service-only in this release (the lane was validated as a systemd unit).\nDrop --no-service, or install one of the 27B targets for the foreground ./run.sh path.\n' >&2; exit 1
|
|
fi
|
|
|
|
step() { printf '\n\033[1;36m── %s%s\033[0m\n' "${SECONDARY:+${SECONDARY/27b/27B} lane, }" "$*"; }
|
|
# True (0) when a service has to be restarted to run what is on disk: it is not running,
|
|
# or it started before the last change of one of the files it reads. The files are only
|
|
# rewritten when their content changes (cmp before install), so a date that moved is a
|
|
# change. A run that changed nothing restarted the proxy, cutting every request in flight
|
|
# through it, even with the engine kept (found in review, 2026-09-24).
|
|
# stale_since: in lanes.sh (sourced above), with the lanes' own freshness check
|
|
# (die() is defined above, before the port validations that call it first.)
|
|
|
|
# The settings this command line gives explicitly, as conformity.py's --chose arguments, in
|
|
# CHOSE (2026-10-17): the list below shows them as set here, and record_install writes them as
|
|
# the operator's choices. The values are the resolved ones.
|
|
collect_choices() {
|
|
CHOSE=()
|
|
if [ -n "$_ENV_MODEL_CHOICE" ]; then CHOSE+=(--chose "target.$LANE=$MODEL_CHOICE"); fi
|
|
if [ -n "$_ENV_DRAFT2_REPO$_ENV_DRAFT2_QUANT$_ENV_DRAFT2_TOKENS" ]; then
|
|
CHOSE+=(--chose "DRAFT2=$DRAFT2_REPO ($DRAFT2_QUANT, D=$DRAFT2_TOKENS)")
|
|
fi
|
|
# the run for the 27B lane beside a flash one does not get CONTEXT_MODE (it is unset for it)
|
|
if [ -n "$_ENV_CONTEXT_MODE" ] && [ "$LANE" = 27b ]; then CHOSE+=(--chose "CONTEXT_MODE=$CONTEXT_MODE"); fi
|
|
if [ -n "$_ENV_ENGINE_BIND" ]; then CHOSE+=(--chose "ENGINE_BIND=$ENGINE_BIND"); fi
|
|
if [ -n "$_ENV_PROXY_BIND" ]; then CHOSE+=(--chose "PROXY_BIND=$PROXY_BIND"); fi
|
|
if [ -n "$_ENV_PORT" ]; then CHOSE+=(--chose "PORT=$PORT"); fi
|
|
if [ -n "$_ENV_PROXY_PORT" ]; then CHOSE+=(--chose "PROXY_PORT=$PROXY_PORT"); fi
|
|
if [ -n "$_ENV_HF_CACHE" ]; then CHOSE+=(--chose "HF_CACHE=$HF_CACHE"); fi
|
|
if [ -n "$_ENV_PLE_DIR" ]; then CHOSE+=(--chose "PLE_DIR=$PLE_DIR"); fi
|
|
if [ -n "$FLASH_TIER_ENV" ]; then CHOSE+=(--chose "FLASH_TIER=$FLASH_TIER"); fi
|
|
if [ -n "$_ENV_SPEC_TOKEN_MAP_SIZE" ]; then CHOSE+=(--chose "SPEC_TOKEN_MAP_SIZE=$SPEC_TOKEN_MAP_SIZE"); fi
|
|
if [ -n "$_ENV_FLASH_REPLAYSSM_SPEC" ]; then CHOSE+=(--chose "FLASH_REPLAYSSM_SPEC=$FLASH_REPLAYSSM_SPEC"); fi
|
|
if [ -n "$_ENV_KOLIBRI_VARIANT" ]; then CHOSE+=(--chose "KOLIBRI_VARIANT=$_ENV_KOLIBRI_VARIANT"); fi
|
|
if [ -n "$_ENV_IMAGE_MODEL" ]; then CHOSE+=(--chose "IMAGE_MODEL=$_ENV_IMAGE_MODEL"); fi
|
|
if [ -n "$_ENV_VIDEO_VARIANT" ]; then CHOSE+=(--chose "VIDEO_VARIANT=$_ENV_VIDEO_VARIANT"); fi
|
|
if [ -n "$_ENV_FLASH_UNSLOTH_TARGET" ]; then CHOSE+=(--chose "FLASH_UNSLOTH_TARGET=$_ENV_FLASH_UNSLOTH_TARGET"); fi
|
|
return 0
|
|
}
|
|
# This box against what this release recommends, in one list before anything changes
|
|
# (2026-10-17). The lines above say each setting as the run decides it; this says them
|
|
# together: what moves now (an old default nothing records as chosen), what stays the
|
|
# operator's (recorded, set on this command line, or never a default), and the site's own
|
|
# settings apart. conformity.py classes them by the rules the convergence above asked it for.
|
|
# The run for the other text lane prints none (its settings are this run's), nor a
|
|
# --no-service run, which writes no unit. Never fatal.
|
|
if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ]; then
|
|
collect_choices
|
|
echo
|
|
REC_FLAG=(); [ "$RECOMMENDED" -eq 0 ] || REC_FLAG=(--recommended)
|
|
python3 "$REPO_DIR/conformity.py" plan --config-dir "$CONFIG_DIR" --repo-dir "$REPO_DIR" \
|
|
--units /etc/systemd/system/ --lane "$LANE" ${CHOSE[@]+"${CHOSE[@]}"} ${REC_FLAG[@]+"${REC_FLAG[@]}"} \
|
|
|| echo "NOTE: could not list this box's settings against the recommended ones; the run goes on."
|
|
fi
|
|
# --plan ends here, before the first step: nothing above writes but the marker of --no-cockpit (and
|
|
# --with-cockpit takes it away), which it leaves as it is, as it leaves an older release's --no-<lane>
|
|
# markers, which any other run takes away.
|
|
if [ "$PLAN_ONLY" -eq 1 ]; then
|
|
echo
|
|
echo "--plan: nothing was changed. The same command without --plan applies it."
|
|
exit 0
|
|
fi
|
|
|
|
step "1/10 Preflight checks"
|
|
[ "$(uname -m)" = "aarch64" ] || die "This setup targets GB10 (aarch64). Detected: $(uname -m)."
|
|
# These paths are written into the units and the flash launcher: inside a quoted
|
|
# `bash -c` line, in a docker `-v src:dst`, and in systemd's own syntax, where % is a
|
|
# specifier. A space, a colon, a quote, a $ or a % in one was accepted and broke the
|
|
# unit it went into, seen only when that failed to start (found in review, 2026-09-24).
|
|
for _p in "HOME=$HOME" "HF_CACHE=$HF_CACHE" "PLE_DIR=$PLE_DIR"; do
|
|
case "${_p#*=}" in
|
|
/*) case "${_p#*=}" in *[!A-Za-z0-9._/+@-]*) die "${_p%%=*}=${_p#*=}: the units this installs cannot carry that path. Use an absolute path of letters, digits and . _ / + @ - only." ;; esac ;;
|
|
*) die "${_p%%=*}=${_p#*=}: an absolute path is needed (the units carry it as it is)." ;;
|
|
esac
|
|
done
|
|
unset _p
|
|
command -v nvidia-smi >/dev/null || die "nvidia-smi not found. Is the NVIDIA driver stack installed? (stock on DGX OS)"
|
|
# nvidia-smi says what is wrong when it cannot reach the driver, and exits non-zero:
|
|
# inside a bare $(...) under set -e that ended the install with only "Install failed at
|
|
# line N", its own explanation captured into a variable nobody printed (found in review,
|
|
# 2026-09-24).
|
|
if ! GPU_OUT="$(nvidia-smi --query-gpu=name --format=csv,noheader 2>&1)"; then
|
|
die "nvidia-smi cannot reach the GPU: $(printf '%s' "$GPU_OUT" | tr '\n' ' ' | cut -c1-300). The NVIDIA driver is probably not loaded; after a kernel or driver update, a reboot loads it ('nvidia-smi' alone shows the same error)."
|
|
fi
|
|
GPU_NAME="$(printf '%s\n' "$GPU_OUT" | head -1)"
|
|
echo "GPU: $GPU_NAME"
|
|
case "$GPU_NAME" in *GB10*) ;; *) echo "WARNING: expected GB10, found '$GPU_NAME'. Continuing, but this config was only validated on GB10 (memory sizing may not fit other GPUs)." ;; esac
|
|
command -v docker >/dev/null || die "docker not found. Install Docker + NVIDIA Container Toolkit (stock on DGX OS)."
|
|
command -v python3 >/dev/null || die "python3 not found on the host (needed for the template patcher; stock on DGX OS)."
|
|
command -v ss >/dev/null || die "ss not found (iproute2, stock on DGX OS): the preflight cannot check the ports without it."
|
|
# /proc/meminfo, not `free`: free(1) localizes its row labels (issue #3). In GiB, as the kernel
|
|
# counts it: the reference box's 128 GB is 121.6 GiB of MemTotal. Its class was read at the top.
|
|
TOTAL_GIB="$(QWEN38_MEMINFO="${QWEN38_MEMINFO:-/proc/meminfo}" python3 -I "$REPO_DIR/boxmem.py" gib)"
|
|
[ "$MEM_CLASS" != none ] || die "This box has ${TOTAL_GIB} GiB of memory (MemTotal), and the lanes here need a 64 GB or a 128 GB DGX Spark."
|
|
# An account outside the docker group, as a new box's is, joins it here, after every refusal above
|
|
# (and --help, --plan or a mistyped flag never get here), and the run starts again with it; a daemon
|
|
# down or a refusal elsewhere stops with the way out (lanes.sh docker_grant). --no-service uses no
|
|
# sudo: it says how instead.
|
|
DOCKER_GRANT=yes; [ "$NO_SERVICE" -eq 0 ] || DOCKER_GRANT=no
|
|
docker_grant bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
|
|
[ -z "$DOCKER_SAID" ] || exec 1>&3 3>&-
|
|
# this run, said to the cockpit while it lasts (lanes.sh, run_mark); the run it starts for the other
|
|
# text lane is part of it
|
|
[ -n "$SECONDARY" ] || run_mark "$CONFIG_DIR"; trap forget_run_mark EXIT
|
|
# 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
|
|
# Beside a side lane at boot, the text lane above is the one the box served last. Left out by its flag,
|
|
# or not prepared (its image or its checkpoint not on the box), it gets its units only, as the case
|
|
# above: none of its downloads, nothing started, the box's port, cache and binds kept, read from that
|
|
# same lane; named (--with-<lane>), or with --all-weights, it is updated whole. The other text lane
|
|
# follows its own rule (step 6, whole only once prepared), and the rest of the box is updated.
|
|
# Issue #57 (2026-10-21): a box booting Qwen3.8 Flash-Next FP4-Local fetched the flash lane it had left out again,
|
|
# 35 and 136 GB, under "Leaving the flash lane out". A --no-<lane> no longer outlives its run, so a
|
|
# lane not prepared is what keeps those downloads off the next one too.
|
|
LEFT_OUT=0; LEFT_WHY=""
|
|
TEXT_NAMED="$WITH_27B"; [ "$LANE" = flash ] && TEXT_NAMED="$WITH_FLASH"
|
|
if [ "$SIDE_BOOT" -gt 0 ]; then
|
|
if { [ "$LANE" = flash ] && [ "$WANT_FLASH" -eq 0 ]; } || { [ "$LANE" = 27b ] && [ "$WANT_27B" -eq 0 ]; }; then
|
|
LEFT_OUT=1; LEFT_WHY="left out (--no-$LANE)"
|
|
# --no-service prepares this lane for ./run.sh in the foreground: with its downloads left out, the run
|
|
# said "Prepared" and run.sh then stopped on a checkpoint not found (found in review, 2026-10-21)
|
|
[ "$NO_SERVICE" -eq 0 ] || die "--no-service prepares the ${LANE/27b/27B} lane for ./run.sh, and that lane is left out (--no-$LANE): nothing would run. Drop --no-$LANE to prepare it whole, or run without --no-service"
|
|
elif [ "$NO_SERVICE" -eq 0 ] && [ "$ALL_WEIGHTS" -eq 0 ] && [ "$TEXT_NAMED" -eq 0 ] && ! text_lane_prepared "$LANE"; then
|
|
LEFT_OUT=1; LEFT_WHY="not prepared on this box"
|
|
fi
|
|
if [ "$LEFT_OUT" -eq 1 ] && [ "$UNITS_ONLY" -eq 0 ]; then
|
|
echo "NOTE: the ${LANE/27b/27B} lane is $LEFT_WHY: its units only, none of its downloads, and this run starts nothing."
|
|
UNITS_ONLY=1
|
|
fi
|
|
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).
|
|
mkdir -p "$HF_CACHE" 2>/dev/null || true
|
|
# `|| true` inside: a df that fails (a path it cannot reach) under pipefail ended the
|
|
# install at this line, and the "found unknown GiB" below never said why (found in review,
|
|
# 2026-09-24).
|
|
FREE_DISK_GB=$({ df -BG --output=avail "$HF_CACHE" 2>/dev/null || true; } | tail -1 | tr -dc '0-9')
|
|
# Fresh installs need ~45 GiB for the 27B stack (checkpoints + caches) and ~180 GiB for
|
|
# Flash-Next (its NVFP4 checkpoint alone is 136 GB), plus ~50 GiB for the flash lane's
|
|
# PLE table where PLE_DIR lands; what the cache already holds comes off (below). These
|
|
# checks count GiB, as df -BG does; the README's "Requirements" gives the same numbers in
|
|
# GB, rounded up (tests/test_docs_facts.py converts them): keep the two together.
|
|
# The room a pull takes at its peak, counted for both of Docker's image stores: the classic one
|
|
# keeps a layer's download until it is unpacked, the containerd one (the default of Docker 29
|
|
# on a new install) keeps every download beside what it unpacked. In GiB as df -BG rounds them
|
|
# up: ceil(peak x 1.02) + 1. Measured from the registry and on the reference box (2026-10-15):
|
|
# the 27B's image is 33.7 GB unpacked and 14.8 GB to download, 45.1 GiB at the peak; the flash
|
|
# lane's 34.4 GB and 15.3 GB, 46.3 GiB. It asked for 40 and 35, which a pull on a disk with just
|
|
# that free outgrew in either store (found in review, 2026-10-15).
|
|
NEED_GB=45; DOCKER_NEED_GB=48; IMG_LABEL="31 GiB Docker image"
|
|
if [ "$LANE" = "flash" ]; then
|
|
NEED_GB=180; DOCKER_NEED_GB=49; IMG_LABEL="32 GiB Docker image"
|
|
fi
|
|
# What is left to download, not what a checkpoint weighs. huggingface_hub creates the
|
|
# snapshot folder before the first byte of the first file (file_download.py, 1.31.0), so a
|
|
# folder there said nothing, and a flash download interrupted at 74 GB of 124 was checked
|
|
# against 10 on its resume (found in review, 2026-09-24). A snapshot is cached when every
|
|
# shard its index names is in it, since a file appears there only once its blob is whole;
|
|
# otherwise what the cache already holds for this repo comes off the need (lanes.sh ckpt_cached,
|
|
# which the switch and a first Load read through ckpt_room_gb).
|
|
HF_REPO_CACHE="$HF_CACHE/hub/models--${MODEL_REPO//\//--}"
|
|
if ckpt_cached "$HF_REPO_CACHE" "$MODEL_REV"; then
|
|
NEED_GB=10
|
|
else
|
|
HAVE_B="$({ du -s --apparent-size -B1 "$HF_REPO_CACHE/blobs" 2>/dev/null || true; } | cut -f1)"
|
|
NEED_GB=$((NEED_GB - ${HAVE_B:-0} / 1073741824)); [ "$NEED_GB" -ge 10 ] || NEED_GB=10 # floor: never under the need
|
|
fi
|
|
PLE_OWN_DEV=""
|
|
if [ "$LANE" = "flash" ] && [ "$UNITS_ONLY" -eq 0 ] && ! ls "$PLE_DIR"/ple_table_*.bin >/dev/null 2>&1; then
|
|
# The 47.7 GiB sparse backing file is written on every boot, in PLE_DIR; the space
|
|
# has to be there whether or not a previous boot left one behind, and on that disk:
|
|
# it was counted against HF_CACHE's, which says nothing when PLE_DIR is elsewhere.
|
|
PLE_PARENT="$PLE_DIR"; while [ ! -e "$PLE_PARENT" ]; do PLE_PARENT="$(dirname "$PLE_PARENT")"; done
|
|
if [ "$(stat -L -c %d "$PLE_PARENT")" = "$(stat -L -c %d "$HF_CACHE")" ]; then
|
|
NEED_GB=$((NEED_GB + 50))
|
|
else
|
|
PLE_OWN_DEV="$(stat -L -c %d "$PLE_PARENT")"
|
|
PLE_FREE_GB="$({ df -BG --output=avail "$PLE_PARENT" 2>/dev/null || true; } | tail -1 | tr -dc '0-9')"
|
|
[ -n "$PLE_FREE_GB" ] && [ "$PLE_FREE_GB" -ge 50 ] || die "Need ~50 GiB free under PLE_DIR=$PLE_DIR for the flash lane's PLE table (47.7 GiB, written at every boot); found ${PLE_FREE_GB:-unknown} GiB. Free some space or set PLE_DIR to another disk."
|
|
fi
|
|
fi
|
|
# A lane installed on demand takes no room now: its first Load checks the room for what it
|
|
# fetches (prepare-lane.sh, then its switch).
|
|
[ "$UNITS_ONLY" -eq 0 ] || NEED_GB=0
|
|
[ -n "$FREE_DISK_GB" ] && [ "$FREE_DISK_GB" -ge "$NEED_GB" ] || die "Need ~${NEED_GB} GiB free for the checkpoints and caches under $HF_CACHE; found ${FREE_DISK_GB:-unknown} GiB. Free some space or set HF_CACHE to another disk."
|
|
# Docker from the Snap package, beside the NVIDIA Container Toolkit DGX OS installs on the host, fails to
|
|
# start a container with the GPU (canonical/docker-snap#357). Step 3 found it only after the image was
|
|
# pulled, and said the toolkit was missing (issue #58, 2026-10-21). Canonical's two ways round it remove
|
|
# DGX OS packages or change every container's GPU option, and the Snap engine sees only the home: the
|
|
# lanes run on Docker CE, and this stops before the first byte.
|
|
if SNAP_DOCKER="$(docker_snap_engine)" && host_nvidia_toolkit; then
|
|
die "This box's Docker engine is the Snap package ($SNAP_DOCKER), and the NVIDIA Container Toolkit is installed on the host, as DGX OS installs it. Canonical documents that the Snap engine then fails to start containers with the GPU: https://github.com/canonical/docker-snap#nvidia-container-toolkit-compatibility
|
|
The lanes run on DGX OS's own Docker CE. Nothing was changed. Make it the engine this account reaches, after moving what you keep from the Snap engine (its images and containers live under /var/snap/docker): sudo snap stop --disable docker, then sudo systemctl enable --now docker. Then run this again."
|
|
fi
|
|
DOCKER_ROOT=$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || echo /var/lib/docker)
|
|
DOCKER_FREE_GB=$({ df -BG --output=avail "$DOCKER_ROOT" 2>/dev/null || true; } | tail -1 | tr -dc '0-9')
|
|
# What step 2 pulls, decided here because the room it needs depends on it.
|
|
if [ "$LANE" = "flash" ]; then
|
|
PULL_TARGET="$FLASH_IMAGE"
|
|
else
|
|
PULL_TARGET="$IMAGE"
|
|
fi
|
|
# An image already here needs no room for itself, only the container's: an update
|
|
# on a box with 36 GB free was refused for want of 40, with the image in place and
|
|
# nothing to download (reference box, 2026-09-23).
|
|
if docker image inspect "$PULL_TARGET" >/dev/null 2>&1; then
|
|
DOCKER_NEED_GB=5; IMG_LABEL="container (its image is already here)"
|
|
fi
|
|
[ "$UNITS_ONLY" -eq 0 ] || DOCKER_NEED_GB=0
|
|
[ "${DOCKER_FREE_GB:-0}" -ge "$DOCKER_NEED_GB" ] || die "Need ~${DOCKER_NEED_GB} GiB free on $DOCKER_ROOT for the $IMG_LABEL; found ${DOCKER_FREE_GB:-?} GiB (docker images live there, not under \$HOME)."
|
|
# One disk for both, as on the reference box: the two needs add up there. Checked apart,
|
|
# 45 GB free passed a first 27B install that needs 45 for the checkpoints and 40 for the
|
|
# image on that same disk (found in review, 2026-09-24).
|
|
HF_DEV="$(stat -L -c %d "$HF_CACHE" 2>/dev/null || true)"; DOCKER_DEV="$(stat -L -c %d "$DOCKER_ROOT" 2>/dev/null || true)"
|
|
if [ -n "$HF_DEV" ] && [ "$HF_DEV" = "$DOCKER_DEV" ]; then
|
|
BOTH_GB=$((NEED_GB + DOCKER_NEED_GB))
|
|
[ "${FREE_DISK_GB:-0}" -ge "$BOTH_GB" ] || die "Need ~${BOTH_GB} GiB free on the disk that holds both $HF_CACHE and $DOCKER_ROOT (${NEED_GB} for the checkpoints and caches, ${DOCKER_NEED_GB} for the $IMG_LABEL); found ${FREE_DISK_GB:-unknown} GiB. Free some space, or set HF_CACHE to another disk."
|
|
fi
|
|
# The PLE table and the image on one disk that is not the cache's (the cache on a disk of its
|
|
# own): their needs add up there too. Checked apart, 60 GB free passed both (found in review,
|
|
# 2026-10-15).
|
|
if [ -n "$PLE_OWN_DEV" ] && [ "$PLE_OWN_DEV" = "$DOCKER_DEV" ]; then
|
|
PLE_BOTH_GB=$((50 + DOCKER_NEED_GB))
|
|
[ "${DOCKER_FREE_GB:-0}" -ge "$PLE_BOTH_GB" ] || die "Need ~${PLE_BOTH_GB} GiB free on the disk that holds both PLE_DIR=$PLE_DIR and $DOCKER_ROOT (50 for the flash lane's PLE table, ${DOCKER_NEED_GB} for the $IMG_LABEL); found ${DOCKER_FREE_GB:-unknown} GiB. Free some space or set PLE_DIR to another disk."
|
|
fi
|
|
# A secondary run shares the port with the lane its parent serves, which holds it by
|
|
# design: the parent checked both ports, and owns the proxy.
|
|
if [ -z "$SECONDARY" ] && ss -tlnH 2>/dev/null | awk '{print $4}' | grep -q ":$PORT\$"; then
|
|
# The port may be held by either of OUR engines: same-engine reinstall
|
|
# (converge) or a cross-engine switch (the old engine is stopped at step 9).
|
|
if docker inspect qwen38-sglang --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: qwen38-sglang is already running on :$PORT, installing over it ($([ "$LANE" = flash ] && echo 'lane switch at the final step' || echo 'converging config'))."
|
|
elif docker inspect qwen38-flash --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)" \
|
|
|| docker inspect qwen38-flash --format '{{json .HostConfig.PortBindings}}' 2>/dev/null | grep -q "\"${PORT}\""; then
|
|
echo "Note: qwen38-flash is already running on :$PORT, installing over it ($([ "$LANE" = 27b ] && echo 'lane switch at the final step' || echo 'converging config'))."
|
|
elif docker inspect qwen38-kolibri --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Kolibri-1 lane is serving on :$PORT; this run updates the lanes beside it."
|
|
elif docker inspect qwen38-nemotron --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Nemotron 3.5 Bolt lane is serving on :$PORT; this run updates the lanes beside it."
|
|
elif docker inspect qwen38-nemotron-super --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Nemotron 3.5 Super VL lane is serving on :$PORT; this run updates the lanes beside it."
|
|
elif docker inspect qwen38-flash-local --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Qwen3.8 Flash-Next FP4-Local lane is serving on :$PORT; this run updates the lanes beside it."
|
|
elif docker inspect qwen38-ornith-122b --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Ornith 1.5 122B lane is serving on :$PORT; this run updates the lanes beside it."
|
|
elif docker inspect qwen38-flash-unsloth --format '{{join .Args " "}}' 2>/dev/null | grep -qE -- "--port ${PORT}(\s|$)"; then
|
|
echo "Note: the Qwen3.8 Flash-Next Unsloth GGUF lane is serving on :$PORT; this run updates the lanes beside it."
|
|
else
|
|
die "Port $PORT is already in use by another program (see: ss -tlnp | grep :$PORT). Free it, or install with PORT=<other> ./install.sh"
|
|
fi
|
|
fi
|
|
if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ] && ss -tlnH 2>/dev/null | awk '{print $4}' | grep -q ":$PROXY_PORT\$"; then
|
|
# Ours only if the proxy that runs is the one on that port: a running proxy made ANY
|
|
# busy PROXY_PORT pass, another program's included, which then kept the new unit from
|
|
# binding (found in review, 2026-09-24).
|
|
KA_PORT_NOW="$(grep -oE 'keepalive-proxy\.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null | head -1 | tr -dc '0-9' || true)"
|
|
if [ "$KA_PORT_NOW" = "$PROXY_PORT" ] && systemctl is-active --quiet qwen38-keepalive 2>/dev/null; then
|
|
echo "Note: the keepalive proxy is already running on :$PROXY_PORT, re-installing over it."
|
|
else
|
|
die "Port $PROXY_PORT (keepalive proxy) is already in use by another program. Free it, or install with PROXY_PORT=<other>"
|
|
fi
|
|
fi
|
|
# sudo is needed from step 8 on, and it is asked for here, before the downloads rather
|
|
# than after them: `sudo -n` alone never prompts, and a fresh box where sudo wants a
|
|
# password (DGX OS does) died at step 8 after ~20 min of pulls (found in review,
|
|
# 2026-09-24). With a terminal sudo asks now; without one (a background run) `sudo -v`
|
|
# fails at once, and refusing now costs nothing where refusing at step 8 cost the pulls.
|
|
if [ "$NO_SERVICE" -eq 0 ] && ! sudo -n true 2>/dev/null; then
|
|
echo "sudo is needed from step 8 on (systemd units); it asks for your password now, before the downloads."
|
|
sudo -v || die "sudo could not be used here: run 'sudo -v' in this terminal, then re-run ./install.sh"
|
|
fi
|
|
echo "OK (aarch64, ${TOTAL_GIB} GiB of memory: a ${MEM_CLASS} GB box, ${FREE_DISK_GB} GiB free)"
|
|
# What the image and video lanes build or run with, which DGX OS lacks: Python's headers, which
|
|
# their first Load builds xatlas against, and ffmpeg, which the video pipeline refuses to start
|
|
# without. Installed now, while this terminal can give sudo its password: the first Load runs from
|
|
# the cockpit, which has no terminal, and both lanes' installers stopped on it (an ASUS GX10, DGX
|
|
# OS 7.6.0, 2026-10-20). Their own checks, the same, still say what an install here could not put.
|
|
HOST_PKGS=()
|
|
# --no-start and --no-service return before those lanes, and need neither (nor sudo for them)
|
|
if [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; then
|
|
:
|
|
elif [ "$WANT_IMAGE" -eq 1 ] || [ "$WANT_VIDEO" -eq 1 ]; then
|
|
python3 -c 'import venv, ensurepip' 2>/dev/null || HOST_PKGS+=(python3-venv)
|
|
[ -f "$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["include"])' 2>/dev/null)/Python.h" ] || HOST_PKGS+=(python3-dev)
|
|
fi
|
|
if [ "$NO_START" -eq 0 ] && [ "$NO_SERVICE" -eq 0 ] && [ "$WANT_VIDEO" -eq 1 ] \
|
|
&& ! { command -v ffmpeg && command -v ffprobe; } >/dev/null 2>&1; then
|
|
HOST_PKGS+=(ffmpeg)
|
|
fi
|
|
[ "${#HOST_PKGS[@]}" -eq 0 ] || host_packages "the image and video lanes" "${HOST_PKGS[@]}" || true
|
|
|
|
if [ "$UNITS_ONLY" -eq 1 ]; then
|
|
if [ -n "$ATS_CANNOT" ]; then step "2/10 The Flash-Next image: not pulled, as this GPU cannot start the flash lane"
|
|
elif [ "$LEFT_OUT" -eq 1 ] && [ "$LANE" = "flash" ]; then step "2/10 The Flash-Next image: not pulled, as the flash lane is $LEFT_WHY (its next Load pulls what it lacks)"
|
|
elif [ "$LEFT_OUT" -eq 1 ]; then step "2/10 The SGLang image: not pulled, as the 27B lane is $LEFT_WHY (its next Load pulls what it lacks)"
|
|
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
|
|
step "2/10 Pulling the official SGLang Flash-Next image (~16 GB to download, 35 GB on disk, one-time, resumable)"
|
|
docker pull "$PULL_TARGET" || die "docker pull failed. Causes: no internet, Docker Hub rate limit (retry in a few minutes or 'docker login'), or the pinned image was removed upstream, its dated tag (lmsysorg/sglang:nightly-cu134-20261011-53295c6) with it: update this repo, or open an issue on GitHub if it is up to date"
|
|
PULLED_IMAGE="$PULL_TARGET"
|
|
else
|
|
step "2/10 Pulling the SGLang image (~15 GB to download, 34 GB on disk, one-time, resumable)"
|
|
docker pull "$PULL_TARGET" || die "docker pull failed. Causes: no internet, Docker Hub rate limit (retry in a few minutes or 'docker login'), or the pinned digest was removed upstream: try IMAGE=lmsysorg/sglang:v0.5.22 ./install.sh, the moving tag of the same release"
|
|
PULLED_IMAGE="$PULL_TARGET"
|
|
fi
|
|
# pin_tag, the local tag a digest pull needs to survive a docker image prune: in lanes.sh
|
|
# (sourced above), which prepare-lane.sh shares for a lane prepared at its first Load.
|
|
# A pin that moves takes its tag with it: unpin_stale, in lanes.sh too, which the lanes' own
|
|
# installers share (the Qwen3.8 Flash-Next FP4-Local lane's pulls its image by digest as this does).
|
|
pin_tag "$LANE" "$PULLED_IMAGE"
|
|
if [ "$LANE" = "flash" ]; then pin_tag 27b "$IMAGE"; else pin_tag flash "$FLASH_IMAGE"; fi
|
|
unpin_stale "$LANE" "$PULLED_IMAGE" || true
|
|
if [ "$LANE" = "flash" ]; then unpin_stale 27b "$IMAGE" || true; else unpin_stale flash "$FLASH_IMAGE" || true; fi
|
|
|
|
if [ -n "$ATS_CANNOT" ]; then
|
|
step "3/10 The GPU from a container: not asked, as this GPU cannot start the flash lane"
|
|
elif [ "$LEFT_OUT" -eq 1 ]; then
|
|
step "3/10 The GPU from a container: not asked, as the ${LANE/27b/27B} lane is $LEFT_WHY"
|
|
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"
|
|
# --entrypoint: the image ships NVIDIA's own entrypoint script
|
|
# (/opt/nvidia/nvidia_entrypoint.sh), which prints a banner and runs its argument;
|
|
# overriding it is what makes this a plain nvidia-smi call with plain output.
|
|
# What Docker said is kept and shown: the check named the toolkit whatever had failed, Docker's own
|
|
# error thrown away (issue #58, 2026-10-21).
|
|
GPU_OUT="$(docker run --rm --gpus all --entrypoint nvidia-smi "$PULLED_IMAGE" -L 2>&1)" && GPU_RC=0 || GPU_RC=$?
|
|
GPU_SEEN="$(printf '%s\n' "$GPU_OUT" | grep -m1 '^GPU' || true)"
|
|
if [ -z "$GPU_SEEN" ]; then
|
|
GPU_HINT="If the NVIDIA Container Toolkit is missing or unconfigured: sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker"
|
|
if SNAP_DOCKER="$(docker_snap_engine)"; then
|
|
GPU_HINT="This box's Docker engine is the Snap package ($SNAP_DOCKER): https://github.com/canonical/docker-snap#nvidia-container-toolkit-compatibility. The lanes run on DGX OS's own Docker CE."
|
|
fi
|
|
die "The GPU check failed: 'docker run --gpus all' with nvidia-smi -L exited $GPU_RC and listed no GPU. Docker said:
|
|
$(printf '%s\n' "$GPU_OUT" | tail -n 6)
|
|
Engine: $(docker_engine_line)
|
|
$GPU_HINT"
|
|
fi
|
|
echo "OK, container sees: $GPU_SEEN"
|
|
fi
|
|
|
|
if [ "$UNITS_ONLY" -eq 1 ]; then
|
|
if [ -n "$ATS_CANNOT" ]; then step "4/10 The Flash-Next checkpoint: not fetched, as this GPU cannot start the flash lane"
|
|
elif [ "$LEFT_OUT" -eq 1 ] && [ "$LANE" = "flash" ]; then step "4/10 The Flash-Next checkpoint: not fetched, as the flash lane is $LEFT_WHY (its next Load fetches what it lacks)"
|
|
elif [ "$LEFT_OUT" -eq 1 ]; then step "4/10 The checkpoints (the target and its DFlash2 draft): not fetched, as the 27B lane is $LEFT_WHY (its next Load fetches what it lacks)"
|
|
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)"
|
|
echo "This is the big one: at 100 MB/s it takes ~25 min. Interrupting is safe, re-running resumes."
|
|
else
|
|
step "4/10 Downloading checkpoints (~24 GB, ~33 for an FP8 target, one-time, reuses/resumes any local copy)"
|
|
fi
|
|
mkdir -p "$HF_CACHE" "$CONFIG_DIR/sglang-cache"
|
|
# A kept custom model is already serving from this cache: skip its download.
|
|
DL_MODEL_REPO="$MODEL_REPO"
|
|
[ "$KEEP_MODEL_VERBATIM" -eq 1 ] && DL_MODEL_REPO=""
|
|
# Flash has no separate draft checkpoints: its MTP head ships inside the
|
|
# target checkpoint itself. Empty repo vars are skipped by the downloader.
|
|
DL_DRAFT2_REPO="$DRAFT2_REPO"
|
|
if [ "$LANE" = "flash" ]; then DL_DRAFT2_REPO=""; fi
|
|
# Unauthenticated downloads get throttled by the Hub (measured: a fresh-cache
|
|
# pull stalled at 3.3 GB). A token in $HF_CACHE/token is picked up through the
|
|
# mount; HF_TOKEN in the environment is passed through as well.
|
|
DL_TOKEN_ARGS=()
|
|
# by name: docker takes the value from its own environment, so the token is not in the
|
|
# docker client's argv, which any local user can read in /proc (found in review, 2026-09-24)
|
|
if [ -n "${HF_TOKEN:-}" ]; then export HF_TOKEN; DL_TOKEN_ARGS=(-e HF_TOKEN); fi
|
|
# HF_HUB_DISABLE_XET: the hub library's Xet transfer backend stalled silently
|
|
# during the release campaign (ESTAB socket, zero bytes, forever; 0-8 MB/s
|
|
# when moving at all) while the classic CDN path measured 89 MB/s on the same
|
|
# box, same second. HF_HUB_DOWNLOAD_TIMEOUT turns any remaining silent stall
|
|
# into a ReadTimeout that the retry loop below resumes from.
|
|
# ckpt-fetch.py, the one fetch of every lane's checkpoint, in the pinned image (resumed
|
|
# attempts, each keeping every file already whole; the Xet exception the flash checkpoint's
|
|
# 53.7 GB n-gram table needs; the byte count, when hf-progress.py is there to mount: a bind of
|
|
# a missing file makes docker create a root-owned directory in its place). A pinned-sha
|
|
# download writes no refs/main, and serving with HF_HUB_OFFLINE=1 (the 1m unit) resolves
|
|
# "main" through it and would fail on a fresh machine: --refs-main fill writes it where it is
|
|
# missing and never moves one the box serves.
|
|
[ -f "$REPO_DIR/ckpt-fetch.py" ] || die "ckpt-fetch.py is missing next to install.sh: run it from the repository."
|
|
DL_PROGRESS_ARGS=()
|
|
[ -f "$REPO_DIR/hf-progress.py" ] && DL_PROGRESS_ARGS=(-v "$REPO_DIR/hf-progress.py:/opt/qwen38/hf-progress.py:ro")
|
|
dl_fetch(){ # $1 repo, $2 revision; an empty repo is a kept custom model (already in cache) or flash's drafter (none)
|
|
[ -n "$1" ] || return 0
|
|
echo "── $1 @ $2"
|
|
docker run --rm --network host --user "$(id -u):$(id -g)" \
|
|
--entrypoint python3 \
|
|
-e HF_HOME=/hf -e HF_HUB_DOWNLOAD_TIMEOUT=30 -e HF_HUB_DISABLE_XET=1 \
|
|
"${DL_TOKEN_ARGS[@]}" "${DL_PROGRESS_ARGS[@]}" \
|
|
-v "$REPO_DIR/ckpt-fetch.py:/opt/qwen38/ckpt-fetch.py:ro" \
|
|
-v "$HF_CACHE":/hf \
|
|
"$PULLED_IMAGE" /opt/qwen38/ckpt-fetch.py "$1" "$2" --refs-main fill \
|
|
|| die "Checkpoint download failed. Causes: no internet, HuggingFace throttling of unauthenticated downloads (set HF_TOKEN=<your 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
|
|
[ -n "$ATS_CANNOT" ] || [ "$LEFT_OUT" -eq 1 ] || 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"
|
|
echo "checkpoints ready"
|
|
fi
|
|
|
|
# Say the image the unit will actually carry, not the pin it came from: those
|
|
# are the same thing on a default install and different the moment someone
|
|
# passes SERVE_IMAGE=, which is the one case where this line is the only
|
|
# on-screen confirmation that the override took.
|
|
LANE_SERVE_IMAGE="$([ "$LANE" = flash ] && echo "$FLASH_SERVE_IMAGE" || echo "$SERVE_IMAGE")"
|
|
LANE_PIN_IMAGE="$([ "$LANE" = flash ] && echo "$FLASH_IMAGE" || echo "$IMAGE")"
|
|
if [ "$LANE_SERVE_IMAGE" = "$LANE_PIN_IMAGE" ]; then
|
|
step "5/10 Serving image: the pinned official one, nothing to build"
|
|
echo "$LANE_SERVE_IMAGE"
|
|
else
|
|
step "5/10 Serving image: an operator override, nothing to build"
|
|
echo "$LANE_SERVE_IMAGE (SERVE_IMAGE=, instead of the pin $LANE_PIN_IMAGE)"
|
|
# Step 2 pulls the pin, never an override, and the overlay build that used to
|
|
# guarantee this tag existed is gone since v1.14. Without this check the
|
|
# install completes green, writes and enables the unit, and the engine then
|
|
# loops on an unpullable local tag for the full 20-minute health wait.
|
|
[ "$UNITS_ONLY" -eq 1 ] || docker image inspect "$LANE_SERVE_IMAGE" >/dev/null 2>&1 \
|
|
|| die "serving image not present: $LANE_SERVE_IMAGE. Nothing pulls an override, so build or pull it first, or drop SERVE_IMAGE= to serve the pin ($LANE_PIN_IMAGE)."
|
|
fi
|
|
|
|
# The reduced draft vocabulary (lanes.sh: flash_token_map says how and why).
|
|
if [ "$LANE" = "flash" ] && [ "${SPEC_TOKEN_MAP_SIZE:-0}" -gt 0 ] && [ "$UNITS_ONLY" -eq 0 ]; then
|
|
flash_token_map "$FLASH_IMAGE" "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" "$SPEC_TOKEN_MAP_SIZE" \
|
|
"Re-run ./install.sh after the checkpoint is in place to build and serve it." \
|
|
|| die "building the reduced draft vocabulary failed. It is an optimization, not a requirement: re-run with SPEC_TOKEN_MAP_SIZE=0 to serve without it, and please open an issue with the output above."
|
|
fi
|
|
|
|
# What the engine this run installs reads when it starts, as it stands before this run
|
|
# writes any of it, and whether the running engine already has exactly that. Step 9
|
|
# restarts the engine only when one of the two says otherwise: an update used to cost a
|
|
# full boot (8 min on the 27B, 12 on flash) even when it changed nothing the engine reads.
|
|
ENGINE_UNIT_PATH="$SGL_UNIT_PATH"; [ "$LANE" = "flash" ] && ENGINE_UNIT_PATH="$FLASH_UNIT_PATH"
|
|
ENGINE_CKPTS=("$MODEL_REPO@$MODEL_REV")
|
|
[ "$LANE" = "27b" ] && ENGINE_CKPTS+=("$DRAFT2_REPO@$DRAFT2_REV")
|
|
ENGINE_FP_BEFORE=""; ENGINE_RUNNING_IT="no: not installed yet"
|
|
if [ -f "$ENGINE_UNIT_PATH" ]; then
|
|
ENGINE_FP_BEFORE="$(python3 "$REPO_DIR/engine-inputs.py" fingerprint "$ENGINE_UNIT_PATH" "$CONFIG_DIR" "$HF_CACHE" "${ENGINE_CKPTS[@]}" 2>/dev/null || true)"
|
|
ENGINE_RUNNING_IT="$(python3 "$REPO_DIR/engine-inputs.py" running "$ENGINE_UNIT_PATH" "$CONFIG_DIR" "$HF_CACHE" "${ENGINE_CKPTS[@]}" 2>/dev/null || echo "no: could not tell")"
|
|
fi
|
|
|
|
step "6/10 API key + patched chat template"
|
|
if [ ! -s "$CONFIG_DIR/api-key" ]; then
|
|
# Subshell umask like install-agent.sh: with umask 022 the file would be
|
|
# born 644 and world-readable until the chmod below runs.
|
|
( umask 077 && head -c 24 /dev/urandom | base64 | tr -d '/+=' > "$CONFIG_DIR/api-key" ) \
|
|
|| die "could not write $CONFIG_DIR/api-key"
|
|
chmod 600 "$CONFIG_DIR/api-key"
|
|
echo "API key generated at $CONFIG_DIR/api-key"
|
|
else
|
|
echo "API key already present, keeping it"
|
|
fi
|
|
KEY="$(cat "$CONFIG_DIR/api-key")" # used by the step-9 smoke test
|
|
# The engine is handed its key in a file SGLang merges in memory, written by this script
|
|
# before every start (the units, the flash launcher, run.sh): as --api-key "$(cat ...)" it
|
|
# was in the argv of the docker client and of the server (found in review, 2026-09-24).
|
|
cmp -s "$REPO_DIR/engine-secrets.sh" "$CONFIG_DIR/engine-secrets.sh" \
|
|
|| install -m 755 "$REPO_DIR/engine-secrets.sh" "$CONFIG_DIR/engine-secrets.sh"
|
|
bash "$CONFIG_DIR/engine-secrets.sh" || die "could not write the engine's key file from $CONFIG_DIR/api-key (see above)"
|
|
# Every engine unit runs this before it starts (the last engine's GPU memory has to be back,
|
|
# 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 (the five fixes: reasoning_effort normalization, lean, the
|
|
# refusal's wording, mid-conversation system messages as <system-reminder> blocks,
|
|
# and Claude Code's tool_reference blocks as text; see patch-template.py).
|
|
TEMPLATE_OUT="$CONFIG_DIR/chat-template-sglang.jinja"
|
|
[ "$LANE" = "flash" ] && TEMPLATE_OUT="$CONFIG_DIR/chat-template-flashnext.jinja"
|
|
if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then
|
|
[ -s "$TEMPLATE_OUT" ] \
|
|
|| die "custom model kept, but no patched template at $TEMPLATE_OUT. Pass MODEL_CHOICE=stock, uncensored, fp8, uncensored-fp8 or arete to regenerate it."
|
|
echo "custom target model kept: existing patched template left untouched"
|
|
elif [ "$UNITS_ONLY" -eq 1 ]; then
|
|
[ -n "$ATS_CANNOT" ] || echo "the chat template comes from the checkpoint: the lane's $([ "$LEFT_OUT" -eq 1 ] && echo next || echo 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."
|
|
fi
|
|
# The checkpoint configs the context mode needs, YaRN patched in or restored. Written right
|
|
# before the unit that reads them, never at this step: a run that died between the two
|
|
# (the opencode download of step 7, a sudo that could no longer ask at step 8) left the
|
|
# installed unit of the old mode on configs of the new one, and a unit on configs of the
|
|
# other mode crashes at load, the next time systemd starts it (found in review,
|
|
# 2026-09-24). Called at step 8 just before the unit is installed, or at the end of step 7
|
|
# on a --no-service install, which writes no unit.
|
|
apply_context_configs(){
|
|
if [ "$UNITS_ONLY" -eq 1 ]; then
|
|
# no checkpoint yet: its preparation patches the draft's config, its switch the target's
|
|
[ "$LANE" = "27b" ] && echo "the checkpoints' configs for the $CONTEXT_MODE window: set at the lane's first Load"
|
|
return 0
|
|
fi
|
|
if [ "$CONTEXT_MODE" = "1m" ]; then
|
|
# Both configs must carry the YaRN patch (target AND draft, or the draft
|
|
# crashes at load). Idempotent; originals backed up as config.json.pre-yarn.
|
|
# A kept custom model has no known pin: its newest cached snapshot is patched.
|
|
if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then
|
|
python3 "$REPO_DIR/patch-yarn.py" "$HF_CACHE" "$MODEL_REPO" || die "YaRN patch failed on the target model"
|
|
else
|
|
python3 "$REPO_DIR/patch-yarn.py" "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" || die "YaRN patch failed on the target model"
|
|
fi
|
|
python3 "$REPO_DIR/patch-yarn.py" "$HF_CACHE" "$DRAFT2_REPO" "$DRAFT2_REV" || die "YaRN patch failed on the DFlash2 draft"
|
|
else
|
|
# Coming home from 1m: a native server crashes at load on a YaRN-patched
|
|
# config (measured 2026-09-11: target context_length 1010000 against a
|
|
# derived 262144), so a native install restores the pre-YaRN originals.
|
|
# Refuses with a re-download fix-it when a config is patched but its backup
|
|
# is gone. Flash configs are never patched (1m is a 27B mode), so only the
|
|
# 27B lane restores.
|
|
#
|
|
# One combination leaves a box that boots into a crash, and it is quiet about
|
|
# it: --no-service returns at the end of step 7, so an installed 1m unit keeps
|
|
# asking for 1,010,000 from a config this restore just put back to 262,144,
|
|
# and the engine dies at load the next time systemd starts it. Seen here on
|
|
# 2026-09-18 while testing a native install against a 1m box's cache.
|
|
# ONLY --no-service. --no-start reaches step 8, renders the native template
|
|
# over that unit and enables it, so nothing is stranded there and warning
|
|
# about it would be a lie with two wrong remedies attached (caught in review
|
|
# the day this guard was written).
|
|
if [ "$LANE" = "27b" ] && [ "$NO_SERVICE" -eq 1 ] && [ -r "$SGL_UNIT_PATH" ]; then
|
|
_INSTALLED_CTX="$(grep -oE -- '--context-length [0-9]+' "$SGL_UNIT_PATH" 2>/dev/null | awk '{print $2}' | head -1 || true)"
|
|
if [ -n "$_INSTALLED_CTX" ] && [ "$_INSTALLED_CTX" -gt 262144 ]; then
|
|
echo "WARNING: the installed unit serves --context-length $_INSTALLED_CTX, and this native"
|
|
echo " install is about to restore the pre-YaRN configs it reads. --no-service writes"
|
|
echo " no unit, so that unit would crash at load the next time it starts."
|
|
echo " Either re-run without --no-service (the unit is rewritten native),"
|
|
echo " or put the box back with: CONTEXT_MODE=1m ./install.sh"
|
|
fi
|
|
fi
|
|
if [ "$LANE" = "27b" ]; then
|
|
if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then
|
|
python3 "$REPO_DIR/patch-yarn.py" --restore "$HF_CACHE" "$MODEL_REPO" || die "YaRN restore failed on the kept model"
|
|
else
|
|
python3 "$REPO_DIR/patch-yarn.py" --restore "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" || die "YaRN restore failed on the target model"
|
|
fi
|
|
python3 "$REPO_DIR/patch-yarn.py" --restore "$HF_CACHE" "$DRAFT2_REPO" "$DRAFT2_REV" || die "YaRN restore failed on the DFlash2 draft"
|
|
fi
|
|
fi
|
|
# Arete's checkpoint declares no KV cache: the lane's fp8 declaration goes into its config,
|
|
# after the window's (a YaRN restore puts back a config saved before it), as its switch does.
|
|
if [ "$MODEL_CHOICE" = arete ]; then
|
|
python3 "$REPO_DIR/patch-kv.py" "$HF_CACHE" "$MODEL_REPO" "$MODEL_REV" || die "the fp8 KV cache declaration failed on the target model"
|
|
fi
|
|
}
|
|
|
|
|
|
# ── The other text lane, installed beside this one ─────────────────────────────
|
|
# Since v1.20 a run installs both text lanes: the one it serves, and the other one, ready
|
|
# to load from the cockpit. The other one is this same script, started again for that
|
|
# lane (QWEN38_SECONDARY above). Here, before step 7, so that opencode lists both lanes
|
|
# from the first run on. What is shared with the lane served here (the port, the HF
|
|
# 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_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
|
|
else
|
|
SECOND_LANE=27b; SECOND_UNIT=qwen38-sglang.service; SECOND_WANT="$WANT_27B"; SECOND_TARGET=stock
|
|
fi
|
|
if [ "$SECOND_WANT" -eq 1 ]; then
|
|
[ -f "/etc/systemd/system/$SECOND_UNIT" ] || SECOND_FRESH=1
|
|
# new for the proofs at the end: no unit yet, or its units only (on demand, not prepared),
|
|
# 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
|
|
# 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
|
|
# (--with-flash, --with-27b) or --all-weights; its first Load from the cockpit prepares it.
|
|
SECOND_UNITS=0
|
|
SECOND_NAMED="$WITH_FLASH"; [ "$SECOND_LANE" = 27b ] && SECOND_NAMED="$WITH_27B"
|
|
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."
|
|
fi
|
|
else
|
|
SECOND_STATE=off
|
|
fi
|
|
fi
|
|
|
|
if [ -n "$SECONDARY" ]; then
|
|
step "7/10 opencode: left to the run that serves, which lists this lane too"
|
|
elif [ "$OPENCODE" -eq 0 ]; then
|
|
step "7/10 opencode integration: off"
|
|
mkdir -p "$CONFIG_DIR"
|
|
[ -f "$OC_OFF_MARK" ] || printf 'disabled with ./install.sh --no-opencode on %s\n' "$(date -u +%Y-%m-%dT%H:%MZ)" > "$OC_OFF_MARK"
|
|
if grep -q 'dgx-spark-qwen38' "$HOME/.local/bin/oc" 2>/dev/null; then
|
|
rm -f "$HOME/.local/bin/oc"; echo "removed this repo's oc launcher"
|
|
fi
|
|
rm -f "$CONFIG_DIR/opencode.json"
|
|
echo "no generated config, no launcher; switch-model.sh leaves your opencode default model alone."
|
|
echo "Your own ~/.config/opencode/opencode.json is never touched either way. Re-enable: ./install.sh --with-opencode"
|
|
else
|
|
rm -f "$OC_OFF_MARK"
|
|
step "7/10 opencode provider config + oc launcher"
|
|
# What opencode-web reads, as it stands before this step writes any of it: the server is
|
|
# restarted at the end of the step only when one of them changed (see there). A file that
|
|
# is not there yet is part of the answer, not a failure: cat fails on a missing file, and
|
|
# under pipefail that failed the assignment, so set -e ended every first install here,
|
|
# where neither file exists yet (v1.18.7 on a box with nothing installed, 2026-09-30).
|
|
oc_configs_sum(){ { cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum; }
|
|
OC_SUM_BEFORE="$(oc_configs_sum)"
|
|
# ── opencode itself, at the pinned version (see the OPENCODE_VERSION pin) ─────────
|
|
# Absent: the release asset is downloaded, checked against its pinned sha256 and put
|
|
# where opencode's own installer puts it. Older in that place: replaced the same way.
|
|
# Older elsewhere (npm, bun, opencode's own Homebrew tap): opencode's own upgrader, which
|
|
# knows its method. Older from Homebrew Core, or from a Homebrew keg that does not say which
|
|
# tap it came from: kept, and said so. For Homebrew the upgrader runs brew upgrade, which
|
|
# installs the formula's own version whatever version it is asked for: opencode's tap stays
|
|
# on 1.x, but Homebrew Core's formula is OpenCode 2 now (2.1.2 on 2026-10-22), whose server is
|
|
# not the 1.x `opencode serve` the Agent tab relays, and up to 1.19.1 the upgrader took it.
|
|
# Newer: kept, and said so, because going back a version can leave sessions a newer
|
|
# opencode wrote unreadable. None of it fails the install: opencode is one integration.
|
|
OC_HOME_BIN="$HOME/.opencode/bin/opencode"
|
|
OC_HOME_DIR="${OC_HOME_BIN%/opencode}"
|
|
oc_version(){ { "$1" --version 2>/dev/null || true; } | tail -1 | tr -d 'v[:space:]'; }
|
|
ver_lt(){ [ "$1" != "$2" ] && [ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -1)" = "$1" ]; }
|
|
# Homebrew links a formula's binary from <prefix>/Cellar/<formula>/<version>/bin and writes the
|
|
# tap the formula came from in that keg's INSTALL_RECEIPT.json (source.tap, Homebrew's tab.rb):
|
|
# anomalyco/tap for opencode's own 1.x formula (sst/tap before the project moved, a name an older
|
|
# keg keeps), homebrew/core for Homebrew's
|
|
oc_brew_not_tap(){ local bin; bin="$(readlink -f "$1" 2>/dev/null || true)"
|
|
case "$bin" in */Cellar/opencode/*/bin/opencode) ;; *) return 1 ;; esac
|
|
! grep -qsE '"tap"[[:space:]]*:[[:space:]]*"(anomalyco|sst)/tap"' "${bin%/bin/opencode}/INSTALL_RECEIPT.json"; }
|
|
oc_fetch_pinned(){ # prints the cause of a failure; the caller says what it leaves behind
|
|
local tmp url="https://github.com/anomalyco/opencode/releases/download/v$OPENCODE_VERSION/opencode-linux-arm64.tar.gz"
|
|
tmp="$(mktemp -d)"
|
|
if ! curl -fsSL --retry 3 -m 600 -o "$tmp/oc.tar.gz" "$url"; then
|
|
rm -rf "$tmp"; echo "NOTE: could not download opencode $OPENCODE_VERSION ($url)"; return 1
|
|
fi
|
|
if ! printf '%s %s\n' "$OPENCODE_SHA256" "$tmp/oc.tar.gz" | sha256sum -c --quiet - >/dev/null 2>&1; then
|
|
rm -rf "$tmp"; echo "NOTE: the opencode $OPENCODE_VERSION download does not match its pinned sha256, so it was not installed"; return 1
|
|
fi
|
|
if ! tar -xzf "$tmp/oc.tar.gz" -C "$tmp" opencode; then
|
|
rm -rf "$tmp"; echo "NOTE: the opencode $OPENCODE_VERSION archive did not unpack"; return 1
|
|
fi
|
|
mkdir -p "$OC_HOME_DIR"
|
|
# a new file renamed over the old one: a server still running the old binary keeps it.
|
|
# Its failure is the function's: the rm after it made every run return 0, and a full
|
|
# disk read "installed" (found in review, 2026-09-24).
|
|
local placed=0
|
|
install -m 755 "$tmp/opencode" "$OC_HOME_BIN.new" && mv -f "$OC_HOME_BIN.new" "$OC_HOME_BIN" && placed=1
|
|
rm -rf "$tmp" "$OC_HOME_BIN.new"
|
|
[ "$placed" -eq 1 ] || { echo "NOTE: could not put opencode $OPENCODE_VERSION at $OC_HOME_BIN"; return 1; }
|
|
}
|
|
OC_FOUND="$(command -v opencode || true)"
|
|
OC_ON_PATH="$OC_FOUND" # what a shell of the user's finds, before the fallback below
|
|
[ -z "$OC_FOUND" ] && [ -x "$OC_HOME_BIN" ] && OC_FOUND="$OC_HOME_BIN"
|
|
OC_WAS_ABSENT=0; [ -z "$OC_FOUND" ] && OC_WAS_ABSENT=1
|
|
OC_HAVE=""; [ -n "$OC_FOUND" ] && OC_HAVE="$(oc_version "$OC_FOUND")"
|
|
if [ "$OPENCODE_PIN" != "1" ]; then
|
|
echo "opencode ${OC_HAVE:-not installed}: kept as it is (OPENCODE_PIN=$OPENCODE_PIN)"
|
|
elif [ "$OC_HAVE" = "$OPENCODE_VERSION" ]; then
|
|
echo "opencode $OC_HAVE: the version this repo tests"
|
|
elif [ -z "$OC_FOUND" ] || { [ "$OC_FOUND" -ef "$OC_HOME_BIN" ] && ver_lt "$OC_HAVE" "$OPENCODE_VERSION"; }; then
|
|
if [ -z "$OC_FOUND" ]; then
|
|
echo "opencode is not installed: installing $OPENCODE_VERSION (the release asset, checked against its pinned sha256)"
|
|
else
|
|
echo "opencode $OC_HAVE -> $OPENCODE_VERSION: replacing it with the release asset, checked against its pinned sha256"
|
|
fi
|
|
if oc_fetch_pinned; then
|
|
OC_FOUND="$OC_HOME_BIN"; OC_HAVE="$(oc_version "$OC_HOME_BIN")"
|
|
echo "opencode $OC_HAVE installed at $OC_HOME_BIN"
|
|
elif [ -z "$OC_FOUND" ]; then
|
|
echo " opencode is still not installed, and the Agent view and the oc launcher need it. Re-run ./install.sh"
|
|
echo " once GitHub is reachable, or install it from https://opencode.ai (this repo tests $OPENCODE_VERSION)."
|
|
else
|
|
echo " opencode stays at $OC_HAVE."
|
|
fi
|
|
elif ver_lt "$OC_HAVE" "$OPENCODE_VERSION" && oc_brew_not_tap "$OC_FOUND"; then
|
|
echo "NOTE: opencode $OC_HAVE comes from Homebrew, not from opencode's own tap, kept: its upgrader would"
|
|
echo " run brew upgrade, which installs Homebrew's version, not $OPENCODE_VERSION, and Homebrew Core's"
|
|
echo " formula is OpenCode 2 now, which oc and the Agent view are not written for. For $OPENCODE_VERSION:"
|
|
echo " brew uninstall opencode, then run this installer again (it installs $OPENCODE_VERSION at"
|
|
echo " ~/.opencode/bin), or brew install anomalyco/tap/opencode (opencode's own formula, on 1.x)."
|
|
elif ver_lt "$OC_HAVE" "$OPENCODE_VERSION"; then
|
|
echo "opencode $OC_HAVE -> $OPENCODE_VERSION through opencode's own upgrader ($OC_FOUND)"
|
|
"$OC_FOUND" upgrade "$OPENCODE_VERSION" </dev/null >/dev/null 2>&1 \
|
|
|| echo "NOTE: opencode upgrade $OPENCODE_VERSION failed; run it yourself"
|
|
OC_HAVE="$(oc_version "$OC_FOUND")"
|
|
else
|
|
echo "NOTE: opencode $OC_HAVE is newer than the $OPENCODE_VERSION this repo tests. Kept: going back"
|
|
echo " a version can leave sessions a newer opencode wrote unreadable. OPENCODE_PIN=0 silences this."
|
|
fi
|
|
if [ "$OPENCODE_PIN" = "1" ] && [ -n "$OC_HAVE" ] && ver_lt "$OC_HAVE" "$OPENCODE_VERSION"; then
|
|
echo "NOTE: opencode is still $OC_HAVE after the step above; oc and the Agent view keep running it"
|
|
fi
|
|
# The rest of this run (the Agent tab's unit, the oc launcher) finds opencode on PATH, and
|
|
# a first install puts it in the shell's PATH the way opencode's own installer does.
|
|
if [ -n "$OC_FOUND" ] && [ "$OC_FOUND" -ef "$OC_HOME_BIN" ]; then
|
|
case ":$PATH:" in *":$OC_HOME_DIR:"*) ;; *) export PATH="$OC_HOME_DIR:$PATH" ;; esac
|
|
# A shell the user opens later finds it only through a line: one this run installs,
|
|
# and one already here that is on no PATH (a v1.18.3 install skipped the line for a
|
|
# commented-out one, and an update never wrote it after). A commented-out line is no PATH.
|
|
if [ -z "$OC_ON_PATH" ] && ! grep -qsE '^[^#]*\.opencode/bin' "$HOME/.bashrc"; then
|
|
if [ "$OC_WAS_ABSENT" -eq 1 ]; then
|
|
printf '\n# opencode, installed by dgx-spark-qwen38 (%s)\nexport PATH="$HOME/.opencode/bin:$PATH"\n' "$OPENCODE_VERSION" >> "$HOME/.bashrc"
|
|
else
|
|
printf '\n# opencode, put on the PATH by dgx-spark-qwen38\nexport PATH="$HOME/.opencode/bin:$PATH"\n' >> "$HOME/.bashrc"
|
|
fi
|
|
echo "added ~/.opencode/bin to your PATH in ~/.bashrc (open a new shell, or: export PATH=\"\$HOME/.opencode/bin:\$PATH\")"
|
|
fi
|
|
fi
|
|
# A complete, ready-to-use opencode config (https://opencode.ai). The limits
|
|
# satisfy the serving window in BOTH modes, including when opencode's hidden
|
|
# 32000 output cap is lifted by the oc launcher below. The engine refuses any
|
|
# request whose prompt + max_tokens passes its window, and the prompt opencode
|
|
# sends can reach its compaction threshold plus one worst step (oc-limits.sh):
|
|
# native: 173000 - 20000 + 43863 + 64000 = 260863 <= 262144
|
|
# 1m: 700000 (compaction at 680000) + 200000 = 880000, against pools of
|
|
# 902,398 / 889,131 / 889,722 / 887,797 on v0.5.19 at 0.76 (2026-09-17
|
|
# and 18), a margin of 7,797 tokens over the worst; but the same image
|
|
# also booted to 854,123 and 873,429, and v0.5.21 to 872,414, 878,687
|
|
# and 877,859 (2026-10-09), where the pair does not fit. These
|
|
# static numbers are the starting point, not the contract: step 9
|
|
# runs oc-fit-limits.py against the pool the boot actually got and
|
|
# rewrites them (551,000 + 183,000 there). A box that skips that fit
|
|
# (--no-opencode, or the NOTE path when the engine is not up) keeps
|
|
# the static pair. The proxy does not refuse it: its guard is 92 % of
|
|
# the pool, and the largest prompt opencode sends with this pair, the
|
|
# compaction point plus one worst step (680,000 + 43,863 = 723,863),
|
|
# stays under it on every pool the lane booted to (832,993 the least). What
|
|
# does not fit is that prompt plus a whole answer: one that runs past
|
|
# about 109,000 tokens at the very end of a full session.
|
|
# Service installs point agent clients at the keepalive proxy (step 8): SGLang
|
|
# buffers tool-call arguments at any context length and agent CLIs abort
|
|
# silent streams. --no-service has no proxy: direct server port for ./run.sh.
|
|
# The key is referenced via {file:...}: no secret in the file.
|
|
# opencode limits per context mode: one table, in oc-limits.sh, because
|
|
# switch-model.sh has to write the same numbers and a second copy is how the two
|
|
# drift. See that script for why the numbers matter (a limit above what the lane
|
|
# serves turns a compaction into a 400 mid-session).
|
|
if [ "${LANE:-27b}" = "flash" ]; then
|
|
OC_SELECTOR="$FLASH_TIER"
|
|
else
|
|
OC_SELECTOR="$CONTEXT_MODE"
|
|
fi
|
|
# captured first: `read <<<"$(cmd)"` returns 0 whatever cmd returned, so this refusal
|
|
# never fired and a refused target died below under "returned no limits"
|
|
OC_ROW="$("$REPO_DIR/oc-limits.sh" "$MODEL_CHOICE" "$OC_SELECTOR")" \
|
|
|| die "oc-limits.sh refused MODEL_CHOICE=$MODEL_CHOICE with $OC_SELECTOR (repo bug: please open an issue)"
|
|
read -r OC_CTX OC_OUT OC_LABEL <<<"$OC_ROW"
|
|
[ -n "${OC_CTX:-}" ] && [ -n "${OC_OUT:-}" ] \
|
|
|| die "oc-limits.sh returned no limits for $MODEL_CHOICE/$OC_SELECTOR"
|
|
# The output CEILING is not this target's number: opencode sends
|
|
# max_tokens = min(limit.output, the ceiling), limit.output is what a switch
|
|
# rewrites, and a ceiling taken from the installed target survives the switch
|
|
# and cuts the next lane's turn in silence. So it is the table's maximum.
|
|
OC_OUT_CAP="$("$REPO_DIR/oc-limits.sh" --max-out)" \
|
|
|| die "oc-limits.sh --max-out failed (repo bug: please open an issue)"
|
|
[ "${OC_OUT_CAP:-0}" -ge "$OC_OUT" ] \
|
|
|| die "oc-limits.sh --max-out returned $OC_OUT_CAP, below this target's $OC_OUT"
|
|
OC_PORT="$PROXY_PORT"
|
|
[ "${NO_SERVICE:-0}" -eq 1 ] && OC_PORT="$PORT"
|
|
# end oc mode
|
|
# A provider appears in the picker only when its engine is installed on this
|
|
# box (nobody should be offered a model that nothing serves); the model being
|
|
# installed right now always appears. The default model is the one being
|
|
# installed. json.dump writes the file: no hand-escaping.
|
|
OC_27B=0; OC_FLASH=0; OC_KOLIBRI=0; OC_NEMOTRON=0; OC_NEMOTRON_SUPER=0; OC_FLASH_LOCAL=0; OC_ORNITH_122B=0; OC_FLASH_UNSLOTH=0
|
|
{ [ "$LANE" = "27b" ] || [ -f "$SGL_UNIT_PATH" ]; } && OC_27B=1
|
|
{ [ "$LANE" = "flash" ] || [ -f "$FLASH_UNIT_PATH" ]; } && OC_FLASH=1
|
|
# The Kolibri lane is installed at the end of a run (install-kolibri.sh): its provider comes
|
|
# with the first run that finds its unit, or with the first switch to it.
|
|
[ -f "$KOLIBRI_UNIT_PATH" ] && OC_KOLIBRI=1
|
|
OC_KOLIBRI_CTX=""; OC_KOLIBRI_OUT=""; OC_KOLIBRI_NAME=""
|
|
if [ "$OC_KOLIBRI" -eq 1 ]; then
|
|
OC_KOLIBRI_TARGET=kolibri
|
|
# the NVFP4 checkpoint as install-kolibri.sh pins it (it was written here a second time)
|
|
OC_KOLIBRI_NVFP4="$(sed -n 's/^KOLIBRI_NVFP4_REPO="\([^"]*\)"$/\1/p' "$REPO_DIR/install-kolibri.sh")"
|
|
[ -n "$OC_KOLIBRI_NVFP4" ] && grep -qs -- "$OC_KOLIBRI_NVFP4 --revision" "$KOLIBRI_UNIT_PATH" && OC_KOLIBRI_TARGET=kolibri-nvfp4
|
|
OC_KOLIBRI_PAIR="$("$REPO_DIR/oc-limits.sh" "$OC_KOLIBRI_TARGET")" \
|
|
|| die "oc-limits.sh refused $OC_KOLIBRI_TARGET (repo bug: please open an issue)"
|
|
OC_KOLIBRI_CTX="${OC_KOLIBRI_PAIR%% *}"; OC_KOLIBRI_OUT="$(echo "$OC_KOLIBRI_PAIR" | cut -d' ' -f2)"
|
|
OC_KOLIBRI_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$OC_KOLIBRI_TARGET" 262144 || true)"
|
|
fi
|
|
# The Nemotron lane, the same way: one checkpoint today, its provider with its unit.
|
|
[ -f "$NEMOTRON_UNIT_PATH" ] && OC_NEMOTRON=1
|
|
OC_NEMOTRON_CTX=""; OC_NEMOTRON_OUT=""; OC_NEMOTRON_NAME=""
|
|
if [ "$OC_NEMOTRON" -eq 1 ]; then
|
|
OC_NEMOTRON_PAIR="$("$REPO_DIR/oc-limits.sh" nemotron)" \
|
|
|| die "oc-limits.sh refused nemotron (repo bug: please open an issue)"
|
|
OC_NEMOTRON_CTX="${OC_NEMOTRON_PAIR%% *}"; OC_NEMOTRON_OUT="$(echo "$OC_NEMOTRON_PAIR" | cut -d' ' -f2)"
|
|
OC_NEMOTRON_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label nemotron 262144 || true)"
|
|
fi
|
|
# The Nemotron Super lane, its own provider (its own model and window) with its unit.
|
|
[ -f "$NEMOTRON_SUPER_UNIT_PATH" ] && OC_NEMOTRON_SUPER=1
|
|
OC_NEMOTRON_SUPER_CTX=""; OC_NEMOTRON_SUPER_OUT=""; OC_NEMOTRON_SUPER_NAME=""
|
|
if [ "$OC_NEMOTRON_SUPER" -eq 1 ]; then
|
|
OC_NEMOTRON_SUPER_PAIR="$("$REPO_DIR/oc-limits.sh" nemotron-super)" \
|
|
|| die "oc-limits.sh refused nemotron-super (repo bug: please open an issue)"
|
|
OC_NEMOTRON_SUPER_CTX="${OC_NEMOTRON_SUPER_PAIR%% *}"; OC_NEMOTRON_SUPER_OUT="$(echo "$OC_NEMOTRON_SUPER_PAIR" | cut -d' ' -f2)"
|
|
OC_NEMOTRON_SUPER_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label nemotron-super 1048576 || true)"
|
|
fi
|
|
# The Qwen3.8 Flash-Next FP4-Local lane, its own provider (its own served model) with its unit.
|
|
[ -f "$FLASH_LOCAL_UNIT_PATH" ] && OC_FLASH_LOCAL=1
|
|
OC_FLASH_LOCAL_CTX=""; OC_FLASH_LOCAL_OUT=""; OC_FLASH_LOCAL_NAME=""; OC_FLASH_LOCAL_WINDOW=""
|
|
if [ "$OC_FLASH_LOCAL" -eq 1 ]; then
|
|
# its unit's window: 1,048,576 tokens with FLASH_LOCAL_CONTEXT=1m (v1.45.2), the pair to match
|
|
OC_FLASH_LOCAL_WINDOW="$({ grep -oE -- '--max-model-len [0-9]+' "$FLASH_LOCAL_UNIT_PATH" 2>/dev/null || true; } | awk 'NR == 1 {print $2}')"
|
|
OC_FLASH_LOCAL_PAIR="$("$REPO_DIR/oc-limits.sh" flash-local --from "$FLASH_LOCAL_UNIT_PATH")" \
|
|
|| die "oc-limits.sh refused flash-local (repo bug: please open an issue)"
|
|
OC_FLASH_LOCAL_CTX="${OC_FLASH_LOCAL_PAIR%% *}"; OC_FLASH_LOCAL_OUT="$(echo "$OC_FLASH_LOCAL_PAIR" | cut -d' ' -f2)"
|
|
OC_FLASH_LOCAL_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label flash-local "${OC_FLASH_LOCAL_WINDOW:-262144}" || true)"
|
|
fi
|
|
# The Ornith 1.5 122B lane, its own provider (its own served model) with its unit.
|
|
[ -f "$ORNITH_122B_UNIT_PATH" ] && OC_ORNITH_122B=1
|
|
OC_ORNITH_122B_CTX=""; OC_ORNITH_122B_OUT=""; OC_ORNITH_122B_NAME=""
|
|
if [ "$OC_ORNITH_122B" -eq 1 ]; then
|
|
OC_ORNITH_122B_PAIR="$("$REPO_DIR/oc-limits.sh" ornith-122b)" \
|
|
|| die "oc-limits.sh refused ornith-122b (repo bug: please open an issue)"
|
|
OC_ORNITH_122B_CTX="${OC_ORNITH_122B_PAIR%% *}"; OC_ORNITH_122B_OUT="$(echo "$OC_ORNITH_122B_PAIR" | cut -d' ' -f2)"
|
|
OC_ORNITH_122B_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label ornith-122b 1048576 || true)"
|
|
fi
|
|
# The Qwen3.8 Flash-Next Unsloth GGUF lane, its own provider (its own served model) with its unit.
|
|
[ -f "$FLASH_UNSLOTH_UNIT_PATH" ] && OC_FLASH_UNSLOTH=1
|
|
OC_FLASH_UNSLOTH_CTX=""; OC_FLASH_UNSLOTH_OUT=""; OC_FLASH_UNSLOTH_NAME=""; OC_FLASH_UNSLOTH_WINDOW=""; OC_FLASH_UNSLOTH_TARGET=""
|
|
if [ "$OC_FLASH_UNSLOTH" -eq 1 ]; then
|
|
# its unit's window, the -c its llama-server takes, and the pair of that window: 262,144 for each request, 1,048,576
|
|
# with FLASH_UNSLOTH_CONTEXT=1m (decisions 1316 and 1318, 2026-11-12); and the target the unit serves, which the
|
|
# entry's name says (lanes.sh), its installer's default for a unit that names neither of its two (v1.49); the one
|
|
# this run hands its installer (FLASH_UNSLOTH_TARGET, given or moved above) when it installs the lane, as the unit
|
|
# it renders later in the run serves that one
|
|
OC_FLASH_UNSLOTH_WINDOW="$(llamacpp_window "$FLASH_UNSLOTH_UNIT_PATH")"
|
|
OC_FLASH_UNSLOTH_TARGET="$(flash_unsloth_target "$FLASH_UNSLOTH_UNIT_PATH" "$REPO_DIR/install-flash-unsloth.sh")"
|
|
[ "$WANT_FLASH_UNSLOTH" -ne 1 ] || [ -z "${FLASH_UNSLOTH_TARGET:-}" ] || OC_FLASH_UNSLOTH_TARGET="$FLASH_UNSLOTH_TARGET"
|
|
[ -n "$OC_FLASH_UNSLOTH_TARGET" ] \
|
|
|| OC_FLASH_UNSLOTH_TARGET="$(sed -n 's/^FLASH_UNSLOTH_DEFAULT="\([a-z0-9-]*\)"$/\1/p' "$REPO_DIR/install-flash-unsloth.sh")"
|
|
OC_FLASH_UNSLOTH_PAIR="$("$REPO_DIR/oc-limits.sh" "$OC_FLASH_UNSLOTH_TARGET" --from "$FLASH_UNSLOTH_UNIT_PATH")" \
|
|
|| die "oc-limits.sh refused ${OC_FLASH_UNSLOTH_TARGET:-the Qwen3.8 Flash-Next Unsloth GGUF lane} (repo bug: please open an issue)"
|
|
OC_FLASH_UNSLOTH_CTX="${OC_FLASH_UNSLOTH_PAIR%% *}"; OC_FLASH_UNSLOTH_OUT="$(echo "$OC_FLASH_UNSLOTH_PAIR" | cut -d' ' -f2)"
|
|
OC_FLASH_UNSLOTH_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$OC_FLASH_UNSLOTH_TARGET" "${OC_FLASH_UNSLOTH_WINDOW:-262144}" || true)"
|
|
fi
|
|
# How much of a conversation survives a compaction verbatim, from the same table.
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_CTX (repo bug: please open an issue)"
|
|
# On 1m the table gives bounds and the fit to the pool sets the pair (fitted() below and
|
|
# --keep-lower), so the compaction goes with the fitted pair too: sized from the bound here,
|
|
# it was set back at every run and the fit at the end set it again, two writes, two backups
|
|
# and two opencode-web restarts per update (seen on the reference box, 2026-09-25). A 64 GB box
|
|
# is fitted at the end too (its native pair was sized on a 128 GB box's pool), so the same holds
|
|
# there (found in review, 2026-10-23).
|
|
if { [ "$CONTEXT_MODE" = "1m" ] || [ "$MEM_CLASS" = 64 ]; } && [ "$LANE" != "flash" ]; then
|
|
OC_FIT_CTX="$(python3 - "$CONFIG_DIR/opencode.json" "$OC_CTX" "$OC_OUT" <<'PY' 2>/dev/null || true
|
|
import json, sys
|
|
try:
|
|
lim = json.load(open(sys.argv[1]))["provider"]["qwen38"]["models"]["qwen3.8-27b"]["limit"]
|
|
c, o = int(lim["context"]), int(lim["output"])
|
|
if 0 < c <= int(sys.argv[2]) and 0 < o <= int(sys.argv[3]):
|
|
print(c)
|
|
except Exception:
|
|
pass
|
|
PY
|
|
)"
|
|
if [ -n "$OC_FIT_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_FIT_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_FIT_CTX (repo bug: please open an issue)"
|
|
fi
|
|
fi
|
|
# The Kolibri lane serving at boot: opencode's default is Kolibri (OC_POINT_* below), and the
|
|
# compaction block, global, goes with the default's window, as a switch to it sizes it. Sized
|
|
# from the Qwen lane, a 27B in 1M mode kept 132,000 verbatim against Kolibri's threshold of
|
|
# 185,000 (153,000 when this was found), and opencode compacted again every step or two (found in
|
|
# review, 2026-10-14).
|
|
if [ "$KOLIBRI_BOOT" -eq 1 ] && [ "$OC_KOLIBRI" -eq 1 ] && [ -n "$OC_KOLIBRI_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_KOLIBRI_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_KOLIBRI_CTX (repo bug: please open an issue)"
|
|
fi
|
|
if [ "$NEMOTRON_BOOT" -eq 1 ] && [ "$OC_NEMOTRON" -eq 1 ] && [ -n "$OC_NEMOTRON_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_NEMOTRON_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_NEMOTRON_CTX (repo bug: please open an issue)"
|
|
fi
|
|
if [ "$NEMOTRON_SUPER_BOOT" -eq 1 ] && [ "$OC_NEMOTRON_SUPER" -eq 1 ] && [ -n "$OC_NEMOTRON_SUPER_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_NEMOTRON_SUPER_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_NEMOTRON_SUPER_CTX (repo bug: please open an issue)"
|
|
fi
|
|
if [ "$FLASH_LOCAL_BOOT" -eq 1 ] && [ "$OC_FLASH_LOCAL" -eq 1 ] && [ -n "$OC_FLASH_LOCAL_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_FLASH_LOCAL_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_FLASH_LOCAL_CTX (repo bug: please open an issue)"
|
|
fi
|
|
if [ "$ORNITH_122B_BOOT" -eq 1 ] && [ "$OC_ORNITH_122B" -eq 1 ] && [ -n "$OC_ORNITH_122B_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_ORNITH_122B_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_ORNITH_122B_CTX (repo bug: please open an issue)"
|
|
fi
|
|
if [ "$FLASH_UNSLOTH_BOOT" -eq 1 ] && [ "$OC_FLASH_UNSLOTH" -eq 1 ] && [ -n "$OC_FLASH_UNSLOTH_CTX" ]; then
|
|
OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_FLASH_UNSLOTH_CTX")" \
|
|
|| die "oc-limits.sh --preserve failed for $OC_FLASH_UNSLOTH_CTX (repo bug: please open an issue)"
|
|
fi
|
|
# The other engine's limits, for when both providers are present: the 27B block
|
|
# keeps its context-mode limits, flash always serves its native window. A flash install
|
|
# runs in native mode, so the 27B's own mode comes from its unit: taken from this run, a
|
|
# 1M 27B got the native 194048/64000, which oc and the Agent tab read first since they
|
|
# load this file over the user's (reference box, 2026-09-23).
|
|
OC_27B_MODE="$CONTEXT_MODE"
|
|
if [ "$LANE" = "flash" ]; then
|
|
OC_27B_MODE=native
|
|
if grep -qs -- '--context-length 1010000' "$SGL_UNIT_PATH"; then OC_27B_MODE=1m; fi
|
|
fi
|
|
# Its pair comes from the same table, for the checkpoint that unit serves: FP8 has its
|
|
# own 1M pair, and a copy of the numbers here had drifted from the table (it gave an FP8
|
|
# box 700000/200000; found in review, 2026-09-24).
|
|
OC_27B_CHOICE=stock
|
|
case "$(grep -oE -- '--model-path [^ ]+' "$SGL_UNIT_PATH" 2>/dev/null | head -1 | cut -d' ' -f2 || true)" in
|
|
"$FP8_REPO"|"$UNCFP8_REPO") OC_27B_CHOICE=fp8 ;;
|
|
esac
|
|
OC_27B_PAIR="$("$REPO_DIR/oc-limits.sh" "$OC_27B_CHOICE" "$OC_27B_MODE")" \
|
|
|| die "oc-limits.sh refused $OC_27B_CHOICE/$OC_27B_MODE (repo bug: please open an issue)"
|
|
OC_27B_CTX="${OC_27B_PAIR%% *}"; OC_27B_OUT="$(echo "$OC_27B_PAIR" | cut -d' ' -f2)"
|
|
# The lane that is not being installed keeps the name of the checkpoint its unit serves,
|
|
# from the same table as the served one. A flash install wrote the 27B entry a generic
|
|
# name, the next switch back renamed it, so the first update after every switch rewrote
|
|
# the file and restarted opencode-web for a name (the reference box, 2026-09-30).
|
|
OC_27B_TARGET=stock
|
|
case "$(grep -oE -- '--model-path [^ ]+' "$SGL_UNIT_PATH" 2>/dev/null | head -1 | cut -d' ' -f2 || true)" in
|
|
"$UNC_REPO") OC_27B_TARGET=uncensored ;;
|
|
"$FP8_REPO") OC_27B_TARGET=fp8 ;;
|
|
"$UNCFP8_REPO") OC_27B_TARGET=uncensored-fp8 ;;
|
|
"$ARETE_REPO") OC_27B_TARGET=arete ;;
|
|
esac
|
|
OC_27B_WINDOW=262144; [ "$OC_27B_MODE" = "1m" ] && OC_27B_WINDOW=1010000
|
|
OC_27B_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$OC_27B_TARGET" "$OC_27B_WINDOW" || true)"
|
|
OC_FLASH_TARGET=flash
|
|
case "$(grep -oE -- '--model-path [^ ]+' "$CONFIG_DIR/launch-flash.sh" 2>/dev/null | head -1 | cut -d' ' -f2 || true)" in
|
|
"$FLASH_UNC_REPO") OC_FLASH_TARGET=flash-uncensored ;;
|
|
"$FLASH_NVDA_REPO") OC_FLASH_TARGET=flash-nvda ;;
|
|
esac
|
|
OC_FLASH_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$OC_FLASH_TARGET" 262144 || true)"
|
|
# Its pair from the same table, for the tier its launcher runs, as the 27B's above. A copy
|
|
# here, 110000/32000 (the throughput tier's), cut the 205,000 window of the concurrency and
|
|
# context tiers to 110,000 at every run that served the 27B (the reference box, 2026-10-06).
|
|
OC_FLASH_CTX=""; OC_FLASH_OUT=""
|
|
if [ "$OC_FLASH" -eq 1 ] && [ "$LANE" != "flash" ]; then
|
|
OC_FLASH_PAIR="$("$REPO_DIR/oc-limits.sh" "$OC_FLASH_TARGET" --from "$CONFIG_DIR/launch-flash.sh")" \
|
|
|| die "oc-limits.sh refused $OC_FLASH_TARGET (repo bug: please open an issue)"
|
|
OC_FLASH_CTX="${OC_FLASH_PAIR%% *}"; OC_FLASH_OUT="$(echo "$OC_FLASH_PAIR" | cut -d' ' -f2)"
|
|
fi
|
|
# The served entry's name comes from the table oc-point-default.py applies below. The
|
|
# generator wrote a generic one that the call below then renamed, so the file was written
|
|
# twice at every run, and the rename now leaves a backup (found in review, 2026-09-24).
|
|
OC_WINDOW=262144; [ "$CONTEXT_MODE" = "1m" ] && OC_WINDOW=1010000
|
|
OC_SERVED_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$MODEL_CHOICE" "$OC_WINDOW")" \
|
|
|| die "oc-point-default.py --label failed (repo bug: please open an issue)"
|
|
OC_LANE="$LANE" OC_27B="$OC_27B" OC_FLASH="$OC_FLASH" OC_PORT="$OC_PORT" \
|
|
OC_CTX="$OC_CTX" OC_OUT="$OC_OUT" OC_LABEL="$OC_LABEL" OC_CONTEXT_MODE="$OC_27B_MODE" OC_MEM_CLASS="$MEM_CLASS" \
|
|
OC_27B_CTX="$OC_27B_CTX" OC_27B_OUT="$OC_27B_OUT" OC_SERVED_NAME="$OC_SERVED_NAME" \
|
|
OC_27B_NAME="$OC_27B_NAME" OC_FLASH_NAME="$OC_FLASH_NAME" \
|
|
OC_FLASH_CTX="$OC_FLASH_CTX" OC_FLASH_OUT="$OC_FLASH_OUT" \
|
|
OC_KOLIBRI="$OC_KOLIBRI" OC_KOLIBRI_CTX="$OC_KOLIBRI_CTX" OC_KOLIBRI_OUT="$OC_KOLIBRI_OUT" \
|
|
OC_KOLIBRI_NAME="$OC_KOLIBRI_NAME" OC_KOLIBRI_BOOT="$KOLIBRI_BOOT" OC_REPO_DIR="$REPO_DIR" \
|
|
OC_NEMOTRON="$OC_NEMOTRON" OC_NEMOTRON_CTX="$OC_NEMOTRON_CTX" OC_NEMOTRON_OUT="$OC_NEMOTRON_OUT" \
|
|
OC_NEMOTRON_NAME="$OC_NEMOTRON_NAME" OC_NEMOTRON_BOOT="$NEMOTRON_BOOT" \
|
|
OC_NEMOTRON_SUPER="$OC_NEMOTRON_SUPER" OC_NEMOTRON_SUPER_CTX="$OC_NEMOTRON_SUPER_CTX" OC_NEMOTRON_SUPER_OUT="$OC_NEMOTRON_SUPER_OUT" \
|
|
OC_NEMOTRON_SUPER_NAME="$OC_NEMOTRON_SUPER_NAME" OC_NEMOTRON_SUPER_BOOT="$NEMOTRON_SUPER_BOOT" \
|
|
OC_FLASH_LOCAL="$OC_FLASH_LOCAL" OC_FLASH_LOCAL_CTX="$OC_FLASH_LOCAL_CTX" OC_FLASH_LOCAL_OUT="$OC_FLASH_LOCAL_OUT" \
|
|
OC_FLASH_LOCAL_NAME="$OC_FLASH_LOCAL_NAME" OC_FLASH_LOCAL_BOOT="$FLASH_LOCAL_BOOT" \
|
|
OC_ORNITH_122B="$OC_ORNITH_122B" OC_ORNITH_122B_CTX="$OC_ORNITH_122B_CTX" OC_ORNITH_122B_OUT="$OC_ORNITH_122B_OUT" \
|
|
OC_ORNITH_122B_NAME="$OC_ORNITH_122B_NAME" OC_ORNITH_122B_BOOT="$ORNITH_122B_BOOT" \
|
|
OC_FLASH_UNSLOTH="$OC_FLASH_UNSLOTH" OC_FLASH_UNSLOTH_CTX="$OC_FLASH_UNSLOTH_CTX" OC_FLASH_UNSLOTH_OUT="$OC_FLASH_UNSLOTH_OUT" \
|
|
OC_FLASH_UNSLOTH_NAME="$OC_FLASH_UNSLOTH_NAME" OC_FLASH_UNSLOTH_BOOT="$FLASH_UNSLOTH_BOOT" \
|
|
OC_KEEP="$OC_KEEP" OC_PIN="$OPENCODE_PIN" OC_DENY="$(python3 "$REPO_DIR/oc-merge-limits.py" --deny-permission)" \
|
|
OC_CONFIG_DIR="$CONFIG_DIR" python3 - <<'PYEOF' || die "could not write the opencode provider config"
|
|
import json
|
|
import os
|
|
|
|
cfg_dir = os.environ["OC_CONFIG_DIR"]
|
|
lane = os.environ["OC_LANE"]
|
|
# "lean" first: it is the level the patched template defaults to, so a picker
|
|
# that lists it first shows the level a client gets when it selects nothing.
|
|
# The three Qwen levels stay, unchanged, for anyone who wants them by name.
|
|
variants = {lvl: {"chat_template_kwargs": {"reasoning_effort": lvl}}
|
|
for lvl in ("lean", "low", "medium", "xhigh")}
|
|
key_ref = f"{{file:{cfg_dir}/api-key}}"
|
|
base_url = f"http://127.0.0.1:{os.environ['OC_PORT']}/v1"
|
|
# the name oc-point-default.py gives the served lane's entry, empty for a target it has none for
|
|
served_name = os.environ.get("OC_SERVED_NAME", "")
|
|
|
|
def prov(name, model_id, model_name, ctx, out):
|
|
return {
|
|
"npm": "@ai-sdk/openai-compatible",
|
|
"name": name,
|
|
"options": {"baseURL": base_url, "apiKey": key_ref},
|
|
"models": {model_id: {
|
|
"name": model_name,
|
|
"limit": {"context": ctx, "input": ctx, "output": out},
|
|
"variants": variants,
|
|
"attachment": True,
|
|
"modalities": {"input": ["text", "image"], "output": ["text"]},
|
|
}},
|
|
}
|
|
|
|
def fitted(provider, model_id, bound_ctx, bound_out):
|
|
"""The pair a fit to the engine's pool left here under the table's 1m bounds, if any.
|
|
On a 1m box the table only gives bounds and the fit (end of the install, or the
|
|
cockpit) sets the pair: writing the bounds over it made every 1m run write twice, the
|
|
bounds here and the fit at the end, with an opencode restart for each (found in
|
|
review, 2026-09-24)."""
|
|
try:
|
|
with open(f"{cfg_dir}/opencode.json") as f:
|
|
lim = json.load(f)["provider"][provider]["models"][model_id]["limit"]
|
|
c, o = int(lim["context"]), int(lim["output"])
|
|
except Exception:
|
|
return None
|
|
return (c, o) if 0 < c <= bound_ctx and 0 < o <= bound_out else None
|
|
|
|
providers = {}
|
|
if os.environ["OC_27B"] == "1":
|
|
if lane == "27b":
|
|
ctx, out, label = int(os.environ["OC_CTX"]), int(os.environ["OC_OUT"]), os.environ["OC_LABEL"]
|
|
else: # flash install on a box that also has the 27B unit: keep its own limits
|
|
ctx, out = int(os.environ["OC_27B_CTX"]), int(os.environ["OC_27B_OUT"])
|
|
label = "local, 1M" if os.environ["OC_CONTEXT_MODE"] == "1m" else "local"
|
|
# a 64 GB box's pair is fitted at the end as 1m's is (its native pair a bound there)
|
|
if os.environ["OC_CONTEXT_MODE"] == "1m" or os.environ.get("OC_MEM_CLASS") == "64":
|
|
ctx, out = fitted("qwen38", "qwen3.8-27b", ctx, out) or (ctx, out)
|
|
providers["qwen38"] = prov("Qwen3.8-27B (DGX Spark)", "qwen3.8-27b",
|
|
lane == "27b" and served_name or os.environ.get("OC_27B_NAME")
|
|
or f"Qwen3.8-27B NVFP4+DFlash2 ({label})",
|
|
ctx, out)
|
|
if os.environ["OC_FLASH"] == "1":
|
|
# the flash lane's limits follow the pool math above (OC_CTX/OC_OUT); a 27B
|
|
# install that also lists flash takes the table's pair for the tier its launcher runs
|
|
fctx, fout = ((int(os.environ["OC_CTX"]), int(os.environ["OC_OUT"])) if lane == "flash"
|
|
else (int(os.environ["OC_FLASH_CTX"]), int(os.environ["OC_FLASH_OUT"])))
|
|
providers["flashnext"] = prov("Qwen3.8-Flash-Next (DGX Spark)", "qwen3.8-flash-next",
|
|
lane == "flash" and served_name or os.environ.get("OC_FLASH_NAME")
|
|
or "Qwen3.8-Flash-Next NVFP4+MTP (local, 262K)",
|
|
fctx, fout)
|
|
if os.environ.get("OC_KOLIBRI") == "1":
|
|
# one definition, shared with switch-model.sh (oc-kolibri.py says why)
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_kolibri", os.path.join(os.environ["OC_REPO_DIR"], "oc-kolibri.py"))
|
|
ock = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ock)
|
|
providers["kolibri"] = ock.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_KOLIBRI_CTX"]), int(os.environ["OC_KOLIBRI_OUT"]),
|
|
os.environ.get("OC_KOLIBRI_NAME") or "Kolibri-1 FP8 official (local, 262K)")
|
|
if os.environ.get("OC_NEMOTRON") == "1":
|
|
# one definition, shared with switch-model.sh (oc-nemotron.py says why)
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_nemotron", os.path.join(os.environ["OC_REPO_DIR"], "oc-nemotron.py"))
|
|
ocn = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ocn)
|
|
providers["nemotron"] = ocn.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_NEMOTRON_CTX"]), int(os.environ["OC_NEMOTRON_OUT"]),
|
|
os.environ.get("OC_NEMOTRON_NAME") or "Nemotron 3.5 Bolt (local, 262K)")
|
|
if os.environ.get("OC_NEMOTRON_SUPER") == "1":
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_nemotron", os.path.join(os.environ["OC_REPO_DIR"], "oc-nemotron.py"))
|
|
ocn = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ocn)
|
|
providers["nemotron-super"] = ocn.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_NEMOTRON_SUPER_CTX"]), int(os.environ["OC_NEMOTRON_SUPER_OUT"]),
|
|
os.environ.get("OC_NEMOTRON_SUPER_NAME") or "Nemotron 3.5 Super VL (local, 1M)",
|
|
"nemotron-super")
|
|
if os.environ.get("OC_FLASH_LOCAL") == "1":
|
|
# one definition, shared with switch-model.sh (oc-flash-local.py says why)
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_flash_local", os.path.join(os.environ["OC_REPO_DIR"], "oc-flash-local.py"))
|
|
ocf = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ocf)
|
|
providers["flash-local"] = ocf.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_FLASH_LOCAL_CTX"]), int(os.environ["OC_FLASH_LOCAL_OUT"]),
|
|
os.environ.get("OC_FLASH_LOCAL_NAME") or "Qwen3.8-Flash-Next FP4-Local (local, 262K)")
|
|
if os.environ.get("OC_ORNITH_122B") == "1":
|
|
# one definition, shared with switch-model.sh (oc-ornith.py says why)
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_ornith", os.path.join(os.environ["OC_REPO_DIR"], "oc-ornith.py"))
|
|
oco = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(oco)
|
|
providers["ornith-122b"] = oco.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_ORNITH_122B_CTX"]), int(os.environ["OC_ORNITH_122B_OUT"]),
|
|
os.environ.get("OC_ORNITH_122B_NAME") or "Ornith 1.5 122B (local, 1M)")
|
|
if os.environ.get("OC_FLASH_UNSLOTH") == "1":
|
|
# one definition, shared with switch-model.sh (oc-flash-unsloth.py says why)
|
|
import importlib.util
|
|
spec = importlib.util.spec_from_file_location("oc_flash_unsloth", os.path.join(os.environ["OC_REPO_DIR"], "oc-flash-unsloth.py"))
|
|
ocu = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ocu)
|
|
providers["flash-unsloth"] = ocu.provider(base_url, f"{cfg_dir}/api-key",
|
|
int(os.environ["OC_FLASH_UNSLOTH_CTX"]), int(os.environ["OC_FLASH_UNSLOTH_OUT"]),
|
|
os.environ.get("OC_FLASH_UNSLOTH_NAME")
|
|
or "Qwen3.8-Flash-Next Unsloth UD-Q4_K_XL + DFlash2 (local, 262K)")
|
|
|
|
default = "flashnext/qwen3.8-flash-next" if lane == "flash" else "qwen38/qwen3.8-27b"
|
|
if os.environ.get("OC_KOLIBRI_BOOT") == "1" and "kolibri" in providers:
|
|
default = "kolibri/kolibri-1" # the lane this box serves stays opencode's default
|
|
if os.environ.get("OC_NEMOTRON_BOOT") == "1" and "nemotron" in providers:
|
|
default = "nemotron/nemotron-3.5-bolt"
|
|
if os.environ.get("OC_NEMOTRON_SUPER_BOOT") == "1" and "nemotron-super" in providers:
|
|
default = "nemotron-super/nemotron-3.5-super-vl"
|
|
if os.environ.get("OC_FLASH_LOCAL_BOOT") == "1" and "flash-local" in providers:
|
|
default = "flash-local/qwen3.8-flash-next-fp4"
|
|
if os.environ.get("OC_ORNITH_122B_BOOT") == "1" and "ornith-122b" in providers:
|
|
default = "ornith-122b/ornith-1.5-122b"
|
|
if os.environ.get("OC_FLASH_UNSLOTH_BOOT") == "1" and "flash-unsloth" in providers:
|
|
default = "flash-unsloth/qwen3.8-flash-next-unsloth"
|
|
# Compaction is global in opencode.json, not per-model, so it is sized from the
|
|
# INSTALLED target (oc-limits.sh --preserve) and rewritten by every install and
|
|
# switch. preserve_recent_tokens exists because opencode's own default clamps it
|
|
# at 15,000 whatever the window: on a 262K lane a compaction at 205,000 tokens
|
|
# would keep 15,000 and summarise the other 190,000, which is not using the
|
|
# window, it is refilling it from scratch. prune stays off: opencode's pruning
|
|
# swaps old tool output for a placeholder (past the most recent 40,000 tokens of
|
|
# it), which changes the history the engine cached, so the next turn recomputes
|
|
# everything after the first cleared output (2026-10-13: 232 of 527 tool parts
|
|
# cleared in a 410K-token session). Room is made by compaction instead.
|
|
doc = {"$schema": "https://opencode.ai/config.json", "provider": providers,
|
|
"compaction": {"preserve_recent_tokens": int(os.environ["OC_KEEP"]), "prune": False},
|
|
"model": default, "small_model": default}
|
|
# Cohere's report (2026-10-26): the shell rules for its hosts, under a key of their own, as
|
|
# oc-merge-limits.py --deny-permission gives them (OC_DENY). opencode merges this file over the
|
|
# user's own config for oc and the Agent tab, so they come after the user's rules there, but for
|
|
# a key added after the block in a global config that holds it too: opencode keeps a key where
|
|
# the first config had it (review, 2026-10-29, docs/agents-and-network.md). An OC_DENY that is
|
|
# set but empty stops here.
|
|
if os.environ.get("OC_DENY") is not None:
|
|
doc["permission"] = json.loads(os.environ["OC_DENY"])
|
|
# With the version pinned, opencode looks for no update at all: false, the JSON boolean
|
|
# (its schema takes a boolean or "notify", not the string "false"). With any other value
|
|
# 1.19's TUI checks every 10 minutes and, once it is on the newest 1.x, shows "/update to
|
|
# upgrade to OpenCode 2.0" on its home screen (1.18.35 announces 2.x as soon as GitHub's
|
|
# latest release is one), and OpenCode 2's server is not the 1.x `opencode serve` the
|
|
# Agent tab's relay is written for. Up to 1.18, unset meant opencode installed its own
|
|
# patch releases (see the OPENCODE_VERSION pin).
|
|
if os.environ.get("OC_PIN") == "1":
|
|
doc["autoupdate"] = False
|
|
# written only when it changes, so its date says when it last did: opencode-web is
|
|
# restarted below only for a config newer than it
|
|
text = json.dumps(doc, indent=2) + "\n"
|
|
try:
|
|
with open(f"{cfg_dir}/opencode.json") as f:
|
|
same = f.read() == text
|
|
except OSError:
|
|
same = False
|
|
if not same:
|
|
with open(f"{cfg_dir}/opencode.json", "w") as f:
|
|
f.write(text)
|
|
print(f"{'kept' if same else 'wrote'} {cfg_dir}/opencode.json (default {default}, "
|
|
f"providers: {', '.join(providers) or 'none'})")
|
|
PYEOF
|
|
echo "opencode limits: context $OC_CTX, output $OC_OUT, port $OC_PORT"
|
|
# opencode's threshold is limit.input - min(20,000, limit.output) (see oc-limits.sh)
|
|
echo " compaction fires at $((OC_CTX - (OC_OUT < 20000 ? OC_OUT : 20000))) tokens and keeps $OC_KEEP verbatim"
|
|
OC_USER_CFG="$HOME/.config/opencode/opencode.json"
|
|
# A box with no opencode config of its own gets this one. There is nothing to merge
|
|
# into and nothing of the user's to keep, and nothing else points opencode at the file
|
|
# above: without this, a first install left opencode, oc and the Agent tab with no
|
|
# provider for the model the box serves, and a printed cp command to find.
|
|
if [ ! -e "$OC_USER_CFG" ]; then
|
|
mkdir -p "$HOME/.config/opencode"
|
|
install -m 644 "$CONFIG_DIR/opencode.json" "$OC_USER_CFG"
|
|
echo " no opencode config yet: installed this repo's at $OC_USER_CFG"
|
|
# the copy carries the shell rules for the hosts of Cohere's report already (deny_permission)
|
|
elif ! grep -qsE '"(qwen38|flashnext|kolibri|nemotron|nemotron-super|flash-local|ornith-122b|flash-unsloth)"' "$OC_USER_CFG"; then
|
|
# the user's own config, with none of this repo's providers in it: theirs to merge
|
|
echo " your $OC_USER_CFG has no provider for this box: merge the \"qwen38\" (or \"flashnext\")"
|
|
echo " block from $CONFIG_DIR/opencode.json into it (docs/opencode.md). oc and the Agent tab"
|
|
echo " read the box's shell rules from that file; plain opencode needs them in yours"
|
|
echo " (docs/agents-and-network.md)"
|
|
else
|
|
# A config set up for this box, by the copy above or by hand, lists the lanes the
|
|
# box had then. A lane installed since (the 27B first, the flash lane later) brings
|
|
# its provider in: without it the merges below find nothing to merge, and opencode
|
|
# sends the other lane's limits and label to the one that serves.
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" --add-providers "$CONFIG_DIR/opencode.json" || true
|
|
# plain opencode reads this file alone: the shell rules for the hosts of Cohere's report go
|
|
# last in it (docs/agents-and-network.md)
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" --deny-bash || true
|
|
fi
|
|
# An existing opencode.json keeps the user's other providers, but its limits for
|
|
# THIS lane must follow the served engine (v1.5.2: a flash conversation allowed
|
|
# to grow to 226000 tokens outgrew the 159k KV pool and wedged the scheduler).
|
|
if [ -f "$OC_USER_CFG" ] && [ "$OPENCODE_PIN" = "1" ]; then
|
|
# false, not "notify": with any other value opencode offers OpenCode 2, which the Agent
|
|
# tab's relay is not written for (see the generated config above). This file is the one
|
|
# that check reads (opencode's global config); a box an earlier run set to "notify"
|
|
# moves to false here.
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" --autoupdate false || true
|
|
fi
|
|
if [ -f "$OC_USER_CFG" ]; then
|
|
if [ "${LANE:-27b}" = "flash" ]; then
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" flashnext qwen3.8-flash-next "$OC_CTX" "$OC_OUT" || true
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" --compaction "$OC_KEEP" || true
|
|
# The lean level exists in this lane's template because the run above just
|
|
# patched it. It is offered only for the lane being installed: a provider
|
|
# entry advertising a level the served template does not know answers 500.
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" flashnext qwen3.8-flash-next --add-variant lean || true
|
|
else
|
|
# Never downgrade a 27B unit that serves a larger window than this run's
|
|
# CONTEXT_MODE computed (a native-mode re-install clobbered a 1m user's
|
|
# 700000/200000 back to 194048/64000, reference box 2026-08-30). Only a mode
|
|
# nobody asked for, though: an explicit CONTEXT_MODE=native installs the native
|
|
# unit at step 8, and the 1M limits kept here then asked 700,000 of a 262,144
|
|
# window, a 400 past it, under advice to pass CONTEXT_MODE=1m (found in review,
|
|
# 2026-09-24). Since the mode converges on the installed unit, an explicit one is
|
|
# the only way here.
|
|
# A 64 GB box goes back to the native window on its own (the convergence says so): keeping the
|
|
# 1M limits there asked 700,000 of a 262,144 window, under advice to pass the CONTEXT_MODE=1m it
|
|
# refuses (found in review, 2026-10-23)
|
|
UNIT_CTX="$(grep -oE -- '--context-length [0-9]+' "$SGL_UNIT_PATH" 2>/dev/null | awk '{print $2}' | head -1 || true)"
|
|
if [ -n "$UNIT_CTX" ] && [ "$UNIT_CTX" -gt 262144 ] && [ "$CONTEXT_MODE" != "1m" ] && [ -z "$_ENV_CONTEXT_MODE" ] \
|
|
&& [ "$MEM_CLASS" != 64 ]; then
|
|
echo "NOTE: the installed 27B unit serves --context-length $UNIT_CTX; keeping the existing"
|
|
echo " opencode limits (these $CONTEXT_MODE-mode values would shrink them). Re-run with"
|
|
echo " CONTEXT_MODE=1m to manage them, or edit $OC_USER_CFG yourself."
|
|
else
|
|
# on 1m and on a 64 GB box the table's pair is a bound, and the fit at the end sets the
|
|
# pair: keep one already under it (see oc-merge-limits.py --keep-lower)
|
|
OC_KEEP_LOWER=(); { [ "$CONTEXT_MODE" = "1m" ] || [ "$MEM_CLASS" = 64 ]; } && OC_KEEP_LOWER=(--keep-lower)
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" qwen38 qwen3.8-27b "$OC_CTX" "$OC_OUT" ${OC_KEEP_LOWER[@]+"${OC_KEEP_LOWER[@]}"} || true
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" --compaction "$OC_KEEP" || true
|
|
fi
|
|
# Offered whatever the limits branch decided above: the level comes from the
|
|
# template this run patched, not from the context mode.
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" qwen38 qwen3.8-27b --add-variant lean || true
|
|
fi
|
|
# The Qwen3.8 Flash-Next FP4-Local lane's pair follows its unit's window (FLASH_LOCAL_CONTEXT=1m): --add-providers
|
|
# above adds a missing provider only, and the compaction block is sized from this pair when the lane boots (second
|
|
# review of v1.45.2). A config edited by hand that refuses the pair is said, as switch-model.sh says it: the update
|
|
# kept the old pair without a word (code review of v1.48.0, 2026-11-12). Its 3, "not in path: nothing to merge", is a
|
|
# config of the user's own with neither entry, and says nothing (review of v1.48.0, 2026-11-13)
|
|
if [ "$OC_FLASH_LOCAL" -eq 1 ] && [ -n "$OC_FLASH_LOCAL_CTX" ]; then
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" flash-local qwen3.8-flash-next-fp4 \
|
|
"$OC_FLASH_LOCAL_CTX" "$OC_FLASH_LOCAL_OUT" >/dev/null \
|
|
|| { [ $? -eq 3 ] || echo "NOTE: could not update the Qwen3.8 Flash-Next FP4-Local limits in $OC_USER_CFG; check them by hand ($OC_FLASH_LOCAL_CTX $OC_FLASH_LOCAL_OUT)"; }
|
|
fi
|
|
# and the Qwen3.8 Flash-Next Unsloth GGUF lane's follows its unit's window the same way (2026-11-12: 262,144 by
|
|
# default, 1,048,576 in its 1M mode)
|
|
if [ "${OC_FLASH_UNSLOTH:-0}" -eq 1 ] && [ -n "${OC_FLASH_UNSLOTH_CTX:-}" ]; then
|
|
python3 "$REPO_DIR/oc-merge-limits.py" "$OC_USER_CFG" flash-unsloth qwen3.8-flash-next-unsloth \
|
|
"$OC_FLASH_UNSLOTH_CTX" "$OC_FLASH_UNSLOTH_OUT" >/dev/null \
|
|
|| { [ $? -eq 3 ] || echo "NOTE: could not update the Qwen3.8 Flash-Next Unsloth GGUF limits in $OC_USER_CFG; check them by hand ($OC_FLASH_UNSLOTH_CTX $OC_FLASH_UNSLOTH_OUT)"; }
|
|
fi
|
|
fi
|
|
# The default model and the served entry's picker name follow the install, not
|
|
# just the limits: an install that changes lane left opencode offering and
|
|
# defaulting to the previous lane (reference box 2026-09-11: flash selected
|
|
# while stock 1M served). Same helper as switch-model.sh, one label table; it moves
|
|
# the user's default only when that one is unset or already this box's.
|
|
OC_POINT_LANE="$LANE"; OC_POINT_CHOICE="$MODEL_CHOICE"; OC_POINT_WINDOW="$OC_WINDOW"
|
|
if [ "$KOLIBRI_BOOT" -eq 1 ] && [ "$OC_KOLIBRI" -eq 1 ]; then
|
|
# the Kolibri lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=kolibri; OC_POINT_CHOICE="$OC_KOLIBRI_TARGET"; OC_POINT_WINDOW=262144
|
|
fi
|
|
if [ "$NEMOTRON_BOOT" -eq 1 ] && [ "$OC_NEMOTRON" -eq 1 ]; then
|
|
# the Nemotron lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=nemotron; OC_POINT_CHOICE=nemotron; OC_POINT_WINDOW=262144
|
|
fi
|
|
if [ "$NEMOTRON_SUPER_BOOT" -eq 1 ] && [ "$OC_NEMOTRON_SUPER" -eq 1 ]; then
|
|
# the Nemotron Super lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=nemotron-super; OC_POINT_CHOICE=nemotron-super; OC_POINT_WINDOW=1048576
|
|
fi
|
|
if [ "$FLASH_LOCAL_BOOT" -eq 1 ] && [ "$OC_FLASH_LOCAL" -eq 1 ]; then
|
|
# the Qwen3.8 Flash-Next FP4-Local lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=flash-local; OC_POINT_CHOICE=flash-local; OC_POINT_WINDOW="${OC_FLASH_LOCAL_WINDOW:-262144}"
|
|
fi
|
|
if [ "$ORNITH_122B_BOOT" -eq 1 ] && [ "$OC_ORNITH_122B" -eq 1 ]; then
|
|
# the Ornith 1.5 122B lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=ornith-122b; OC_POINT_CHOICE=ornith-122b; OC_POINT_WINDOW=1048576
|
|
fi
|
|
if [ "$FLASH_UNSLOTH_BOOT" -eq 1 ] && [ "$OC_FLASH_UNSLOTH" -eq 1 ]; then
|
|
# the Qwen3.8 Flash-Next Unsloth GGUF lane is this box's lane: opencode's default stays on it
|
|
OC_POINT_LANE=flash-unsloth; OC_POINT_CHOICE="$OC_FLASH_UNSLOTH_TARGET"; OC_POINT_WINDOW="${OC_FLASH_UNSLOTH_WINDOW:-262144}"
|
|
fi
|
|
python3 "$REPO_DIR/oc-point-default.py" "$CONFIG_DIR/opencode.json" "$OC_POINT_LANE" "$OC_POINT_CHOICE" "$OC_POINT_WINDOW" \
|
|
|| die "could not point the generated opencode config at the installed lane"
|
|
if [ -f "$OC_USER_CFG" ]; then
|
|
python3 "$REPO_DIR/oc-point-default.py" "$OC_USER_CFG" "$OC_POINT_LANE" "$OC_POINT_CHOICE" "$OC_POINT_WINDOW" || true
|
|
fi
|
|
# pi and omp (docs/pi.md): their files are regenerated from the opencode.json written above, as
|
|
# switch-model.sh does after a switch (block 4f), and only on a box that asked for them once
|
|
# (./pi-gen.py made the directories). An update left them behind it: v1.30.0's changed Kolibri's
|
|
# pair in opencode.json and not in pi's models.json, until the next switch (found 2026-10-14).
|
|
if [ -d "$CONFIG_DIR/pi" ] || [ -d "$CONFIG_DIR/omp" ]; then
|
|
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
|
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
|
fi
|
|
# Every opencode.json this install touches has been written by now, except the limits
|
|
# a 1m install fits to the pool once the engine is up (step 9, which restarts it again when a limit comes down),
|
|
# so the server that reads them can be restarted. It parses opencode.json ONCE at startup and
|
|
# never again (measured 2026-09-13: the file said 225,000 while the running
|
|
# server still answered 175,000 on /config), so without this the Agent tab keeps
|
|
# compacting against the previous install's window. Last, not mid-write: a
|
|
# restart before the user's own config is merged would reload the old numbers.
|
|
# Only when one of them changed: this restart ended whatever turn the Agent tab was in
|
|
# the middle of, on every run, a run that changed nothing included (up to three restarts
|
|
# of opencode-web per install on 2026-09-23; found in review, 2026-09-24).
|
|
if systemctl list-unit-files opencode-web.service >/dev/null 2>&1 \
|
|
&& systemctl is-active --quiet opencode-web.service; then
|
|
if [ "$(oc_configs_sum)" != "$OC_SUM_BEFORE" ]; then
|
|
sudo systemctl restart opencode-web.service \
|
|
&& echo "opencode-web.service restarted so it reads the new limits" \
|
|
|| echo "NOTE: restart opencode-web.service by hand, or the Agent view keeps the old limits"
|
|
else
|
|
echo "opencode-web.service kept: the configs it reads did not change"
|
|
fi
|
|
fi
|
|
# oc: launcher that lifts opencode's hidden 32000 max_tokens cap to the
|
|
# declared output limit (without it, long thinking is cut at 32000 and the
|
|
# turn ends silently). Never clobbers a foreign oc binary (e.g. OpenShift).
|
|
OC_BIN="$HOME/.local/bin/oc"
|
|
OC_EXISTING="$(command -v oc || true)"
|
|
# Not ours: a file at the launcher's own path without this repo's mark (OpenShift's oc
|
|
# lives there too), or another oc first on the PATH. Only the second was looked at, so an
|
|
# oc at the very path was overwritten, and so was one in a ~/.local/bin this shell's PATH
|
|
# lacks (found in review, 2026-09-24).
|
|
OC_FOREIGN=""
|
|
if [ -e "$OC_BIN" ] && ! grep -q 'dgx-spark-qwen38' "$OC_BIN" 2>/dev/null; then
|
|
OC_FOREIGN="$OC_BIN"
|
|
elif [ -n "$OC_EXISTING" ] && [ "$OC_EXISTING" != "$OC_BIN" ] && ! grep -q 'dgx-spark-qwen38' "$OC_EXISTING" 2>/dev/null; then
|
|
OC_FOREIGN="$OC_EXISTING"
|
|
fi
|
|
if [ -n "$OC_FOREIGN" ]; then
|
|
echo "NOTE: an unrelated 'oc' command exists at $OC_FOREIGN; not installing the launcher."
|
|
# OPENCODE_CONFIG as the launcher sets it: without it opencode sends the prompts to its
|
|
# own hosted model when the global config names no provider for this box (2026-09-23)
|
|
echo " Launch opencode with: OPENCODE_CONFIG=$CONFIG_DIR/opencode.json OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX=$OC_OUT_CAP opencode --yolo"
|
|
else
|
|
mkdir -p "$HOME/.local/bin"
|
|
cat > "$OC_BIN" <<OCWRAP
|
|
#!/bin/bash
|
|
# oc launcher installed by dgx-spark-qwen38: opencode wired to the local server.
|
|
# Lifts opencode's hidden 32000 max_tokens cap above every output limit this
|
|
# repo declares; without this, long thinking phases are cut at 32000 and the
|
|
# turn ends silently. It is a ceiling: the per-model limit.output in
|
|
# opencode.json is the number that follows a model switch, and this one only has
|
|
# to stay above it, which is why it is not the installed target's own limit.
|
|
# --yolo auto-approves permissions (the reference box runs this way; remove it
|
|
# below if you prefer per-action prompts).
|
|
export OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX="\${OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX:-$OC_OUT_CAP}"
|
|
# The box's providers and default model, over whatever the global opencode config
|
|
# says (opencode loads OPENCODE_CONFIG after it). Without this, a config with no
|
|
# provider for this box sent oc's prompts to opencode's own hosted model (2026-09-23).
|
|
[ -f "$CONFIG_DIR/opencode.json" ] && export OPENCODE_CONFIG="\${OPENCODE_CONFIG:-$CONFIG_DIR/opencode.json}"
|
|
OPENCODE_BIN="\$(command -v opencode || true)"
|
|
[ -n "\$OPENCODE_BIN" ] || OPENCODE_BIN="\$HOME/.opencode/bin/opencode"
|
|
if [ ! -x "\$OPENCODE_BIN" ]; then
|
|
echo "oc: opencode is not installed. Re-run ./install.sh in $REPO_DIR: it installs the opencode this repo tests ($OPENCODE_VERSION)." >&2
|
|
exit 127
|
|
fi
|
|
# --yolo goes LAST: opencode's parser rejects global flags before a
|
|
# subcommand (opencode --yolo run ... prints the help instead of running)
|
|
exec "\$OPENCODE_BIN" "\$@" --yolo
|
|
OCWRAP
|
|
chmod +x "$OC_BIN"
|
|
echo "installed the oc launcher at $OC_BIN (output ceiling $OC_OUT_CAP, this target's limit $OC_OUT)"
|
|
case ":$PATH:" in
|
|
*":$HOME/.local/bin:"*) ;;
|
|
*) echo "NOTE: $HOME/.local/bin is not in this shell's PATH: a new login has it (Ubuntu's ~/.profile"
|
|
echo " adds it once the folder exists), or call $OC_BIN directly." ;;
|
|
esac
|
|
fi
|
|
fi
|
|
# end of step 7
|
|
|
|
# claude-local (discussion #59, 2026-10-23): Claude Code on the lane this box serves, with that
|
|
# lane's context and answer budget, worked out at each launch by claude-local.py (its docstring
|
|
# says how). Installed whether or not the opencode integration is on, since it falls back to a
|
|
# pair that fits every lane; the run for the other text lane leaves it to the run that serves.
|
|
# Never clobbers a claude-local that is not this repo's, but for the one discussion #59's reply of
|
|
# 2026-10-22 gave to copy to that path until this launcher came (known by its first comment and
|
|
# its last line): it is kept beside, in case it was edited, and replaced (Hasan, 2026-10-23).
|
|
# None of it fails the install, as none of opencode's does: a launcher that could not be written
|
|
# stopped a whole run before its units (found in review, 2026-10-24).
|
|
if [ -z "$SECONDARY" ]; then
|
|
CL_BIN="$HOME/.local/bin/claude-local"
|
|
if [ -f "$CL_BIN" ] && grep -qx '# ~/.local/bin/claude-local: Claude Code on the lane the box serves' "$CL_BIN" \
|
|
&& grep -qx 'exec claude "$@"' "$CL_BIN"; then
|
|
if mv -f "$CL_BIN" "$CL_BIN.from-59"; then
|
|
echo "the claude-local of discussion #59's reply is kept as $CL_BIN.from-59, and this repo's launcher replaces it"
|
|
fi
|
|
fi
|
|
if [ -e "$CL_BIN" ] && ! grep -q 'dgx-spark-qwen38' "$CL_BIN" 2>/dev/null; then
|
|
echo "NOTE: an unrelated 'claude-local' exists at $CL_BIN; not installing the launcher."
|
|
echo " Launch Claude Code on this box with: python3 -I $REPO_DIR/claude-local.py"
|
|
elif mkdir -p "$HOME/.local/bin" && cat > "$CL_BIN" <<CLWRAP && chmod +x "$CL_BIN"; then
|
|
#!/bin/bash
|
|
# claude-local launcher installed by dgx-spark-qwen38: Claude Code on the lane this box serves.
|
|
# The key, the model and the limits are read at each launch by claude-local.py in the clone.
|
|
export QWEN38_CONFIG_DIR="\${QWEN38_CONFIG_DIR:-$CONFIG_DIR}"
|
|
export QWEN38_PROXY_URL="\${QWEN38_PROXY_URL:-http://127.0.0.1:$PROXY_PORT}"
|
|
exec python3 -I "$REPO_DIR/claude-local.py" "\$@"
|
|
CLWRAP
|
|
echo "installed the claude-local launcher at $CL_BIN (Claude Code on the lane that serves)"
|
|
else
|
|
echo "NOTE: could not write the claude-local launcher at $CL_BIN (see above); the install goes on."
|
|
echo " Launch Claude Code on this box with: python3 -I $REPO_DIR/claude-local.py"
|
|
fi
|
|
fi
|
|
|
|
# What this run installed, written down in $CONFIG_DIR/installed.json by conformity.py (since
|
|
# v1.36.0, 2026-10-17): the release and its commit, how the run ended, and the choices made on
|
|
# this command line. It is what tells a value an older release installed by default from one
|
|
# the operator chose, at the next update and in the cockpit, which until then took the clone's
|
|
# CHANGELOG for the release the services ran. MODEL_REV, the images and the ceilings are for
|
|
# one run and never recorded. The run for the other text lane (QWEN38_SECONDARY) writes
|
|
# nothing: PORT, HF_CACHE and the binds reach it from this run, explicit-looking but not
|
|
# choices of its own. Never fatal: without a record the next update classes the box by its age.
|
|
ran_whole_before() { # a run of this repo ended whole on this box before (installed.json)
|
|
python3 -c 'import json, sys; sys.exit(0 if json.load(open(sys.argv[1])).get("path") in ("full", "side-boot") else 1)' \
|
|
"$CONFIG_DIR/installed.json" 2>/dev/null
|
|
}
|
|
bolt_answers() { # $1 seconds: Bolt's engine answers on its port before then, its unit not failed
|
|
local end=$((SECONDS + $1))
|
|
while [ "$SECONDS" -lt "$end" ]; do
|
|
[ "$(systemctl is-active qwen38-nemotron.service 2>/dev/null)" != failed ] || return 1
|
|
curl -sf -m 5 -o /dev/null "http://127.0.0.1:$PORT/health" && return 0
|
|
sleep 10
|
|
done
|
|
return 1
|
|
}
|
|
text_lane_answers() { # $1 seconds: an engine answers on the text port before then; nothing is started or stopped
|
|
local end=$((SECONDS + $1)) n=0
|
|
while [ "$SECONDS" -lt "$end" ] && [ "$n" -lt $(( $1 / 10 )) ]; do
|
|
curl -sf -m 5 -o /dev/null "http://127.0.0.1:$PORT/health" && return 0
|
|
sleep 10; n=$((n + 1))
|
|
done
|
|
return 1
|
|
}
|
|
bolt_first_load() { # Bolt loaded as the cockpit's Load does it; 0 when it answers, the box back on the 27B else
|
|
bash "$REPO_DIR/prepare-lane.sh" nemotron || return 1
|
|
BOLT_SWITCHED=1 # from here opencode's pair is rewritten: by Bolt's switch, then by the switch back
|
|
if ! bash "$REPO_DIR/switch-model.sh" nemotron; then
|
|
bash "$REPO_DIR/switch-model.sh" "$MODEL_CHOICE" || true
|
|
return 1
|
|
fi
|
|
if sudo systemctl stop "$UNIT_NAME" && sudo systemctl start qwen38-nemotron.service && bolt_answers 1800; then
|
|
return 0
|
|
fi
|
|
sudo systemctl stop qwen38-nemotron.service || true
|
|
bash "$REPO_DIR/switch-model.sh" "$MODEL_CHOICE" || true
|
|
sudo systemctl start "$UNIT_NAME" || true
|
|
return 1
|
|
}
|
|
# One quiet line, the last of a run that ended whole (Hasan, 2026-11-09): the project is found by what its users say
|
|
# of it, and this is the only place the installer says so. No prompt, no reminder, nothing the run waits for. Not
|
|
# from the installer started again for another lane (SECONDARY): its end is not the run's.
|
|
star_line() {
|
|
if [ -n "$SECONDARY" ]; then return 0; fi
|
|
echo " If Alzeo serves you well, a star helps other owners find it: https://github.com/hasso5703/alzeo"
|
|
}
|
|
record_install() { # $1 how the run ended: full, side-boot, no-start or no-service
|
|
if [ -n "$SECONDARY" ]; then return 0; fi
|
|
local chose=()
|
|
# --no-service writes no unit: run.sh reads the environment at every start instead
|
|
if [ "$1" != no-service ]; then
|
|
collect_choices
|
|
chose=(${CHOSE[@]+"${CHOSE[@]}"})
|
|
fi
|
|
python3 "$REPO_DIR/conformity.py" record --config-dir "$CONFIG_DIR" --repo-dir "$REPO_DIR" \
|
|
--units /etc/systemd/system/ --lane "$LANE" --path "$1" ${chose[@]+"${chose[@]}"} \
|
|
|| echo "NOTE: could not record this install in $CONFIG_DIR/installed.json (see above); the next update classes this box by its age."
|
|
return 0
|
|
}
|
|
|
|
if [ "$NO_SERVICE" -eq 1 ]; then
|
|
apply_context_configs
|
|
printf '\n\033[1;32m✅ Prepared (no systemd, nothing needed sudo).\033[0m\n'
|
|
echo " Run in the foreground: ./run.sh (Ctrl+C stops it; first boot ≈ 9 min)"
|
|
# Not just two folders: the summary said so, and left out the serving image, opencode,
|
|
# the oc launcher and the provider this box adds to the user's opencode config, which
|
|
# reads the key in the config folder: opencode refuses to start while it points at a key
|
|
# that is gone (found in review, 2026-09-24).
|
|
echo " To remove it later: ./uninstall.sh --list names everything this left and changes nothing:"
|
|
echo " $CONFIG_DIR (the key, templates), the checkpoints in $HF_CACHE, the serving image, opencode"
|
|
echo " and its oc launcher, and a provider in your opencode config that reads $CONFIG_DIR/api-key."
|
|
echo " Remove that provider with the key, or opencode refuses to start."
|
|
echo " No cockpit either: it is a systemd unit, and --no-service installs none."
|
|
record_install no-service
|
|
star_line
|
|
exit 0
|
|
fi
|
|
|
|
step "8/10 Installing the systemd service (sudo needed)"
|
|
# The steps below make most of this script's sudo calls, and a dead timestamp used to
|
|
# kill the install here with no message at all (set -e on a bare `sudo cp`, reference
|
|
# box 2026-09-13, three times in one afternoon: background runs and passwordless
|
|
# contexts have no tty for sudo to ask on). The ticket asked for at step 1 can have
|
|
# expired during the downloads (sudo keeps one 15 min), so it is renewed here: with a
|
|
# terminal sudo asks again, without one `sudo -v` fails at once and the refusal names
|
|
# the fix. `sudo -n` alone never asked, and a fresh one-liner died here after ~20 min.
|
|
sudo -n true 2>/dev/null || sudo -v || die "sudo needs a fresh timestamp before the systemd step: run 'sudo -v', then re-run ./install.sh (completed steps are skipped)"
|
|
UNIT_PATH="/etc/systemd/system/$UNIT_NAME"
|
|
if [ -f "$UNIT_PATH" ]; then
|
|
# Safety net for hand-tuned units: the previous unit stays recoverable.
|
|
sudo cp "$UNIT_PATH" "$CONFIG_DIR/$UNIT_NAME.bak-preupdate"
|
|
sudo chown "$(id -u):$(id -g)" "$CONFIG_DIR/$UNIT_NAME.bak-preupdate"
|
|
echo "previous unit backed up at $CONFIG_DIR/$UNIT_NAME.bak-preupdate"
|
|
fi
|
|
if [ "$LANE" = "flash" ]; then
|
|
UNIT_TPL="$REPO_DIR/qwen38-flash.service.template"
|
|
SERVE_IMAGE_FINAL="$FLASH_SERVE_IMAGE"
|
|
else
|
|
UNIT_TPL="$REPO_DIR/qwen38-sglang.service.template"
|
|
[ "$CONTEXT_MODE" = "1m" ] && UNIT_TPL="$REPO_DIR/qwen38-sglang-1m.service.template"
|
|
[ "$MEM_CLASS" = 64 ] && UNIT_TPL="$REPO_DIR/qwen38-sglang-64.service.template"
|
|
SERVE_IMAGE_FINAL="$SERVE_IMAGE"
|
|
fi
|
|
# Serve-time revision lock: the pinned sha is passed to the server itself, so
|
|
# an upstream push to the checkpoint repo can never change what is served
|
|
# (download-time pinning alone leaves "main" resolvable at boot). A kept
|
|
# custom model reuses its unit's existing --revision, or none.
|
|
if [ "$KEEP_MODEL_VERBATIM" -eq 1 ]; then
|
|
MODEL_REV_ARGS=""
|
|
[ -n "${CUR_REV:-}" ] && MODEL_REV_ARGS="--revision $CUR_REV"
|
|
else
|
|
MODEL_REV_ARGS="--revision $MODEL_REV"
|
|
fi
|
|
# The 27B lane serves with an fp8 KV cache. The NVFP4 checkpoints carry their own
|
|
# KV scales so SGLang picks it up from the checkpoint; Qwen's FP8 release does not,
|
|
# and defaults to a bf16 KV cache that costs about half the pool (measured on the
|
|
# reference box, same 1m unit: 771,139 tokens with the flag, 382,706 without). So
|
|
# the FP8 pair asks for it explicitly, which is what the reference box has served
|
|
# since 2026-08-31 and what every FP8 pool number in this repo was measured on. Arete's
|
|
# NVFP4 declares none, and gets the lane's declaration in its config (apply_context_configs),
|
|
# not this flag, which would put the draft's cache in fp8 too (patch-kv.py).
|
|
case "$MODEL_CHOICE" in
|
|
fp8|uncensored-fp8) KV_CACHE_ARGS="--kv-cache-dtype fp8_e4m3 " ;;
|
|
*) KV_CACHE_ARGS="" ;;
|
|
esac
|
|
|
|
# The reduced draft vocabulary is a speculative-path flag: a tier that does not
|
|
# speculate must not receive it. Rendered as a whole line so an off setting
|
|
# leaves no dangling backslash in the launcher.
|
|
SPEC_TOKEN_MAP_LINE=""
|
|
case "$FLASH_TIER_ARGS" in
|
|
*--speculative-algorithm*)
|
|
if [ "${SPEC_TOKEN_MAP_SIZE:-0}" -gt 0 ] && [ -s "$CONFIG_DIR/$TOKEN_MAP_NAME" ]; then
|
|
SPEC_TOKEN_MAP_LINE="TIER+=(--speculative-token-map /out/$TOKEN_MAP_NAME)"
|
|
elif [ "${SPEC_TOKEN_MAP_SIZE:-0}" -gt 0 ]; then
|
|
# Not built yet (a lane installed on demand, whose first Load builds it; a run with no
|
|
# snapshot yet): the launcher takes it at the first start after it is, with no new install.
|
|
SPEC_TOKEN_MAP_LINE="[ -s \"$CONFIG_DIR/$TOKEN_MAP_NAME\" ] && TIER+=(--speculative-token-map /out/$TOKEN_MAP_NAME)"
|
|
fi ;;
|
|
esac
|
|
|
|
# Whatever the convergence block decided, the per-checkpoint and per-tier args
|
|
# are derived from it here, once, before anything is rendered.
|
|
resolve_flash_checkpoint_args
|
|
resolve_flash_tier_args
|
|
# And a flash launcher without its checkpoint's own flags is a ten-minute boot
|
|
# that dies at MoE autotune, so it never gets written.
|
|
if [ "$LANE" = "flash" ] && [ -z "$FLASH_QUANT_ARGS" ]; then
|
|
die "internal error: the flash lane resolved no checkpoint flags for MODEL_CHOICE=$MODEL_CHOICE. Refusing to write a launcher that would fail ten minutes into its boot. Please open an issue with this line."
|
|
fi
|
|
|
|
render_tpl() { # $1 template file; substituted result on stdout
|
|
# Values are paths and versions, and paths may carry sed-special bytes
|
|
# (& expands to the match, | is the delimiter, backslash escapes): escape
|
|
# once so a mount point like /mnt/a&b can never corrupt an installed unit.
|
|
esc() { printf '%s' "$1" | sed -e 's/[\\/&|]/\\&/g'; }
|
|
sed -e "s|__HOME__|$(esc "$HOME")|g" \
|
|
-e "s|__USER__|$(esc "$(id -un)")|g" \
|
|
-e "s|__GROUP__|$(esc "$(id -gn "$(id -un)")")|g" \
|
|
-e "s|__PORT__|$(esc "$PORT")|g" \
|
|
-e "s|__ENGINE_BIND__|$(esc "$ENGINE_BIND")|g" \
|
|
-e "s|__IMAGE__|$(esc "$SERVE_IMAGE_FINAL")|g" \
|
|
-e "s|__HF_CACHE__|$(esc "$HF_CACHE")|g" \
|
|
-e "s|__DRAFT2_REV__|$(esc "$DRAFT2_REV")|g" \
|
|
-e "s|__DRAFT2_REPO__|$(esc "$DRAFT2_REPO")|g" \
|
|
-e "s|__DRAFT2_QUANT__|$(esc "$DRAFT2_QUANT")|g" \
|
|
-e "s|__DRAFT2_TOKENS__|$(esc "$DRAFT2_TOKENS")|g" \
|
|
-e "s|__MODEL_REV_ARGS__|$(esc "$MODEL_REV_ARGS")|g" \
|
|
-e "s|__MODEL__|$(esc "$MODEL_REPO")|g" \
|
|
-e "s|__PLE_DIR__|$(esc "$PLE_DIR")|g" \
|
|
-e "s|__MODEL_REV__|$(esc "$MODEL_REV")|g" \
|
|
-e "s|__KV_CACHE_ARGS__|$(esc "$KV_CACHE_ARGS")|g" \
|
|
-e "s|__FLASH_TIER_ARGS__|$(esc "$FLASH_TIER_ARGS")|g" \
|
|
-e "s|__FLASH_QUANT_ARGS__|$(esc "$FLASH_QUANT_ARGS")|g" \
|
|
-e "s|__FLASH_MEM_FRACTION__|$(esc "$FLASH_MEM_FRACTION")|g" \
|
|
-e "s|__PLE_RSS_BUDGET_GB__|$(esc "$PLE_RSS_BUDGET_GB")|g" \
|
|
-e "s|__SPEC_TOKEN_MAP_LINE__|$(esc "$SPEC_TOKEN_MAP_LINE")|g" \
|
|
"$1"
|
|
}
|
|
# What this run renders before installing it is removed however the run ends: a die between
|
|
# a mktemp and its rm left the rendered file in /tmp (2026-10-03). Subshells reset the trap.
|
|
RENDERED=()
|
|
forget_rendered(){ local f; for f in "${RENDERED[@]}"; do if [ -f "$f" ]; then rm -f -- "$f"; fi; done; return 0; }
|
|
trap 'forget_rendered; forget_run_mark' EXIT
|
|
if [ "$LANE" = "flash" ]; then
|
|
mkdir -p "$PLE_DIR"
|
|
# The docker-run command lives in a plain launch script, not in ExecStart:
|
|
# systemd applies its own C-style unescaping before bash would, and the JSON
|
|
# arguments (--speculative-config, splitting_ops) do not survive two rounds.
|
|
TMP_LAUNCH="$(mktemp)"; RENDERED+=("$TMP_LAUNCH")
|
|
render_tpl "$REPO_DIR/qwen38-flash-launch.sh.template" > "$TMP_LAUNCH"
|
|
bash -n "$TMP_LAUNCH" || die "rendered flash launch script does not parse (report this repo bug)"
|
|
# rewritten only when it changes: the engine reads it at start, and a rewrite, even an
|
|
# identical one, would make the next run restart a running engine (engine-inputs.py)
|
|
# said as it is: an update that changed nothing here read "wrote" all the same
|
|
if cmp -s "$TMP_LAUNCH" "$CONFIG_DIR/launch-flash.sh"; then
|
|
echo "launch script unchanged: $CONFIG_DIR/launch-flash.sh"
|
|
else
|
|
install -m 755 "$TMP_LAUNCH" "$CONFIG_DIR/launch-flash.sh"
|
|
echo "wrote $CONFIG_DIR/launch-flash.sh"
|
|
fi
|
|
rm -f "$TMP_LAUNCH"
|
|
fi
|
|
TMP_UNIT="$(mktemp)"; RENDERED+=("$TMP_UNIT")
|
|
render_tpl "$UNIT_TPL" > "$TMP_UNIT"
|
|
apply_context_configs # the configs, then at once the unit that reads them
|
|
# the same rule for the unit: an identical one is left as it is, mtime included, and one changed
|
|
# only in the lines naming the other lanes keeps its date (lanes.sh unit_put)
|
|
UNIT_PUT="$(unit_put "$TMP_UNIT" "/etc/systemd/system/$UNIT_NAME")"
|
|
[ "$UNIT_PUT" != deps ] || echo "unit updated: only the lines naming the other lanes changed, which the engine does not read"
|
|
rm -f "$TMP_UNIT"
|
|
# Cross-engine switch: exactly one serving unit may start at boot. The other
|
|
# engine's unit (if present) is disabled now and stopped at step 9, right
|
|
# before this one starts; its unit file is kept for a fast switch back.
|
|
OTHER_UNIT=""
|
|
if [ "$LANE" = "flash" ]; then
|
|
[ -f "$SGL_UNIT_PATH" ] && OTHER_UNIT="qwen38-sglang.service"
|
|
else
|
|
[ -f "$FLASH_UNIT_PATH" ] && OTHER_UNIT="qwen38-flash.service"
|
|
fi
|
|
# A secondary run installs its lane beside the one serving and leaves the boot lane alone:
|
|
# the three disables below, the proxy's unit and enabling its own are the serving run's.
|
|
if [ -z "$SECONDARY" ] && [ -n "$OTHER_UNIT" ] && systemctl is-enabled --quiet "$OTHER_UNIT" 2>/dev/null; then
|
|
echo "disabling the other engine's unit at boot: $OTHER_UNIT (file kept, switch back anytime with ./switch-model.sh)"
|
|
sudo systemctl disable "$OTHER_UNIT"
|
|
fi
|
|
# The image lane is the third engine. When this run makes a text lane the boot lane (an
|
|
# explicit MODEL_CHOICE on a box that booted images), leaving it enabled would put two
|
|
# engines at the next boot.
|
|
if [ -z "$SECONDARY" ] && [ "$IMAGE_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-image.service 2>/dev/null; then
|
|
echo "disabling the image lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-image.service
|
|
fi
|
|
# The video lane is the fourth engine, under the same rule.
|
|
if [ -z "$SECONDARY" ] && [ "$VIDEO_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-video.service 2>/dev/null; then
|
|
echo "disabling the video lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-video.service
|
|
fi
|
|
# The Kolibri lane is the fifth, under the same rule.
|
|
if [ -z "$SECONDARY" ] && [ "$KOLIBRI_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-kolibri.service 2>/dev/null; then
|
|
echo "disabling the Kolibri-1 lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-kolibri.service
|
|
fi
|
|
# The Nemotron lanes are the sixth and the seventh, under the same rule.
|
|
if [ -z "$SECONDARY" ] && [ "$NEMOTRON_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-nemotron.service 2>/dev/null; then
|
|
echo "disabling the Nemotron 3.5 Bolt lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-nemotron.service
|
|
fi
|
|
if [ -z "$SECONDARY" ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-nemotron-super.service 2>/dev/null; then
|
|
echo "disabling the Nemotron 3.5 Super VL lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-nemotron-super.service
|
|
fi
|
|
# The Qwen3.8 Flash-Next FP4-Local lane is the eighth, under the same rule.
|
|
if [ -z "$SECONDARY" ] && [ "$FLASH_LOCAL_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-flash-local.service 2>/dev/null; then
|
|
echo "disabling the Qwen3.8 Flash-Next FP4-Local lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-flash-local.service
|
|
fi
|
|
# The Ornith 1.5 122B lane is the ninth, under the same rule.
|
|
if [ -z "$SECONDARY" ] && [ "$ORNITH_122B_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-ornith-122b.service 2>/dev/null; then
|
|
echo "disabling the Ornith 1.5 122B lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-ornith-122b.service
|
|
fi
|
|
if [ -z "$SECONDARY" ] && [ "$FLASH_UNSLOTH_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-flash-unsloth.service 2>/dev/null; then
|
|
echo "disabling the Qwen3.8 Flash-Next Unsloth GGUF lane at boot (unit kept, switch back anytime from the cockpit)"
|
|
sudo systemctl disable qwen38-flash-unsloth.service
|
|
fi
|
|
KEEPALIVE_UNIT="qwen38-keepalive.service"
|
|
KA_CHANGED=0 # whether this run changed what the proxy runs (see its restart below)
|
|
# The proxy, its code and its unit are the serving run's (see the secondary run above).
|
|
if [ -z "$SECONDARY" ]; then
|
|
# One-prompt ceiling enforced by the proxy (tokens; 0 = pool share only). The proxy
|
|
# always refuses a prompt above its share of the KV pool as well, so the smaller of
|
|
# the two binds and a tier with a small pool needs no separate ceiling.
|
|
#
|
|
# Flash lane, 128,000 from v1.5.6 to v1.7 and 200,000 from v1.8: the prefill of a
|
|
# long prompt grew the engine's memory by ~0.27 GiB per 1k tokens beyond ~90k
|
|
# (measured 29/08, a 120k prompt cost ~9 GiB of host headroom), which put a 150k
|
|
# prompt at the memory edge. That growth was the PLE table's mapping faulting in
|
|
# whole page-cache folios, and v1.8 serves an engine that trims it.
|
|
#
|
|
# How far it trims was only half measured: 200,058 tokens cost 3.5 GiB, and above
|
|
# that was left deliberately unmeasured because a livelock on this box costs a
|
|
# power cycle. Measured on 2026-09-13, MemAvailable sampled through each prefill,
|
|
# engine up 19 h with the PLE budget already filled:
|
|
#
|
|
# 195,784 tokens -> 1.16 GiB of host headroom, 94.7 s
|
|
# 225,051 tokens -> 1.57 GiB, 111.3 s
|
|
# 249,500 tokens -> 1.52 GiB, 126.1 s, floor 7.0 GiB
|
|
#
|
|
# The cost is flat past 200k and an order of magnitude below what the v1.5 engine
|
|
# paid, so memory is no longer what caps this lane. What caps it is the engine's
|
|
# own wall, max_req_input_len = 262,138: the ceiling is 250,000, which leaves
|
|
# 12,138 tokens of slack under it. That band matters because until 2026-09-13 the
|
|
# launcher passed --allow-auto-truncate and a prompt over the wall came back
|
|
# silently cut rather than refused.
|
|
# The flash lane's ceiling goes in the unit whatever lane this installs: the proxy applies
|
|
# it while the flash lane serves (v6.25), so a switch no longer has to move it with a
|
|
# restart. PROMPT_CEILING_TOKENS, when given, is a ceiling on any lane.
|
|
PROMPT_CEILING="${PROMPT_CEILING_TOKENS:-0}"
|
|
FLASH_PROMPT_CEILING="${FLASH_PROMPT_CEILING_TOKENS:-250000}"
|
|
[[ "$PROMPT_CEILING$FLASH_PROMPT_CEILING" =~ ^[0-9]+$ ]] || die "PROMPT_CEILING_TOKENS and FLASH_PROMPT_CEILING_TOKENS take a number of tokens"
|
|
# Every service install gets the keepalive proxy: SGLang buffers tool-call
|
|
# arguments while they stream (127 s of measured silence on a 400-line write,
|
|
# at native context) and agent CLIs abort a silent stream (~140-180 s for
|
|
# opencode). It also aborts zombie generations when the client disconnects.
|
|
cmp -s "$REPO_DIR/keepalive-proxy.py" "$CONFIG_DIR/keepalive-proxy.py" \
|
|
|| { install -m 755 "$REPO_DIR/keepalive-proxy.py" "$CONFIG_DIR/keepalive-proxy.py"; KA_CHANGED=1; }
|
|
TMP_KA="$(mktemp)"; RENDERED+=("$TMP_KA")
|
|
sed -e "s|__HOME__|$HOME|g" \
|
|
-e "s|__USER__|$(id -un)|g" \
|
|
-e "s|__GROUP__|$(id -gn "$(id -un)")|g" \
|
|
-e "s|__PORT__|$PORT|g" \
|
|
-e "s|__PROXY_PORT__|$PROXY_PORT|g" \
|
|
-e "s|__PROXY_BIND__|$PROXY_BIND|g" \
|
|
-e "s|__PROMPT_CEILING__|$PROMPT_CEILING|g" \
|
|
-e "s|__FLASH_PROMPT_CEILING__|$FLASH_PROMPT_CEILING|g" \
|
|
"$REPO_DIR/qwen38-keepalive.service.template" > "$TMP_KA"
|
|
cmp -s "$TMP_KA" "/etc/systemd/system/$KEEPALIVE_UNIT" \
|
|
|| { sudo install -m 644 "$TMP_KA" "/etc/systemd/system/$KEEPALIVE_UNIT"; KA_CHANGED=1; }
|
|
rm -f "$TMP_KA"
|
|
sudo systemctl enable "$KEEPALIVE_UNIT"
|
|
# The ceiling lives in the unit this installer writes. A switch-model.sh
|
|
# drop-in from an earlier lane would override it silently, so it goes: either
|
|
# path converges on the installed lane's ceiling.
|
|
if [ -f "/etc/systemd/system/$KEEPALIVE_UNIT.d/ceiling.conf" ]; then
|
|
echo "removing the stale keepalive ceiling drop-in (the installed unit carries the ceiling now)"
|
|
sudo rm -f "/etc/systemd/system/$KEEPALIVE_UNIT.d/ceiling.conf"
|
|
KA_CHANGED=1
|
|
sudo rmdir "/etc/systemd/system/$KEEPALIVE_UNIT.d" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
# The Claude Code warmup was removed in v1.3: clean up what earlier versions
|
|
# installed (only the warmup drop-in; any other drop-in in the .d dir is kept).
|
|
if [ -f "/etc/systemd/system/$UNIT_NAME.d/warmup.conf" ]; then
|
|
echo "removing the deprecated Claude Code warmup drop-in"
|
|
sudo rm -f "/etc/systemd/system/$UNIT_NAME.d/warmup.conf"
|
|
sudo rmdir "/etc/systemd/system/$UNIT_NAME.d" 2>/dev/null || true
|
|
fi
|
|
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 [ -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 [ -z "$ATS_CANNOT" ] && [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ] && [ "$KOLIBRI_BOOT" -eq 0 ] && [ "$NEMOTRON_BOOT" -eq 0 ] && [ "$NEMOTRON_SUPER_BOOT" -eq 0 ] && [ "$FLASH_LOCAL_BOOT" -eq 0 ] && [ "$ORNITH_122B_BOOT" -eq 0 ] && [ "$FLASH_UNSLOTH_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. 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.
|
|
if [ "$KA_CHANGED" -eq 1 ] || stale_since "$KEEPALIVE_UNIT" "/etc/systemd/system/$KEEPALIVE_UNIT" "$CONFIG_DIR/keepalive-proxy.py"; then
|
|
sudo systemctl restart "$KEEPALIVE_UNIT" \
|
|
|| echo "NOTE: could not restart $KEEPALIVE_UNIT; restart it by hand so it runs the new code"
|
|
fi
|
|
if [ "$COCKPIT" -eq 1 ] && [ -x "$REPO_DIR/dashboard/install-dashboard.sh" ]; then
|
|
if "$REPO_DIR/dashboard/install-dashboard.sh"; then
|
|
# The Agent tab's installer too, after the cockpit that relays it, as step 10 runs it: it
|
|
# restarts opencode-web on the opencode step 7 put in place, and points it at the one on
|
|
# the PATH. Step 10 is the text path's only, so a box booting this lane kept the opencode
|
|
# it started with until its next boot (the reference box on the FP4-Local lane, 2026-10-22).
|
|
if [ "$OPENCODE" -eq 1 ] && command -v opencode >/dev/null 2>&1; then
|
|
"$REPO_DIR/dashboard/install-agent.sh" \
|
|
|| echo "NOTE: the Agent view did not install; the rest of the cockpit is up (retry: ./dashboard/install-agent.sh)"
|
|
fi
|
|
else
|
|
echo "NOTE: the cockpit did not reinstall; retry with ./dashboard/install-dashboard.sh"
|
|
fi
|
|
fi
|
|
# --no-smoke always: a proof starts and stops a lane, and a side lane is serving here.
|
|
# Since v1.20 a side lane missing here is installed too, unless it was left out
|
|
# (lane_wanted): installed and updated, proved by its first load from the cockpit.
|
|
if [ "$WANT_IMAGE" -eq 1 ]; then
|
|
"$REPO_DIR/install-image.sh" "$(side_mode image "$WITH_IMAGE")" \
|
|
|| echo "NOTE: the image lane did not install or update; retry with ./install-image.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_VIDEO" -eq 1 ]; then
|
|
"$REPO_DIR/install-video.sh" "$(side_mode video "$WITH_VIDEO")" \
|
|
|| echo "NOTE: the video lane did not install or update; retry with ./install-video.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_KOLIBRI" -eq 1 ]; then
|
|
"$REPO_DIR/install-kolibri.sh" "$(side_mode kolibri "$WITH_KOLIBRI")" \
|
|
|| echo "NOTE: the Kolibri-1 lane did not install or update; retry with ./install-kolibri.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_NEMOTRON" -eq 1 ]; then
|
|
"$REPO_DIR/install-nemotron.sh" "$(side_mode nemotron "$WITH_NEMOTRON")" \
|
|
|| echo "NOTE: the Nemotron 3.5 Bolt lane did not install or update; retry with ./install-nemotron.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_NEMOTRON_SUPER" -eq 1 ]; then
|
|
"$REPO_DIR/install-nemotron-super.sh" "$(side_mode nemotron-super "$WITH_NEMOTRON_SUPER")" \
|
|
|| echo "NOTE: the Nemotron 3.5 Super VL lane did not install or update; retry with ./install-nemotron-super.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_FLASH_LOCAL" -eq 1 ]; then
|
|
"$REPO_DIR/install-flash-local.sh" "$(side_mode flash-local "$WITH_FLASH_LOCAL")" \
|
|
|| echo "NOTE: the Qwen3.8 Flash-Next FP4-Local lane did not install or update; retry with ./install-flash-local.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_ORNITH_122B" -eq 1 ]; then
|
|
"$REPO_DIR/install-ornith-122b.sh" "$(side_mode ornith-122b "$WITH_ORNITH_122B")" \
|
|
|| echo "NOTE: the Ornith 1.5 122B lane did not install or update; retry with ./install-ornith-122b.sh --no-smoke"
|
|
fi
|
|
if [ "$WANT_FLASH_UNSLOTH" -eq 1 ]; then
|
|
"$REPO_DIR/install-flash-unsloth.sh" "$(side_mode flash-unsloth "$WITH_FLASH_UNSLOTH")" \
|
|
|| echo "NOTE: the Qwen3.8 Flash-Next Unsloth GGUF lane did not install or update; retry with ./install-flash-unsloth.sh --no-smoke"
|
|
fi
|
|
SERVING_LANE=""
|
|
[ "$IMAGE_BOOT" -eq 1 ] && SERVING_LANE="image"
|
|
[ "$VIDEO_BOOT" -eq 1 ] && SERVING_LANE="video"
|
|
[ "$KOLIBRI_BOOT" -eq 1 ] && SERVING_LANE="Kolibri-1"
|
|
[ "$NEMOTRON_BOOT" -eq 1 ] && SERVING_LANE="Nemotron 3.5 Bolt"
|
|
[ "$NEMOTRON_SUPER_BOOT" -eq 1 ] && SERVING_LANE="Nemotron 3.5 Super VL"
|
|
[ "$FLASH_LOCAL_BOOT" -eq 1 ] && SERVING_LANE="Qwen3.8 Flash-Next FP4-Local"
|
|
[ "$ORNITH_122B_BOOT" -eq 1 ] && SERVING_LANE="Ornith 1.5 122B"
|
|
[ "$FLASH_UNSLOTH_BOOT" -eq 1 ] && SERVING_LANE="Qwen3.8 Flash-Next Unsloth GGUF"
|
|
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 on this run, so not updated; a run without it updates it"
|
|
else echo " the 27B lane can serve on this GPU: left out by --no-27b on this run; a run without it adds it, ready to load (58 GB)"; fi ;;
|
|
esac
|
|
elif [ "$LEFT_OUT" -eq 1 ]; then
|
|
# Its way back is a Load, which fetches what it lacks and checks the room first. It said
|
|
# ./install.sh --with-<lane>, whose run fetches the lane whole at once (35 and 136 GB for the
|
|
# flash), and on a disk too small dies at its step 1 with the marker already gone, as every
|
|
# update after it then does (found in review, 2026-10-21). The other text lane is said as on
|
|
# the path above.
|
|
if [ "$SECOND_STATE" = failed ]; then
|
|
step "Done, but the ${SECOND_LANE/27b/27B} lane did not install (see its NOTE above); the ${LANE/27b/27B} lane is $LEFT_WHY, so it got its units only, none of its downloads"
|
|
else
|
|
step "Done: the ${LANE/27b/27B} lane is $LEFT_WHY, so it got its units only, none of its downloads"
|
|
fi
|
|
echo " the $SERVING_LANE lane stays this box's serving lane"
|
|
if [ "$MODEL_CHOICE" = custom ]; then
|
|
# a kept custom model has no switch target, and no Load prepares it: the installer is the way back
|
|
echo " back to it: ./install.sh --with-$LANE, which installs it whole with the custom model it keeps"
|
|
else
|
|
if [ "$COCKPIT" -eq 1 ]; then
|
|
echo " back to it: Load it from the cockpit's Lanes view, which fetches what it lacks; it then serves, and runs bring it up to date until another lane serves"
|
|
else
|
|
echo " back to it: ./prepare-lane.sh $LANE $MODEL_CHOICE fetches what it lacks, then ./switch-model.sh $MODEL_CHOICE switches to it"
|
|
fi
|
|
echo " ./install.sh --with-$LANE prepares it whole instead: that run fetches it all at once"
|
|
fi
|
|
case "$SECOND_STATE" in
|
|
installed) echo " the ${SECOND_LANE/27b/27B} lane is up to date, ready to Load" ;;
|
|
units) echo " the ${SECOND_LANE/27b/27B} lane got its units: its first Load fetches its image and weights" ;;
|
|
cannot) echo " the flash lane got its units only: this GPU cannot start it ($SECOND_CANNOT)" ;;
|
|
failed) echo " the ${SECOND_LANE/27b/27B} lane: ./install.sh --with-$SECOND_LANE installs it whole" ;;
|
|
off) if too_big "$SECOND_LANE"; then
|
|
echo " the ${SECOND_LANE/27b/27B} lane needs a 128 GB DGX Spark, and this box is a 64 GB one"
|
|
else
|
|
echo " the ${SECOND_LANE/27b/27B} lane is left out too, by --no-$SECOND_LANE on this run"
|
|
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=<target> ./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
|
|
star_line
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$NO_START" -eq 1 ]; then
|
|
step "Done (service installed and enabled at boot; start it with: sudo systemctl start $UNIT_NAME)"
|
|
if [ -n "$OTHER_UNIT" ] && systemctl is-active --quiet "$OTHER_UNIT" 2>/dev/null; then
|
|
echo "NOTE: $OTHER_UNIT is still serving; stop it first (one engine at a time):"
|
|
echo " sudo systemctl stop $OTHER_UNIT && sudo systemctl start $UNIT_NAME"
|
|
fi
|
|
echo "also start the keepalive proxy with: sudo systemctl start $KEEPALIVE_UNIT"
|
|
[ "$COCKPIT" -eq 1 ] && echo "the cockpit is not installed on the --no-start path: ./dashboard/install-dashboard.sh once the engine runs"
|
|
record_install no-start
|
|
star_line
|
|
exit 0
|
|
fi
|
|
|
|
# Kept only when the running engine started after every file it reads was last written,
|
|
# this run changed none of them by content (engine-inputs.py), and it answers.
|
|
ENGINE_KEEP=0; ENGINE_WHY=""
|
|
if [ "${RESTART_ENGINE:-0}" = "1" ]; then
|
|
ENGINE_WHY="RESTART_ENGINE=1"
|
|
elif [ "$ENGINE_RUNNING_IT" != "yes" ]; then
|
|
ENGINE_WHY="${ENGINE_RUNNING_IT#no: }"
|
|
elif [ -z "$ENGINE_FP_BEFORE" ] || [ "$(python3 "$REPO_DIR/engine-inputs.py" fingerprint "$ENGINE_UNIT_PATH" "$CONFIG_DIR" "$HF_CACHE" "${ENGINE_CKPTS[@]}" 2>/dev/null || true)" != "$ENGINE_FP_BEFORE" ]; then
|
|
ENGINE_WHY="this run changed what it reads"
|
|
elif ! curl -sf -m 5 "http://127.0.0.1:$PORT/health" >/dev/null 2>&1; then
|
|
ENGINE_WHY="it does not answer /health"
|
|
else
|
|
ENGINE_KEEP=1
|
|
fi
|
|
if [ "$ENGINE_KEEP" -eq 1 ]; then
|
|
step "9/10 Keeping the running engine: nothing it reads changed since it started (RESTART_ENGINE=1 restarts it)"
|
|
elif [ "$LANE" = "flash" ]; then
|
|
step "9/10 Starting (every boot ≈ 12-15 min: the weight load writes the whole 47.7 GiB PLE table into its file, then CUDA graph capture)"
|
|
else
|
|
step "9/10 Starting (≈ 3.5 min on the reference box: the weights, then CUDA graph capture)"
|
|
fi
|
|
[ "$ENGINE_KEEP" -eq 0 ] && [ "$ENGINE_RUNNING_IT" != "no: not installed yet" ] && echo "why: $ENGINE_WHY"
|
|
if [ -n "$OTHER_UNIT" ] && systemctl is-active --quiet "$OTHER_UNIT" 2>/dev/null; then
|
|
echo "stopping the other engine first ($OTHER_UNIT): one engine at a time on a GB10"
|
|
sudo systemctl stop "$OTHER_UNIT"
|
|
fi
|
|
SMOKE_MODEL="qwen3.8-27b"
|
|
[ "$LANE" = "flash" ] && SMOKE_MODEL="qwen3.8-flash-next"
|
|
[ "$ENGINE_KEEP" -eq 1 ] || sudo systemctl restart "$UNIT_NAME"
|
|
# A unit that dies at load never reads "failed" here: Restart=always relaunches it after
|
|
# RestartSec=15, which never reaches systemd's default limit of 5 starts in 10 s, so
|
|
# is-active says "activating" between attempts and the loop below waited its full 20
|
|
# minutes with the journal unread. systemd counts the relaunches (NRestarts), and a manual
|
|
# restart does not zero the count (checked on the reference box's systemd 255), so the
|
|
# count now is the baseline and one more is a crash (found in review, 2026-09-24).
|
|
engine_restarts() { systemctl show -p NRestarts --value "$UNIT_NAME" 2>/dev/null | tr -dc '0-9'; }
|
|
ENGINE_RESTARTS0="$(engine_restarts)"
|
|
# The same proof for a text lane started later in this run (the other text lane, new
|
|
# beside this one, and this one again after the side lanes proved themselves): start the
|
|
# unit, wait as the loop below waits (20 min; a failed unit or a relaunch is a death),
|
|
# then one real generation judged as the smoke below judges it. Says why and returns 1
|
|
# instead of dying: the caller decides what a failure costs. $1 unit, $2 the name it
|
|
# serves, $3 "stop" to stop it once it answered or failed.
|
|
prove_text_lane(){
|
|
local unit="$1" model="$2" after="${3:-}" r0 n st raw verdict rc=0
|
|
r0="$(systemctl show -p NRestarts --value "$unit" 2>/dev/null | tr -dc '0-9')"
|
|
sudo systemctl start "$unit" || { echo "NOTE: $unit did not start (journalctl -u $unit -n 50)"; return 1; }
|
|
for n in $(seq 1 150); do
|
|
if curl -s -m 2 "http://127.0.0.1:$PORT/health" >/dev/null 2>&1; then
|
|
raw="$(curl -s -m 300 "http://127.0.0.1:$PORT/v1/chat/completions" \
|
|
-H @<(printf 'Authorization: Bearer %s\n' "$KEY") -H 'Content-Type: application/json' \
|
|
-d '{"model":"'"$model"'","messages":[{"role":"user","content":"Reply with exactly: READY"}],"max_tokens":600}')" \
|
|
|| rc=$?
|
|
verdict="$(printf '%s' "$raw" | python3 -c 'import json,sys
|
|
try:
|
|
m=json.load(sys.stdin)["choices"][0]["message"]
|
|
text=(m.get("content") or "")+(m.get("reasoning_content") or "")
|
|
print("CORRUPT" if "!"*32 in text else "OK" if text.strip() else "EMPTY")
|
|
except Exception as e:
|
|
print(f"FAIL:{e}")')"
|
|
[ "$after" = stop ] && sudo systemctl stop "$unit"
|
|
if [ "$rc" -eq 0 ] && [ "$verdict" = OK ]; then
|
|
echo "$unit answered a real generation, up after ~$(( (n - 1) * 8 )) s"
|
|
return 0
|
|
fi
|
|
echo "NOTE: $unit came up, and its generation failed (curl exit $rc, $verdict): journalctl -u $unit -n 50"
|
|
return 1
|
|
fi
|
|
st="$(systemctl is-active "$unit" || true)"
|
|
if [ "$st" = failed ] || { [ -n "$r0" ] && [ "$(systemctl show -p NRestarts --value "$unit" 2>/dev/null | tr -dc '0-9')" -gt "$r0" ]; }; then
|
|
journalctl -u "$unit" --no-pager | tail -25
|
|
sudo systemctl stop "$unit" 2>/dev/null || true
|
|
echo "NOTE: $unit died during startup, logs above"
|
|
return 1
|
|
fi
|
|
[ $((n % 15)) -eq 0 ] && echo " still loading... ($((n * 8)) s)"
|
|
sleep 8
|
|
done
|
|
[ "$after" = stop ] && sudo systemctl stop "$unit"
|
|
echo "NOTE: $unit did not answer within 20 min: journalctl -u $unit -n 50"
|
|
return 1
|
|
}
|
|
# what the wait is made of: the flash lane rewrites its PLE table on every boot, and said
|
|
# "first boot compiles kernels" through a 13-minute load that compiled nothing
|
|
LOAD_WHY="first boot compiles kernels, be patient"
|
|
[ "$LANE" = "flash" ] && LOAD_WHY="every boot writes the 47.7 GiB PLE table, be patient"
|
|
for i in $(seq 1 150); do
|
|
if curl -s -m 2 "http://127.0.0.1:$PORT/health" >/dev/null 2>&1; then
|
|
echo "health OK, running a real generation smoke test..."
|
|
# curl on its own, so its failure is named: in the pipe it came out through the ERR trap
|
|
# as "Install failed at line N", and the pointer to the journal below never showed. A
|
|
# kept engine may be in the middle of someone's long prefill, which the smoke request
|
|
# waits behind, so it gets more than a freshly booted one (found in review, 2026-09-24).
|
|
SMOKE_MAX_S=300; [ "$ENGINE_KEEP" -eq 1 ] && SMOKE_MAX_S=1800
|
|
# The key goes in as a header file (printf is a builtin): on curl's command line it
|
|
# was readable by any local user in /proc (found in review, 2026-09-24).
|
|
SMOKE_RC=0
|
|
SMOKE_RAW="$(curl -s -m "$SMOKE_MAX_S" "http://127.0.0.1:$PORT/v1/chat/completions" \
|
|
-H @<(printf 'Authorization: Bearer %s\n' "$KEY") -H 'Content-Type: application/json' \
|
|
-d '{"model":"'"$SMOKE_MODEL"'","messages":[{"role":"user","content":"Reply with exactly: READY"}],"max_tokens":600}')" \
|
|
|| SMOKE_RC=$?
|
|
[ "$SMOKE_RC" -eq 0 ] || die "Server is up but the smoke generation got no answer (curl exit $SMOKE_RC; 28 is its ${SMOKE_MAX_S} s timeout). Check: journalctl -u $UNIT_NAME -n 50"
|
|
# A wall of "!" (token 0) is this hardware's known decode corruption, and it is not an
|
|
# answer: any non-empty text used to pass, so it ended in "Installed, verified". The
|
|
# smoke calls the engine directly, past the proxy's own tripwire, so it looks itself.
|
|
SMOKE="$(printf '%s' "$SMOKE_RAW" | python3 -c 'import json,sys
|
|
try:
|
|
m=json.load(sys.stdin)["choices"][0]["message"]
|
|
text=(m.get("content") or "")+(m.get("reasoning_content") or "")
|
|
print("CORRUPT" if "!"*32 in text else "OK" if text.strip() else "EMPTY")
|
|
except Exception as e:
|
|
print(f"FAIL:{e}")')"
|
|
[ "$SMOKE" != "CORRUPT" ] || die "Server is up but the smoke generation came back as a run of '!' (token 0), the decode corruption this hardware is known for, not an answer. Restart the engine (sudo systemctl restart $UNIT_NAME), and if it comes back the same, check: journalctl -u $UNIT_NAME -n 50"
|
|
[ "$SMOKE" = "OK" ] || die "Server is up but the smoke generation failed ($SMOKE). Check: journalctl -u $UNIT_NAME -n 50"
|
|
# A restarted engine can come back with another pool than the one the proxy has cached
|
|
# (it keeps a reading 10 minutes), so the proxy goes with it; with the engine kept, only
|
|
# new code or a new unit is a reason to cut the requests in flight through it.
|
|
if [ "$ENGINE_KEEP" -eq 0 ] || [ "$KA_CHANGED" -eq 1 ] \
|
|
|| stale_since "$KEEPALIVE_UNIT" "/etc/systemd/system/$KEEPALIVE_UNIT" "$CONFIG_DIR/keepalive-proxy.py"; then
|
|
sudo systemctl restart "$KEEPALIVE_UNIT"
|
|
else
|
|
echo "keepalive proxy kept: the engine was kept and nothing the proxy runs changed"
|
|
fi
|
|
PROXY_OK=0
|
|
for _ in 1 2 3 4 5; do
|
|
curl -s -m 5 "http://127.0.0.1:$PROXY_PORT/health" >/dev/null 2>&1 && { PROXY_OK=1; break; }
|
|
sleep 2
|
|
done
|
|
[ "$PROXY_OK" = 1 ] || die "the keepalive proxy did not come up on :$PROXY_PORT. Check: journalctl -u $KEEPALIVE_UNIT -n 30"
|
|
echo "keepalive proxy OK on :$PROXY_PORT (agent clients use this port)"
|
|
# Superseded artifacts from earlier versions of THIS repo, if any: detect
|
|
# and say how to reclaim them; never delete data on the operator's behalf.
|
|
LEFTOVER_NOTES=""
|
|
if [ "$LANE" = "flash" ]; then
|
|
for ref in "vllm/vllm-openai:qwen38-flash-next" "vllm/vllm-openai@sha256:fc120ece0a388cc0aa1caad4a9f1cd92113484ab7ec2fd0efadd62585be05bf8" "qwen38-flash:v1.4" "qwen38-flash:v1.5" "qwen38-flash:v1.5.2"; do
|
|
docker image inspect "$ref" >/dev/null 2>&1 && LEFTOVER_NOTES="${LEFTOVER_NOTES} docker rmi '$ref'\n"
|
|
done
|
|
fi
|
|
while IFS= read -r tagref; do
|
|
# Never offer to delete what is being served. The overlay tags of both lanes
|
|
# are offered: the 27B one since v1.14 serves the official image, the flash
|
|
# one since v1.18.7 retired OVERLAY_FLASH=1, its rollback.
|
|
[ -n "$tagref" ] && [ "$tagref" != "$SERVE_IMAGE" ] && [ "$tagref" != "$FLASH_SERVE_IMAGE" ] \
|
|
&& case "$LEFTOVER_NOTES" in *"'$tagref'"*) ;; *) LEFTOVER_NOTES="${LEFTOVER_NOTES} docker rmi '$tagref'\n" ;; esac
|
|
done < <({ docker images --format '{{.Repository}}:{{.Tag}}' qwen38-dflash2 2>/dev/null; docker images --format '{{.Repository}}:{{.Tag}}' qwen38-flash 2>/dev/null; } || true)
|
|
if [ -n "$LEFTOVER_NOTES" ]; then
|
|
echo " Note: earlier versions of this repo left superseded images; reclaim when you like:"
|
|
printf '%b' "$LEFTOVER_NOTES"
|
|
echo " (full inventory anytime: ./uninstall.sh --list)"
|
|
fi
|
|
# The 1m limits the generator writes are static, and their worst case
|
|
# (compaction at about 680,000, one agent step, and 200,000 of output) sits
|
|
# ABOVE every pool the lane booted to (832,993 to 922,094): a long session's last
|
|
# answers can run out of pool. On a smaller pool the proxy refuses the
|
|
# prompt itself mid-conversation, which is the field case that produced
|
|
# oc-fit-limits.py in the first place (2026-08-30). That was a documented
|
|
# manual step while 1m was opt-in. It cannot stay one now that 1m is what a
|
|
# plain install serves.
|
|
# A 64 GB box too, on its native window: its pool is far smaller than the one the native pair
|
|
# was sized on, and the pair's worst case ran past it (found in review, 2026-10-23).
|
|
if { [ "$CONTEXT_MODE" = "1m" ] || [ "$MEM_CLASS" = 64 ]; } && [ "$OPENCODE" -eq 1 ]; then
|
|
echo "fitting the opencode limits to the KV pool this boot actually got:"
|
|
# --restart-agent-if-lowered: opencode-web reads its config only at startup, so a limit this
|
|
# fit has to bring DOWN restarts it; limits it raises still fit as they run, and a restart ends
|
|
# the turn the Agent tab is in: every update cut it, the pool of this boot being larger than the
|
|
# one of the boot that set them (v1.44.3 on the reference box, 2026-11-08).
|
|
python3 "$REPO_DIR/oc-fit-limits.py" --engine "http://127.0.0.1:$PORT" --restart-agent-if-lowered \
|
|
|| echo " NOTE: could not fit them; run python3 oc-fit-limits.py yourself, or the cockpit's button"
|
|
fi
|
|
|
|
# ── 10/10 ───────────────────────────────────────────────────────────────
|
|
# The cockpit is installed here, not by a second command the operator has to
|
|
# find: a one-liner that leaves an engine and no way to drive it is half an
|
|
# install. It runs AFTER the engine answered a real generation, so the page
|
|
# it opens on is a working box rather than a loading screen, and a cockpit
|
|
# that fails to install never fails the engine that is already serving.
|
|
COCKPIT_URL=""
|
|
if [ "$COCKPIT" -eq 1 ]; then
|
|
step "10/10 Alzeo cockpit (the web UI this box is meant to be driven from)"
|
|
DASH_ENV=()
|
|
if [ ! -f /etc/systemd/system/qwen38-dashboard.service ]; then
|
|
# First install only. A re-run passes nothing, so install-dashboard.sh
|
|
# converges on the bind and port already installed: an upgrade must
|
|
# never flip a reachable cockpit back to loopback.
|
|
# Loopback alone is useless on a headless box and 0.0.0.0 puts the login
|
|
# on every interface, so the default is the tailnet address when the box
|
|
# has one: private by construction, reachable from a laptop or a phone.
|
|
TS_IP4="$(tailscale ip -4 2>/dev/null | head -1 || true)"
|
|
if [ -n "$TS_IP4" ]; then
|
|
DASH_ENV=(DASH_BIND="$TS_IP4")
|
|
echo "first cockpit install: binding the tailnet address $TS_IP4 (the API key is the only gate)"
|
|
else
|
|
echo "first cockpit install: no tailnet address on this box, binding 127.0.0.1."
|
|
echo " to reach it from another machine: DASH_BIND=0.0.0.0 ./dashboard/install-dashboard.sh"
|
|
fi
|
|
fi
|
|
if env ${DASH_ENV[@]+"${DASH_ENV[@]}"} "$REPO_DIR/dashboard/install-dashboard.sh"; then
|
|
# The Agent tab needs opencode on PATH. Not having it costs one tab, and
|
|
# one missing tab is not a reason to fail an install that is otherwise up.
|
|
if [ "$OPENCODE" -eq 1 ] && command -v opencode >/dev/null 2>&1; then
|
|
"$REPO_DIR/dashboard/install-agent.sh" \
|
|
|| echo "NOTE: the Agent view did not install; the rest of the cockpit is up (retry: ./dashboard/install-agent.sh)"
|
|
elif [ "$OPENCODE" -eq 1 ]; then
|
|
echo "NOTE: opencode is not on your PATH (step 7 did not install it: see its NOTE, or OPENCODE_PIN=0),"
|
|
echo " so the Agent view is not installed. Re-run ./install.sh, or install it and run ./dashboard/install-agent.sh"
|
|
fi
|
|
# The URL to print is the installed unit's own bind and port, read back
|
|
# rather than assumed: install-agent.sh re-renders that unit, and a
|
|
# converged re-run may be serving on an address this run never chose.
|
|
CK_UNIT=/etc/systemd/system/qwen38-dashboard.service
|
|
CK_PORT="$({ grep -m1 -E '^Environment=COCKPIT_PORT=' "$CK_UNIT" || true; } | cut -d= -f3-)"
|
|
CK_BIND="$({ grep -m1 -E '^Environment=COCKPIT_BIND=' "$CK_UNIT" || true; } | cut -d= -f3-)"
|
|
CK_HOST="${CK_BIND:-127.0.0.1}"
|
|
case "$CK_HOST" in
|
|
0.0.0.0|::|"[::]")
|
|
# A wildcard bind is not an address you can type: name one.
|
|
CK_HOST="$(tailscale ip -4 2>/dev/null | head -1 || true)"
|
|
[ -n "$CK_HOST" ] || CK_HOST="$(hostname -I 2>/dev/null | awk '{print $1}')"
|
|
[ -n "$CK_HOST" ] || CK_HOST="127.0.0.1" ;;
|
|
esac
|
|
COCKPIT_URL="http://$CK_HOST:${CK_PORT:-30090}"
|
|
else
|
|
echo "NOTE: the cockpit did not install. The engine above is up and serving."
|
|
echo " retry with ./dashboard/install-dashboard.sh (logs: journalctl -u qwen38-dashboard -n 30)"
|
|
fi
|
|
elif systemctl is-active --quiet qwen38-dashboard.service 2>/dev/null; then
|
|
# --no-cockpit with one already running: it imports this repo's python at
|
|
# start, so an update that leaves it running serves the new html against
|
|
# the old python in memory (2026-09-08: the switch selector offered a
|
|
# target the action layer refused). Restart it, do not reinstall it.
|
|
echo "restarting the cockpit so it picks up this repo's code (it imports it at start)"
|
|
sudo systemctl restart qwen38-dashboard.service \
|
|
|| echo " NOTE: could not restart it; do it by hand or its controls and its checks disagree"
|
|
fi
|
|
|
|
# ── Every other lane ─────────────────────────────────────────────────────
|
|
# Since v1.20 the image and the video lanes are installed by default, like the other
|
|
# text lane above (lane_wanted: --no-image and --no-video leave them out of the run that
|
|
# passes them). They are prepared here while this lane keeps serving. Each lane this
|
|
# run installs for the first time then proves it serves, and those proofs need the
|
|
# GPU to themselves, so they come last and together: this lane stops once, each new
|
|
# lane boots, answers and stops, and this lane comes back and proves itself again
|
|
# before the run says it is done. A routine update proves nothing twice: it updates
|
|
# the lanes it finds and leaves this one serving. A lane that does not install (a
|
|
# disk too small for it, a download that fails) is said, and the rest goes on.
|
|
# New here, and proved when this run builds it whole: a lane with no unit yet, or one whose
|
|
# runtime is not on the box (installed on demand, its units only: --all-weights on such a
|
|
# box built every lane and proved none, found in review, 2026-10-15).
|
|
IMAGE_FRESH=0; VIDEO_FRESH=0; KOLIBRI_FRESH=0; NEMOTRON_FRESH=0; NEMOTRON_SUPER_FRESH=0; FLASH_LOCAL_FRESH=0; ORNITH_122B_FRESH=0; FLASH_UNSLOTH_FRESH=0
|
|
{ [ -f /etc/systemd/system/qwen38-image.service ] && side_begun image; } || IMAGE_FRESH=1
|
|
{ [ -f /etc/systemd/system/qwen38-video.service ] && side_begun video; } || VIDEO_FRESH=1
|
|
{ [ -f "$KOLIBRI_UNIT_PATH" ] && side_begun kolibri; } || KOLIBRI_FRESH=1
|
|
{ [ -f "$NEMOTRON_UNIT_PATH" ] && side_begun nemotron; } || NEMOTRON_FRESH=1
|
|
{ [ -f "$NEMOTRON_SUPER_UNIT_PATH" ] && side_begun nemotron-super; } || NEMOTRON_SUPER_FRESH=1
|
|
{ [ -f "$FLASH_LOCAL_UNIT_PATH" ] && side_begun flash-local; } || FLASH_LOCAL_FRESH=1
|
|
{ [ -f "$ORNITH_122B_UNIT_PATH" ] && side_begun ornith-122b; } || ORNITH_122B_FRESH=1
|
|
{ [ -f "$FLASH_UNSLOTH_UNIT_PATH" ] && side_begun flash-unsloth; } || FLASH_UNSLOTH_FRESH=1
|
|
IMAGE_STATE=off; VIDEO_STATE=off; KOLIBRI_STATE=off; NEMOTRON_STATE=off; NEMOTRON_SUPER_STATE=off; FLASH_LOCAL_STATE=off; ORNITH_122B_STATE=off; FLASH_UNSLOTH_STATE=off
|
|
if [ "$WANT_IMAGE" -eq 1 ]; then
|
|
step "Qwen-Image 2.1 lane (text-to-image, editing, native RGBA)"
|
|
IMAGE_MODE="$(side_mode image "$WITH_IMAGE")"
|
|
if "$REPO_DIR/install-image.sh" "$IMAGE_MODE"; then IMAGE_STATE=installed; [ "$IMAGE_MODE" = --units-only ] && IMAGE_STATE=units; else
|
|
IMAGE_STATE=failed
|
|
echo "NOTE: the image lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_VIDEO" -eq 1 ]; then
|
|
step "MiniMax-H3 lane (text-to-video with joint video-and-audio)"
|
|
VIDEO_MODE="$(side_mode video "$WITH_VIDEO")"
|
|
if "$REPO_DIR/install-video.sh" "$VIDEO_MODE"; then VIDEO_STATE=installed; [ "$VIDEO_MODE" = --units-only ] && VIDEO_STATE=units; else
|
|
VIDEO_STATE=failed
|
|
echo "NOTE: the video lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_KOLIBRI" -eq 1 ]; then
|
|
step "Kolibri-1 lane (Aleph Alpha's German and English reasoning model, on vLLM)"
|
|
KOLIBRI_MODE="$(side_mode kolibri "$WITH_KOLIBRI")"
|
|
if "$REPO_DIR/install-kolibri.sh" "$KOLIBRI_MODE"; then KOLIBRI_STATE=installed; [ "$KOLIBRI_MODE" = --units-only ] && KOLIBRI_STATE=units; else
|
|
KOLIBRI_STATE=failed
|
|
echo "NOTE: the Kolibri-1 lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_NEMOTRON" -eq 1 ]; then
|
|
step "Nemotron 3.5 Bolt lane (NVIDIA's 2-bit 74B reasoning model with vision, on vLLM)"
|
|
NEMOTRON_MODE="$(side_mode nemotron "$WITH_NEMOTRON")"
|
|
if "$REPO_DIR/install-nemotron.sh" "$NEMOTRON_MODE"; then NEMOTRON_STATE=installed; [ "$NEMOTRON_MODE" = --units-only ] && NEMOTRON_STATE=units; else
|
|
NEMOTRON_STATE=failed
|
|
echo "NOTE: the Nemotron 3.5 Bolt lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_NEMOTRON_SUPER" -eq 1 ]; then
|
|
step "Nemotron 3.5 Super VL lane (NVIDIA's 120B reasoning model with vision and a 1M window, on vLLM)"
|
|
NEMOTRON_SUPER_MODE="$(side_mode nemotron-super "$WITH_NEMOTRON_SUPER")"
|
|
if "$REPO_DIR/install-nemotron-super.sh" "$NEMOTRON_SUPER_MODE"; then NEMOTRON_SUPER_STATE=installed; [ "$NEMOTRON_SUPER_MODE" = --units-only ] && NEMOTRON_SUPER_STATE=units; else
|
|
NEMOTRON_SUPER_STATE=failed
|
|
echo "NOTE: the Nemotron 3.5 Super VL lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_FLASH_LOCAL" -eq 1 ]; then
|
|
step "Qwen3.8 Flash-Next FP4-Local lane (NVIDIA's FP4 build of the flash model, on vLLM with b12x)"
|
|
FLASH_LOCAL_MODE="$(side_mode flash-local "$WITH_FLASH_LOCAL")"
|
|
if "$REPO_DIR/install-flash-local.sh" "$FLASH_LOCAL_MODE"; then FLASH_LOCAL_STATE=installed; [ "$FLASH_LOCAL_MODE" = --units-only ] && FLASH_LOCAL_STATE=units; else
|
|
FLASH_LOCAL_STATE=failed
|
|
echo "NOTE: the Qwen3.8 Flash-Next FP4-Local lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_ORNITH_122B" -eq 1 ]; then
|
|
step "Ornith 1.5 122B lane (Ornith AI's 122B mixture of experts with vision, on vLLM with b12x)"
|
|
ORNITH_122B_MODE="$(side_mode ornith-122b "$WITH_ORNITH_122B")"
|
|
if "$REPO_DIR/install-ornith-122b.sh" "$ORNITH_122B_MODE"; then ORNITH_122B_STATE=installed; [ "$ORNITH_122B_MODE" = --units-only ] && ORNITH_122B_STATE=units; else
|
|
ORNITH_122B_STATE=failed
|
|
echo "NOTE: the Ornith 1.5 122B lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
if [ "$WANT_FLASH_UNSLOTH" -eq 1 ]; then
|
|
step "Qwen3.8 Flash-Next Unsloth GGUF lane (Unsloth's GGUF of the flash model, on llama.cpp)"
|
|
FLASH_UNSLOTH_MODE="$(side_mode flash-unsloth "$WITH_FLASH_UNSLOTH")"
|
|
if "$REPO_DIR/install-flash-unsloth.sh" "$FLASH_UNSLOTH_MODE"; then FLASH_UNSLOTH_STATE=installed; [ "$FLASH_UNSLOTH_MODE" = --units-only ] && FLASH_UNSLOTH_STATE=units; else
|
|
FLASH_UNSLOTH_STATE=failed
|
|
echo "NOTE: the Qwen3.8 Flash-Next Unsloth GGUF lane did not install (the lines above say why); the rest goes on."
|
|
fi
|
|
fi
|
|
# What to prove: what this run installed for the first time, or what was asked for
|
|
# by name (--with-<lane>, which also proves a lane already there).
|
|
SECOND_WITH=0
|
|
{ [ "$SECOND_LANE" = flash ] && [ "$WITH_FLASH" -eq 1 ]; } && SECOND_WITH=1
|
|
{ [ "$SECOND_LANE" = 27b ] && [ "$WITH_27B" -eq 1 ]; } && SECOND_WITH=1
|
|
PROVE_SECOND=0; PROVE_IMAGE=0; PROVE_VIDEO=0; PROVE_KOLIBRI=0; PROVE_NEMOTRON=0; PROVE_NEMOTRON_SUPER=0; PROVE_FLASH_LOCAL=0; PROVE_ORNITH_122B=0; PROVE_FLASH_UNSLOTH=0
|
|
{ [ "$SECOND_STATE" = installed ] && { [ "$SECOND_NEW" -eq 1 ] || [ "$SECOND_WITH" -eq 1 ]; }; } && PROVE_SECOND=1
|
|
{ [ "$IMAGE_STATE" = installed ] && { [ "$IMAGE_FRESH" -eq 1 ] || [ "$WITH_IMAGE" -eq 1 ]; }; } && PROVE_IMAGE=1
|
|
{ [ "$VIDEO_STATE" = installed ] && { [ "$VIDEO_FRESH" -eq 1 ] || [ "$WITH_VIDEO" -eq 1 ]; }; } && PROVE_VIDEO=1
|
|
{ [ "$KOLIBRI_STATE" = installed ] && { [ "$KOLIBRI_FRESH" -eq 1 ] || [ "$WITH_KOLIBRI" -eq 1 ]; }; } && PROVE_KOLIBRI=1
|
|
{ [ "$NEMOTRON_STATE" = installed ] && { [ "$NEMOTRON_FRESH" -eq 1 ] || [ "$WITH_NEMOTRON" -eq 1 ]; }; } && PROVE_NEMOTRON=1
|
|
{ [ "$NEMOTRON_SUPER_STATE" = installed ] && { [ "$NEMOTRON_SUPER_FRESH" -eq 1 ] || [ "$WITH_NEMOTRON_SUPER" -eq 1 ]; }; } && PROVE_NEMOTRON_SUPER=1
|
|
{ [ "$FLASH_LOCAL_STATE" = installed ] && { [ "$FLASH_LOCAL_FRESH" -eq 1 ] || [ "$WITH_FLASH_LOCAL" -eq 1 ]; }; } && PROVE_FLASH_LOCAL=1
|
|
{ [ "$ORNITH_122B_STATE" = installed ] && { [ "$ORNITH_122B_FRESH" -eq 1 ] || [ "$WITH_ORNITH_122B" -eq 1 ]; }; } && PROVE_ORNITH_122B=1
|
|
{ [ "$FLASH_UNSLOTH_STATE" = installed ] && { [ "$FLASH_UNSLOTH_FRESH" -eq 1 ] || [ "$WITH_FLASH_UNSLOTH" -eq 1 ]; }; } && PROVE_FLASH_UNSLOTH=1
|
|
if [ $((PROVE_SECOND + PROVE_IMAGE + PROVE_VIDEO + PROVE_KOLIBRI + PROVE_NEMOTRON + PROVE_NEMOTRON_SUPER + PROVE_FLASH_LOCAL + PROVE_ORNITH_122B + PROVE_FLASH_UNSLOTH)) -gt 0 ]; then
|
|
step "Proving the new lanes serve: the ${LANE/27b/27B} lane stops meanwhile, then comes back"
|
|
sudo systemctl stop "$UNIT_NAME"
|
|
if [ "$PROVE_SECOND" -eq 1 ]; then
|
|
SECOND_MODEL=qwen3.8-27b; [ "$SECOND_LANE" = flash ] && SECOND_MODEL=qwen3.8-flash-next
|
|
echo "starting the ${SECOND_LANE/27b/27B} lane ($SECOND_UNIT)"
|
|
if prove_text_lane "$SECOND_UNIT" "$SECOND_MODEL" stop; then SECOND_STATE=proved; else SECOND_STATE=unproved; fi
|
|
fi
|
|
# Nothing serves while they run, so each leaves the box as it found it: stopped.
|
|
if [ "$PROVE_IMAGE" -eq 1 ]; then
|
|
if "$REPO_DIR/install-image.sh"; then IMAGE_STATE=proved; else IMAGE_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_VIDEO" -eq 1 ]; then
|
|
if "$REPO_DIR/install-video.sh"; then VIDEO_STATE=proved; else VIDEO_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_KOLIBRI" -eq 1 ]; then
|
|
if "$REPO_DIR/install-kolibri.sh"; then KOLIBRI_STATE=proved; else KOLIBRI_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_NEMOTRON" -eq 1 ]; then
|
|
if "$REPO_DIR/install-nemotron.sh"; then NEMOTRON_STATE=proved; else NEMOTRON_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_NEMOTRON_SUPER" -eq 1 ]; then
|
|
if "$REPO_DIR/install-nemotron-super.sh"; then NEMOTRON_SUPER_STATE=proved; else NEMOTRON_SUPER_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_FLASH_LOCAL" -eq 1 ]; then
|
|
if "$REPO_DIR/install-flash-local.sh"; then FLASH_LOCAL_STATE=proved; else FLASH_LOCAL_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_ORNITH_122B" -eq 1 ]; then
|
|
if "$REPO_DIR/install-ornith-122b.sh"; then ORNITH_122B_STATE=proved; else ORNITH_122B_STATE=unproved; fi
|
|
fi
|
|
if [ "$PROVE_FLASH_UNSLOTH" -eq 1 ]; then
|
|
if "$REPO_DIR/install-flash-unsloth.sh"; then FLASH_UNSLOTH_STATE=proved; else FLASH_UNSLOTH_STATE=unproved; fi
|
|
fi
|
|
step "The ${LANE/27b/27B} lane again"
|
|
prove_text_lane "$UNIT_NAME" "$SMOKE_MODEL" \
|
|
|| die "the ${LANE/27b/27B} lane did not come back after the other lanes' proofs (the lines above say why). Start it with: sudo systemctl start $UNIT_NAME"
|
|
# A new boot is a new pool: the proxy reads it again, and opencode's 1m limits
|
|
# follow it, as after the first boot above.
|
|
ENGINE_KEEP=0
|
|
if [ "$ENGINE_KEEP" -eq 0 ] || [ "$KA_CHANGED" -eq 1 ] \
|
|
|| stale_since "$KEEPALIVE_UNIT" "/etc/systemd/system/$KEEPALIVE_UNIT" "$CONFIG_DIR/keepalive-proxy.py"; then
|
|
sudo systemctl restart "$KEEPALIVE_UNIT"
|
|
fi
|
|
PROXY_OK=0
|
|
for _ in 1 2 3 4 5; do
|
|
curl -s -m 5 "http://127.0.0.1:$PROXY_PORT/health" >/dev/null 2>&1 && { PROXY_OK=1; break; }
|
|
sleep 2
|
|
done
|
|
[ "$PROXY_OK" = 1 ] || die "the keepalive proxy did not come back on :$PROXY_PORT. Check: journalctl -u $KEEPALIVE_UNIT -n 30"
|
|
if { [ "$CONTEXT_MODE" = "1m" ] || [ "$MEM_CLASS" = 64 ]; } && [ "$OPENCODE" -eq 1 ]; then
|
|
python3 "$REPO_DIR/oc-fit-limits.py" --engine "http://127.0.0.1:$PORT" --restart-agent \
|
|
|| echo " NOTE: could not fit them; run python3 oc-fit-limits.py yourself, or the cockpit's button"
|
|
fi
|
|
fi
|
|
|
|
printf '\n\033[1;32m✅ Installed, verified, and enabled at boot.\033[0m\n'
|
|
if [ -n "$COCKPIT_URL" ]; then
|
|
printf '\n\033[1;36m ▶ OPEN THE COCKPIT: %s\033[0m\n' "$COCKPIT_URL"
|
|
echo " log in with the API key in $CONFIG_DIR/api-key"
|
|
echo
|
|
echo " Start, stop and switch the served model, watch every live request,"
|
|
echo " read the engine logs, run the benchmarks and drive an agent, from"
|
|
echo " that page. Nothing else needs installing or starting by hand."
|
|
echo
|
|
echo " Raw endpoints, for clients that ask for them:"
|
|
else
|
|
echo
|
|
fi
|
|
# The proxy for every client: it passes every route of the engine through, with its
|
|
# guards. These lines named the engine's own port, which listens on loopback since
|
|
# v1.17 (unreachable from another machine) and has none of the guards (found in
|
|
# review, 2026-09-24).
|
|
echo " Clients : http://<host>:$PROXY_PORT (keepalive proxy, for opencode and every other client)"
|
|
echo " OpenAI : http://<host>:$PROXY_PORT/v1/chat/completions"
|
|
echo " Anthropic : http://<host>:$PROXY_PORT/v1/messages (Bearer auth only)"
|
|
echo " Engine : $ENGINE_BIND:$PORT, behind the proxy (ENGINE_BIND=0.0.0.0 opens it)"
|
|
echo " API key : $CONFIG_DIR/api-key"
|
|
# started again with the docker group (lanes.sh): the terminal it came from has not got it
|
|
if [ -n "${QWEN38_DOCKER_RELAUNCHED:-}" ]; then
|
|
echo " Docker : $(id -un) is in the docker group; a terminal opened before this install gets it at its next login (the cockpit and these scripts need nothing)"
|
|
fi
|
|
if [ "$OPENCODE" -eq 1 ]; then
|
|
OC_NOW="$( { opencode --version 2>/dev/null || true; } | tail -1 | tr -d 'v[:space:]')"
|
|
# What starts it from the user's own shell: this script's PATH is not theirs, the
|
|
# launcher is skipped when another oc exists, and ~/.local/bin may be new.
|
|
OC_START="oc"
|
|
if ! grep -qs 'dgx-spark-qwen38' "$HOME/.local/bin/oc"; then
|
|
OC_START="${OC_OUT_CAP:+OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX=$OC_OUT_CAP }opencode --yolo"
|
|
elif [ "$(command -v oc || true)" != "$HOME/.local/bin/oc" ]; then
|
|
OC_START="$HOME/.local/bin/oc"
|
|
fi
|
|
OC_READS="${OC_USER_CFG:-$HOME/.config/opencode/opencode.json}"
|
|
if [ -z "$OC_NOW" ]; then
|
|
echo " opencode : NOT installed (see step 7). Its config is ready at $OC_READS;"
|
|
echo " re-run ./install.sh to install it, or get it from https://opencode.ai"
|
|
elif [ "$OC_NOW" = "$OPENCODE_VERSION" ]; then
|
|
echo " opencode : $OC_NOW, the version this repo tests; start it with: $OC_START (config: $OC_READS)"
|
|
else
|
|
echo " opencode : $OC_NOW (this repo tests $OPENCODE_VERSION); start it with: $OC_START (config: $OC_READS)"
|
|
fi
|
|
else
|
|
# remembered, unlike a lane: an agent that runs commands, which an update must not turn back on;
|
|
# said at every run with the day it was asked (Hasan, 2026-10-23, option B)
|
|
echo " opencode : integration off, as asked ($(head -1 "$OC_OFF_MARK" 2>/dev/null || echo 'by --no-opencode')), kept by every update; ./install.sh --with-opencode turns it on"
|
|
fi
|
|
[ "$COCKPIT" -eq 0 ] && echo " cockpit : off, as asked ($(head -1 "$CK_OFF_MARK" 2>/dev/null || echo 'by --no-cockpit')), kept by every update; ./install.sh --with-cockpit turns it on"
|
|
# One line per lane this run did not serve, with what happened to it and what to do.
|
|
lane_line(){ # $1 label, $2 state, $3 its flag, $4 its switch target, $5 its size, $6 its unit file
|
|
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
|
|
echo " $1: installed, ready to load ($5 in all): ./prepare-lane.sh $3 builds it, then ./switch-model.sh $4 switches to it"
|
|
fi ;;
|
|
# installed, then its proof failed: a plain run updates it and proves nothing (it is no
|
|
# longer new), so the line said a retry that never came (review, 2026-10-14)
|
|
unproved) echo " $1: NOT ready, see its NOTE above; it is installed but did not prove it serves: ./install.sh --with-$3 proves it again" ;;
|
|
# 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
|
|
# 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 too_big "$3"; then
|
|
echo " $1: needs a 128 GB DGX Spark, and this box is a 64 GB one"
|
|
elif [ -f "$6" ]; then
|
|
echo " $1: left out by --no-$3 on this run, so not updated; a run without it updates it"
|
|
else
|
|
echo " $1: left out by --no-$3 on this run; a run without it adds it, ready to load ($5)"
|
|
fi ;;
|
|
esac
|
|
}
|
|
if [ "$SECOND_LANE" = flash ]; then
|
|
lane_line "Flash-Next " "$SECOND_STATE" flash flash "223 GB" "$FLASH_UNIT_PATH"
|
|
elif [ "$SECOND_LANE" = 27b ]; then
|
|
lane_line "Qwen3.8 27B" "$SECOND_STATE" 27b stock "58 GB" "$SGL_UNIT_PATH"
|
|
fi
|
|
lane_line "Images " "$IMAGE_STATE" image image "46 GB" /etc/systemd/system/qwen38-image.service
|
|
lane_line "Videos " "$VIDEO_STATE" video video "174 GB" /etc/systemd/system/qwen38-video.service
|
|
lane_line "Kolibri-1 " "$KOLIBRI_STATE" kolibri kolibri "102 GB" "$KOLIBRI_UNIT_PATH"
|
|
lane_line "Nemotron " "$NEMOTRON_STATE" nemotron nemotron "51 GB" "$NEMOTRON_UNIT_PATH"
|
|
lane_line "Super VL " "$NEMOTRON_SUPER_STATE" nemotron-super nemotron-super "102 GB" "$NEMOTRON_SUPER_UNIT_PATH"
|
|
lane_line "FP4-Local " "$FLASH_LOCAL_STATE" flash-local flash-local "121 GB" "$FLASH_LOCAL_UNIT_PATH"
|
|
lane_line "Ornith 122B" "$ORNITH_122B_STATE" ornith-122b ornith-122b "96 GB" "$ORNITH_122B_UNIT_PATH"
|
|
lane_line "Unsloth " "$FLASH_UNSLOTH_STATE" flash-unsloth flash-unsloth "90 GB" "$FLASH_UNSLOTH_UNIT_PATH"
|
|
[ "$LANE" = "27b" ] && echo " Benchmark : ./bench.sh"
|
|
# A 64 GB DGX Spark serves Nemotron 3.5 Bolt (Hasan, 2026-10-24): there the 27B gets two requests
|
|
# and a pool of 59,625 tokens (measured on a 64 GB budget, 2026-10-24, its Mamba cache taking much
|
|
# of what the weights leave), where Bolt holds its 262,144-token window 2.55 times over at a
|
|
# 110.8 tok/s greedy median. A new box has proved its 27B by now: Bolt is loaded the way the
|
|
# cockpit's Load does it (prepare-lane.sh, switch-model.sh, which only points the boot and
|
|
# opencode at it, then the 27B stopped and Bolt started), and the 27B stays a Load away. A Bolt
|
|
# that does not come up puts the box back on the 27B. New: no run ever ended whole here
|
|
# (installed.json), so a first run that died, or stopped at --no-start, still counts, and
|
|
# --recommended, what a new box gets. A box that boots a lane, a run that names a 27B target,
|
|
# or one that leaves Bolt out keeps the 27B.
|
|
if [ "$MEM_CLASS" = 64 ] && [ "$SIDE_BOOT" -eq 0 ] && [ -z "$SECONDARY" ] && [ -z "$_ENV_MODEL_CHOICE" ] \
|
|
&& [ "$WANT_NEMOTRON" -eq 1 ] && { [ "$RECOMMENDED" -eq 1 ] || ! ran_whole_before; }; then
|
|
step "A 64 GB DGX Spark serves Nemotron 3.5 Bolt: loading it as the cockpit does (the 27B stays installed)"
|
|
BOLT_SWITCHED=0
|
|
if bolt_first_load; then
|
|
# Nothing is fitted here. Bolt's opencode limits are its own pair (oc-limits.sh nemotron), written with its
|
|
# provider at step 7 or by the switch above, which points opencode at Bolt and restarts the Agent tab's server
|
|
# when its configs changed. The fit that stood here reads SGLang's /server_info, which vLLM does not have: on
|
|
# a box with opencode on it failed each time, and the run's ending said "no engine to read ... start one
|
|
# first" under a Bolt that served, then gave a NOTE naming a cockpit button which, on this lane, answers that
|
|
# there is nothing to fit (read in the code, then run against a server that answers 404 as vLLM, 2026-11-10)
|
|
echo " Nemotron 3.5 Bolt serves now, and at boot; the 27B is a Load away in the cockpit"
|
|
else
|
|
echo "NOTE: Bolt did not come up (see above), so the 27B serves this box (if it was stopped, it starts"
|
|
echo " again and answers in a few minutes). Load Bolt from the cockpit to try again."
|
|
# Once Bolt's switch ran, the switch back to the 27B wrote its nominal opencode pair (173,000 + 64,000 at its
|
|
# native window) over the one fitted above to its pool, some 59,625 tokens on this class. A cockpit that runs
|
|
# fits them again once the 27B answers (its autofit, unless it was turned off); with none, nothing did, and
|
|
# opencode asked for nearly four times the pool until the next update (found in review, 2026-11-10). So the
|
|
# 27B is waited for, then fitted. It is only waited for: nothing here starts or stops its unit, and no sudo
|
|
# is prompted for at the end of a run. systemd starts the 27B again by itself when its first try finds the GPU's
|
|
# memory not given back yet (engine-preflight.sh), and the proof of the other lanes, which stops a unit it
|
|
# sees restarting, would have left this box with no engine (found in review the same day). After a
|
|
# preparation that failed the switch never ran: nothing moved, and nothing is done.
|
|
if [ "$OPENCODE" -eq 1 ] && [ "$BOLT_SWITCHED" -eq 1 ] \
|
|
&& ! systemctl is-active --quiet qwen38-dashboard.service 2>/dev/null; then
|
|
echo " opencode's limits are fitted to the 27B's pool again once it answers (20 min at most)"
|
|
if text_lane_answers 1200; then
|
|
python3 "$REPO_DIR/oc-fit-limits.py" --engine "http://127.0.0.1:$PORT" --restart-agent \
|
|
|| echo " NOTE: could not fit them; run python3 oc-fit-limits.py yourself"
|
|
else
|
|
echo " NOTE: the 27B does not answer yet, and opencode keeps its nominal limits, above its pool here: once it serves, run python3 oc-fit-limits.py"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
record_install full
|
|
star_line
|
|
exit 0
|
|
fi
|
|
ST="$(systemctl is-active "$UNIT_NAME" || true)"
|
|
[ "$ST" = "failed" ] && { journalctl -u "$UNIT_NAME" --no-pager | tail -25; die "Service failed during startup, logs above. Common cause: another process eating GPU/unified memory (this config needs the machine to itself)."; }
|
|
NOW_RESTARTS="$(engine_restarts)"
|
|
if [ -n "$NOW_RESTARTS" ] && [ -n "$ENGINE_RESTARTS0" ] && [ "$NOW_RESTARTS" -gt "$ENGINE_RESTARTS0" ]; then
|
|
journalctl -u "$UNIT_NAME" --no-pager | tail -25
|
|
die "The engine died during startup and systemd is relaunching it (Restart=always, $((NOW_RESTARTS - ENGINE_RESTARTS0)) relaunch(es) so far): logs above. Stop the loop with: sudo systemctl stop $UNIT_NAME"
|
|
fi
|
|
[ $((i % 15)) -eq 0 ] && echo " still loading... ($((i*8))s; $LOAD_WHY)"
|
|
sleep 8
|
|
done
|
|
die "Server did not come up within 20 min. Watch: journalctl -u $UNIT_NAME -f"
|