mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 21:04:21 +01:00
Both lanes now run an image this repo did not build. The 27B lane held out since v1.2 for two reasons, checked on the box instead of restated. The overlay carried nothing upstream lacks: diffed file by file against v0.5.19, not one of its functions is missing there, and upstream carries about ten this box never had. The one that looked unique is upstream under another name, better placed and ROCm-only anyway. The mrope fix (sglang#34446, merged 2026-08-30) is in the release, checked inside the image. And the sm_121 objection never departed the two: v0.5.19 ships sgl_kernel for sm90 and sm100 only, and so does the image this lane served before it, byte for byte. Measured, same flags, same probes: 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 exact at 300,108 prompt tokens on both. The release is behind on one number, 514 s against 493 s on that long prefill. The memory fraction moves to 0.76 because the official image claims a smaller static budget: at an identical 0.70 it sized a 770,118-token pool against 906,524 while leaving 10 GB unused. 0.76 hands the pool back (902,398) with a wider margin than the old pin had. dflash2/ is deleted with its build step, its OVERLAY_27B switch and its CI gate. The rollback is the previous image itself, still on the box: SERVE_IMAGE=qwen38-dflash2:v1.2.3 ./install.sh Gates updated with the change, not around it: the 1m template fraction, the anti-drift pair, both pin contracts, the uninstall inventory and the cockpit recipe tests. Local CI: 51 ok, 0 failures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
187 lines
9.0 KiB
Python
187 lines
9.0 KiB
Python
#!/usr/bin/env python3
|
|
"""A plain 27B install serves the 1M window, and nothing is refused for it.
|
|
|
|
Until v1.12.1 the default was `native` and 1M was opt-in behind an env var, so
|
|
the window this stack is built around was off for anyone who did not read the
|
|
README section about it. Flipping a default is easy; flipping it without
|
|
breaking the paths that cannot serve it is the work, and that is what these
|
|
tests hold:
|
|
|
|
the flash lane and --no-service cannot serve 1m, so an unset CONTEXT_MODE
|
|
falls back to native there IN SILENCE, while an explicit CONTEXT_MODE=1m
|
|
still refuses by name on both. A default that refuses something the operator
|
|
never typed is a bug, and the old refusals sat above the flag parsing where
|
|
a naive default would have hit them.
|
|
|
|
an installed unit still wins over the default, in BOTH directions. Before
|
|
this change only the 1m direction was converged (nothing could downgrade a
|
|
1m box), so with 1m as the default a plain re-run on a native box would have
|
|
patched YaRN into its cached configs and moved its memory fraction. That is
|
|
not what an update means.
|
|
|
|
Every run stops at a later refusal on purpose, past the whole context-mode
|
|
resolution and long before the preflight downloads anything.
|
|
"""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
INSTALL = str(REPO / "install.sh")
|
|
SGL_UNIT = pathlib.Path("/etc/systemd/system/qwen38-sglang.service")
|
|
|
|
|
|
def fresh_box_install():
|
|
"""A copy of install.sh whose unit paths point at an empty directory.
|
|
|
|
The fresh-box default is invisible on any machine that already has a unit,
|
|
because convergence correctly wins there, and that is every developer box
|
|
and the reference box itself. Rather than skip the assertion where it
|
|
matters most, the two path assignments are rewritten to a temp dir, so the
|
|
convergence block finds nothing and the default is what answers. The
|
|
rewrite is checked: if either assignment is renamed upstream, this fails
|
|
loudly instead of quietly testing the real /etc again.
|
|
"""
|
|
empty = tempfile.mkdtemp(prefix="no-units-")
|
|
text = pathlib.Path(INSTALL).read_text()
|
|
out = text
|
|
for var, unit in (("SGL_UNIT_PATH", "qwen38-sglang.service"),
|
|
("FLASH_UNIT_PATH", "qwen38-flash.service")):
|
|
old = '%s="/etc/systemd/system/%s"' % (var, unit)
|
|
if old not in out:
|
|
raise AssertionError("install.sh no longer assigns %s the way this test rewrites it" % var)
|
|
out = out.replace(old, '%s="%s/%s"' % (var, empty, unit))
|
|
copy = pathlib.Path(empty) / "install.sh"
|
|
copy.write_text(out)
|
|
copy.chmod(0o755)
|
|
return str(copy)
|
|
# Contradictory cockpit flags: the first refusal BELOW the context-mode
|
|
# resolution, so the resolution has run and said what it decided.
|
|
STOP = ["--no-cockpit", "--with-cockpit"]
|
|
# MODEL_CHOICE is pinned on every 27B case. Without it the lane comes from
|
|
# whatever unit this box has enabled, so the same test read "1m" on a 27B box
|
|
# and "silently native" on a flash one: it failed the first time the reference
|
|
# box was mid-switch, which is the test depending on the machine rather than on
|
|
# the code.
|
|
STOCK = {"MODEL_CHOICE": "stock"}
|
|
|
|
|
|
def run(args=(), script=None, **env_extra):
|
|
env = {"PATH": "/usr/local/bin:/usr/bin:/bin",
|
|
"HOME": tempfile.mkdtemp(prefix="ctxmode-home-")}
|
|
env.update(env_extra)
|
|
r = subprocess.run([script or INSTALL, *args], capture_output=True, text=True,
|
|
env=env, cwd=str(REPO), timeout=60)
|
|
return r.returncode, r.stdout + r.stderr
|
|
|
|
|
|
DEFAULT_LINE = "Context mode: 1m (1,010,000 tokens)."
|
|
KEPT_NATIVE = "Keeping the installed context mode: native."
|
|
KEPT_1M = "Keeping the installed context mode: 1m."
|
|
|
|
|
|
class TheDefault(unittest.TestCase):
|
|
def test_the_mode_is_always_decided_out_loud(self):
|
|
# Exactly one of the three lines fires on a 27B install: the default,
|
|
# or one of the two convergences. Silence would mean a mode nobody
|
|
# chose and nobody was told about.
|
|
_, out = run(STOP, **STOCK)
|
|
said = [s for s in (DEFAULT_LINE, KEPT_NATIVE, KEPT_1M) if s in out]
|
|
self.assertEqual(len(said), 1, "expected exactly one, got %r" % said)
|
|
|
|
def test_a_fresh_27b_install_defaults_to_1m(self):
|
|
_, out = run(STOP, script=fresh_box_install(), **STOCK)
|
|
self.assertIn(DEFAULT_LINE, out)
|
|
self.assertNotIn(KEPT_NATIVE, out)
|
|
|
|
def test_an_installed_native_unit_beats_the_default(self):
|
|
# The direction that did not exist before v1.12.1. Same run, with the
|
|
# unit paths left alone, on a box that has one.
|
|
# The convergence follows the ENABLED lane, not merely a unit file on
|
|
# disk: a box holding both units but serving flash has no installed 27B
|
|
# choice to keep. Skipping on that is the test agreeing with the code
|
|
# rather than asserting a promise the code does not make.
|
|
if not SGL_UNIT.exists():
|
|
self.skipTest("no 27B unit installed here to converge on")
|
|
enabled = subprocess.run(["systemctl", "is-enabled", "--quiet", "qwen38-sglang.service"],
|
|
capture_output=True)
|
|
if enabled.returncode != 0:
|
|
self.skipTest("the 27B unit is not the enabled lane here, so there is no installed choice")
|
|
_, out = run(STOP, **STOCK)
|
|
installed_1m = "--context-length 1010000" in SGL_UNIT.read_text()
|
|
self.assertIn(KEPT_1M if installed_1m else KEPT_NATIVE, out)
|
|
self.assertNotIn(DEFAULT_LINE, out)
|
|
|
|
def test_the_flash_lane_falls_back_to_native_without_refusing(self):
|
|
rc, out = run(STOP, MODEL_CHOICE="flash")
|
|
self.assertEqual(rc, 1)
|
|
self.assertIn("contradict each other", out) # it got to the stop
|
|
self.assertNotIn("is a 27B mode", out) # not refused on its way
|
|
self.assertNotIn(DEFAULT_LINE, out) # and it is not on 1m
|
|
|
|
def test_no_service_is_never_refused_for_a_default_nobody_typed(self):
|
|
rc, out = run([*STOP, "--no-service"], **STOCK)
|
|
self.assertEqual(rc, 1)
|
|
self.assertIn("contradict each other", out) # it got to the stop
|
|
self.assertNotIn("needs the systemd path", out) # not refused on its way
|
|
self.assertNotIn(DEFAULT_LINE, out) # and it is not on 1m
|
|
|
|
def test_no_service_falls_back_to_native_and_says_so(self):
|
|
_, out = run([*STOP, "--no-service"], script=fresh_box_install(), **STOCK)
|
|
self.assertIn("--no-service installs the native 262144 window", out)
|
|
self.assertNotIn(DEFAULT_LINE, out)
|
|
|
|
|
|
class TheExplicitRefusalsSurvive(unittest.TestCase):
|
|
def test_explicit_1m_on_the_flash_lane_is_still_refused_by_name(self):
|
|
rc, out = run(STOP, MODEL_CHOICE="flash", CONTEXT_MODE="1m")
|
|
self.assertEqual(rc, 1)
|
|
self.assertIn("is a 27B mode", out)
|
|
|
|
def test_explicit_1m_with_no_service_is_still_refused_by_name(self):
|
|
# No STOP here: the cockpit contradiction sits above this refusal and
|
|
# would shadow it.
|
|
rc, out = run(["--no-service"], CONTEXT_MODE="1m")
|
|
self.assertEqual(rc, 1)
|
|
self.assertIn("needs the systemd path", out)
|
|
|
|
def test_a_bad_value_is_still_refused_and_empty_is_not_one(self):
|
|
rc, out = run(STOP, CONTEXT_MODE="2m", **STOCK)
|
|
self.assertEqual(rc, 1)
|
|
self.assertIn('CONTEXT_MODE must be "native" or "1m"', out)
|
|
|
|
|
|
class TheWiring(unittest.TestCase):
|
|
src = pathlib.Path(INSTALL).read_text()
|
|
|
|
def test_convergence_covers_both_directions(self):
|
|
self.assertIn('echo "Keeping the installed context mode: 1m.', self.src)
|
|
self.assertIn('echo "Keeping the installed context mode: native.', self.src)
|
|
|
|
def test_the_default_is_resolved_after_the_flags_are_parsed(self):
|
|
# It depends on --no-service, so a default computed at the top of the
|
|
# file (where the old one lived) cannot see it.
|
|
self.assertLess(self.src.index('for arg in "$@"; do'),
|
|
self.src.index('if [ -z "$CONTEXT_MODE" ]; then\n if [ "$LANE" = "flash" ]'))
|
|
|
|
def test_the_1m_limits_are_fitted_to_the_real_pool_after_boot(self):
|
|
# The static 1m limits overshoot the measured 863,398-token floor, and
|
|
# fitting them was a documented manual step while 1m was opt-in.
|
|
self.assertIn('oc-fit-limits.py" --engine', self.src)
|
|
i = self.src.index('oc-fit-limits.py" --engine')
|
|
self.assertIn('[ "$CONTEXT_MODE" = "1m" ]', self.src[i - 700:i])
|
|
|
|
def test_the_1m_unit_template_is_the_one_that_carries_the_window(self):
|
|
tpl = (REPO / "qwen38-sglang-1m.service.template").read_text()
|
|
self.assertIn("--context-length 1010000", tpl)
|
|
# 0.76 since v1.14: the official image claims a smaller static budget
|
|
# than the locally built one did, so the same 0.70 cost 15% of the pool
|
|
# while leaving 10 GB unused. Measured, see the IMAGE pin in install.sh.
|
|
self.assertIn("--mem-fraction-static 0.76", tpl)
|
|
self.assertIn("SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1", tpl)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|