Merge f-0216-fixes: Mac app-mode setup with no draft layer plans no drafter, the Qwen3.6 engine gets no VRAM command, strata_mcp's missing-engine check, install.sh reads a CRLF install-manifest.txt

This commit is contained in:
Niko1221 committed 2026-11-16 13:03:30 +01:00
commit 7562425543
9 files changed
+142 -3

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ main() {
host=$(printf '%s' "$FEED" | sed -n 's#^[A-Za-z][A-Za-z0-9+.-]*://\([^/:]*\).*#\1#p')
host=${host:-$FEED}
fetch "$FEED/install-manifest.txt" "$work/manifest.txt" || die "$host did not answer (or this computer is offline), so the installer could not start. Check that this computer can open https://$host, then run the same line again. Nothing was installed."
line=$(awk -v p="$platform" '$1 == p { print; exit }' "$work/manifest.txt")
line=$(awk -v p="$platform" '{ sub(/\r$/, "") } $1 == p { print; exit }' "$work/manifest.txt") # a manifest saved with CRLF line ends reads the same
[ -n "$line" ] || die "this release has no Terminal for $platform."
set -- $line
version=$2; rel=$3; want=$4
+9 -1
View File
@@ -5234,6 +5234,12 @@ class Service:
started with, a segment or more below the size it had)."""
return self.vram_reserve if self.vram_reserve_asked else 0
def _engine_has_vram_command(self) -> bool:
"""Does the running engine know the VRAM command? The Strata engine says so in its INFO line (vram_elastic=0 or 1, every engine
since 0.1.39; 0 refuses the command with its reason). The Qwen3.6 engine path (src/qwen35/q36_engine.cu) reports no such key and
has no such command: it answered "VRAM n" with its usage text ("expected: GEN <max_new> ..."), 0.2.15 release test."""
return "vram_elastic" in (getattr(self.engine, "info", None) or {})
def _vision_up(self):
"""The image turn's start for an elastic encoder that is not running (the caller holds self.fifo): the expert
cache first keeps the encoder's elastic_mib of VRAM free on top of the reserve, then the encoder starts (load and
@@ -5242,6 +5248,8 @@ class Service:
v = self.vision
if not getattr(v, "elastic", False) or v.alive():
return
if self.loaded() and not self._engine_has_vram_command():
self.vision_no_shrink = self.vision_no_shrink_said = True # the Qwen3.6 engine: no VRAM command (it would answer with its usage text)
if hasattr(self.engine, "vram") and self.loaded() and not self.vision_no_shrink:
try:
out = self.engine.vram((self._engine_reserve() or 0) + v.elastic_mib)
@@ -5469,7 +5477,7 @@ class Service:
started with), applied between requests - a request that is running finishes first (up to wait_s). Only an
engine started with --vram-elastic (the config's "vram_elastic": true) can do it; it never resizes on its own.
An unloaded engine applies it when it loads. -> {"status": ..., and the engine's figures}."""
if not hasattr(self.engine, "vram"):
if not hasattr(self.engine, "vram") or (self.loaded() and not self._engine_has_vram_command()):
raise ValueError("this engine cannot resize its VRAM use")
if not self.fifo.acquire(timeout=self.vram_wait_s):
raise ModelBusy("a request is still running; try again when it has finished")
+21
View File
@@ -124,6 +124,27 @@ class Elastic(unittest.TestCase):
self.assertIn("the image encoder stopped after 60 s without a picture", out.getvalue())
self.assertNotIn("expert cache", out.getvalue())
def test_the_qwen36_engine_is_not_sent_a_command_it_does_not_have(self):
# the Qwen3.6 engine path reports no vram_elastic and has no VRAM command: it answered "VRAM 2048" with its usage text, and the log said
# "the expert cache did not make room for the image encoder (expected: GEN <max_new> ...)" at every picture (0.2.15 release test, boston)
del self.engine.info["vram_elastic"]
usage = "expected: GEN <max_new> [key=value ...] <id,id,...>"
self.engine.vram = lambda reserve, timeout=120.0: (self.engine.calls.append(reserve), (_ for _ in ()).throw(ValueError(usage)))[1]
out = io.StringIO()
with contextlib.redirect_stdout(out):
self.picture()
self.svc.last_image_at = 0
self.assertEqual(self.svc._vision_idle_down(), "down")
self.picture()
self.assertEqual(self.engine.calls, []) # never asked
self.assertEqual(self.vision.starts, 2) # the encoder starts all the same
self.assertNotIn("expected: GEN", out.getvalue())
self.assertNotIn("did not make room", out.getvalue())
with self.assertRaises(ValueError) as e: # POST /v1/vram: the server's own sentence, not the engine's usage text
self.svc.vram(4000)
self.assertEqual(str(e.exception), "this engine cannot resize its VRAM use")
self.assertEqual(self.engine.calls, [])
def test_the_load_never_starts_an_elastic_encoder(self):
self.assertFalse(self.svc._vision_down())
self.svc.vision = ElasticVision(tempfile.mkdtemp(), elastic=False)
+1
View File
@@ -20,6 +20,7 @@ class VramEngine(ResidentEngine):
def __init__(self, tok, elastic=True):
super().__init__(tok)
self.elastic, self.calls = elastic, []
self.info["vram_elastic"] = int(elastic) # the Strata engine's INFO line says it (0: VRAM is refused with the reason)
def vram(self, reserve_mib, timeout=120.0):
self.calls.append(reserve_mib)
+3
View File
@@ -9300,6 +9300,9 @@ def mac_control_setup(a) -> int:
cfg["draft_vocab"] = a.draft_vocab
if a.browser is not None:
cfg["open_browser"] = a.browser
if no_layer: # the model list says it has no draft layer, and DFlash2 is made for Qwen3.8-Flash-Next only: no drafter exists for it.
cfg["mtp"] = False # Written as Windows and Linux write it (setup_config, feed_no_drafter), so the plan and the start say
cfg["drafting"] = "off" # "Drafting: Off" instead of an MTP that has nothing to load (TRIAGE-0215)
if vision != "none": # the Mac's one program reads on the GPU (--gpu) or the CPU (strata_control/vision_reader.py)
from strata_control import vision_reader as VR
cfg["args"].append("--vision")
@@ -0,0 +1,52 @@
"""The release's list files read the same with CRLF line ends. 0.2.15's publish scripts wrote UPLOAD-ORDER.txt with CRLF on Windows and every
upload of that run failed on the names' trailing CR (fixed in the release scripts, which now write LF). The one list file the released tools read is
install-manifest.txt: packaging/install.sh takes its platform line with awk and uses the last field (the size) in shell arithmetic, so a manifest
saved with CRLF (an editor, a copy through Windows) stopped the install there. install.ps1 reads it with Get-Content, which takes either ending.
packaging/feed_tool.py writes it with LF."""
import os
import re
import shutil
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SH = ROOT / "packaging" / "install.sh"
MANIFEST = ("linux-x86_64 0.2.15 strata-control-0.1.61-linux-x86_64.tar.gz " + "a" * 64 + " 97550582\n"
"macos-arm64 0.2.15 strata-control-0.1.61-macos-arm64.tar.gz " + "b" * 64 + " 48715939\n")
def manifest_line() -> str:
m = re.search(r"^\s*line=\$\(awk [^\n]*manifest\.txt\"\)", SH.read_text(encoding="utf-8"), re.M)
assert m, "install.sh reads no platform line from install-manifest.txt"
return m.group(0).strip()
@unittest.skipIf(os.name == "nt" or not shutil.which("sh") or not shutil.which("awk"), "needs POSIX sh and awk")
class ManifestLineEnds(unittest.TestCase):
def read(self, text: str, platform: str = "linux-x86_64") -> subprocess.CompletedProcess:
with tempfile.TemporaryDirectory() as d:
(Path(d) / "manifest.txt").write_bytes(text.encode())
script = (f"platform={platform}; work=\"$1\"\n{manifest_line()}\n"
'set -- $line\nprintf "%s|%s|%s|%s|%s\\n" "$1" "$2" "$3" "$4" "$(( ${5:-0} / 1048576 ))"\n')
return subprocess.run(["sh", "-c", script, "sh", d], capture_output=True, text=True, timeout=30)
def test_lf_and_crlf_give_the_same_fields(self):
want = "linux-x86_64|0.2.15|strata-control-0.1.61-linux-x86_64.tar.gz|" + "a" * 64 + "|93\n"
for text in (MANIFEST, MANIFEST.replace("\n", "\r\n")):
r = self.read(text)
self.assertEqual((r.returncode, r.stdout), (0, want), (repr(text[:20]), r.stderr))
r = self.read(MANIFEST.replace("\n", "\r\n"), "macos-arm64")
self.assertEqual(r.stdout.split("|")[3], "b" * 64) # the checksum compared with the download has no CR either
class Writers(unittest.TestCase):
def test_feed_tool_writes_the_manifest_with_lf(self):
src = (ROOT / "packaging" / "feed_tool.py").read_text(encoding="utf-8")
self.assertRegex(src, r'"install-manifest\.txt"\)\.write_text\(install_manifest, encoding="utf-8", newline="\\n"\)')
if __name__ == "__main__":
unittest.main()
+12 -1
View File
@@ -692,6 +692,17 @@ class Strata:
except (OSError, ValueError):
return {}
@staticmethod
def engine_here(reference: str, cfg: dict) -> bool:
"""A run config's engine named as a component ("component:strata-engine", what every install of the app and `strata launch` writes): is that
engine installed? It is not a path on disk, so it was always counted missing, and the app listed "the engine program" beside any file that
really was missing. Looked up without the SHA-256 check of a start (strata_control.engine_component.expand, full=False)."""
try:
from strata_control import engine_component as ec
return bool(ec.expand(reference, cfg, full=False))
except Exception: # noqa: BLE001 - no engine, an unknown component, a damaged folder: missing
return False
def describe_config(self, path: Path, usage: dict | None = None) -> dict:
cfg = self.read_config(path)
a = cfg.get("args") if isinstance(cfg.get("args"), list) else []
@@ -700,7 +711,7 @@ class Strata:
return a[a.index(k) + 1] if k in a and a.index(k) + 1 < len(a) else None
tag = path.stem[len("strata-"):]
missing = [p for p in [cfg.get("exe"), *[x for x in a if isinstance(x, str) and x.endswith(".gguf")]]
if not p or not Path(p).exists()]
if not p or not (self.engine_here(p, cfg) if str(p).startswith("component:") else Path(p).exists())]
gaps = shard_gaps([x for x in a if isinstance(x, str) and x.endswith(".gguf")]) # a model in parts is whole only with every part
missing += gaps
script = self.root / f"run-{tag}.{'bat' if WIN else 'sh'}"
+21
View File
@@ -427,6 +427,27 @@ class ControlMode(unittest.TestCase):
rc, _ = self.run_setup() # the Flash-Next size itself says nothing of the kind
self.assertFalse([s for s in self.said if "model list says" in s])
def test_a_model_without_a_draft_layer_plans_and_starts_no_drafter(self):
# the run config of such a model says what Windows and Linux write ("mtp": false, "drafting": "off"), so the plan and the start say
# "Drafting: Off"; before, neither key was written and both said "Drafting: MTP" with nothing to load (TRIAGE-0215)
from strata_control import drafting, mac_fit
for hw in (M4, M5): # a Mac that streams and one that keeps the model in memory
with mock.patch.dict(mac_fit.MAC_MODELS["Q2_0"], {"no_mtp": True}):
rc, _ = self.run_setup(hw=hw)
self.assertEqual(rc, 0)
cfg = self.config()
self.assertIs(cfg.get("mtp"), False, hw)
self.assertEqual(cfg.get("drafting"), "off", hw)
self.assertNotIn("--mtp", cfg["args"])
for name in (cfg["model_name"], "feedfam-q4_k_m"): # the feed model's own name as well
d = drafting.apply(dict(cfg, model_name=name), data_dir=self.data, backend="metal", archs=[])
self.assertEqual((d.drafter, drafting.summary_line(d)), ("off", "Drafting: Off"), (hw, name))
(self.home / "strata-q2_0.json").unlink() # (a fresh install: nothing carried over from the runs above)
rc, _ = self.run_setup(hw=M5) # the Flash-Next size keeps its drafter: neither key is written
cfg = self.config()
self.assertNotIn("drafting", cfg)
self.assertNotIn("mtp", cfg)
def test_a_big_mac_keeps_the_pack_in_memory_and_adds_the_draft_layer(self):
rc, ran = self.run_setup(hw=M5, argv=("--yes", "--no-start", "--model", "IQ3_XXS"))
self.assertEqual(rc, 0)
+22
View File
@@ -1122,6 +1122,28 @@ class DiskUsageTest(unittest.TestCase):
desc = s.describe_config(s.configs()[0])
self.assertEqual([m for m in desc["missing_files"] if m.endswith(".gguf")], [])
def test_the_engine_component_is_missing_only_when_it_is_not_installed(self):
# every install writes "exe": "component:strata-engine"; it is not a path, so it was always counted missing and the app listed
# "the engine program" beside any file that really was missing (0.2.15 release test)
from strata_control import engine_component as ec
part1 = self.blob(self.own / "Model-00001-of-00002.gguf", 10)
cfg = {"exe": "component:strata-engine", "args": ["--native", part1], "port": 8080, "backend": "cuda"}
(self.root / "strata-two-parts.json").write_text(json.dumps(cfg), encoding="utf-8")
s = M.Strata(self.root)
with mock.patch.object(ec, "expand", return_value=str(self.root / "engine" / "strata")) as looked:
desc = s.describe_config(s.configs()[0])
self.assertEqual(len(desc["missing_files"]), 1, desc["missing_files"])
self.assertTrue(desc["missing_files"][0].endswith("Model-00002-of-00002.gguf"))
self.assertEqual(looked.call_args.kwargs.get("full"), False, "no SHA-256 pass for a list")
self.blob(self.own / "Model-00002-of-00002.gguf", 10)
desc = s.describe_config(s.configs()[0])
self.assertEqual(desc["missing_files"], [])
self.assertTrue(desc["ready"])
with mock.patch.object(ec, "expand", side_effect=ec.EngineMissing("no package here", None)):
desc = s.describe_config(s.configs()[0])
self.assertEqual(desc["missing_files"], ["component:strata-engine"]) # the app's word for it: "the engine program"
self.assertFalse(desc["ready"])
class DraftLayerAndCancel(unittest.TestCase):
"""#3257: the draft layer's download shows real progress, and a cancel ends the whole tree."""