PR #553 — Add vLLM-compatible per-request metrics
Verdict: Not worth it as it stands. Close this as a separate flag. The vLLM metrics shape itself is legitimate (third-party gateways read it), but the object belongs on the runtime's instants inside whatever single timing mechanism the project chooses — the same author's #552, stacked on #548 — not on a new opt-in flag in the HTTP layer.
I read the charter, the full diff (11 files, ~+300/−10), vLLM's per-request-metrics spec, the helios runtime/encode/latency paths, #536/#548/#551/#552, and llama-swap v250's buildMetrics. Everything below is re-verified at head d6d7c7f9; there are no new commits since the previous review.
What it adds
helios/src/server/http.rs:122-194 adds RequestTiming (HTTP admission, first/last output token, first content, seen/committed token counts). http.rs:479 builds it; http.rs:562-573 ticks it on Token/LogprobToken; http.rs:614 adds the committed count on Finished; http.rs:660-672 and :686-688 attach timing.value() to the last frame before [DONE], or to the non-streaming body. Gated by state.per_request_metrics && matches!(protocol, Chat | Completions) (http.rs:458-459). Plumbing spans flare-cli/src/cli.rs:624-626,697-699,1519-1522, flare-cli/src/main.rs:355-356, flare/src/configuration.rs:31-34,136-138, flare/src/settings.rs:32,159,284-297, flare/src/controller.rs:2563, helios/src/server.rs:131-133,150,176,335, helios/src/server/config.rs:357-361; docs at docs/api.md:882-903, docs/cli-design.md:738,1319-1320.
Against the charter
"Solve the right problem in the right place" — fails. The PR concedes the HTTP boundary is wrong: queue_time_ms is a hard-coded Value::Null (http.rs:189), documented as such (docs/api.md:896), so one of six fields can never hold a value. tokens_per_second runs from HTTP admission (http.rs:181-185), folding transfer wait, scheduler queue, and prefill into what vLLM defines as generation throughput. The correct instants already exist in the runtime — runtime.rs:899 (arrival_ns), :920-922 (enqueue_ns), plus the committed-token stamps #548 adds — which is where #552 renders from.
"What gets merged" — no authorization. The charter accepts maintainer requests, roadmap items, reproducible bugs, measured perf/memory issues, or bad docs. This has none: the observability ask #536 is closed by #548; #551 is the author's own gap report written for this work; "vLLM does it / gateways read it" is competitor parity, which docs/core-design.md:210-219 explicitly disclaims ("Flare does not aim for vLLM's feature matrix") and which the earlier #548 review already ruled out. Per-request billing/SLA also sits outside the vision ("not trying to be a general-purpose production server").
"Stay focused / no random switches" — fails. A third enable-* boolean with a matching [server] key, threaded through Run, OrbitRun, and OrbitPush, to run a second timing mechanism beside latency.rs:99-112 FirstResponseSamples and the RequestTimes arriving with #548. It is single-polarity (main.rs:355-356 ORs CLI and config), so [server] per_request_metrics = true cannot be disabled from the command line — unlike the project's --history-drafts/--no-history-drafts and --mtp-adaptive-verification/--no-… pairs (cli.rs:974-1021).
Honest pluses: off by default; wire format, runtime, and prepared core untouched when off; Bootstrap rejects a non-boolean (config.rs:357-361); both docs updated; independent of #548/#549; and the description follows the charter's four-part form, states its own limitation, and marks what was not run.
Cost: the CPU cost is trivial (one Instant::now() per output token, a vDSO read). The cost is conceptual: one more flag, one more config key, one more object carrying vLLM's names with different meanings, and six fields of divergence for docs/api.md to keep true.
Concrete defects (re-verified)
- "No cost when off" is false.
RequestTiming::newis unconditional (http.rs:479) andtiming.token()runs outside anyper_request_metricscheck (http.rs:562-573), so every request takes a clock read per output token. PR body: "none while it is off";docs/api.md:900-903: "disabling it reads no clock for timing". Both wrong, both oneiffrom correct — the claim looks untested. - Any request with
stopstrings gets an all-null object. Withprompt.stop_stringsnon-empty the runtime emitsGenerationEvent::Protocolinstead ofToken— both atruntime.rs:446-458and atruntime.rs:1961-1971(TextStops::finish).http.rs:574-576handlesProtocolwithouttiming.token(), so TTFT,generation_time_ms,mean_itl_ms,tokens_per_secondand content-TTFT are all null for a very common request shape. No test. time_to_first_content_token_msinverts vLLM's semantics. Fed bylatency::stream_text(http.rs:502-506,663→latency.rs:116-142), which matchesdelta.reasoning_content,delta.reasoning,thinking. vLLM's spec says this field excludes reasoning and tool-call output so a gateway can separate "started emitting" (108.2 ms) from "started answering" (268.2 ms). Here it collapses to TTFT on every thinking model — the models this project targets. The author's own validation run reports 473.78 and 473.79 ms.n > 1is not suppressed. Reachable on Completions (decode.rs:742-755). vLLM nulls the object forn > 1and multi-prompt; heredocs/api.md:900-901promises one object for the whole response, andtiming.token()fires for every choice's tokens, sofirst/lastare the outermost across choices whilemean_itl_msdivides that span byseen_tokens - 1(http.rs:171-176) — overstating per-token speed ~n×.- Placement contradicts both the description and vLLM.
frames[..done].last_mut()(http.rs:667-670) targets whatever precedes[DONE], andencode.rs:647-660pushes the usage chunk first — so withstream_options.include_usage(vLLM's documented requirement) the object rides the usage chunk; without it, thefinish_reasonchunk, where vLLM consumers do not look. The PR body says thefinish_reasonchunk; the code does not, once usage is enabled. - Mixed denominators.
mean_itl_msdividesseen_tokens(onlyTokenevents) whiletokens_per_seconddividescommitted_tokens, which includes EOS and tokens withheld by text stops (docs/api.md:319). Undocumented divergence. - Thin coverage. Two helios HTTP tests (
phase_tests.rs:4475-4552), one flare settings test, one CLI test. Nothing for Completions,n > 1, multi-prompt,include_usagestreams, absence on Messages/Responses, string stops (defect 2),max_tokens: 0, or the off-state clock read (defect 1).
Simpler ways to the same end
- #552 (open draft, same author, stacked on #548) emits llama.cpp (not opened)'s
timingsfrom the runtime's instants: correct scheduler boundary, realprompt_ms/predicted_ms/cache_n, draft counts, all four protocols, no flag, no config key, and it closes #551 on its own terms. - Already shipped:
return_token_ids+return_token_timestampsgivetoken_timestamps_nsandperformance{ingress_ns, enqueue_ns, reused_prompt_tokens}(observation.rs:56-75,http.rs:694-696), from which all six of this PR's fields can be computed exactly — including queue time, which this PR can never report. Per request, opt-in, no new flag.
The decisive harm: merging this with #552 degrades the stated consumer
llama-swap v250 internal/server/metrics.go buildMetrics applies timings first, then lets metrics overwrite it: promptPerSecond = (inputTokens − cached)/time_to_first_token_ms, tokensPerSecond = 1000/mean_itl_ms. With both objects in one body this PR's HTTP-layer numbers win, and because #552's prompt_n is already prompt-minus-cache, cache_n is subtracted twice — a fully cached row reports a negative prompt rate. That is exactly the limitation this PR's own evidence section admits; merging both guarantees it. Merging the pair is strictly worse for the gateway than merging #552 alone.
What I would ask for instead
Close this PR as a separate flag. If maintainers want the vLLM metrics shape for third-party gateways, fold it into the single runtime-sourced timing mechanism and then: drop the flag and the [server] key; exclude reasoning from time_to_first_content_token_ms; suppress or null the object for n > 1 and multi-prompt; fix the Protocol/text-stop path; remove the unconditional Instant::now(); and make queue_time_ms the real admission-to-first-scheduled-step interval rather than a constant null.
Nothing here disputes the author's evidence discipline — the description follows the charter's four-part form, states its own limitation, and marks what was not run. The disagreement is about layer and scope, not effort, and the author's own #552 is the better vehicle for the same goal. That both my earlier assessment (note #5) and this re-verification (notes #6, #7) reach the same verdict on unchanged code is itself the finding: no further round is needed.