From 24dd67a5c3e809bca72e5b3b0d5e4d55fdc35391 Mon Sep 17 00:00:00 2001 From: Hasan Basbunar Date: Mon, 9 Nov 2026 14:01:33 +0100 Subject: [PATCH] clients: the FP4-Local lane's 1M pair, read from its unit oc-limits.sh gave the FP4-Local lane its 262K pair whatever the window, and switch-model.sh and install.sh named a window of 262,144. With FLASH_LOCAL_CONTEXT=1m, opencode, pi and claude-local therefore stayed at 185K before compaction under a "(local, 262K)" label, while the cockpit said 1M (code review of v1.45.2). oc-limits.sh flash-local now takes a mode (native | 1m), or reads it with --from from the unit's --max-model-len, the way the 27B's mode is read. At 1M the pool decides: 840,000 + 32,000 fits the cockpit's check with a pool 10 % smaller than the 1,061,819 measured, and the window holds the prompt at compaction, one agent step and the answer. The switch reads the unit it has just staged, the installer reads the installed unit, and both take the label from that unit's window. The CI gate pins both pairs, the derivation from a unit, and the two writers' wiring. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ install.sh | 10 ++++++---- oc-limits.sh | 29 +++++++++++++++++++++++------ switch-model.sh | 8 +++++--- 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f8acb33..9e277105 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -546,6 +546,18 @@ jobs: [ "$(l "$t" concurrency)" = "205000 32000 local" ] || { echo "$t/concurrency drifted"; exit 1; } [ "$(l "$t" throughput)" = "110000 32000 local" ] || { echo "$t/throughput drifted"; exit 1; } done + # The Qwen3.8 Flash-Next FP4-Local lane, at its native window and at its 1M one (FLASH_LOCAL_CONTEXT=1m, + # v1.45.2), whose pair is sized on its pool: the cockpit's check (fit_verdict) with a pool 10 % smaller + # than the 1,061,819 measured (2026-11-09), and the window holding the prompt at opencode's compaction + # point, one agent step and the answer. + [ "$(l flash-local)" = "205000 32000 local, 262K" ] || { echo "flash-local's default drifted"; exit 1; } + [ "$(l flash-local native)" = "205000 32000 local, 262K" ] || { echo "flash-local native drifted"; exit 1; } + [ "$(l flash-local 1m)" = "840000 32000 local, 1M" ] || { echo "flash-local 1m drifted"; exit 1; } + read -r C O _ <<<"$(l flash-local 1m)" + LOW=$(( 1061819 * 92 / 100 * 90 / 100 )) + [ $(( C + O )) -le "$LOW" ] || { echo "flash-local 1m: $C + $O passes $LOW, its pool less 10 %"; exit 1; } + [ $(( C - 20000 + 43863 + O )) -le 1048576 ] || { echo "flash-local 1m: past its 1,048,576 window"; exit 1; } + ! l flash-local nonsense 2>/dev/null || { echo "an unknown flash-local mode must be refused"; exit 1; } # Nonsense is refused rather than defaulted, or a typo silently serves # the wrong budget. ! l banana native 2>/dev/null || { echo "an unknown target must be refused"; exit 1; } @@ -562,6 +574,15 @@ jobs: [ "$(l flash --from "$tmp/l24.sh")" = "110000 32000 local" ] || { echo "derived tier (24) wrong"; exit 1; } [ "$(l stock --from "$tmp/u1m.service")" = "700000 200000 local, 1M" ] || { echo "derived 1m wrong"; exit 1; } [ "$(l stock --from "$tmp/unat.service")" = "173000 64000 local" ] || { echo "derived native wrong"; exit 1; } + printf ' --max-model-len 1048576 \\\n --host 127.0.0.1 \\\n' > "$tmp/fl1m.service" + printf ' --max-model-len 262144 \\\n --host 127.0.0.1 \\\n' > "$tmp/flnat.service" + [ "$(l flash-local --from "$tmp/fl1m.service")" = "840000 32000 local, 1M" ] || { echo "derived flash-local 1m wrong"; exit 1; } + [ "$(l flash-local --from "$tmp/flnat.service")" = "205000 32000 local, 262K" ] || { echo "derived flash-local native wrong"; exit 1; } + # and both writers read the FP4-Local pair from its unit, which says its window + grep -qF 'oc-limits.sh" flash-local --from "$FLASH_LOCAL_UNIT_PATH"' install.sh \ + || { echo "install.sh does not read the FP4-Local pair from its unit"; exit 1; } + grep -qF 'oc-limits.sh" flash-local --from "$FLASH_LOCAL_UNIT"' switch-model.sh \ + || { echo "switch-model.sh does not read the FP4-Local pair from its unit"; exit 1; } [ "$(l flash --from /nonexistent)" = "205000 32000 local" ] || { echo "a missing invocation must fall back to the default tier"; exit 1; } out="$(l flash --from /nonexistent 2>"$scratch/oclim.err")"; rc=$? [ "$rc" = "0" ] || { echo "a missing invocation must not fail the switch"; exit 1; } diff --git a/install.sh b/install.sh index 49c23e01..3b7ed489 100755 --- a/install.sh +++ b/install.sh @@ -2370,12 +2370,14 @@ if [ "$OC_NEMOTRON_SUPER" -eq 1 ]; then 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_CTX=""; OC_FLASH_LOCAL_OUT=""; OC_FLASH_LOCAL_NAME=""; OC_FLASH_LOCAL_WINDOW="" if [ "$OC_FLASH_LOCAL" -eq 1 ]; then - OC_FLASH_LOCAL_PAIR="$("$REPO_DIR/oc-limits.sh" flash-local)" \ + # 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 262144 || true)" + 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 @@ -2771,7 +2773,7 @@ if [ "$NEMOTRON_SUPER_BOOT" -eq 1 ] && [ "$OC_NEMOTRON_SUPER" -eq 1 ]; then 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=262144 + 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 diff --git a/oc-limits.sh b/oc-limits.sh index 64e7a320..ee1ad0a7 100755 --- a/oc-limits.sh +++ b/oc-limits.sh @@ -262,12 +262,29 @@ case "$CHOICE" in CTX=990000; OUT=32000; LABEL="local, 1M" ;; flash-local) - # The Qwen3.8 Flash-Next FP4-Local lane serves the flash lane's 262,144-token window, and vLLM refuses any - # request whose prompt + max_tokens passes it. Its KV cache holds 921,090 tokens at the card's - # memory share (measured 2026-10-19), the window 3.5 times over, so the window decides, by the - # flash lane's rule and numbers (the same model, the same window, the proxy's same ceiling): - # 205,000 - 20,000 + 43,863 + 32,000 = 260,863 <= 262,144 - CTX=205000; OUT=32000; LABEL="local, 262K" + # Its context mode (native | 1m, FLASH_LOCAL_CONTEXT of install-flash-local.sh), or, with --from, its unit's + # --max-model-len: the switch reads the unit it has just staged. + MODE="$SELECTOR" + if [ -z "$MODE" ]; then + MAX_LEN="$(flag '--max-model-len')" + if [ "${MAX_LEN:-0}" -gt 262144 ] 2>/dev/null; then MODE=1m; else MODE=native; fi + fi + case "$MODE" in + # The Qwen3.8 Flash-Next FP4-Local lane serves the flash lane's 262,144-token window, and vLLM refuses any + # request whose prompt + max_tokens passes it. Its KV cache holds 921,090 tokens at the card's + # memory share (measured 2026-10-19), the window 3.5 times over, so the window decides, by the + # flash lane's rule and numbers (the same model, the same window, the proxy's same ceiling): + # 205,000 - 20,000 + 43,863 + 32,000 = 260,863 <= 262,144 + native) CTX=205000; OUT=32000; LABEL="local, 262K" ;; + # At its 1M window (1,048,576 tokens by YaRN, v1.45.2) the pool decides: 1,061,819 tokens at the lane's share + # (measured 2026-11-09), the window 1.01 times over, and the proxy relays a prompt up to 92 % of it, no flash + # ceiling there. The pair keeps the lane's answer budget and fits the cockpit's check (fit_verdict) with a pool + # 10 % smaller than the one measured, the margin oc-fit-limits.py keeps for a boot that gets less: + # 840,000 + 32,000 = 872,000 <= 1,061,819 x 0.92 x 0.90 = 879,186 + # 840,000 - 20,000 + 43,863 + 32,000 = 895,863 <= 1,048,576 + 1m) CTX=840000; OUT=32000; LABEL="local, 1M" ;; + *) printf 'oc-limits: unknown context mode "%s"\n' "$MODE" >&2; exit 2 ;; + esac ;; ornith-122b) # The Ornith 1.5 122B lane serves a window of 1,048,576 tokens (the model's own 262,144 four diff --git a/switch-model.sh b/switch-model.sh index e3f8db82..fccde298 100755 --- a/switch-model.sh +++ b/switch-model.sh @@ -571,8 +571,10 @@ if [ "$CHOICE" = "flash-local" ]; then echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone" else FLL_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" - FLL_PAIR="$("$REPO_DIR/oc-limits.sh" flash-local)" || FLL_PAIR="" - FLL_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label flash-local 262144 || true)" + # the pair and the window of the unit just staged: 1,048,576 tokens with FLASH_LOCAL_CONTEXT=1m (v1.45.2) + FLL_WINDOW="$({ grep -oE -- '--max-model-len [0-9]+' "$FLASH_LOCAL_UNIT" 2>/dev/null || true; } | awk 'NR == 1 {print $2}')" + FLL_PAIR="$("$REPO_DIR/oc-limits.sh" flash-local --from "$FLASH_LOCAL_UNIT")" || FLL_PAIR="" + FLL_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label flash-local "${FLL_WINDOW:-262144}" || true)" FLL_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)" FLL_SRC="$(mktemp)" if [ -n "$FLL_PAIR" ] && python3 "$REPO_DIR/oc-flash-local.py" "http://127.0.0.1:${FLL_PORT:-30001}/v1" "$CONFIG_DIR/api-key" \ @@ -583,7 +585,7 @@ if [ "$CHOICE" = "flash-local" ]; then for OC_JSON in "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json"; do [ -f "$OC_JSON" ] || continue python3 "$REPO_DIR/oc-merge-limits.py" "$OC_JSON" --add-providers "$FLL_SRC" >/dev/null || true - python3 "$REPO_DIR/oc-point-default.py" "$OC_JSON" flash-local flash-local 262144 \ + python3 "$REPO_DIR/oc-point-default.py" "$OC_JSON" flash-local flash-local "${FLL_WINDOW:-262144}" \ || echo "NOTE: could not update $OC_JSON (hand-edited?); set its \"model\" field yourself" [ -n "$FLL_KEEP" ] && { python3 "$REPO_DIR/oc-merge-limits.py" "$OC_JSON" --compaction "$FLL_KEEP" \ || echo "NOTE: could not update the compaction block in $OC_JSON; check it by hand ($FLL_KEEP)"; }