Correctness review of PR #548 (head 055663a) — request histograms and vLLM-parity metrics
Key findings
- Should fix — the HTTP e2e/choice observations are gated by a response-wide flag while completions are per choice, so in a response where one choice trips the parallel-tool limit the sibling choices the runtime counted as completed record no
flare_request_e2e_seconds,flare_request_choices, orflare_request_max_choice_generated_tokensobservation (helios/src/server/http.rs:604-612vshelios/src/server/protocol/encode.rs:89,505-507,helios/src/server/http.rs:530). This makesflare_request_e2e_seconds_count < flare_requests_completed_totalfor a causedocs/api.md:311-318does not list. Reachability through the public API is currently blocked (tools are rejected for/v1/completions, andn > 1is rejected for every protocol that carries tools —helios/src/server/protocol/decode.rs:813-815,:753-755), so the defect is latent, not live. - Resolved since the last round: the previous blocking finding —
helios/src/server/metrics/process.rs:68(not opened) calling the feature-gatedcrate::runtime_core::open_descriptors()under--features server— is gone; commit54e06b30deleteshelios/src/server/metrics/process.rs(not opened) and its call site, and noprocess_*series remain in the tree. That also makes the older "docs contradictflare_-only naming" nit moot. - Everything else I checked in the runtime half holds:
Metrics::request_completedis the sole writer of the completion counter, the histogram populations match the documented ones, andRequestRecordsurvives park/requeue with itsmax_tokensandpreemptions. - Nits: the non-stream e2e observation is taken before the body is ever polled, which is looser than the "delivered response" wording in the docs; the TPOT/decode preemption span is not documented although it is real; and
!countathttp.rs:606is dead (count responses return at:284-286).
Should fix 1 — response-wide tool-limit gate drops sibling choices' HTTP observations
Where: helios/src/server/http.rs:604-612
// One observation per successful response: a tool-limit cancellation reaches
// this point but the runtime counts it as cancelled, so it is excluded.
if !count && !encoder.tool_limit_reached {
state.model.metrics().response_completed(
admitted_at.elapsed().as_nanos() as u64,
decoded.request.choices,
&generated,
);
}
Evidence chain (all read in context):
tool_limit_reachedis one flag for the whole response: declaredhelios/src/server/protocol/encode.rs:89, initialisedfalseat:142, set at:505-507(if !self.parallel_tool_calls && self.outputs[index].has_tools() { self.tool_limit_reached = true; break; }), and consumed without an index athelios/src/server/http.rs:476-481and:531-532, and again at:569-573.- Per-choice state is separate:
generated[index] = generated_tokens(http.rs:530), one element per generation (let mut generated = vec![0u32; size],http.rs:407), andsize = decoded.request.generation_count()(http.rs:217-220,helios/src/server/inference.rs:198-209). - The runtime counts each choice as its own completed request and has already run the counter and histograms before the HTTP layer decides:
helios/src/server/runtime.rs:1875-1884(stop path,output_limit: false,reason == "stop") and:2038-2047(finish path,output_limit: reason == "length",reasoncomputed at:2037). Cancellation has its own counter, incremented elsewhere (runtime.rs:1329-1330,:1350,:1373,:1420). - The tool-limit stop is a client-side decoder cancel (
http.rs:569-573→generation.cancel()), issued after the runtime has already completed the request. So for a sibling choice that finished naturally, the runtime both counted it and observed all runtime histograms, buthttp.rs:606suppresses the HTTP observations for the whole response. - The documentation says the exclusion is per response only for "responses the runtime records as cancelled" (
docs/api.md:311-318), and the vLLM mapping table repeats it (docs/api.md:501). A sibling choice is not such a response's completion — it is a completed request whose HTTP measurement vanished.
Consequence: for any response that mixes a naturally finished choice with a choice that trips the parallel-tool limit, flare_request_e2e_seconds_count, flare_request_choices, and flare_request_max_choice_generated_tokens under-count relative to flare_requests_completed_total by every surviving sibling. That is exactly the counter/histogram divergence the PR set out to remove by funnelling the counter and histograms through one function (helios/src/server/metrics.rs:543-558).
Reachability (verified this round — this is what makes it a "should fix" and not "blocking"):
n > 1is accepted only forProtocol::Completions:helios/src/server/protocol/decode.rs:742-755(if protocol != Protocol::Completions && choices != 1 { return Err("n must be 1") }).- Tools are rejected outright for Completions:
helios/src/server/protocol/decode.rs:813-815(reject(&body, &["tools", "tool_choice"])), sotool_limit_reachedcan only be set on Chat/Messages/Responses, which are restricted to one generation by:753-755. - Therefore today no public request reaches "several generations plus tools". The code is still wrong in scope, and it becomes live the moment tools are allowed on Completions (which the Completions decoder currently rejects as unsupported, a restriction a later change could lift).
Fix (minimal, per-choice): decide per finished generation instead of per response — e.g. record which indices were finished with crate::output::Termination::Cancelled at http.rs:531-532 and pass only the surviving choices' counts, still observing e2e once when at least one choice was delivered. Alternative if the behaviour is intended: state in docs/api.md:311-318 that a response in which any choice hits the parallel tool limit contributes no e2e/choice observations for any of its choices.
What would settle it: a phase test of the kind used at helios/src/server/runtime/phase_tests.rs (not opened) (disabled_parallel_calls_complete_http_and_stop_decoding, added by this PR) that builds a two-choice response where one choice trips the tool limit and asserts flare_request_e2e_seconds_count against flare_requests_completed_total. Today such a request cannot be built through the decoder, which is itself the evidence that the path is latent.
Verified correct (checked in code — no finding)
- The counter and the histograms cannot diverge inside the runtime.
Metrics::request_completed(helios/src/server/metrics.rs:545-603) contains the only increment of the completion counter (:558), and both former directfetch_addsites now call it (helios/src/server/runtime.rs:1875-1884,:2038-2047). - Populations match the documentation.
output_limitedis added only when the completion reportedreason == "length"(runtime.rs:2037→:2045→metrics.rs:559-561), sostop = completed − output_limited. Time histograms requirefirst_token_ns(metrics.rs:577-602), so a zero-token completion enters only the token-count, preemption and output-limit observations — matchingdocs/api.md:328-341. Decode and TPOT requiregenerated_tokens > 1(metrics.rs:593-602), matchingdocs/api.md:340-341.request_max_tokensis observed only when the limit is nonzero (metrics.rs:570-573). RequestRecordsurvives the lifecycle. It moves withIncomingthrough parking and readmission (runtime.rs:2130,:2660),max_tokensis set once under!readmitted(runtime.rs:1566-1570), andpreemptionsis bumped at the park (runtime.rs:2110), so a preempted, resumed request still yields exactly one queue/prefill/TTFT observation and the right preemption count.cache_lookup_tokensis at the same site ascache_lookups(helios/src/scheduler.rs:1601,:1802), zero for prompt-logprob lookups, and carried in the stats copy (metrics.rs:771).- Admission rejections are wired only at the three stated paths (
helios/src/server.rs:816,helios/src/server/http.rs:240,helios/src/server/runtime.rs:869,:945); the paused-admission 503 and the unavailable-runtime 503 are not counted, matchingdocs/api.md. /v1/messages/count_tokenscannot enter the e2e histogram: it returns athttp.rs:284-286, before the delivery stream is created.- The first-response sampler is unchanged in shape: one observation, latched by
recorded(helios/src/server/latency.rs:116-127), so a stream that offers text and then fails still records it (docs/api.md:319-321), and the median gauge and 60-second window are untouched.
Nits
http.rs:606's!countis dead.countresponses return athttp.rs:284-286, before the delivery stream exists, so the condition can never be false there. Harmless, but it suggests a guard that does not exist for the streaming path.- The non-stream observation is taken before the body is polled.
response_completedruns inside the generator athttp.rs:606-612, while the non-stream body is streamed lazily afterwards (http.rs:646-651). A client that receives headers and drops the connection is therefore still counted, whereas a stream client that abandons before draining is not.docs/api.md:311-318documents only the streaming half ("requires the client to drain the body"), so the word "delivered" is generous for the non-stream case. Either note the asymmetry or move the observation into the body wrapper. - The preemption span is documented for inter-token latency but not for decode/TPOT.
docs/api.md:342-345says the interval spanning a preemption is included forflare_inter_token_latency_seconds; the same is true offlare_request_decode_secondsandflare_time_per_output_token_seconds, which are computed from first-to-last committed token (metrics.rs:593-601) and therefore also include the wait for readmission. One sentence next todocs/api.md:340-341would remove the guess.
Evidence limitations
- No compiler or live scrape was available here; the resolved build-break claim is established from the file list (no
metrics/process.rs(not opened) among the 9 changed files) plus a tree-wide search finding noprocess_*series and nometrics::processreference.cargo check --features serverwould settle it in seconds. - The author's own evidence (814 passed / 1 failed, the single failure being a missing
FLARE_TEST_TEMPLATE_DIR) is disclosed, and the unrun items (GPU workload, live scrape, exported core, Windows build) are disclosed too (AGENTS.md(not opened) on disclosing unrun checks). - The claim that this PR and #549 "merge in either order" is asserted, not tested; they touch adjacent rows of the same fixture and the same docs table, so a rebase is plausible but unverified.
- The tool-limit reachability argument depends on the current decoder restrictions (
decode.rs:753-755,:813-815); if any supported protocol is added that accepts bothn > 1andtools, finding 1 becomes live immediately.
Open questions
- Should a multi-choice response in which one choice hits the tool limit contribute e2e and choice observations for the choices that completed? The fix in finding 1 depends on that product decision.
- Is the non-stream e2e observation intended to count a response whose body the client never reads? If so, the docs should say it; if not, the observation should move into the body stream.