Re review report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/c2f102d1-7a11-4b11-9865-caccdcff66fa.md

Recommendation: Ready To Merge

PR #548 cleanly implements per-request latency/size/preemption histograms and related runtime/admission counters on top of current main (c146d7be, post-#620), with all blocking and substantive code items from lukealonso's 2026-11-28 review resolved at 93fdc89. The worker-owned RequestRecord keeps the hot loop allocation-free and atomic-free (fixed 84-byte InterTokenIntervals), recording at Metrics::request_completed keeps counters and distributions structurally aligned, and all new lifecycle tests exercise real Worker/ModelRuntime/HTTP paths. Before clicking merge, confirm GitHub Actions CI is green on 93fdc89, unlink the stale [closes] reference on #536 in the GitHub sidebar (the PR body already says Part of #536), and consider fixing the one-sentence doc contradiction at docs/api.md:322-325 noted under Nits.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

  1. Deduplicate bucket-index lookup (helios/src/server/metrics.rs:293-297, :360-364): Histogram::observe and InterTokenIntervals::observe repeat the identical 4-line .bounds.iter().position(|bound| value <= *bound).unwrap_or(...) search. Adding fn index(&self, value: u64) -> usize on Buckets<N> lets both call buckets.index(value) / TOKEN_SECONDS.index(value).
  2. Fold model_step_tokens into the TOKEN_COUNTS render array (helios/src/server/metrics.rs:1638-1666, :1679-1684): self.model_step_tokens uses &TOKEN_COUNTS just like the five-element loop immediately above it and can be the sixth tuple in that array.
  3. Optional minor churn cleanup (helios/src/server/latency.rs:34-36, helios/src/server/metrics.rs:341-346): Keeping FirstResponseSamples(Mutex<Samples>) as a tuple struct avoids the cosmetic .0 → .window rename across six hunks (latency.rs:79, 118, 192, 198, 207, 216); similarly, RequestTimes is only ever destructured inside RequestRecord (metrics.rs:606) and can be flattened into RequestRecord if desired.

Nits

  1. docs/api.md:322-325 contradicts helios/src/server/protocol/encode.rs:600-601 and helios/src/server/metrics.rs:2159-2165: docs/api.md:322-325 says "A choice stopped at the parallel_tool_calls: false tool limit is not delivered, including a choice whose generation completed naturally before the limit stopped delivery: the encoder counts it as cancelled, and it enters neither choice histogram." In fact, encode.rs:600 captures let cancelled = cause == Termination::Cancelled; before line 601's tool_limit_reached override, and metrics.rs:2162-2165 explicitly asserts [None, Some(5)] when choice 1 finishes with Termination::Eos after tool_limit_reached is set. Update docs/api.md:322-325 to state that choices whose runtime generation ended as Termination::Cancelled (such as after the parallel_tool_calls: false tool limit cancels decoding) are excluded from the choice histograms, while choices whose generation completed naturally before cancellation arrived still enter them (matching flare_requests_completed_total).
  2. Minor doc precision (docs/api.md:334-336, :371-373): Optionally note that first_scheduled_ns is stamped right after input packing succeeds (runtime.rs:2290-2306), and that http_slots also counts batched (n > 1 or multi-prompt) HTTP 429 rejections when fewer than size - 1 additional slots remain (http.rs:230-245).
  3. Minor defensive tweaks (helios/src/server/metrics.rs:645-654, helios/src/server/latency.rs:118-121): In request_completed, adding && generated_tokens > 1 alongside times.last_token_ns > first guards generated_tokens - 1 against any synthetic caller passing generated_tokens <= 1 (impossible in production since two committing steps yield >= 2 tokens). In FirstResponse::output, dropping samples before self.metrics.first_response(...) avoids doing the bucket scan under the mutex.
  4. Unlink stale [closes] relation on #536: The PR body was already updated to Part of #536, but GitHub's Development sidebar still links #536 as [closes]; unlink it so merging does not prematurely close #536 while process_* remains unimplemented.

Dropped on verification