mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 12:54:19 +01:00
Ornith AI's Ornith 1.5 122B (MIT), a mixture of experts of the Qwen3.5 family with vision, in its authors' NVFP4 build pinned at its revision of 2026-10-21, served by vLLM with b12x in the Flash FP4-Local lane's image: its MTP head drafting 2 tokens, 8 requests at a time, prefix caching with the Mamba states aligned, the checkpoint's chat template and sampling as published, served as ornith-1.5-122b. Its window is 1,048,576 tokens: YaRN at factor 4, written whole into text_config.rope_parameters, the one form this vLLM reads (the model card's rope_scaling changed no probability on the reference box), and a KV cache fixed at 17 GiB, 1,301,680 tokens. Installed on demand like the other lanes: install-ornith-122b.sh with its pins (--units-only, --prepare, --stage, --uninstall), the --no-ornith-122b and --with-ornith-122b flags, a switch-model.sh and prepare-lane.sh target, its sudoers lines, every other unit's Conflicts= and After=, the keepalive's hold, the uninstall's lists. The image is shared: each lane's uninstall leaves the io_uring filter and the image to the other while it is installed, and pin_untag says which tag still keeps it. The cockpit shows it in the b12x family, opencode and pi get a provider whose variants are its template's (enable_thinking on, or none), and the proxy (v6.45) turns a request's reasoning effort into enable_thinking for it: none and minimal off, the rest on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
286 lines
15 KiB
Bash
Executable File
286 lines
15 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The opencode limits a target deserves: one table, three callers.
|
|
#
|
|
# install.sh writes these limits at install time, switch-model.sh rewrites them
|
|
# at switch time, and CI asserts them. They are not decoration: opencode compacts
|
|
# a conversation when it reaches `limit.context`, and if that number is larger
|
|
# than what the lane can serve, the keepalive proxy refuses the request with a
|
|
# 400 BEFORE opencode ever decides to compact. The user then sees a hard failure
|
|
# in the middle of a session instead of a compaction. A switch from a 27B box in
|
|
# 1M mode (700,000 context) to the flash lane (200,000 one-prompt ceiling) is
|
|
# exactly that shape, and until 2026-09-08 the switch left the old numbers in
|
|
# place because only the installer knew this table.
|
|
#
|
|
# Duplicating it in each caller would have been the easy fix, and is how two
|
|
# numbers drift apart. So there is one table and it lives here.
|
|
#
|
|
# ./oc-limits.sh <choice> <tier-or-mode> # explicit: what install.sh knows
|
|
# ./oc-limits.sh <choice> --from <invocation> # derived: what a switch can read
|
|
# ./oc-limits.sh --max-out # the ceiling every caller shares
|
|
# ./oc-limits.sh --preserve <ctx> # tokens a compaction keeps verbatim
|
|
#
|
|
# `choice` is a target name. The second argument is the flash serving tier
|
|
# (context | concurrency | throughput) for a flash target, or the 27B context
|
|
# mode (native | 1m) for the others. With `--from`, the answer is derived from
|
|
# what the box actually serves instead: the tier from the launcher's
|
|
# --max-running-requests, the context mode from the unit's --context-length.
|
|
#
|
|
# Prints "CTX OUT LABEL". Every number is measured; the measurements are in
|
|
# BENCHMARKS.md and the reasoning is in the comments below.
|
|
set -uo pipefail
|
|
|
|
usage() {
|
|
printf 'usage: %s <choice> <tier-or-mode>\n %s <choice> --from <invocation-file>\n %s --max-out\n' \
|
|
"$0" "$0" "$0" >&2
|
|
exit 2
|
|
}
|
|
|
|
CHOICE="${1:-}"
|
|
[ -n "$CHOICE" ] || usage
|
|
|
|
# --max-out: the largest output any target can ask for.
|
|
#
|
|
# OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX is a CEILING, not a per-target number:
|
|
# opencode sends max_tokens = min(limit.output, that ceiling). limit.output is
|
|
# the number that follows a switch (rewritten from this table), so the ceiling
|
|
# only has to sit above every value the table can produce. Deriving it from the
|
|
# INSTALLED target instead is the bug this exists to prevent: a box installed on
|
|
# the flash lane wrote a 64,000 ceiling, the switch to a 27B box in 1M mode
|
|
# raised limit.output to 200,000, the ceiling stayed, and a long turn was cut at
|
|
# 64,000 with no error and no text, which is the exact failure the 32,000
|
|
# default produces. Computed by asking this table for every pair, so it cannot
|
|
# drift from it.
|
|
if [ "$CHOICE" = "--max-out" ]; then
|
|
MAXOUT=0
|
|
for _c in flash flash-nvda flash-uncensored; do
|
|
for _t in context concurrency throughput; do
|
|
_o="$("$0" "$_c" "$_t" | awk '{print $2}')"
|
|
[ -n "$_o" ] || { printf 'oc-limits: --max-out could not read %s %s\n' "$_c" "$_t" >&2; exit 2; }
|
|
[ "$_o" -gt "$MAXOUT" ] && MAXOUT="$_o"
|
|
done
|
|
done
|
|
for _c in stock uncensored fp8 uncensored-fp8; do
|
|
for _t in native 1m; do
|
|
_o="$("$0" "$_c" "$_t" | awk '{print $2}')"
|
|
[ -n "$_o" ] || { printf 'oc-limits: --max-out could not read %s %s\n' "$_c" "$_t" >&2; exit 2; }
|
|
[ "$_o" -gt "$MAXOUT" ] && MAXOUT="$_o"
|
|
done
|
|
done
|
|
[ "$MAXOUT" -gt 0 ] || { printf 'oc-limits: --max-out found no limits\n' >&2; exit 2; }
|
|
printf '%s\n' "$MAXOUT"
|
|
exit 0
|
|
fi
|
|
# --preserve: how much of the recent conversation survives a compaction verbatim.
|
|
#
|
|
# opencode's default is min(15,000, max(2,000, threshold/4)), and that 15,000 cap
|
|
# is the problem on a big window: it was chosen for models with a 128K context,
|
|
# and on this lane it means a compaction at 205,000 tokens keeps 15,000 and
|
|
# summarises the other 190,000. The window is then not being used, it is being
|
|
# refilled from scratch every time.
|
|
#
|
|
# So the installed value is opencode's own intent without the cap: a quarter of
|
|
# the compaction threshold, which is limit.context minus the 20,000 opencode
|
|
# reserves. Rounded to 1,000. Sized from the INSTALLED target because the key is
|
|
# global in opencode.json while the threshold is per-target: install.sh and
|
|
# switch-model.sh rewrite it with the limits, so it always tracks the lane that
|
|
# serves (and oc-fit-limits.py with them, when it fits the context to the pool). A
|
|
# value at or above the threshold would make select() keep everything and summarise
|
|
# the lot, which a quarter never is: the cap at a third this carried could not apply,
|
|
# and is gone (found in review, 2026-09-24).
|
|
if [ "$CHOICE" = "--preserve" ]; then
|
|
CTX_IN="${2:-}"
|
|
case "$CTX_IN" in ''|*[!0-9]*) printf 'oc-limits: --preserve needs a context size\n' >&2; exit 2 ;; esac
|
|
THRESH=$(( CTX_IN - 20000 ))
|
|
[ "$THRESH" -gt 0 ] || { printf '0\n'; exit 0; }
|
|
printf '%s\n' "$(( THRESH / 4 / 1000 * 1000 ))"
|
|
exit 0
|
|
fi
|
|
SECOND="${2:-}"
|
|
INVOCATION=""
|
|
SELECTOR=""
|
|
|
|
case "$SECOND" in
|
|
--from)
|
|
INVOCATION="${3:-}"
|
|
[ -n "$INVOCATION" ] || usage
|
|
# A missing file keeps the old contract (defaults, rc 0: switch-model.sh
|
|
# treats "no limits" as leave-everything, mid-switch is no place to die),
|
|
# but it says so loudly instead of silently serving another lane's numbers.
|
|
[ -f "$INVOCATION" ] || echo "oc-limits.sh: --from $INVOCATION is not a file; using defaults" >&2
|
|
;;
|
|
"") ;; # nothing given: fall back to the defaults below
|
|
*) SELECTOR="$SECOND" ;;
|
|
esac
|
|
|
|
flag() { # $1 flag name -> its value in the invocation, or empty
|
|
[ -n "$INVOCATION" ] && [ -f "$INVOCATION" ] || return 0
|
|
grep -oE -- "$1 [0-9]+" "$INVOCATION" 2>/dev/null | awk '{print $2}' | head -1
|
|
}
|
|
|
|
case "$CHOICE" in
|
|
flash|flash-nvda|flash-uncensored)
|
|
TIER="$SELECTOR"
|
|
if [ -z "$TIER" ]; then
|
|
# Derived, or defaulted: the tier is what the launcher pins as concurrency.
|
|
case "$(flag '--max-running-requests')" in
|
|
24) TIER=throughput ;;
|
|
8) TIER=concurrency ;;
|
|
*) TIER=context ;;
|
|
esac
|
|
fi
|
|
# The budget is min(the proxy's one-prompt ceiling, what the tier's KV pool
|
|
# holds alongside the answer).
|
|
#
|
|
# Where the context-tier number comes from, since it is not the ceiling:
|
|
# opencode does NOT estimate its context. It compacts when the LAST response's
|
|
# reported usage reaches limit.input minus min(20,000, its output cap), so the
|
|
# threshold is simply CTX - 20,000 (opencode 1.18.27, SessionCompaction). The
|
|
# numbers it compares are the engine's own prompt_tokens, exact.
|
|
#
|
|
# What can still overrun the ceiling is the step AFTER that check: opencode
|
|
# decides between turns, then a single turn appends its tool results and sends.
|
|
# So the rule is threshold + one worst step <= the proxy's ceiling. Measured
|
|
# here over 2,156 flash-lane steps (opencode's own session store, 2026-09): the
|
|
# largest single-step prompt growth is 43,863 tokens, p99 18,512.
|
|
#
|
|
# 225,000 - 20,000 + 43,863 = 248,863 <= 250,000 ceiling
|
|
#
|
|
# The ceiling is 250,000 because the box was measured there rather than assumed
|
|
# (2026-09-13, this engine, MemAvailable sampled through each prefill):
|
|
#
|
|
# 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 old 128,000 and 200,000 ceilings came from a v1.5 engine whose PLE mapping
|
|
# faulted in whole page-cache folios (~0.27 GiB per 1k tokens past 90k, and 3.5
|
|
# GiB at 200k). v1.8 serves an engine that does not: a full-depth prefill now
|
|
# costs about 1.5 GiB and leaves 7 GiB, so the memory argument for stopping at
|
|
# 200,000 no longer holds and the window the model actually has is usable.
|
|
# What does still hold is the engine's own wall, max_req_input_len = 262,138:
|
|
# 250,000 leaves 12,138 tokens of slack under it, which is the band that keeps
|
|
# a mis-count on the proxy's side from reaching a truncation on the engine's.
|
|
#
|
|
# The 175,000 this replaces, and the 190,000 before it, were both set by reading
|
|
# proxy refusals as opencode "drifting" from the engine's count. It does not
|
|
# drift: the proxy was charging every image a flat 4,096 tokens where the engine
|
|
# charges 880 to 1,562 for an agent screenshot, so a session holding 24 of them
|
|
# was refused ~61,000 tokens early. Fixed in the proxy (v6.15).
|
|
#
|
|
# And the answer has to fit beside that prompt: the engine refuses any request whose
|
|
# input + max_tokens passes its 262,144 window (validate_total_tokens, on in the
|
|
# flash image; checked 2026-09-24), and opencode asks for max_tokens = OUT. So the
|
|
# same threshold + worst step, with the answer on top, must fit the window:
|
|
#
|
|
# 205,000 - 20,000 + 43,863 + 32,000 = 260,863 <= 262,144
|
|
#
|
|
# 225,000 met the ceiling and not this: a prompt past 230,144 was refused by the
|
|
# engine, in the band one large step reaches after the threshold (found in review,
|
|
# 2026-09-24). oc-fit-limits.py applies the same rule after each boot.
|
|
case "$TIER" in
|
|
context) CTX=205000; OUT=32000 ;; # threshold + one worst step + the answer fits the 262,144 window, and stays under the 250,000 ceiling (see above)
|
|
concurrency) CTX=205000; OUT=32000 ;; # the context tier's pair since v1.20.3: one
|
|
# request fits as it does there (the same threshold, worst step and answer under the
|
|
# same ceiling and window), and eight at once share the pool. When they outgrow it,
|
|
# the engine queues the newcomers and retracts as it must, which costs time and fails
|
|
# nothing. 100,000/16,000 until then kept eight at once inside the pool, and cut every
|
|
# agent's session at 84,000 tokens: measured live on 2026-10-01, eight opencode
|
|
# subagents held 60 to 68 % of the 474,816-token pool at that window, and a
|
|
# documentation agent compacted at 88,520. The operator's call: a queue rather than a
|
|
# 100K window.
|
|
throughput) CTX=110000; OUT=32000 ;; # a big pool, but 24 requests share it
|
|
*) printf 'oc-limits: unknown flash tier "%s"\n' "$TIER" >&2; exit 2 ;;
|
|
esac
|
|
LABEL="local"
|
|
;;
|
|
stock|uncensored|fp8|uncensored-fp8|custom)
|
|
# custom: a --model-path this table does not know, kept from the installed 27B unit
|
|
# (install.sh). It had no row, so every update of such a box died at step 7 (found in
|
|
# review, 2026-09-24). Its weights are of no known format, so in 1m it gets the pair of
|
|
# the smaller pool; the fit at the end of the install then sets the pair its engine's
|
|
# real pool allows.
|
|
MODE="$SELECTOR"
|
|
if [ -z "$MODE" ]; then
|
|
CTX_LEN="$(flag '--context-length')"
|
|
if [ "${CTX_LEN:-0}" -gt 262144 ] 2>/dev/null; then MODE=1m; else MODE=native; fi
|
|
fi
|
|
case "$MODE" in
|
|
1m)
|
|
case "$CHOICE" in
|
|
fp8|uncensored-fp8|custom)
|
|
# FP8 weights cost KV pool (measured on the retired image at
|
|
# fraction 0.70, same 1M unit: 863,398 on NVFP4, 771,139 on FP8),
|
|
# and the NVFP4 numbers do not transfer: 680,000 of compaction plus
|
|
# 200,000 of output is an 880,000 worst case.
|
|
# Re-measured 2026-09-18 on the official v0.5.19 image at 0.76:
|
|
# 881,895 on FP8 against 887,797 on NVFP4, so the gap all but closed
|
|
# and this pair is now conservative rather than tight. Kept as is:
|
|
# these are the static numbers, oc-fit-limits.py rewrites them from
|
|
# the pool the boot actually got, and the CI gate that asserts them
|
|
# against 771,139 stays the stricter of the two bounds on purpose.
|
|
CTX=480000; OUT=160000 ;;
|
|
*)
|
|
CTX=700000; OUT=200000 ;;
|
|
esac
|
|
LABEL="local, 1M"
|
|
;;
|
|
# 262,144 window: threshold + one worst step + the answer must fit it, the rule the
|
|
# flash context tier explains above (173,000 - 20,000 + 43,863 + 64,000 = 260,863).
|
|
# 194,048 fitted 64,000 beside a prompt of exactly 194,048, not beside the one a
|
|
# large step brings past compaction (found in review, 2026-09-24).
|
|
native) CTX=173000; OUT=64000; LABEL="local" ;;
|
|
*) printf 'oc-limits: unknown context mode "%s"\n' "$MODE" >&2; exit 2 ;;
|
|
esac
|
|
;;
|
|
kolibri|kolibri-nvfp4)
|
|
# The Kolibri lane serves Aleph Alpha's 262,144-token window, and vLLM refuses any
|
|
# request whose prompt + max_tokens passes it. Its KV cache holds about 2.1 million
|
|
# tokens (8 requests at the full window, either checkpoint), so the pool binds nothing
|
|
# and the window decides, by the rule the flash context tier explains above:
|
|
# 205,000 - 20,000 + 43,863 + 32,000 = 260,863 <= 262,144
|
|
# It was the native 27B pair, 173,000 + 64,000, for reasoning room at the high effort its
|
|
# template defaults to: opencode compacted at 153,000 tokens, and the 64,000 kept for each
|
|
# answer went unused. Measured in an opencode session on the reference box (2026-10-14,
|
|
# 26 replies at that effort, reasoning included): median 386 tokens, longest 1,742.
|
|
# 32,000 is that longest eighteen times over, the flash lane's answer, and compaction
|
|
# comes at 185,000.
|
|
CTX=205000; OUT=32000; LABEL="local, 262K"
|
|
;;
|
|
nemotron)
|
|
# The Nemotron lane serves Bolt's 262,144-token window, and vLLM refuses any request whose
|
|
# prompt + max_tokens passes it. Its KV cache holds 6.5 million tokens (24 requests at the full
|
|
# window, measured 2026-10-16), so the pool binds nothing and the window decides, by the same
|
|
# rule and the same numbers as the Kolibri lane's:
|
|
# 205,000 - 20,000 + 43,863 + 32,000 = 260,863 <= 262,144
|
|
CTX=205000; OUT=32000; LABEL="local, 262K"
|
|
;;
|
|
nemotron-super)
|
|
# The Nemotron Super lane serves Super VL's window of 1,048,576 tokens, and vLLM refuses any
|
|
# request whose prompt + max_tokens passes it. Its KV cache holds the window 1.2 times over
|
|
# (measured 2026-10-16), so the window decides here too, by the same rule:
|
|
# 990,000 - 20,000 + 43,863 + 32,000 = 1,045,863 <= 1,048,576
|
|
CTX=990000; OUT=32000; LABEL="local, 1M"
|
|
;;
|
|
flash-local)
|
|
# The Flash 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"
|
|
;;
|
|
ornith-122b)
|
|
# The Ornith 1.5 122B lane serves a window of 1,048,576 tokens (the model's own 262,144 four
|
|
# times over, with YaRN), and vLLM refuses any request whose prompt + max_tokens passes it. Its KV
|
|
# cache is fixed at 17 GiB, 1,301,680 tokens (measured 2026-10-21), the window 1.24 times over, so
|
|
# the window decides, by the Nemotron Super lane's rule and numbers (Ornith's tokenizer counts text
|
|
# as Qwen's does: the same vocabulary, merges and pre-tokenizer, seven audio tokens fewer; checked
|
|
# 2026-10-21):
|
|
# 990,000 - 20,000 + 43,863 + 32,000 = 1,045,863 <= 1,048,576
|
|
CTX=990000; OUT=32000; LABEL="local, 1M"
|
|
;;
|
|
*) printf 'oc-limits: unknown target "%s"\n' "$CHOICE" >&2; exit 2 ;;
|
|
esac
|
|
|
|
printf '%s %s %s\n' "$CTX" "$OUT" "$LABEL"
|