mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
The Load's prepare fetched the new revision with `switch-model.sh <target> --fetch`, which stops right after the download, so on the serving lane's short path (prepare, apply_pending, restart, no switch) the new checkpoint's config.json was never YaRN-patched for a 1M unit (which does not load on an unpatched config), never restored for a native one, Arete's fp8 KV cache was never declared, and the chat template was never regenerated from the new revision (sixth review of v1.52.0, 2026-11-19, GLM 5.3, defect 1, verified in the code and on the box: the 27B serves the 1M window). The switch's steps 2, 2a and 2b are now one function, lanes.sh's `patch_served_checkpoint`, which the switch calls with the unit in place and prepare-lane.sh, when an update waits for this Load and this Load loads its target, with the unit that waits and the cache it mounts: the 27B and the flash serve their new revision with those steps done, on the short path as on the other. The patches are idempotent, so a journey that runs both changes nothing twice. tests/test_prepare_load_wait.py runs the prepare on a fabricated cache and fails on the code before (config unpatched, no template); test_switch_native_restore and test_arete_target read the function where it now lives. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
3.4 KiB
Python
73 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""A switch on a native 27B box restores a target's config that still carries YaRN.
|
|
|
|
A native server crashes at load on a YaRN-patched config.json (measured 2026-09-11). A
|
|
27B target served while the box was in 1m mode keeps that patch in the shared cache when
|
|
the box goes back to native, since install.sh restores the target it installs and not the
|
|
others. switch-model.sh skipped the patch in native mode and restored nothing, so a switch
|
|
to such a target queued an engine that could not start (found in review, 2026-09-24).
|
|
The switch's steps after the fetch now live in lanes.sh's patch_served_checkpoint, called by
|
|
the switch with the unit in place and by prepare-lane.sh with the unit that waits; the
|
|
function runs here with patch-yarn.py and patch-template.py replaced by stubs that record
|
|
calls.
|
|
"""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
LANES = (REPO / "lanes.sh").read_text()
|
|
FN = LANES[LANES.index("patch_served_checkpoint(){"):LANES.index("\n}\n", LANES.index("patch_served_checkpoint(){")) + 3]
|
|
|
|
|
|
def run(lane, choice, context_length, restore_rc=0):
|
|
d = pathlib.Path(tempfile.mkdtemp(prefix="sw-restore-"))
|
|
(d / "unit").write_text(f"ExecStart=... --context-length {context_length} ...\n")
|
|
(d / "patch-yarn.py").write_text(
|
|
"import sys\nopen(sys.argv[0] + '.log', 'a').write(' '.join(sys.argv[1:]) + '\\n')\n"
|
|
f"sys.exit({restore_rc} if '--restore' in sys.argv else 0)\n")
|
|
(d / "patch-template.py").write_text(
|
|
"import sys\nopen(sys.argv[0] + '.log', 'a').write(' '.join(sys.argv[1:]) + '\\n')\n")
|
|
script = ('set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n'
|
|
f'_lanes_dir(){{ echo "{d}"; }}\nCONFIG_DIR="{d}"\n' + FN +
|
|
f'patch_served_checkpoint {lane} {choice} "{d}/unit" /hf org/uncensored abc\necho REACHED\n')
|
|
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
|
|
log = d / "patch-yarn.py.log"
|
|
tlog = d / "patch-template.py.log"
|
|
return (r.stdout + r.stderr,
|
|
log.read_text() if log.exists() else "",
|
|
tlog.read_text() if tlog.exists() else "")
|
|
|
|
|
|
class ANativeSwitchRestores(unittest.TestCase):
|
|
def test_the_target_is_restored_on_a_native_unit(self):
|
|
out, calls, _ = run("27b", "stock", 262144)
|
|
self.assertIn("--restore /hf org/uncensored abc", calls, out)
|
|
self.assertIn("REACHED", out)
|
|
|
|
def test_a_restore_that_fails_stops_the_switch_before_the_unit(self):
|
|
out, _, _ = run("27b", "stock", 262144, restore_rc=1)
|
|
self.assertIn("DIE:", out)
|
|
self.assertNotIn("REACHED", out)
|
|
|
|
def test_a_1m_unit_still_gets_the_patch(self):
|
|
out, calls, _ = run("27b", "stock", 1010000)
|
|
self.assertIn("/hf org/uncensored abc", calls)
|
|
self.assertNotIn("--restore", calls)
|
|
|
|
def test_the_template_is_regenerated_from_the_targets_snapshot(self):
|
|
out, _, tpl = run("27b", "stock", 1010000)
|
|
self.assertIn("/hf", tpl, out)
|
|
self.assertIn("abc org/uncensored", tpl)
|
|
self.assertIn("chat-template-sglang.jinja", tpl)
|
|
|
|
def test_the_flash_lane_gets_no_yarn_call_and_its_own_template(self):
|
|
out, calls, tpl = run("flash", "flash", 262144)
|
|
self.assertEqual(calls, "", out)
|
|
self.assertIn("chat-template-flashnext.jinja", tpl, out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|