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++
server (#208 follow-up): a request stamps last_request_at in load() (the idle thread cannot unload between load and run); unload() sends QUIT before terminate; the VRAM guard checks the first GPU (docs); #163's test engine answers poll()
Niko1221379d7d84b2f5
diff --git a/docs/DETAILS.md b/docs/DETAILS.mdindex be65b89e1..c0911f693 100644--- a/docs/DETAILS.md+++ b/docs/DETAILS.md@@ -304,7 +304,7 @@ server, three server options (all off by default; also as keys in `strata-<model| Option | Config key | What it does || --- | --- | --- || `--idle-unload 600` | `"idle_unload_s": 600` | unload the model after 600 s without requests; the next request loads it again |-| `--min-free-vram-mib 11000` | `"min_free_vram_mib": 11000` | load an unloaded model only when that much VRAM is free (it waits up to 15 s for memory being given back), else answer **503** "the GPU is in use by another program" instead of starting into what a game left |+| `--min-free-vram-mib 11000` | `"min_free_vram_mib": 11000` | load an unloaded model only when that much VRAM is free (it waits up to 15 s for memory being given back), else answer **503** "the GPU is in use by another program" instead of starting into what a game left (with several GPUs it checks the first one) || `--before-load "cmd"` | `"before_load": "cmd"` or `["cmd", "arg"]` | a command run before the model is loaded again, e.g. one that unloads another server's model |`POST /unload` unloads it now (`409` while a request is running) and `POST /load` loads it ahead of a request;diff --git a/serve/server.py b/serve/server.pyindex dadea7a8d..2d41ac439 100644--- a/serve/server.py+++ b/serve/server.py@@ -249,8 +249,13 @@ class StrataEngine:"""Stop the engine process so its VRAM and RAM go back to the system (idle unload, POST /unload); the nextrequest starts it again with restart(). Only between requests: the caller holds the service's fifo."""try:- self.proc.terminate()- self.proc.wait(timeout=20)+ try: # QUIT first, as close() does: the engine frees its memory+ self.proc.stdin.write("QUIT\n")+ self.proc.stdin.flush()+ self.proc.wait(timeout=20)+ except (OSError, ValueError, subprocess.TimeoutExpired):+ self.proc.terminate()+ self.proc.wait(timeout=20)except subprocess.TimeoutExpired:self.proc.kill()self.proc.wait(timeout=20)@@ -695,6 +700,8 @@ class Service:def load(self):"""POST /load and every generation request: start the engine now if it is unloaded (raises GpuBusy)."""+ # a request is on its way: the idle thread must not unload between this and the request's own start+ self.last_request_at = time.time()if self.loaded() and not self._vision_down():returnwith self.fifo:diff --git a/serve/test_server.py b/serve/test_server.pyindex b4fad2265..9b0762fec 100644--- a/serve/test_server.py+++ b/serve/test_server.py@@ -486,7 +486,7 @@ class LiveRate(unittest.TestCase):import queuefrom types import SimpleNamespaceengine = StrataEngine.__new__(StrataEngine)- engine.proc = SimpleNamespace(stdin=io.StringIO())+ engine.proc = SimpleNamespace(stdin=io.StringIO(), poll=lambda: None) # alive() asks it (#208)engine.lines = queue.Queue()engine.can_stop = Falseengine.max_context = 262144