- Python 39.3%
- JavaScript 36.2%
- CSS 23.9%
- Nix 0.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
A deployment should be able to restore its own wording for the gateway box, the router subtitle, the KV export and import links, the broker footer, the empty log line, the missing mode line and the inspect notice. Every new key defaults to the text it replaces, so nothing renders differently unless a config is passed. renderRecipeDrift takes an optional opts.switchHint for the drift note's closing phrase. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> |
||
| telemetry | ||
| web | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
inference-flow
A live view of a prefill/decode-disaggregated (P/D) LLM inference flow: which requests are being prefilled on the prefill engine, handed off, and decoded on the decode engine, with per-engine throughput, KV-cache use, GPU state and a request log. The repository has two parts:
web/: a browser library (plain JavaScript, CSS, no build step) that draws the flow view and the supporting panels. Its tests are Pythonunittestplus headless Chromium.telemetry/pd-telemetry.py: a stdlib-only Python poller. It reads the router, both vLLM engines (Prometheus/metrics), the handoff broker's stats over its abstract unix socket,nvidia-smi, and the router's request log. It serves one JSON snapshot and a request-record feed over HTTP for the browser library. It is read-only: it never sends requests that change router, broker or engine state.
Wire format
The poller's JSON keys are kept for compatibility, so the engine roles map as follows:
| JSON key | Meaning |
|---|---|
tt |
prefill engine |
rtx |
decode engine |
router |
P/D router |
broker |
handoff broker |
gpus |
nvidia-smi GPU sample |
The browser library's pdFlowStart config (below) sets the labels shown for
these roles.
pd-telemetry
Run it with Python 3 (no third-party packages), or through the flake:
nix run .#pd-telemetry -- --help
| Flag | Default | Meaning |
|---|---|---|
--bind |
127.0.0.1 |
Address the HTTP server binds. |
--port |
8791 |
HTTP port. |
--router-url |
http://127.0.0.1:8790 |
Base URL of the P/D router (/router/stats, /health). |
--rtx-metrics-url |
http://127.0.0.1:8765/metrics |
Prometheus /metrics of the decode engine. |
--tt-metrics-url |
required | Prometheus /metrics of the prefill engine. |
--results-dir |
required | Directory with pd-router.jsonl, pd-mode.log and the serve-<LABEL>.log decode logs. Read-only. |
--broker-socket |
required | Name of the handoff broker's abstract unix socket (without the leading NUL byte). |
--nvidia-smi |
/run/current-system/sw/bin/nvidia-smi |
nvidia-smi binary; a wrapper also works. |
--state-file |
empty | JSON file for the day/week/all-time records. Empty keeps them in memory. |
--interval-s |
0.1 |
Sample and stream cadence for live sources, in seconds. |
Endpoints:
GET /pd/state: latest snapshot.GET /pd/requests?since=N&limit=M: request records withseq > N.GET /pd/stream?since=N: server-sent events, one snapshot plus new records per interval.GET /healthz:{"ok": true}.
Browser library: pdFlowStart(root, cfg)
cfg is optional. Every key has a generic default, and the result is stored
as pdFlow.config, merged with the defaults.
| Key | Default | Meaning |
|---|---|---|
models |
/.*/ |
RegExp or string source: gateway model names that count as P/D traffic. |
intro |
generic text | Help paragraph under the title. |
recordsNote |
kept by pd-telemetry · survive restarts |
Note on the records panel. |
handoffNote |
handoff broker · read-only inspect |
Prefix before · N µs per call. |
hosts.gateway.label |
gateway |
Label for the gateway host. |
hosts.prefill |
{ key: 'prefill', label: 'prefill host' } |
key indexes x.hosts[...]. |
hosts.decode |
{ key: 'decode', label: 'decode host' } |
key indexes x.hosts[...]. |
engines.prefill.label |
prefill engine |
Label for the prefill engine. |
engines.decode.label |
decode engine |
Label for the decode engine. |
gateway.name |
gateway |
Inline name of the gateway in the legend, the status pill, the signals row and the summary. |
gateway.title |
Gateway |
Title of the gateway box, and of its signals row. |
gateway.detail |
API /v1 |
Subtitle of the gateway box. |
router.detail |
adaptive |
Subtitle of the router box. |
captions.exportLink |
KV export |
Label of the KV export link, and its legend entry. |
captions.importLink |
pinned memfd → handoff connector |
Label of the import link. |
captions.arenaFoot |
handoff broker · free-list arena |
Footer of the broker box. |
captions.logTag |
handoff |
Word in the empty log line: No <logTag> lines in the current serve log. |
captions.noModeLine |
no mode line |
Shown when the router reports no mode line. |
captions.inspectMissing |
this broker answers op=stats only: the detail needs the op=inspect endpoint |
Shown when the broker has no inspect data. |
gateway, router and captions are merged per key, like hosts.
Browser library: renderRecipeDrift(record, opts)
web/recipe-drift.js returns the serving-recipe panel for a pod's record as a DOM
node, or null when the record publishes no recipe state. opts is optional:
| Key | Default | Meaning |
|---|---|---|
switchHint |
a switch on the host |
Ends the drift note: Reset on the host with <switchHint>. |
Using it from a flake
{
inputs.inference-flow.url = "git+https://<host>/<owner>/inference-flow";
outputs = { self, nixpkgs, inference-flow, ... }: {
# inference-flow.packages.x86_64-linux.web is a directory of the library
# files (without tests). Copy it into your static site:
# cp -r ${inference-flow.packages.x86_64-linux.web} $out/lib
# and run the poller from
# inference-flow.packages.x86_64-linux.pd-telemetry
};
}
Tests
# telemetry (stdlib unittest)
python3 -m unittest discover -s telemetry/tests -p 'test_*.py'
# browser library (needs Chromium; CHROMIUM overrides the lookup on PATH)
CHROMIUM=/path/to/chromium python3 -m unittest discover -s web/tests -p 'test_*.py'
# everything, as the flake runs it
nix flake check
License
MIT. See LICENSE.