Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ Each configured LLM port gets its own `LlmProbe` instance running in parallel. P
- **q27** (signalnine/q27 engine) — `/v1/models` (`owned_by: q27`) or Prometheus `q27_*` series; live tok/s from `q27_*_processed` counter diffs (completion-based totals as fallback), exact computed-only prefill with the cached/uncached split doubling as the prefix-cache hit rate, TTFT/E2E/ITL p95 histograms, and constant-0 preemptions (FIFO admission, no wait queue)
- **TensorFold** (ashhart/TensorFold) — `/v1/models` (`owned_by: tensorfold`). No `/metrics`. Live tok/s comes from `/health` when it publishes `prompt_tokens_total`, `completion_tokens_total`, and `prefill_seconds_total` (decode is the completion-counter diff; prefill is prompt tokens ÷ prefill time). The slots tile reads `streams.max` and `requests_running` on CUDA 0.6.0, and `max_batch_size` on MLX. A stock server that only returns `{ok: true}` stays at 0. Decode/prefill benches and the showcase work regardless.
- **FreeToken** — `/v1/models` (`owned_by: FreeToken`), or a `/v1/stats` document with `throughput.decode_tps` / `prefill_tps` and lifetime prompt/completion totals. Those rates are FreeToken's own 5-second window (0 when idle). `requests.ttft_mean_ms` is a mean; `requests.p95_ms` is end-to-end latency, not TTFT p95. Queue length, slot capacity, and preemptions stay unset.
- **Pico** — `/v1/models` with `owned_by: dsgb10` (the engine tags its DeepSeek-on-GB10 namespace rather than its own name; matched exactly). During sparkDash decode benchmarks and Showcase, the dashboard reads a rolling decode rate from its own active streams, labelled **Dashboard streams**, and clears it when the run ends. This covers only requests made by sparkDash. Pico publishes no counters, gauges or stats endpoints — only `/health`, `/v1/models` and OpenAI `/v1/chat/completions` — so nothing can be read live from the engine itself. With **Settings → Stream-sample engines without gauges** on, the probe measures decode tok/s by sending one tiny streamed completion (a count to 60, greedy, thinking off, ~120 tokens) every 15 s and timing its own token window — the panel labels the figure **sampled**, because it is the engine's single-stream decode speed, not other clients' traffic; sampling pauses while a benchmark, showcase or model launch owns the unit, and prefill is not sampled (a prompt large enough to time it would be real load). With the setting off the panel shows no figure rather than a guessed one. Decode and prefill benches and the showcase work over its standard streaming chat completions (verified against a live Pico serving DeepSeek V4.1 Flash on a DGX Spark); the engine tiles (KV pool, TTFT histograms) stay hidden as with other gauge-less engines.
- **Pico** — `/v1/models` with `owned_by: dsgb10` (the engine tags its DeepSeek-on-GB10 namespace rather than its own name; matched exactly). During sparkDash decode benchmarks and Showcase, the dashboard reads a rolling decode rate from its own active streams, labelled **Dashboard streams**, and clears it when the run ends. This covers only requests made by sparkDash. Pico publishes no counters, gauges or stats endpoints — only `/health`, `/v1/models` and OpenAI `/v1/chat/completions` — so nothing can be read live from the engine itself. What it does keep is its front end's own request log: `dsfront` writes one line per finished request (prompt, cached and completion tokens, TTFT, decode tok/s) to stderr, which the recipe's `service.sh` sends to a file. On Linux units the probe follows that file read-only — it finds the `dsfront serve` process listening on the probed port and reads its stderr through `/proc/<pid>/fd/2` (locally, or over the unit's SSH connection), so no path is configured — starting at the end of the file and taking only what is appended. Each finished request is placed in time from the engine's own figures and the panel shows the tokens produced in the last minute, labelled **Engine log**: every client's traffic, trailing by up to one request because a request is logged when it ends. The same lines feed the output, prompt and cached token totals (counted from when the dashboard began following, not the engine's lifetime). If the log cannot be followed (stderr is not a regular file, no permission, the engine is pinned to another machine with `llmHost`, a Mac or Windows unit) nothing changes from the behaviour described here. With **Settings → Stream-sample engines without gauges** on, the probe measures decode tok/s by sending one tiny streamed completion (a count to 60, greedy, thinking off, ~120 tokens) every 15 s and timing its own token window — the panel labels the figure **sampled**, because it is the engine's single-stream decode speed, not other clients' traffic; sampling pauses while a benchmark, showcase or model launch owns the unit, and prefill is not sampled (a prompt large enough to time it would be real load). With the setting off the panel shows no figure rather than a guessed one. Decode and prefill benches and the showcase work over its standard streaming chat completions (verified against a live Pico serving DeepSeek V4.1 Flash on a DGX Spark); the engine tiles (KV pool, TTFT histograms) stay hidden as with other gauge-less engines.
- **vLLM / sglang** — `/v1/models`; sglang via `/server_info` (`last_gen_throughput` when metrics off; `/get_server_info` fallback), vLLM via Prometheus `/metrics` counters (scientific notation supported)

