mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
install.sh: a 64 GB box's opencode pair is written once, and its 1M limits go
710550c fits opencode's limits to the pool at the end of a run on a
64 GB DGX Spark, as on 1m, but step 7 still wrote the native table's
pair over the fitted one: the compaction preserved from the fit, the
generator's fitted() and the merge's --keep-lower were 1m's only. Each
update then wrote both files twice, with two backups and two restarts
of opencode-web, the Agent tab's turn cut by the first, which is what
--keep-lower put right for 1m on 2026-09-25 (found in review,
2026-10-23). On a 64 GB box the table's pair is a bound there too.
And on a box of that class whose unit served the 1m window, the
convergence takes it back to the native one with no CONTEXT_MODE
given, so the guard that never shrinks a 1m user's limits kept the 1M
pair, 700,000 of a 262,144 window, and advised the CONTEXT_MODE=1m
this box refuses. The guard is not for a 64 GB box.
The generator, the compaction and step 7's merge run from install.sh's
own lines with a merge that writes down what it is asked: the three
64 GB cases fail on the old code, and a 128 GB box is as before. The
native-limits test gives its lines the MEM_CLASS install.sh sets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f6ef5e356
commit
e65a36409e
3 files changed
+73
-13
No files matched your search
+15
-8
@@ -2386,8 +2386,10 @@ OC_KEEP="$("$REPO_DIR/oc-limits.sh" --preserve "$OC_CTX")" \
|
||||
# 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).
|
||||
if [ "$CONTEXT_MODE" = "1m" ] && [ "$LANE" != "flash" ]; then
|
||||
# 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:
|
||||
@@ -2483,7 +2485,7 @@ 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_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" \
|
||||
@@ -2549,7 +2551,8 @@ if os.environ["OC_27B"] == "1":
|
||||
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"
|
||||
if os.environ["OC_CONTEXT_MODE"] == "1m":
|
||||
# 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")
|
||||
@@ -2707,15 +2710,19 @@ if [ -f "$OC_USER_CFG" ]; then
|
||||
# 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" ]; then
|
||||
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 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" ] && OC_KEEP_LOWER=(--keep-lower)
|
||||
# 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
|
||||
|
||||
@@ -28,7 +28,7 @@ def run(env_mode):
|
||||
"import sys\nopen(sys.argv[0] + '.log', 'a').write(' '.join(sys.argv[1:]) + '\\n')\n")
|
||||
script = ("set -euo pipefail\n"
|
||||
f'REPO_DIR="{d}"; SGL_UNIT_PATH="{d}/unit"; OC_USER_CFG="{d}/opencode.json"\n'
|
||||
f"CONTEXT_MODE=native; _ENV_CONTEXT_MODE={env_mode}; OC_CTX=173000; OC_OUT=64000; OC_KEEP=38000\n"
|
||||
f"CONTEXT_MODE=native; _ENV_CONTEXT_MODE={env_mode}; MEM_CLASS=128; OC_CTX=173000; OC_OUT=64000; OC_KEEP=38000\n"
|
||||
+ BLOCK)
|
||||
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
|
||||
log = d / "oc-merge-limits.py.log"
|
||||
|
||||
@@ -215,13 +215,13 @@ class TheGeneratedConfigKeepsItsFit(unittest.TestCase):
|
||||
|
||||
BODY = None
|
||||
|
||||
def run_generator(self, d, mode):
|
||||
def run_generator(self, d, mode, cls="128"):
|
||||
start = INSTALL.index("OC_CONFIG_DIR=\"$CONFIG_DIR\" python3 - <<'PYEOF'")
|
||||
body = INSTALL[INSTALL.index("\n", start) + 1:INSTALL.index("\nPYEOF\n", start)]
|
||||
ctx, out = ("700000", "200000") if mode == "1m" else ("173000", "64000")
|
||||
env = dict(os.environ, OC_LANE="27b", OC_27B="1", OC_FLASH="0", OC_PORT="30001", OC_CTX=ctx,
|
||||
OC_OUT=out, OC_LABEL="local, 1M", OC_CONTEXT_MODE=mode, OC_27B_CTX=ctx, OC_27B_OUT=out,
|
||||
OC_KEEP="38000", OC_PIN="1", OC_CONFIG_DIR=str(d))
|
||||
OC_KEEP="38000", OC_PIN="1", OC_CONFIG_DIR=str(d), OC_MEM_CLASS=cls)
|
||||
r = subprocess.run(["python3", "-c", body], capture_output=True, text=True, env=env, timeout=30)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
f = d / "opencode.json"
|
||||
@@ -248,12 +248,12 @@ class TheGeneratedConfigKeepsItsFit(unittest.TestCase):
|
||||
self.assertEqual(text, before)
|
||||
self.assertEqual(mtime, 1000, "an identical config was written again, and its date moved")
|
||||
|
||||
def keep_after(self, d, mode="1m", lane="27b"):
|
||||
def keep_after(self, d, mode="1m", lane="27b", cls="128"):
|
||||
"""OC_KEEP as install.sh resolves it for the config in d."""
|
||||
start = INSTALL.index("# On 1m the table gives bounds and the fit to the pool sets the pair")
|
||||
block = INSTALL[start:INSTALL.index("\nfi\n", INSTALL.index(" if [ -n \"$OC_FIT_CTX\" ]; then", start)) + 4]
|
||||
script = (f'set -euo pipefail\ndie(){{ echo "DIE $*"; exit 1; }}\nREPO_DIR="{REPO}"\nCONFIG_DIR="{d}"\n'
|
||||
f'CONTEXT_MODE={mode}\nLANE={lane}\nOC_CTX=700000\nOC_OUT=200000\nOC_KEEP=170000\n'
|
||||
f'CONTEXT_MODE={mode}\nLANE={lane}\nMEM_CLASS={cls}\nOC_CTX=700000\nOC_OUT=200000\nOC_KEEP=170000\n'
|
||||
+ block + 'echo "KEEP=$OC_KEEP"\n')
|
||||
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
||||
@@ -277,6 +277,59 @@ class TheGeneratedConfigKeepsItsFit(unittest.TestCase):
|
||||
pair, _, _ = self.run_generator(self.fitted_dir(559000, 186000), "native")
|
||||
self.assertEqual(pair, (173000, 64000))
|
||||
|
||||
def test_a_64_gb_box_keeps_its_fit_under_the_native_bounds(self):
|
||||
# its native pair is a bound, fitted to the pool at the end as 1m's is: writing the bound over
|
||||
# the fit made every update write twice, with two backups and two opencode-web restarts
|
||||
# (found in review, 2026-10-23)
|
||||
pair, _, _ = self.run_generator(self.fitted_dir(140000, 32000), "native", cls="64")
|
||||
self.assertEqual(pair, (140000, 32000))
|
||||
want = int(subprocess.run([str(REPO / "oc-limits.sh"), "--preserve", "140000"],
|
||||
capture_output=True, text=True).stdout)
|
||||
self.assertEqual(self.keep_after(self.fitted_dir(140000, 32000), mode="native", cls="64"), want)
|
||||
# a 128 GB box's native install still writes the table, and keeps its compaction
|
||||
self.assertEqual(self.keep_after(self.fitted_dir(140000, 32000), mode="native"), 170000)
|
||||
|
||||
|
||||
class Step7OnA64GBBox(unittest.TestCase):
|
||||
"""Step 7's merge of the 27B's limits, run from install.sh's own lines with a merge that
|
||||
writes down what it is asked (found in review, 2026-10-23)."""
|
||||
|
||||
def run_step(self, cls, unit_ctx=1010000):
|
||||
d = pathlib.Path(tempfile.mkdtemp(prefix="step7-64-"))
|
||||
(d / "oc-merge-limits.py").write_text(f'import sys\nopen("{d}/calls", "a").write(" ".join(sys.argv[1:]) + "\\n")\n')
|
||||
(d / "unit").write_text(f"ExecStart=... --context-length {unit_ctx} ...\n")
|
||||
start = INSTALL.index(' UNIT_CTX="$(grep -oE -- \'--context-length [0-9]+\'')
|
||||
block = INSTALL[start:INSTALL.index(" # Offered whatever the limits branch decided above", start)]
|
||||
script = (f'set -euo pipefail\nREPO_DIR="{d}"\nSGL_UNIT_PATH="{d}/unit"\nCONTEXT_MODE=native\n_ENV_CONTEXT_MODE=\n'
|
||||
f'MEM_CLASS={cls}\nOC_USER_CFG="{d}/opencode.json"\nOC_CTX=173000\nOC_OUT=64000\nOC_KEEP=38000\n'
|
||||
"if true; then\n" + block + "fi\n")
|
||||
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
||||
calls = (d / "calls").read_text().splitlines() if (d / "calls").exists() else []
|
||||
return r.stdout, calls
|
||||
|
||||
def test_a_64_gb_box_with_a_1m_unit_has_its_limits_managed(self):
|
||||
# the convergence takes it back to the native window: keeping the 1M limits asked 700,000 of
|
||||
# a 262,144 window, under advice to pass the CONTEXT_MODE=1m it refuses
|
||||
out, calls = self.run_step("64")
|
||||
self.assertNotIn("keeping the existing", out)
|
||||
self.assertIn(f"{self.cfg_of(calls)} qwen38 qwen3.8-27b 173000 64000 --keep-lower", calls)
|
||||
|
||||
def test_its_merge_keeps_a_fitted_pair_under_the_bound(self):
|
||||
out, calls = self.run_step("64", unit_ctx=262144)
|
||||
self.assertIn(f"{self.cfg_of(calls)} qwen38 qwen3.8-27b 173000 64000 --keep-lower", calls)
|
||||
|
||||
def test_a_128_gb_box_is_as_before(self):
|
||||
out, calls = self.run_step("128")
|
||||
self.assertIn("keeping the existing", out)
|
||||
self.assertEqual(calls, [])
|
||||
out, calls = self.run_step("128", unit_ctx=262144)
|
||||
self.assertIn(f"{self.cfg_of(calls)} qwen38 qwen3.8-27b 173000 64000", calls)
|
||||
|
||||
@staticmethod
|
||||
def cfg_of(calls):
|
||||
return calls[0].split()[0] if calls else "?"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
Reference in new issue
Block a user