Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
#560 #516: an AMD card on a Linux desktop gets a recommended VRAM reserve (3072 MiB)
Niko122140ae2d1e80e6
diff --git a/docs/AMD_HIP.md b/docs/AMD_HIP.mdindex 0148f7af9..e2b63fc9b 100644--- a/docs/AMD_HIP.md+++ b/docs/AMD_HIP.md@@ -190,6 +190,11 @@ The worker count above was used on a 16-core CPU; measure it for your CPU.The 4K context is a smoke-test starting point, not a model limit. The expert cachesizes itself automatically and leaves 1 GiB of VRAM headroom.+**The card also drives a Linux desktop (#560 #516):** keep more VRAM free than the default 700 MiB, e.g.+`./setup.sh --vram-reserve-mib 3072`. With the cache filling the card, the desktop's next VRAM need makes amdgpu move+GPU memory to system RAM (GTT), the OOM killer then ends KWin/plasmashell or `systemd-oomd` ends apps, or the+compositor fails with "Failed to pin framebuffer with error -12".+The installer supports this backend (see "Install with setup" above). Images run through the CPU encoder for now (`--vision cpu`).Setup installs one AMD card, or several with `--gpus` (the engine's layer split; see RDNA4 below).diff --git a/docs/INSTALL.md b/docs/INSTALL.mdindex 735a10c69..7af3a3e8b 100644--- a/docs/INSTALL.md+++ b/docs/INSTALL.md@@ -201,6 +201,12 @@ By hand: add `"--vram-reserve-mib", "2048"` to the config's `"args"` list and remuch smaller, so answers can be a little slower. The engine sizes its cache from the VRAM free when it starts: whatanother program already holds then is left alone anyway; the reserve is room for what it takes later.+**An AMD card that also drives a Linux desktop (#560 #516):** with the default reserve the expert cache fills the+card, and when the desktop (the compositor, a browser, a new app) needs more VRAM, the amdgpu driver moves GPU memory+to system RAM, which the model's experts already fill: the OOM killer then ends the desktop session (KWin, plasmashell)+or the compositor fails ("Failed to pin framebuffer"). `./setup.sh --vram-reserve-mib 3072` fixed it in both reports+(about 2.3 GB fewer experts in VRAM, a few % of speed). Setup and the server window say so on such a PC.+**A card under 8 GB (#496):** when the default reserve leaves the expert cache too little room, the engine lowers thereserve (down to 300 MiB) until it fits, and warns if the card then ends nearly full. If the start stops with "no VRAMis left for the expert cache", that log line says how much is short; an 8K context and `--draft-vocab en` at setupdiff --git a/serve/server.py b/serve/server.pyindex 270955606..0f4e58a49 100644--- a/serve/server.py+++ b/serve/server.py@@ -2488,6 +2488,36 @@ def warn_tight_ram(arena_mib) -> None:+ "Close other programs, or run START-HERE --setup and pick a smaller size (Q2_0 / IQ2_XS).", flush=True)+DESKTOP_FREE_MIB = 2048 # #560 #516: below this, an AMD card that also drives a Linux desktop can run out+DESKTOP_RESERVE_MIB = 3072 # what kept KDE/Wayland alive beside a full expert cache in both reports+++def linux_desktop(env=None) -> bool:+ """A graphical session on Linux (Wayland or X): its compositor, browser and apps take VRAM after the model has."""+ env = os.environ if env is None else env+ return os.name != "nt" and sys.platform != "darwin" and bool(env.get("WAYLAND_DISPLAY") or env.get("DISPLAY"))+++def desktop_vram_note(backend, vram_free_mib, args: list, desktop: bool) -> str:+ """#560 #516: on Linux, when the desktop needs VRAM the AMD card does not have, amdgpu moves GPU memory (the expert+ cache, ~24 GB) to system RAM, which the experts already fill - the OOM killer then ends the compositor. The+ default reserve (700 MiB) is sized for a card without a desktop. A recommendation, nothing changes: "" when it+ does not apply."""+ if backend != "hip" or not desktop or not isinstance(vram_free_mib, int) or vram_free_mib >= DESKTOP_FREE_MIB:+ return ""+ try:+ reserve = int(args[args.index("--vram-reserve-mib") + 1]) if "--vram-reserve-mib" in args else 700+ except (ValueError, IndexError):+ reserve = 700+ if reserve >= DESKTOP_RESERVE_MIB:+ return ""+ return (f"[strata] note: {vram_free_mib} MiB of VRAM free with the model loaded. If this AMD card also drives your "+ "desktop and the desktop or apps crash after the start (the driver moves the expert cache to RAM and "+ "the OOM killer ends the session), keep more VRAM free: ./setup.sh --vram-reserve-mib "+ f"{DESKTOP_RESERVE_MIB} (remembered; the expert cache gets "+ f"{(DESKTOP_RESERVE_MIB - reserve) / 1024:.1f} GB less, a few % of speed)")++def lan_addresses() -> list[str]:"""This PC's IPv4 addresses on its networks (what another device types in), without loopback/link-local."""import socket@@ -2732,6 +2762,10 @@ def main() -> int:engine = StrataEngine(exe, engine_args(cfg), cwd=cfg.get("cwd"), log=cfg.get("log"), env=env, lazy=lazy)engine.silence_s = silence # an attribute of its own: restart() keeps itwarn_tight_ram(engine.info.get("arena_mib"))+ note = desktop_vram_note(cfg.get("backend"), engine.info.get("vram_free_mib"), engine.spawn[1],+ linux_desktop())+ if note: # #560 #516: before --open starts a browser on that card+ print(note, flush=True)else:engine, vision, sampling_defaults = MockEngine(tok, a.script or ["Thinking about it.</think>\n\nHello from the mock engine."]), None, {}diff --git a/serve/test_server.py b/serve/test_server.pyindex 8f34a74b0..f96c8980e 100644--- a/serve/test_server.py+++ b/serve/test_server.py@@ -876,6 +876,31 @@ class DraftHeadHint(unittest.TestCase):self.assertEqual(start_failure_hint(str(Path(tempfile.mkdtemp()) / "missing.log"), 0), "")+class DesktopVramNote(unittest.TestCase):+ """#560 #516: an AMD card on a Linux desktop with little VRAM left after the start gets a recommended reserve."""++ def test_when_it_applies(self):+ from serve.server import desktop_vram_note+ note = desktop_vram_note("hip", 624, ["--kv", "int8"], True)+ self.assertIn("624 MiB of VRAM free", note)+ self.assertIn("--vram-reserve-mib 3072", note)+ self.assertIn("2.3 GB less", note)++ def test_when_it_does_not(self):+ from serve.server import desktop_vram_note+ self.assertEqual(desktop_vram_note(None, 624, [], True), "") # NVIDIA+ self.assertEqual(desktop_vram_note("hip", 624, [], False), "") # no desktop session+ self.assertEqual(desktop_vram_note("hip", 2994, [], True), "") # room left+ self.assertEqual(desktop_vram_note("hip", None, [], True), "") # lazy start: no INFO yet+ self.assertEqual(desktop_vram_note("hip", 900, ["--vram-reserve-mib", "4000"], True), "") # already raised++ def test_desktop_detection(self):+ from serve import server+ with mock.patch.object(server.os, "name", "posix"), mock.patch.object(server.sys, "platform", "linux"):+ self.assertTrue(server.linux_desktop({"WAYLAND_DISPLAY": "wayland-0"}))+ self.assertFalse(server.linux_desktop({}))++class StartFailureLog(unittest.TestCase):"""#496: whatever stopped the engine before READY, the error carries this start's last log lines."""diff --git a/setup.py b/setup.pyindex eee211599..bc36f6e29 100644--- a/setup.py+++ b/setup.py@@ -2747,6 +2747,24 @@ def small_card_note(ctx: int, draft_vocab: str | None) -> list[str]:return lines+DESKTOP_RESERVE_MIB = 3072 # #560 #516: what kept a KDE/Wayland desktop alive beside a full expert cache+++def linux_desktop(env=None) -> bool:+ """A graphical session on Linux (Wayland or X)."""+ env = os.environ if env is None else env+ return sys.platform.startswith("linux") and bool(env.get("WAYLAND_DISPLAY") or env.get("DISPLAY"))+++def desktop_reserve_note() -> list[str]:+ """#560 #516: an AMD card that also drives a Linux desktop - with the default 700 MiB reserve the expert cache+ fills it, and when the desktop needs more VRAM amdgpu moves the cache to system RAM, where the OOM killer then ends+ the compositor. A recommendation, setup changes nothing."""+ return [f"If this AMD card also drives your desktop and the desktop or apps crash once the model is loaded, keep "+ f"more VRAM free: ./setup.sh --vram-reserve-mib {DESKTOP_RESERVE_MIB}",+ " (remembered for this model; the expert cache gets ~2.3 GB less, a few % of speed)"]++def mtp_corrupt(mtp: Path, env=None) -> bool:"""#327: True when the MTP tensors an install fetched are not the pinned checkpoint's (tools/mtp_fetch.py verify,which hashes only files that changed since they last checked out). A mirror that ignored range requests left the@@ -3556,6 +3574,9 @@ def main() -> int:# is what it takes, and says what is short when even that is not enough. Setup only says what helps.for line in small_card_note(ctx, draft_vocab): # a recommendation: nothing changessay(" " + line)+ elif hip and a.vram_reserve_mib is None and linux_desktop():+ for line in desktop_reserve_note(): # #560 #516: a recommendation: nothing changes+ say(" " + line)if esp is not None:# the package's profile, with llama.cpp's flags (the engine takes the same ones)args += ["--control-vector-scaled", f"{esp}:1.0", "--control-vector-layer-range", "4", "44",diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.pyindex c28127bb5..c7736b34a 100644--- a/tools/test_setup_choices.py+++ b/tools/test_setup_choices.py@@ -368,5 +368,23 @@ class SmallCardTip(unittest.TestCase):self.assertIn("close other programs", tip)+class DesktopReserveTip(unittest.TestCase):+ """#560 #516: an AMD card on a Linux desktop gets a recommended reserve (3072 MiB) - a tip, the config is not+ changed."""++ def test_desktop_detection(self):+ with mock.patch.object(setup.sys, "platform", "linux"):+ self.assertTrue(setup.linux_desktop({"WAYLAND_DISPLAY": "wayland-0"}))+ self.assertTrue(setup.linux_desktop({"DISPLAY": ":0"}))+ self.assertFalse(setup.linux_desktop({})) # a headless box / ssh+ with mock.patch.object(setup.sys, "platform", "win32"):+ self.assertFalse(setup.linux_desktop({"DISPLAY": ":0"})) # Windows counts the desktop itself (#497)++ def test_the_tip(self):+ tip = " ".join(setup.desktop_reserve_note())+ self.assertIn("--vram-reserve-mib 3072", tip)+ self.assertIn("desktop", tip)++if __name__ == "__main__":unittest.main()