Rates are derived from per-probe cumulative counter diffs (or SGLang sticky throughput while it moves). Multiple ports can be added or removed at runtime without restarting the monitor.
Expand Down
33 changes: 33 additions & 0 deletions server/collectors/LlmProbe.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ export class LlmProbe {
this._liveDecodeTps = typeof options.liveDecodeTps === "function" ? options.liveDecodeTps : null;
/** Opt-in (Settings): stream-sample engines that publish no gauges. */
this._streamSampleEnabled = typeof options.streamSampleEnabled === "function" ? options.streamSampleEnabled : null;
/**
* Pico only: follows the engine front end's own request log on the unit
* (picoFrontLog.js). Given as a follower or as `(port) => follower`; absent
* unless the caller provides one, and then the probe behaves exactly as before.
*/
const picoLog = typeof options.picoLog === "function" ? options.picoLog(port) : options.picoLog;
this._picoLog = picoLog && typeof picoLog.poll === "function" ? picoLog : null;
/** True while a bench, showcase or model launch owns the unit — samples pause. */
this._streamSampleBlocked = typeof options.streamSampleBlocked === "function" ? options.streamSampleBlocked : null;
this._streamSampleMinIntervalMs = Number.isFinite(options.streamSampleMinIntervalMs)
Expand Down Expand Up @@ -559,6 +566,8 @@ export class LlmProbe {
}

_resetDetection() {
// Token totals go back to zero below; the log follower's must go with them.
this._picoLog?.reset?.();
this.serverIsOpenAI = null;
this.backendType = null;
this.authOpen = null;
Expand Down Expand Up @@ -1346,22 +1355,46 @@ export class LlmProbe {
// it; replaying it on later polls makes an idle engine look busy forever.
if (this.backendType === "pico") {
this.generationTps = 0;
// The engine's own request log, when it can be followed: every client's
// finished requests, so also the traffic the dashboard did not send.
const logged = await this._pollPicoLog();
const liveTps = this._liveDecodeTps?.(this.port);
if (Number.isFinite(liveTps) && liveTps >= 0) {
this.generationTps = liveTps;
this.generationTpsSource = "dashboard-stream";
this.decodeActive = liveTps > 0;
} else if (logged && logged.generationTps > 0) {
this.generationTps = logged.generationTps;
this.generationTpsSource = "engine-log";
this.decodeActive = true;
} else {
await this._maybeStreamSample();
// Idle by the engine's own log is a measured zero, not a missing figure.
if (logged && this.generationTpsSource == null) this.generationTpsSource = "engine-log";
if (this._liveDecodeTps && this.generationTpsSource == null) {
this.generationTpsSource = "dashboard-stream";
}
}
if (logged) {
this.totalOutputTokens = logged.totalOutputTokens;
this.totalPromptTokens = logged.totalPromptTokens;
this.totalCachedTokens = logged.totalCachedTokens;
}
}

return this._getSnapshot();
}

/** Figures from the Pico front-end log, or null when there is none to follow. Never throws. */
async _pollPicoLog() {
if (!this._picoLog) return null;
try {
return await this._picoLog.poll();
} catch {
return null;
}
}

/** Run at most one sample per minimum interval; never two at once; never while blocked. */
async _maybeStreamSample() {
if (!this._streamSampleEnabled || !this._streamSampleEnabled()) return;
Expand Down
99 changes: 99 additions & 0 deletions server/collectors/__tests__/LlmProbe.pico.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,102 @@ test("Pico uses its port's dashboard stream rate while synthetic sampling is blo
assert.equal(requested.filter((r) => r.path === "/v1/chat/completions").length, 0);
}
});

// ─── The engine front end's own request log ─────────────
/** Stands in for PicoFrontLog: what the log follower reports on each poll. */
function fakeLog(answers) {
const calls = { polls: 0, resets: 0 };
return {
calls,
poll: async () => { calls.polls += 1; const next = answers.shift(); if (next instanceof Error) throw next; return next ?? null; },
reset: () => { calls.resets += 1; },
};
}
const logged = (generationTps, output = 0) => ({
generationTps, totalOutputTokens: output, totalPromptTokens: output * 40, totalCachedTokens: output * 30,
});

test("Pico's decode comes from the engine log when it can be followed, with its token totals", async () => {
const requested = [];
const log = fakeLog([logged(131.5, 1421), logged(0, 1421), null]);
const probe = new LlmProbe({ lanIp: "127.0.0.1" }, 8888, { picoLog: (port) => { assert.equal(port, 8888); return log; } });
probe._fetch = picoFetch(requested);
const active = await probe.probe();
assert.equal(active.backend, "pico");
assert.equal(active.generationTps, 131.5);
assert.equal(active.generationTpsSource, "engine-log");
assert.equal(active.decodeActive, true);
assert.equal(active.totalOutputTokens, 1421);
assert.equal(active.totalPromptTokens, 56840);
assert.equal(active.totalCachedTokens, 42630);
// Idle by the log: a measured zero, still attributed to the log.
const idle = await probe.probe();
assert.equal(idle.generationTps, 0);
assert.equal(idle.generationTpsSource, "engine-log");
assert.equal(idle.decodeActive, false);
assert.equal(idle.totalOutputTokens, 1421);
// The log cannot be followed: no figure and no source, and the totals do not step back.
const lost = await probe.probe();
assert.equal(lost.generationTps, 0);
assert.equal(lost.generationTpsSource, null);
assert.equal(lost.totalOutputTokens, 1421);
// The figures came from the log: the engine was asked for no counters and sent no completion.
assert.deepEqual(requested.filter((p) => p === "/metrics" || p === "/v1/chat/completions"), []);
});

test("the dashboard's own live stream outranks the log; the log outranks a synthetic sample", async () => {
const requested = [];
let liveRate = 75;
const log = fakeLog([logged(140, 100), logged(140, 200), logged(0, 200)]);
const probe = new LlmProbe({ lanIp: "127.0.0.1" }, 8888, sampleOptions({
liveDecodeTps: () => liveRate,
picoLog: log,
}));
probe._fetch = picoFetchWithSample(requested, { stream: SAMPLE_STREAM });
const bench = await probe.probe();
assert.equal(bench.generationTps, 75);
assert.equal(bench.generationTpsSource, "dashboard-stream");
assert.equal(bench.totalOutputTokens, 100); // the log still counts what finished
liveRate = null;
const traffic = await probe.probe();
assert.equal(traffic.generationTps, 140);
assert.equal(traffic.generationTpsSource, "engine-log");
// Real traffic was measured, so no synthetic completion was sent on top of it.
assert.equal(requested.filter((r) => r.path === "/v1/chat/completions").length, 0);
// Idle by the log with sampling on: the opt-in sample behaves as it did before.
const idle = await probe.probe();
assert.equal(idle.generationTpsSource, "probe-sample");
assert.equal(requested.filter((r) => r.path === "/v1/chat/completions").length, 1);
});

test("a failing log follower never fails the probe, and is reset with the detection state", async () => {
const requested = [];
const log = fakeLog([new Error("ssh down"), logged(50, 10)]);
const probe = new LlmProbe({ lanIp: "127.0.0.1" }, 8888, { picoLog: log });
probe._fetch = picoFetch(requested);
const failed = await probe.probe();
assert.equal(failed.available, true);
assert.equal(failed.generationTps, 0);
assert.equal(failed.generationTpsSource, null);
assert.equal((await probe.probe()).totalOutputTokens, 10);
probe._resetDetection();
assert.equal(log.calls.resets, 1);
assert.equal(probe.totalOutputTokens, 0);
});

test("the log follower is polled for Pico only", async () => {
const log = fakeLog([logged(99, 99)]);
const probe = new LlmProbe({ lanIp: "127.0.0.1" }, 8888, { picoLog: log });
probe._fetch = async (url) => {
const path = new URL(String(url)).pathname;
if (path === "/v1/models") {
const payload = { data: [{ id: "m", owned_by: "vllm" }] };
return { ok: true, status: 200, json: async () => payload, text: async () => JSON.stringify(payload) };
}
return { ok: false, status: 404, json: async () => ({}), text: async () => "" };
};
const snap = await probe.probe();
assert.notEqual(snap.backend, "pico");
assert.equal(log.calls.polls, 0);
assert.notEqual(snap.generationTpsSource, "engine-log");
});
Loading