Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

Servers: a request that fails is named on stderr (HTTP 500 and mid-stream error event), not only in the opt-in request log

YanissAmz7bad572a261f
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index c5e11a9..5d85877 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -1832,6 +1832,7 @@ def create_app(engine: Any, model_id: str, template: str, defaults: dict[str, An
except BadRequest as exc: # e.g. an image that does not decode (loaded by the worker)
return err(400, str(exc))
except Exception as exc: # noqa: BLE001
+ lifecycle.request_failed(exc)
return web.json_response({"error": {"message": f"{type(exc).__name__}: {exc}", "type": "server_error"}},
status=500)
text, _ = stop_text(full, job["stop"])
@@ -1942,6 +1943,7 @@ def create_app(engine: Any, model_id: str, template: str, defaults: dict[str, An
while True:
item = await out.get()
if isinstance(item, Exception):
+ lifecycle.request_failed(item)
return web.json_response({"error": {"message": f"{type(item).__name__}: {item}", "type": "server_error"}},
status=500)
if isinstance(item, tuple):
@@ -2118,6 +2120,7 @@ def create_app(engine: Any, model_id: str, template: str, defaults: dict[str, An
except BadRequest as exc:
return err(400, str(exc))
except Exception as exc: # noqa: BLE001
+ lifecycle.request_failed(exc)
return web.json_response({"error": {"message": f"{type(exc).__name__}: {exc}", "type": "server_error"}}, status=500)
text, _ = stop_text(full, job["stop"])
reason, usage = reason_usage(stats, text)
diff --git a/tools/qwen/test_serve.py b/tools/qwen/test_serve.py
index ec8e50a..1d05474 100644
--- a/tools/qwen/test_serve.py
+++ b/tools/qwen/test_serve.py
@@ -711,6 +711,20 @@ class HttpTests(unittest.TestCase):
self.assertIn("kaput", [e for e in ev if "error" in e][0]["error"]["message"])
self.assertEqual(ev[-1]["choices"][0]["finish_reason"], "error")
+ def test_failed_requests_are_logged_on_stderr(self):
+ # the request log is off by default: an OOM on a long prompt left no server line at all (only the client saw the error event)
+ import contextlib, io
+ class Boom(FakeEngine):
+ async def generate(self, prompt, **kw):
+ raise RuntimeError("CUDA out of memory")
+ yield ""
+ for stream in (False, True):
+ err = io.StringIO()
+ with contextlib.redirect_stderr(err):
+ self.chat(Boom(""), {"messages": [{"role": "user", "content": "hi"}]}, stream=stream)
+ self.assertIn("request failed", err.getvalue())
+ self.assertIn("CUDA out of memory", err.getvalue())
+
class LogprobsTests(unittest.TestCase):
ENTRIES = [(-0.5, [(1, -0.5), (9, -1.5)]), (-2.0, [(2, -0.25), (3, -2.0)]), None]
diff --git a/tools/strix_halo/serve_reqlog.py b/tools/strix_halo/serve_reqlog.py
index e5db9b0..26ea0ee 100644
--- a/tools/strix_halo/serve_reqlog.py
+++ b/tools/strix_halo/serve_reqlog.py
@@ -416,6 +416,11 @@ class Lifecycle:
def stream_error(self, rid: str | None, exc: BaseException) -> None:
self.reqlog.log("stream_error", req=rid, error=sanitize(exc))
+ print(f"qserve: request failed mid-stream, error event sent: {type(exc).__name__}: {str(exc)[:300]}", file=sys.stderr, flush=True)
+
+ def request_failed(self, exc: BaseException) -> None:
+ """A non-streaming request ended in HTTP 500 (the request log is off by default: stderr is the only trace)."""
+ print(f"qserve: request failed, HTTP 500: {type(exc).__name__}: {str(exc)[:300]}", file=sys.stderr, flush=True)
# ---- stream level ----------------------------------------------------------------------------