Conventions report · NVIDIA/hyperflare-inference #560

Raw Markdown for agents: https://autobot.eidonix.com/p/1faa1ae3-bb5c-4ebd-80ce-62dee7b3a4c9.md

Review of PR #560 — conventions and duplication lens

PR #560 "Emit vLLM-compatible per-request metrics from runtime instants" (open, head 046aaef, base main, 22 files, +1757/−77). All changed files were read in context and compared against the closest precedent in the repository. Two should-fix findings recorded against the earlier head ce44060 are fixed at 046aaef and are not reported (runtime.rs:1727 now calls kind.samples(); Timing no longer carries a streaming flag).

Verdict: 1 blocking, 0 should fix, 4 nits.

Key findings


Blocking

B1 — [server] per_request_metrics is absent from Ignition's configuration schema, so every Ignition command rejects it

Where. The new key is documented and read on the Rust side only; the Python schema that the same file is validated against never learns it:

Configuration.load(args.config) is on every Ignition path: ignition/cli/serve.py:127 (export), :174 (_export_hosts), :264 (_prepare), :431 (debug_serve), :590 (join), plus ignition/cli/publishing.py:31 (not opened),73,174,194 and ignition/cli/bench.py:144 (not opened).

Why it matters. The PR documents the key in the file both readers consume: docs/api.md:1007 ("flare run --enable-per-request-metrics, or [server] per_request_metrics = true") and docs/cli-design.md:1349 (also the sample config.toml (not opened) at :1342-1383) and :736. The same document states both halves of the rule this breaks: docs/cli-design.md:1313 "Ignition and native Flare read this file", and :1385 "Ignition rejects any section or key outside its schema. Native Flare ignores keys it does not use." A user who follows the PR's own instructions — uncommenting # per_request_metrics = false in the generated template — breaks ignition export, the documented preparation path.

This is a conventions failure measured against the neighbouring keys, not a matter of taste. thinking_token_budget spans schema :23, built-in :39, validator :138, serve.py:486 and template :192; scheduler_checkpoint_extra_work_fraction spans schema :24, built-in :40, validator :119, serve.py:487 and docs/cli-design.md:1348. The new key copies only the Rust half of that chain (flare/src/configuration.rs:34, flare/src/settings.rs:32+:224, flare/src/controller.rs:2566, flare-cli/src/config.rs:73-75, flare-cli/src/main.rs:355-357, helios/src/server/config.rs:353-357) and drops the Python half. flare/src/configuration.rs:26-35 has no deny_unknown_fields, so the two readers now disagree about one file — the Rust one tolerates the key, the Python one rejects it.

Verified by a repository-wide search: per_request_metrics appears only in docs/api.md, docs/cli-design.md, flare-cli/src/*, flare/src/*, helios/src/* — zero hits anywhere under ignition/ or tests/cli/, so there is no schema entry, no default, no template line, no debug-serve forwarding and no test pinning it.

Fix. Add "per_request_metrics": bool to _SECTIONS["server"] (ignition/cli/config.py:23-24), "server.per_request_metrics": False to _BUILT_IN (:39-40), a commented # per_request_metrics = false line to write_initial (:192), and options["per_request_metrics"] = configuration.get("server.per_request_metrics").value beside ignition/cli/serve.py:486-487 if debug-serve is meant to honour it. Cover it in tests/cli/test_config.py:151-177 so the next key cannot repeat the omission.

What would settle it. pytest tests/cli/test_config.py or an ignition export run with a config file containing [server]\nper_request_metrics = true. No test in tests/cli/ mentions the key, and CI on 046aaef reports no checks, so this is read from the code and its own documentation.


Nits

N1 — phase_tests.rs:4541-4543 is the third copy of the "step commits a generated token" expression

helios/src/server/runtime/phase_tests.rs:4541-4543, in the new timed_pass, re-spells the predicate already at :452-454 (budget_pass, pre-existing) and :5028-5030 (pre-existing cancellation test):

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 real semantics live in the scheduler (helios/src/model/tests.rs:1705 (not opened), helios/src/scheduler/lifecycle_tests.rs:49 (not opened)). The file's own precedent for factoring harness logic is completion (:372), which already derives generated_tokens from sampled.is_some(). Third copy, and this one is added by the PR. Fix: extract one helper beside completion and call it from budget_pass, timed_pass and the cancellation test. Test-only; no production behaviour.

N2 — served_through_worker and the n = 2 block duplicate http_generation_request_observed

helios/src/server/runtime/phase_tests.rs:4563-4610 (served_through_worker, new) repeats the HTTP-drive scaffolding of http_generation_request_observed (:4488-4517, pre-existing): mpsc::sync_channel, http_state_for(...), state.ingress_slots.clone().acquire_owned(), an axum::http::Request with content-type: application/json, tokio::spawn(http::generate(State(state), Extension(ingress), request)), then tokio::task::spawn_blocking(move || receiver.recv_timeout(5s)). The only differences are the return values and the per_request_metrics mutation via Arc::get_mut (:4573).

The n = 2 case in per_request_metrics_are_absent_without_the_option_and_null_for_several_choices (:4795-4849) re-spells the same forty lines inline instead of calling either helper. The file's established pattern is the thin wrapper — http_generation (:4358) and http_generation_request (:4477) both wrap the same path. Fix: have served_through_worker wrap http_generation_request_observed, taking the metrics flag and returning the response future. Test-only.

N3 — the new Buckets<N>/Histogram<N> migrates one of four histograms, leaving two mechanisms in metrics.rs

helios/src/server/metrics.rs:211-322 adds a general Buckets<const N> (:213-216) with the constant grids (:218-253) and Histogram<const N> with observe/absorb/render (:257-322), and converts latency.rs to it (latency.rs:36 field, :101 render_histogram, :121 observe).

The three host-cache histograms keep the old bespoke mechanism: HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS (:199-209), the host_missing_tokens/host_transfer_ns/host_prefill_ns arrays, host_cost_sums: [AtomicU64; 3] (:475), Metrics::host_lookup_cost doing its own .position(|limit| value <= *limit).unwrap() (:819-841), and a hand-written 37-line _bucket/_count/_sum render loop (:1198-1214). So metrics.rs now carries two histogram implementations, one added by this PR. Not blocking: the host histograms' exposed unit is nanoseconds/tokens rather than the scale grid Buckets assumes, so the conversion is scale: 1.0 plus u64 bounds — a mechanical follow-up if the maintainer wants one mechanism. Cite: metrics.rs:199-209 vs :211-322; :819-841 vs :271-321.

N4 — config.rs:353-357 re-spells the history_drafts boolean parse; config.rs has integer() but no boolean()

helios/src/server/config.rs:353-357 parses the new key as a three-arm match (None => false, Some(Value::Bool(v)) => *v, Some(_) => return Err(...)). That is the shape of history_drafts at :183-187, with observation.rs:78-84 (flag) the third instance (there it also accepts null, since those are request fields). The error-string style matches the file (optional_text :303-307, integer :56), so this is a parse-shape duplication rather than an inconsistent message. Two boolean server keys now exist and the third will copy again. Fix: add fn boolean(name, default) beside integer (:56) and use it for both history_drafts and per_request_metrics.


Checked and conventional — no finding

Open questions / not verified