Deployments: llama.cpp web UI toggle, clearer start failures, log fixes

- Web UI option for llama.cpp deployments (--no-webui when off); the deployment
  page links to it on the published host port.
- Follow container logs after the start with tail=all: following a created
  container returned an already-closed stream, so startup output was lost.
- Failed starts name the cause from the log (vLLM ValueError, llama.cpp error
  lines) before the last output.
- A deployment's vLLM dtype replaces the runtime's --dtype instead of repeating it.
- vLLM memory estimate: 3 GiB overhead (measured ~6.9 GiB for SmolLM2-135M
  with a 4 GiB KV cache).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-06 12:01:52 +02:00
1 parent 8b74fa69db
commit 66e6a8c4f7
11 files changed
+130 -23

No files matched your search

+15 -14
View File
@@ -12,6 +12,7 @@ import { coreEnv } from "@/lib/env";
import { formatBytes } from "@/lib/format";
import { sanitizeLine } from "./job-log";
import { log } from "./log";
import { errorCauses } from "./log-causes";
import { docker } from "./runtimes";
import type { DockerClient } from "./docker/client";
@@ -60,7 +61,7 @@ export async function flushDeploymentLogs(): Promise<void> {
}
}
function follow(c: DockerClient, d: { id: string; containerId: string }, tail = 0) {
function follow(c: DockerClient, d: { id: string; containerId: string }, tail: number | "all" = 0) {
followers.get(d.id)?.abort();
const ctl = new AbortController();
followers.set(d.id, ctl);
@@ -170,8 +171,10 @@ async function start(c: DockerClient, d: Deployment) {
exitCode: null,
stats: null,
});
follow(c, { id: d.id, containerId: created.Id });
await c.startContainer(created.Id);
// A fresh container: everything it printed belongs to this run. (Following before the start
// returns an empty, already-closed stream.)
follow(c, { id: d.id, containerId: created.Id }, "all");
log.info(`deployment ${d.name}: started ${name}`);
} catch (err) {
await c.removeContainer(name).catch(() => {});
@@ -190,19 +193,17 @@ async function stopContainer(c: DockerClient, d: Deployment) {
await update(d.id, { state: "stopped", stoppedAt: new Date(), stats: null, containerId: null });
}
/** Tail of the log for error messages. */
async function lastLines(id: string, n = 15): Promise<string> {
/** Likely causes plus the tail of the log, for error messages. */
async function failureDetails(id: string, tail = 15): Promise<string> {
await flushDeploymentLogs();
const rows = await db()
.select({ line: deploymentLogs.line })
.from(deploymentLogs)
.where(eq(deploymentLogs.deploymentId, id))
.orderBy(desc(deploymentLogs.id))
.limit(n);
return rows
const lines = (
await db().select({ line: deploymentLogs.line }).from(deploymentLogs).where(eq(deploymentLogs.deploymentId, id)).orderBy(desc(deploymentLogs.id)).limit(2000)
)
.reverse()
.map((r) => r.line)
.join("\n");
.map((r) => r.line);
const causes = errorCauses(lines);
const last = lines.slice(-tail).join("\n");
return [causes.join("\n"), last && (causes.length ? `Last output:\n${last}` : last)].filter(Boolean).join("\n\n");
}
async function healthy(name: string, port: number): Promise<boolean> {
@@ -244,7 +245,7 @@ async function reconcileOne(c: DockerClient, d: Deployment) {
if (!st || !st.Running) {
const why = st?.OOMKilled ? "out of memory (raise the memory limit)" : `exit code ${st?.ExitCode ?? "?"}`;
unfollow(d.id);
const tail = await lastLines(d.id);
const tail = await failureDetails(d.id);
await c.removeContainer(d.containerId).catch(() => {});
return fail(d, `The container stopped (${why}).${tail ? `\n${tail}` : ""}`, st?.ExitCode ?? null);
}
+2 -2
View File
@@ -158,14 +158,14 @@ export class DockerClient {
}
/**
* Follow a container's stdout/stderr (from now, plus the last `tail` lines). The stream uses
* Follow a container's stdout/stderr (from now, plus the last `tail` lines or "all"). The stream uses
* Docker's multiplexed format (8-byte frame headers) for containers without a TTY. Resolves when
* the container stops or `signal` aborts.
*/
async followLogs(
id: string,
onLine: (stream: "stdout" | "stderr", line: string) => void,
options: { tail?: number; signal?: AbortSignal } = {},
options: { tail?: number | "all"; signal?: AbortSignal } = {},
): Promise<void> {
const res = await this.raw(
"GET",
+25
View File
@@ -0,0 +1,25 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { errorCauses } from "./log-causes";
describe("errorCauses", () => {
it("finds vLLM's root cause and skips the wrapper error", () => {
const lines = [
"(Worker pid=171) INFO 10-06 09:49:26 [model_runner.py:16] Warming up done.",
"(Worker pid=171) ERROR 10-06 09:50:06 [multiproc_executor.py:1058] Traceback (most recent call last):",
"(Worker pid=171) ERROR 10-06 09:50:06 [multiproc_executor.py:1058] ValueError: Available memory on node 0 (3.33/8.0 GiB) is too low.",
"(Worker pid=171) ERROR 10-06 09:50:06 [multiproc_executor.py:1058] ValueError: Available memory on node 0 (3.33/8.0 GiB) is too low.",
"RuntimeError: Engine core initialization failed. See root cause above. Failed core proc(s): {}",
];
assert.deepEqual(errorCauses(lines), ["ValueError: Available memory on node 0 (3.33/8.0 GiB) is too low."]);
});
it("finds llama.cpp load errors", () => {
const lines = ["0.00.012 I srv load_model: loading model '/models/x.gguf'", "0.00.013 E llama_model_load: error: unknown model architecture: 'foo'", "0.00.014 E srv load_model: failed to load model, '/models/x.gguf'"];
assert.equal(errorCauses(lines).length, 2);
});
it("returns nothing for a clean log", () => {
assert.deepEqual(errorCauses(["listening on http://0.0.0.0:8080"]), []);
});
});
+20
View File
@@ -0,0 +1,20 @@
// Picks the likely cause of a failed start out of a container log. Pure, for tests.
// "(Worker pid=171) ERROR 10-06 09:50:06 [multiproc_executor.py:1058] " and similar vLLM prefixes.
const VLLM_PREFIX = /^\([\w ]+pid=\d+\)\s+(?:[A-Z]+\s+\d\d-\d\d \d\d:\d\d:\d\d\s+\[[^\]]*\]\s*)?/;
// A Python exception line ("ValueError: …"), llama.cpp's "error:"/"failed to" lines.
const CAUSE = /^(?:[\w.]*(?:Error|Exception): \S|.*\berror: \S|.*\bfailed to (?:load|open|allocate)\b)/i;
// Generic wrappers that only say "see above".
const WRAPPER = /Engine core initialization failed|See root cause above|exiting due to/i;
/** Distinct cause lines in order of first appearance (at most `max`). */
export function errorCauses(lines: string[], max = 3): string[] {
const out: string[] = [];
for (const raw of lines) {
const line = raw.replace(VLLM_PREFIX, "").trim();
if (!CAUSE.test(line) || WRAPPER.test(line) || out.includes(line)) continue;
out.push(line.length > 500 ? `${line.slice(0, 500)}…` : line);
if (out.length >= max) break;
}
return out;
}