Skip to content

Log sidecar

sidecar/asr_log_sidecar.py runs on every inference host. It streams the vLLM journal and allow-listed telemetry commands to the bench client as NDJSON over HTTP on port 8001. The client writes each line into the run's JSONL as a server_log event.

It uses only the standard library and runs on the system Python 3.9 that AL2023 ships.

Endpoints

Path Streams
GET /health Host name, unit, command names, and what the vLLM server is actually running (not streamed; see below)
GET /journal?from=invocation The current run of vllm.service, from its start
GET /journal?since=<unix-seconds> The journal from a timestamp
GET /journal?cursor=<cursor> The journal after a cursor (the client uses this to resume)
GET /command/<name> Stdout of a configured command, one JSON line per output line
GET /ping A tiny JSON body with the host's clock (not streamed). Used for round-trip times.
POST /sink Reads and discards the body, then returns {"bytes", "seconds"}. Used for upload times.

/ping, /sink and /health keep the connection open (HTTP/1.1), like the vLLM client does. Streams close it to end the body. Nagle's algorithm is off: with it on, each response waited about 40 ms for the client's delayed ACK.

Journal lines are journald's own JSON (journalctl -o json), so they include MESSAGE, _PID, __REALTIME_TIMESTAMP, __CURSOR and more. Command lines are wrapped as {"ts": ..., "data": <parsed JSON>}, or as {"ts": ..., "line": "..."} when the line isn't JSON.

/health has a vllm object with the server's live state, read from /proc and the installed env file when it's asked. The client logs it at the start of every run, so each run records the server it measured, and the analyzer can catch a host whose installed settings have drifted from the repository's:

Field Meaning
argv The running vllm serve command line, from the vllm executable on. null when no server is running.
api_servers vLLM API server processes. 1 when vLLM starts no separate ones, because the main process serves.
engines Engine-core processes, one per data-parallel engine.
env The installed /etc/snap-asr-bench/vllm.env as key and value (ASR_SIDECAR_VLLM_ENV names another file). A key containing TOKEN, SECRET, PASSWORD or KEY shows <hidden>. null if unreadable.

If /proc can't be read, vllm holds {"error": ...} instead, and /health still answers.

Commands are fixed in the env file and the client can only choose by name. That stops the unauthenticated port from becoming remote code execution.

Quick install

make install-nvidia and make install-trn2 include the sidecar. To install it on its own, from ~/snap-asr-bench:

make install-sidecar-nvidia   # g4dn, g7e and g6
make install-sidecar-trn2     # trn2

Install by hand

From ~/snap-asr-bench. On trn2, use deploy/trn2/sidecar.env instead of deploy/nvidia/sidecar.env:

sudo mkdir -p /opt/snap-asr-bench /etc/snap-asr-bench
sudo install -m 0755 sidecar/asr_log_sidecar.py /opt/snap-asr-bench/asr_log_sidecar.py
sudo install -m 0644 deploy/nvidia/sidecar.env /etc/snap-asr-bench/sidecar.env
sudo install -m 0644 deploy/systemd/asr-log-sidecar.service /etc/systemd/system/asr-log-sidecar.service
sudo systemctl daemon-reload
sudo systemctl enable --now asr-log-sidecar

The unit runs as ec2-user in the systemd-journal group so it can read the vLLM journal.

Check

On the host:

curl -s localhost:8001/health
curl -sN 'localhost:8001/journal?from=invocation' | head -3
curl -sN localhost:8001/command/nvidia-smi | head -3

From the bench host, use the host's private IP. The security groups only allow this traffic from the bench subnet.

Telemetry commands

Host Name Command
g4dn, g7e, g6 nvidia-smi nvidia-smi --query-gpu=... --format=csv,noheader,nounits --loop-ms=500
trn2 neuron-monitor /opt/aws/neuron/bin/neuron-monitor (JSON report every 5 s by default)

The CSV columns for nvidia-smi are, in order: timestamp, index, name, driver_version, pstate, utilization.gpu, utilization.memory, memory.used, memory.total, power.draw, temperature.gpu, clocks.sm, clocks.mem.

To add a command, edit ASR_SIDECAR_COMMANDS in /etc/snap-asr-bench/sidecar.env and restart the sidecar. The client follows every command listed in /health. All keys are in Configuration.