Conventions report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/c252e177-ed7b-4140-ba68-47c86cf3fb76.md

Conventions and duplication review — PR #548 (head 6624592, 9 files, +1008/−51)

Reviewed at head 6624592 with the merge base f377dc8. Every changed file was read in context (docs/api.md, helios/src/server.rs, server/http.rs, server/latency.rs, server/metrics.rs, server/runtime.rs, server/runtime/phase_tests.rs, server/scheduler.rs (not opened), server/protocol/encode.rs) and each candidate finding was re-checked line by line at this head. No reviews and no CI checks exist on this commit. Rules applied: AGENTS.md:188-193 ("Reject unsupported abstractions and churn … Refactoring must directly support the requested behavior"), docs/design-review.md:74 ("Account for duplicate representations and retained temporary owners"), charter line 12 ("Keep the runtime small and model-agnostic").

Key findings


Should fix 1 — metrics.rs carries three Prometheus-histogram implementations that disagree

File: helios/src/server/metrics.rs:211-322 (new code), against :199-209 / :475 / :819-841 / :1178-1214 and :468 / :854-860 / :1000-1025 (pre-existing code the PR leaves untouched).

What is wrong. The PR introduces one histogram abstraction and leaves two older, hand-rolled ones in place, so the module now answers "how do I write a histogram" three different ways:

Why it matters. The disagreement is visible to a scrape: some of the new series carry # HELP and some do not, _sum and _count come in opposite orders, and bucket bounds are integers in one place (u64::MAX → +Inf) and floats in another. The bucket-index loops are literally the same algorithm written three times (:276-281, :836-840, :854-860). This is exactly the "duplicate representations" that docs/design-review.md:74 requires the design to account for, and the unsupported-abstraction/churn rule at AGENTS.md:188-193 — a generic Histogram<N> added without retiring the two implementations it supersedes leaves three ways to do one thing.

Fix. Rebuild the host-cost and retirement histograms on Histogram<8>/Buckets<8>. That deletes metrics.rs:199-209, the host_cost_sums field (:475), the bucket loop at :836-840, the whole host-cost render block :1178-1214, and, for retirement, the field :468, the fill at :854-860 and the render at :1000-1025. This is behaviour-preserving: u64::MAX terminates the bounds array, so position(...).unwrap() cannot panic, and the existing tests pin every series. If the migration is deliberately deferred, the PR description should name the deferred sites — today it names none, and the description's cost section mentions only the added work.

Should fix 2 — the two HTTP-observed histograms have different owners and render paths

File: helios/src/server/latency.rs:36 and helios/src/server/metrics.rs:406, rendered at helios/src/server.rs:660-708.

What is wrong. The PR adds two histograms observed from the HTTP layer, and gives each a different home:

Why it matters. A reader of Metrics cannot discover that the TTFR series exists — it is the only metric in the scrape that is neither a Metrics field nor produced by metrics::metric (metrics.rs:1834-1839, used at server.rs:666/:673). The scrape body is consequently assembled in four stages: state.model.metrics().render() (server.rs:660), the first-response gauges and median (:661-670), the TTFR histogram (:671), then the input and HTTP gauges (:672-708), with no stated rule for which series go where. Two series that share one observation layer and one observation unit (REQUEST_SECONDS, latency.rs:106 and metrics.rs:609) should not need two mechanisms. Charter line 12 (keep the runtime small) and docs/design-review.md:74 both point the other way.

Fix. Move the TTFR histogram onto Metrics, observe it from FirstResponse::output through the existing metrics_handle() (runtime.rs:813), and delete both render_histogram (latency.rs:101-108) and the server.rs:671 call — or, if the rolling window and its all-time histogram are deliberately kept together (a defensible pairing, documented at docs/api.md:302-389), state that ownership rule in Metrics::render. Only the asymmetry is the finding, not the pairing.


Nits

Nit 1 — per-choice generated-token counts are stored and grouped twice. helios/src/server/http.rs:407 (let mut generated = vec![0u32; size];, filled at :530 from the same Finished event) duplicates what Encoder already holds: Usage { generated: u32 } (protocol/encode.rs:55-58, set at :630-634, incremented by observe_generated_token at :216-219), and the encoder already groups by prompt via choices_per_prompt (:94) with .step_by(self.choices_per_prompt) (:693). Metrics::response_completed then re-groups the caller's vector with generated.chunks(choices) (metrics.rs:610). Two stores and two groupings of one number will diverge the first time either path changes — for example the zero-budget choices finished in http.rs never pass through the encoder's counter. Fix: expose the encoder's per-choice counts (or its choices_per_prompt) and observe from that single source.

Nit 2 — flare_admission_rejections_total bypasses the file's labelled-counter loop. helios/src/server/metrics.rs:1643-1656 is hand-rolled: a literal ["http_slots", "generation_capacity", "request_queue"] (:1647) zipped positionally against &self.admission_rejections (:1649), duplicating AdmissionLimit's variant order (metrics.rs:375-385) with nothing linking the two — admission_rejected indexes it with limit as usize (:685). The file already has the table-driven pattern for labelled counters at metrics.rs:1143-1177 (for (name, labels, counters) … "# TYPE flare_{name} counter" then one line per label). Fix: give AdmissionLimit a name()/ALL and feed the existing loop, so adding a fourth limit cannot silently mislabel a series.

Nit 3 — the request output budget is spelled twice in runtime.rs. helios/src/server/runtime.rs:1568-1569 (incoming.prompt.max_new_tokens + incoming.prompt.reasoning_cut.as_ref().map_or(0, |cut| cut.after)) repeats Prompt::output_event_capacity's sum at runtime.rs:66-67, including the reasoning-cut term that the comment there documents as "part of after" — the policy that a cut's forced token is inside the budget is now encoded in two places. Fix: add a Prompt::output_budget() helper and call it from both. Low severity because the two sites serve different purposes (event-capacity estimate versus the recorded record.max_tokens value).


Resolved since the previous head (not reported as findings)

Verified non-findings (checked, then dropped)

Open questions / could not be verified