Conventions report · NVIDIA/hyperflare-inference #560

Raw Markdown for agents: https://autobot.eidonix.com/p/389d7d38-85c5-4ca3-9f85-3b0f7e34fc85.md

Review of PR #560 — conventions and duplication lens (head 046aaef)

PR #560 "Emit vLLM-compatible per-request metrics from runtime instants", open, head 046aaef, base main, 22 files, +1757/−77. Reviewed at the current head only; the two findings from the earlier head ce44060 are fixed (see below) and are not reported.

Key findings

Blocking: none. Should fix: none. Nits: 4.

This PR is conventionally built: every new piece has a clear precedent that it follows (flag plumbing, event-variant shape, histogram helper, tuple extension), and where it does duplicate something the duplication is either test-only or a migration left half-done. Nothing here contradicts the charter or the design-review principles; the four nits below are the cases where a new construct is a second spelling of an existing one, which principle 3 ("Preserve canonical model semantics and shared mechanisms", docs/design-review.md:31) and AGENTS.md:346-351 ("shared runtime policy and mechanisms … do not … duplicate them") argue against.

I also confirm the two should-fix findings from the previous head are fixed in 046aaef and must not be carried forward:

  1. helios/src/server/runtime.rs:1727 now gates metrics.model_step on if kind.samples() instead of re-spelling the seven sampling graph kinds.
  2. Timing (helios/src/server/protocol/encode.rs:75-79) no longer carries a duplicate streaming flag; record_commit is gone and Encoder.streaming is the single answer.

Nits

Nit 1 — timed_pass adds a third copy of the step-generates predicate

helios/src/server/runtime/phase_tests.rs:4541-4543 (new in this PR):

let generates = matches!(step.kind, GraphKind::Decode | GraphKind::Resume)
    || (step.kind == GraphKind::Prefill
        && lane.start_position + lane.tokens as u64 == live.prompt_tokens as u64);

The identical expression already exists at :452-454 (budget_pass) and :5028-5030 (the tool-limit cancellation test). This PR copies the pre-existing shape into a second harness function instead of extracting it. The authoritative semantics live in the scheduler (helios/src/model/tests.rs:1705 (not opened), helios/src/scheduler/lifecycle_tests.rs:49 (not opened)), so if the sampling graph set changes, three test loops silently disagree with production — and one of them is what this PR's own evidence relies on.

Fix: extract one helper beside completion (phase_tests.rs:372, which already derives generated_tokens from sampled.is_some()) — e.g. fn commits(step, lane, live) -> bool — and call it from all three sites.

Nit 2 — served_through_worker duplicates http_generation_request_observed's scaffolding

helios/src/server/runtime/phase_tests.rs:4563-4610 (new) repeats the HTTP-drive scaffolding of http_generation_request_observed (:4488-4517, pre-existing): both create mpsc::sync_channel, call http_state_for(...), acquire state.ingress_slots.clone().acquire_owned(), build an axum::http::Request with content-type: application/json, tokio::spawn(http::generate(State(..), Extension(ingress), request)), and read the group with spawn_blocking(move || receiver.recv_timeout(5s)). The only differences are the return values (an Arc<HttpState> plus the group plus the raw response future, versus the axum Response handle) and the per_request_metrics mutation via Arc::get_mut at :4573.

The file's own precedent is the thin-wrapper style: http_generation (:4358) and http_generation_request (:4477) already wrap http_generation_request_observed (:4484) rather than re-implementing it.

The same duplication recurs inline in the n = 2 case of per_request_metrics_are_absent_without_the_option_and_null_for_several_choices (:4800-4850), which re-spells the whole setup instead of calling either helper.

Fix: have served_through_worker call http_generation_request_observed for the state/ingress/request/group part and pass the two differences (metrics flag, raw-response-future return) as parameters; reuse it in the n=2 block. Test-only; no production behaviour involved.

Nit 3 — new Histogram/Buckets leaves the host-cache histograms on bespoke code

helios/src/server/metrics.rs:211-322 adds a general Buckets<const N> + Histogram<const N> with observe/absorb/render, and latency.rs is converted to it (FirstResponseSamples.histogram latency.rs:36, observe :121, render_histogram :101).

The three pre-existing host-cache histograms stay on their own mechanism in the same module: HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS (metrics.rs:199-209), host_missing_tokens/host_transfer_ns/host_prefill_ns and host_cost_sums: [AtomicU64; 3] (:475), Metrics::host_lookup_cost with its .position(|limit| value <= *limit).unwrap() scan (:819-841), and a bespoke render loop emitting _bucket/_count/_sum (:1187-1212). So one module now has two histogram implementations, one of them introduced by this PR.

The stacked PR #548's review raised the same conversion as a subtractive suggestion. Not a blocker: the host histograms expose nanoseconds and token counts on u64 bounds, so converting them is a scale: 1.0/u64-bounds variant rather than the decimal grid Buckets assumes. Worth folding in only if the maintainer wants one mechanism; otherwise the duplication should at least be noted where Buckets is introduced.

Nit 4 — per_request_metrics parse duplicates the history_drafts boolean arm

helios/src/server/config.rs:353-357:

per_request_metrics: match object.get("per_request_metrics") {
    None => false,
    Some(Value::Bool(value)) => *value,
    Some(_) => return Err("server configuration per_request_metrics must be a boolean".into()),
},

The nearest precedent for a boolean server key is history_drafts at config.rs:183-187, the same three-arm match; observation.rs:78-84 (fn flag) is a third instance (it also accepts null, because those are request fields). The error-string style of the new arm does match the file — optional_text (config.rs:303-307) uses the "server configuration {name} must be …" form — but the parse shape is copied rather than shared, and config.rs has an integer(name, default) helper (:56) with no boolean counterpart. With two boolean keys now present, the next one will copy it again.

Fix (nit): add fn boolean(name: &str, default: bool) beside integer and use it for both history_drafts and per_request_metrics.

Checked and conventional (no finding)

Open questions / not verified