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++
serve: optional --fit-max-tokens clamps the output cap to remaining context instead of rejecting
peteba8c55e1cc5e
diff --git a/serve/server.py b/serve/server.pyindex 86b0e483c..0691e6472 100644--- a/serve/server.py+++ b/serve/server.py@@ -375,8 +375,10 @@ class Detokenizer:class Service:def __init__(self, engine: Engine, tokenizer, template: ChatTemplate, model_name: str = "qwen3.8-flash-next",- vision: Vision | None = None, sampling_defaults: dict | None = None):+ vision: Vision | None = None, sampling_defaults: dict | None = None,+ fit_max_tokens: bool = False):self.engine, self.tok, self.template, self.model, self.vision = engine, tokenizer, template, model_name, vision+ self.fit_max_tokens = fit_max_tokens # --fit-max-tokens: clamp the output cap instead of 400self.sampling_defaults = dict(sampling_defaults or {}) # the run config's `sampling` blockself.fifo = threading.Lock()self.embeddings = threading.local() # the current request's image embeddings file (GENI)@@ -468,8 +470,10 @@ class Service:f"({self.engine.max_context}); requests are never truncated")max_new = roomelif max_new > room:- raise ValueError(f"prompt ({len(ids)} tokens) + max tokens ({max_new}) exceeds the context "- f"({self.engine.max_context}); requests are never truncated")+ if not self.fit_max_tokens:+ raise ValueError(f"prompt ({len(ids)} tokens) + max tokens ({max_new}) exceeds the context "+ f"({self.engine.max_context}); requests are never truncated")+ max_new = max(1, room) # --fit-max-tokens: a shorter completion beats a 400return ids, kwargs.get("enable_thinking", True) is not False, max_newdef _note(self, n, evs):@@ -989,6 +993,9 @@ def main() -> int:ap.add_argument("--tokenizer", default=str(ROOT / "pack/full/tokenizer"),help="pack tokenizer directory (falls back to a byte tokenizer if absent)")ap.add_argument("--open", action="store_true", help="open the local page in the browser once the model is ready")+ ap.add_argument("--fit-max-tokens", action="store_true",+ help="clamp max_tokens to the remaining context instead of rejecting the request "+ "(default: reject with 400, like llama.cpp)")ap.add_argument("--api-key", default=os.environ.get("STRATA_API_KEY", ""),help="require this key on /v1/* (Authorization: Bearer ... or x-api-key); also $STRATA_API_KEY")a = ap.parse_args()@@ -1034,7 +1041,7 @@ def main() -> int:tpl = tpath / "chat_template.jinja"svc = Service(engine, tok, ChatTemplate(tpl if tpl.exists() else ROOT / "serve/chat_template.jinja"),model_name=cfg.get("model_name", "qwen3.8-flash-next"), vision=vision,- sampling_defaults=sampling_defaults)+ sampling_defaults=sampling_defaults, fit_max_tokens=a.fit_max_tokens)svc.api_key = a.api_key or cfg.get("api_key", "")httpd = serve(svc, host=a.host, port=a.port)print(f"ready: http://{a.host}:{a.port}/v1 (OpenAI: /v1/chat/completions, Anthropic: /v1/messages, "