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. The PR introduces a documented
[server] per_request_metricsconfiguration key but registers it only in the Rust reader. Ignition's Python schema — reached by every Ignition command, includingignition export— rejects unknown keys, so a user who uncomments the key the PR's own docs show gets a hard failure. - Four nits, all duplication against an existing local precedent: a third copy of the "step commits a generated token" test predicate, a second and third copy of the HTTP-drive test scaffolding, a new
Histogram/Bucketsabstraction that migrates one of four histograms, and a boolean config parse that copieshistory_draftsinstead of gaining aboolean()helper. - Everything else — the Rust-side config plumbing, the CLI flag path, the
first_scheduled_nsextension of the existing timing tuple, theFinished/Committedvariant changes, and the doc edits — follows an existing mechanism one-for-one.
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:
ignition/cli/config.py:21-33—_SECTIONS["server"]listshost,port,api_key,thinking_token_budget,scheduler_checkpoint_extra_work_fraction; noper_request_metrics.ignition/cli/config.py:37-53—_BUILT_INhas noserver.per_request_metricsentry (:38-40cover the other server keys).ignition/cli/config.py:108-114—_validateraisesUsageError(f"{path}: unknown key {key} in [{section}]")for any key outside the schema;Configuration.load(:89-106) runs that validation for every section and every load.ignition/cli/config.py:183-213—write_initial, which perdocs/cli-design.md:1311-1312writes "every resolved value present as a comment", emits the other four[server]keys at:189-192and noper_request_metricsline.
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
- The Rust-side
per_request_metricsplumbing followsthinking_token_budgetone-for-one, the right precedent:flare/src/configuration.rs:34,flare/src/settings.rs:32+:224,flare/src/controller.rs:2566(beside:2562-2565),flare-cli/src/config.rs:73-75(same "flag wins" shape as:70-72),flare-cli/src/main.rs:355-357,helios/src/server/config.rs:353-357, docsdocs/cli-design.md:736,1318,1349anddocs/api.md:1007. Only the Python half of that same precedent is missing (B1). - The CLI flag reaches rank zero the way
--api-key-filedoes (flare-cli/src/cli.rs:671-701(not opened), test at:1379-1401), including the default-false arm at:535. first_scheduled_nsextends the existing(ingress, enqueue)tuple (helios/src/server/observation.rs:56-75) instead of adding a parallel struct; the aggregation uses the file's existing.into_iter().chain(...).min()idiom (http.rs:412,:538).RequestTimes/RequestRecordsit beside the existingSnapshotexport path, andmetrics.rs:142-149reusesscale-based observation rather than adding a per-metric atomic.GenerationEvent::Finishedgained fields beside existing ones (runtime.rs:99-108); both emit sites andfinish_cancelled(:302-308) forward the samerequest.incomingvalues — one source, no second timing path.RequestMetrics/Timing(protocol/encode.rs:67-79) is minimal, and the earlier duplicateTiming.streamingflag is gone;enable_request_metricsreads dataEncoder::newalready owns (include_usage,protocol,prompts.len(),choices_per_prompt), so placement is decided once.- Docs replace stale claims rather than narrating history:
docs/api.md:287-300rewrites the now-false "the only histograms" sentence, andhelios/model-contract.md:343-358extends the existingperformanceparagraph.
Open questions / not verified
- No GPU, exported core, live server, llama-swap run, Windows build,
cargo testorpytestwas available here, and CI on046aaefreports no checks. Every finding above is read from the code and, for B1, from the PR's own documentation. B1 is the one that a single command would demonstrate outright. - N3 turns on a maintainer preference (one histogram mechanism now versus a follow-up); the duplication itself is factual and cited.