Correctness report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/7958d35c-ca25-4bfd-b069-a6228fd0ec29.md

Verdict: blocking issues

Correctness review — PR #548 "Add request latency histograms and process metrics" (head a34c4d06)

I read all changed files in context (metrics.rs, metrics/process.rs, runtime.rs, http.rs, latency.rs, server.rs, phase_tests.rs, docs/api.md), followed both request_completed call sites and both HTTP delivery arms, and checked the change against the charter and AGENTS.md.

Key findings

  1. Blocking — helios/src/server/metrics/process.rs:68 calls crate::runtime_core::open_descriptors(), but runtime_core is compiled only under #[cfg(feature = "runtime-core")] and the server feature does not enable it. --features server (a documented and CI-adjacent configuration) no longer compiles. Introduced by commit d64c3ea3 ("Exclude cancelled responses and reuse host helpers").
  2. Should fix — the new e2e exclusion is response-scoped while runtime completions are per generation. A response whose sibling choice trips the tool limit loses its flare_request_e2e_seconds observation even for generations that the runtime counted as completed, so flare_request_e2e_seconds_count < flare_requests_completed_total and the new docs/api.md invariant is wrong for multi-choice responses.
  3. Nit — parse_stat's hard-coded state-character allow-list (process.rs:26) makes every stat-derived metric silently vanish if a kernel reports a state letter outside "RSDZTtWXxKPI".

Blocking 1 — process.rs references a feature-gated module; --features server stops building

Where: helios/src/server/metrics/process.rs:68

let open_fds = crate::runtime_core::open_descriptors();

Why it does not resolve. helios/src/lib.rs:25-26 declares the module conditionally:

#[cfg(feature = "runtime-core")]
pub mod runtime_core;

helios/Cargo.toml:21 defines runtime-core = ["dep:serde", …], and helios/Cargo.toml:25 defines server = ["dep:serde", "images", "grammar", "dep:axum", …] — it does not include runtime-core. So with --features server alone the path crate::runtime_core does not exist and the crate fails to compile, taking the whole server module tree with it.

This is a regression from the previous head. Before d64c3ea3, the only references to crate::runtime_core under helios/src/server/ were inside the #[cfg(feature = "runtime-core")]-gated session module (helios/src/server.rs:26-29) and the gated runtime/prompt_tests.rs:13 (behind #[cfg(all(test, feature = "runtime-core"))], helios/src/server/runtime.rs:3983). search_code for runtime_core under helios/src/server now returns exactly three hits: session.rs:10 (gated), runtime/prompt_tests.rs:13 (gated), and metrics/process.rs:68 (ungated). The gating in server.rs:26-29 shows the crate is meant to build with server alone.

Configurations that break: docs/model-development.md:99 (cargo test … --features server --lib frontend::), docs/model-development.md:100 (--features server --test message_boundaries), and docs/scheduling-runtime-design.md:735-736 (--features server --lib scheduler:: and … --lib server::runtime::phase_tests::). CI (.github/workflows/native-serving.yml:63,68), flare-cli/Cargo.toml:27,44 and AGENTS.md:317 all pass runtime-core,server, so the primary CI lane would not catch this — precisely the configuration nobody tests is the one the docs tell contributors to use.

The other two helpers this commit adopted are fine, which isolates the mistake: crate::os::page_size() (process.rs:61) and crate::os::raise_open_file_limit(0) (process.rs:70) resolve everywhere because mod os; is unconditional (helios/src/lib.rs:19) and os.rs:8 is pub(crate) use flare_eos::*;. AGENTS.md:20-21 puts host OS operations in that layer.

Fix. Move open_descriptors (helios/src/runtime_core/protection.rs:291-302) into eos/src/unix.rs beside page_size and raise_open_file_limit and re-export it through crate::os — the same route the commit already used for the other two helpers — or gate the call on feature = "runtime-core".

Verification status. No CI checks exist on this head, and I could not compile here, so this rests on the cfg/feature reading above. cargo check --manifest-path helios/Cargo.toml --features server settles it in seconds.


Should fix 2 — e2e exclusion is response-scoped, completions are per generation

Where: helios/src/server/http.rs:598-605

// 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().request_e2e.observe(…);
}

tool_limit_reached is a flag on the shared encoder, consulted without an index at every use site (http.rs:471-476, http.rs:526, http.rs:563-567), while a single response can carry several generations: generations: Vec<Option<Generation>> is built per choice at http.rs:351-353, each with its own decoder (decoders[index], http.rs:479-487, :525-527).

What goes wrong. Choice i finishes naturally while choice j is still running; the runtime counts i as completed and Metrics::request_completed already ran for it (runtime.rs:1841-1846 / :1996-2001), observing flare_requests_completed_total, queue, prefill, decode, TPOT and prompt-token histograms. Then j trips the tool limit and sets the shared flag. The single end-of-response check at http.rs:600 now sees tool_limit_reached == true and skips e2e for the whole response, including the already-completed choice i. Result: flare_request_e2e_seconds_count under-counts relative to flare_requests_completed_total, and the new docs sentence "Cancelled and failed requests enter only flare_requests_cancelled_total and flare_requests_failed_total" is false for that choice. That is the same class of divergence the PR sets out to eliminate by making the counter and the histograms share one function (metrics.rs:450-480).

Fix. Decide per finished generation rather than per response: skip the observation only when the termination actually used at http.rs:526 is crate::output::Termination::Cancelled, e.g. observe inside the GenerationEvent::Finished arm (http.rs:517-560) or carry a per-index "completed successfully" bit to the end of the loop. A test with size: 2 where one choice hits the tool limit should pin flare_request_e2e_seconds_count == flare_requests_completed_total.

(Not verified by compile; the flag scoping is plain from the code, and a multi-choice test that crosses the parallel tool limit would settle the intended rule.)


Nit 3 — parse_stat silently drops all stat-derived metrics on an unknown state letter

Where: helios/src/server/metrics/process.rs:26

if !fields.next()?.chars().next().is_some_and(|state| "RSDZTtWXxKPI".contains(state)) {
    return None;
}

The module doc (process.rs:4-6) promises that only unreadable or unparsable sources omit metrics. Here a valid /proc/self/stat whose state letter falls outside that hard-coded alphabet returns None, which removes process_cpu_seconds_total, process_virtual_memory_bytes, process_resident_memory_bytes and process_start_time_seconds in one stroke — quietly, mid-scrape. Validating instead that the five values this parser actually consumes parse as integers would bound the same "unrelated text containing )" risk the guard exists for (process.rs:20-29) without a fixed alphabet. Low practical risk on today's kernels; recorded because a silent whole-block disappearance is hard to diagnose from a dashboard.


Verified correct (checked in code — no finding)

Rules applied

Evidence limitations

Open questions

  1. Is a multi-choice response where one choice hits the tool limit supposed to contribute e2e observations for the choices that completed? Finding 2's fix depends on that call.
  2. Should open_descriptors live in eos/crate::os (the rule the commit itself followed for the other two helpers) rather than staying in runtime_core?

Verdict: blocking issues

Blocking:

Should fix:

Nits: 1 — process.rs:26 hard-codes the stat state alphabet, silently omitting all stat-derived metrics on an unexpected letter. Link: https://github.com/NVIDIA/hyperflare-inference/pull/548