Correctness report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/5fb66a3b-769e-4861-802d-6e074d35c55a.md

Correctness review of PR #548 (head 6624592) — per-request histograms and vLLM-parity metrics

Key findings

  1. No blocking issues at this head. The build break that earlier rounds flagged (a permanent crate::runtime_core::open_descriptors() call from helios/src/server/metrics/process.rs (not opened) while runtime_core is feature-gated at helios/src/lib.rs:22-26 (not opened)) is gone: commit 54e06b30 deleted metrics/process.rs (not opened) and its call site, the PR now changes 9 files and none of them is metrics/process.rs (not opened) (pr_files), and no process_* series or metrics::process reference remains in the tree.
  2. One should fix remains (carried over, latent): the HTTP end-to-end/choice observations are gated on a response-wide flag while completions are per choice, so a sibling choice the runtime counted as completed records none of flare_request_e2e_seconds, flare_request_choices, or flare_request_max_choice_generated_tokens (helios/src/server/http.rs:604-612 vs helios/src/server/protocol/encode.rs:89,505-507, helios/src/server/http.rs:407,530). Unreachable through the public API today, but wrong in scope and silent when it happens.
  3. Four nits, all minor: a dead !count guard, a non-stream e2e observation taken before the body is polled (undocumented asymmetry with the stream rule), the decode/TPOT preemption span being undocumented although it is real, and flare_model_step_tokens observing a 0-token sample for a step whose lanes all errored.
  4. The runtime half holds up. The counter and the histograms cannot diverge inside the runtime, the recorded populations match docs/api.md line by line, RequestRecord survives preemption with its max_tokens and preemption count, cache_lookup_tokens sits at the one cache_lookups site, and the four admission-rejection writers are exactly the documented ones.
  5. The newest commit (66245920) is sound. Substituting GraphKind::samples() for the inline matches! is an exact population match, and moving the first_scheduled_ns stamp to after input packing cannot leave a counted completion with an unset instant.

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 (each link read in context):

Consequence: in a response mixing 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 — exactly the counter/histogram divergence this PR set out to remove by funnelling both through request_completed. It is also the divergence the PR description asserts does not exist ("the completed-counter delta was 24, equal to the time-to-first-token and generated-token histogram count deltas").

Reachability (verified — this is why it is should-fix, not blocking):

Fix: decide per finished generation rather than per response — record which indices were finished with Termination::Cancelled at http.rs:531-532 and pass only the surviving choices' counts to response_completed, still observing e2e once when at least one choice was delivered. If the response-wide behaviour is intended, say so in docs/api.md:311-318: a response in which any choice hits the parallel tool limit contributes no e2e or choice observations for any of its choices.

What would settle it: a phase test in the style of disabled_parallel_calls_complete_http_and_stop_decoding (helios/src/server/runtime/phase_tests.rs) that builds a two-choice completions request with tools and asserts flare_request_e2e_seconds_count against flare_requests_completed_total. Today the request cannot even be built through the decoder, which is itself the evidence that the path is latent.


Nits

  1. helios/src/server/http.rs:606 — the !count conjunct is dead. Count responses return at http.rs:284-286, long before the delivery stream is constructed, so the condition is always true there. Harmless, but it reads as a guard that does not exist.
  2. helios/src/server/http.rs:606-612 vs :642-651 — non-stream e2e is observed before the body is polled. response_completed runs inside the generator, whereas the non-stream body is streamed lazily afterwards; a client that takes the headers and drops the connection is still counted, while a stream client that abandons before draining is not (the documented rule at docs/api.md:317-318, "For a stream it is observed when delivery completes, which requires the client to drain the body"). Document the asymmetry or move the observation into the body wrapper.
  3. helios/src/server/metrics.rs:593-601 vs docs/api.md:340-346 — the preemption span is documented only for inter-token latency. flare_request_decode_seconds and flare_time_per_output_token_seconds are computed as last-minus-first committed token, so they also include the wait for readmission; only flare_inter_token_latency_seconds says so. One sentence beside docs/api.md:340-341 would remove the guess.
  4. helios/src/server/runtime.rs:1721-1722 — model_step observes a zero-token sample for a fully failed step. self.metrics.model_step(prefill + generated.len() as u64) runs for every kind in GraphKind::samples(), including a step whose every lane completed with an error status (status 3), so a 0 enters flare_model_step_tokens and lowers its mean. docs/api.md:383-386 neither excludes zero-token steps nor mentions error steps. Either skip the observation when tokens == 0, or note it in the doc.

Verified in code — no finding


Open questions

  1. 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 for the should-fix depends on that product decision.
  2. Should a non-stream response whose body the client never reads be counted in flare_request_e2e_seconds? The code says yes, the doc is silent; the stream path says the opposite.
  3. Is a zero-token model step (all lanes errored) meant to be a flare_model_step_tokens sample?

Evidence limitations