Full Review — PR #560 "Emit vLLM-compatible per-request metrics from runtime instants"
Head 046aaef, base main, 22 files, +1757/−77. Stacked on the still-open #548 (its commits are in this branch, so the diff against main mixes both). Reviewed as the layer above #548, as the description instructs.
Recommendation: changes requested. Counts: 1 Blocker, 6 Should fix, 6 Subtract/Simplify, 5 Nits.
The mechanism is right-sized and in the right place: the worker owns every instant, the encoder owns placement, no HTTP-layer clock is read, and with the option off nothing is emitted or requested. Two findings from the previous head (ce44060) are genuinely fixed and are not re-reported (RequestTimes is now public/exported; Timing::streaming and record_commit are gone), and the previous round's "false cost claim" blocker is withdrawn because commit 66245920 ("Reuse GraphKind::samples for model-step metrics and stamp scheduled time after packing") belongs to #548, exactly as the description states. What remains is one user-facing break of the documented enable path (the Blocker), reachability/doc gaps, and roughly 180 removable lines, most of them in one test file.
Key findings
- Blocker — the documented way to enable the feature fails every Ignition command.
docs/api.md:1007anddocs/cli-design.md:1318,1349tell users to write[server] per_request_metrics = true, butignition/cli/config.py:23-24has no such key and:112-114raisesunknown key per_request_metrics in [server]. Every Ignition command loads and validates that file. - Should fix — authorization is still unconfirmed, though the evidence gap is now closed. #551 is a reproducible defect report (llama-swap showing
-1rates) and the PR now carries live evidence, so the charter's "reproducible bug" gate is plausibly satisfied; but #551 is authored by the same contributor with no maintainer reply, and #552/#553 were stopped by review on charter grounds. One maintainer line settles it. - Should fix — the flag cannot express an explicit false, so a
[server] per_request_metrics = truefile or a saved Orbit group cannot be overridden for one run, contrary todocs/cli-design.md:1321-1322and:1337-1338. - Should fix — three documentation claims are wrong or unreachable from the document that makes them: the
cli-design.md:736default for a flag shared byflare orbit run(which has no configuration path), theapi.md:1040-1043null paragraph (a permanently-null field described as an unreached instant;n > 1null overstated), andapi.md:1045-1050referencing aperformanceshape the file never defines. - ~180 lines removable with no behaviour lost, ~110 of them in
phase_tests.rs(+535): two new HTTP-level tests re-assert encoder rules and hand-roll plumbingserved_through_workeralready provides. - Verified sound: placement for all four protocols, the
first_scheduled_nsearliest-value fold,RequestTimeslifetime through preemption,GraphKind::samples()equivalence, the option-off wiring, and the event-budget/Finished-only event change.
Blockers
B1. The documented [server] per_request_metrics key is rejected by the Ignition schema, breaking every Ignition command
Where: docs/api.md:1007-1009; docs/cli-design.md:1318 (native flare run key list), :1349 (sample config); ignition/cli/config.py:21-33 (_SECTIONS["server"]), :108-120 (_validate), :183-215 (write_initial); loaders ignition/cli/serve.py:127,174,264,431,590, ignition/cli/bench.py:144 (not opened), ignition/cli/publishing.py:31 (not opened),73,174,194.
What is wrong.
docs/api.md:1007says the option is enabled by "flare run --enable-per-request-metrics, or[server] per_request_metrics = truein the host configuration", anddocs/cli-design.md:1349puts aper_request_metrics = falseline in the[server]sample of the file Ignition writes.ignition/cli/config.py:23-24defines_SECTIONS["server"]as exactly{host, port, api_key, thinking_token_budget, scheduler_checkpoint_extra_work_fraction}. There is noper_request_metrics(verified at head).ignition/cli/config.py:112-114iterates every key and raisesUsageError(f"{path}: unknown key {key} in [{section}]")for anything outside the schema;:115-118would then demand a type entry (bool)._BUILT_IN(:37-53) has no default either, so aconfiguration.get("server.per_request_metrics")would raiseKeyErroruntil both are added.docs/cli-design.md:1311-1313states "Ignition and native Flare read this file", and:1385"Ignition rejects any section or key outside its schema". So the file the new docs tell the user to edit is the same file Ignition validates, and the key is outside its schema.- Every Ignition command loads it:
serve.py:127,174,264,431,590(export, bench/convert paths, debug-serve),bench.py:144(not opened),publishing.py:31 (not opened),73,174,194. Following the new documentation therefore makesignition export— the model preparation step that precedes any serving — fail withUsageError: unknown key per_request_metrics in [server].write_initial(config.py:183-215) also omits the key even thoughdocs/cli-design.md:1311-1312says the file is generated "with the resolved values present as comments".
Why it matters. This is not a doc typo: the enable path the PR documents is unusable for anyone who also runs Ignition, which is the supported way to prepare a core. The PR touched neither ignition/cli/config.py nor tests/cli/test_config.py (not opened), and tests/cli/test_config.py:152-171 (not opened) already parametrizes unknown-key rejection, so CI would catch the mismatch the moment the key is added without the schema entry — and catches nothing today.
Requested change. Add "per_request_metrics": bool to _SECTIONS["server"] (ignition/cli/config.py:23-24) and "server.per_request_metrics": False to _BUILT_IN (:37-53), add the commented line to write_initial (:188-192), and add one positive load test beside the existing negatives in tests/cli/test_config.py:152-171 (not opened). Reproduce with one ignition export while ~/.config/flare/config.toml (not opened) carries the documented line.
Should Fix
S1. A maintainer still has to confirm that per-request response metrics are in scope
Where: charter "What gets merged"; AGENTS.md:188-193 (not opened), :201-205; #551; #536; #552; #553.
The charter merges PRs that address "a maintainer request, a roadmap item, a reproducible bug, a measured performance/memory issue, or bad docs". #551 is a reproducible defect — llama-swap v250 reads prompt_per_second/predicted_per_second from a response-body object and shows -1 for Flare — and the PR now carries a 40-check live matrix plus llama-swap rates, so the evidence half of the gate is met. What is missing is authorization: #551 was opened by the same contributor (WynnD, no association) on 2026-11-27 with zero comments, and the maintainer-authored issue in this area (#536) asks for Prometheus histograms, delivered by #548, not for a response-body object. Both predecessors were halted by review on exactly this ground (#553: "Review Stopped … low value or does not align with the project charter", 2026-11-27 05:17 and 06:40; #552 likewise). vLLM is listed under "Alternatives / Competitors", so "vLLM has it" is not itself a merge reason. Requested change (no code): a maintainer comment on #551 or in the PR confirming the scope, and a description that leads with the llama-swap defect rather than with vLLM parity.
S2. The flag cannot express an explicit false
Where: flare-cli/src/cli.rs:646-649 (Orbit) and :860-863 (run) — plain bool, no negating form; flare-cli/src/config.rs:73-75; flare-cli/src/cli.rs:698-700 (rank_zero_options only emits when true); docs/cli-design.md:1321-1322, :1337-1338.
if !run.enable_per_request_metrics {
run.enable_per_request_metrics = self.server.per_request_metrics.unwrap_or(false);
}
With per_request_metrics = true in a node's file there is no flag that turns it off for one run, and because rank_zero_options only re-emits the flag when true, an Orbit group that ever captured --enable-per-request-metrics keeps it. This contradicts the documented precedence ("Flags override these defaults, including explicit zero limits and values equal to the built-in defaults"; "saved group options and explicit flags take precedence"). The mechanism already exists next door: --kv-cache-limit memory is re-emitted when matches.value_source("kv_cache_limit") == Some(CommandLine) (cli.rs:662-667). Fix: tri-state (Option<bool> via num_args(0..=1)) or --no-enable-per-request-metrics with overrides_with, forwarded to rank zero; at minimum document the limitation beside the flag, and extend the config test (flare-cli/src/config.rs:222-233 alone asserts ""/true/false in the file with the flag turning it on).
S3. docs/cli-design.md:736 claims a configuration default that flare orbit run does not honor
The new row reads "--enable-per-request-metrics … | [server] per_request_metrics, otherwise off", and the flag is declared on both Run (cli.rs:857-863) and OrbitRun (:646-649), with docs/cli-design.md:170-173 listing it among the flags Orbit applies to rank zero. But the configuration fallback lives in Configuration::apply, whose branch matches only cli::Command::Run (flare-cli/src/config.rs:57-58, key applied at :73-75); OrbitRun gets the value from its flag alone. An operator who sets the key, launches flare orbit run, and follows the table expects metrics and silently gets none. Fix: write "[server] per_request_metrics for native flare run, otherwise off" in the configuration column, matching docs/cli-design.md:1317-1318. Secondary, same row: neither --help string mentions the configuration key (cli.rs:646-648, :860-862), so one clause ("default: [server] per_request_metrics") would make --help and the doc agree.
S4. ignition debug-serve and the generated template ignore the key, and one sentence is now stale
Where: ignition/cli/serve.py:485-487, ignition/cli/config.py:183-215, docs/cli-design.md:1385-1387.
debug-serve builds its bootstrap options from configuration.get("server.*") for the keys it knows — thinking_token_budget and scheduler_checkpoint_extra_work_fraction at serve.py:486-487 — and does not set per_request_metrics, so once B1 is fixed it will silently ignore a setting flare run honors while honoring its two neighbours. write_initial omits the key from the template that docs/cli-design.md:1311-1312 says carries "the resolved values present as comments". And docs/cli-design.md:1385-1387 ("Native Flare ignores keys it does not use, except in [prefix_cache]") gains a second exception once native flare run uses a key Ignition's schema previously rejected. Fix: add the key to serve.py's options dict and to the template, and update that sentence.
S5. docs/api.md:1040-1043 misdescribes a permanently-null field and overstates the n > 1 null
Three problems in one paragraph:
- "a field is null when the request did not reach the instants it spans, such as
mean_itl_msfor a single generated token" — buttime_to_first_content_token_msis documented at:1020as "Always null" and hard-coded athelios/src/server/protocol/encode.rs:263. A field that never has a value is not an unreached instant; telling llama-swap and billing clients (the audience the PR names) that it is a supported-but-unavailable measurement invites them to consume a value that will not arrive until #562. Say plainly that the key is present for vLLM shape compatibility and is always null until #562. - "With
ngreater than onemetricsis null" —helios/src/server/protocol/decode.rs:753-755rejectschoices != 1for every protocol except Completions, so Chat/Responses/Messagesn > 1is a 400, never a null. Restrict the sentence to Completions, matching the encoder arm that produces the null (encode.rs:238,:252-253). - Only one null case is shown.
encode.rs:257-273nulls TTFT, generation, queue, tokens/s andmean_itl_mstogether whenfirst_scheduled_ns/first_token_nsare unset (notelet last = first.map(...)), andhelios/src/server/protocol/tests.rs:2445-2448pins that all-null object for a zero-token output-limited response. One clause documenting the zero-token shape closes it.
S6. docs/api.md:1045-1050 compares against a shape the HTTP API reference never defines
The new paragraph says the instants are "on the same process-local origin as choices[0].token_timestamps_ns", but a whole-file search finds token_timestamps_ns only at :1048 and return_token_timestamps only at :992. The file never states that the token instants sit beside choices[0].token_ids, that return_token_timestamps: true is rejected without return_token_ids: true (helios/src/server/observation.rs:37-39), or that performance is emitted only on timed responses. The link to ../helios/model-contract.md (not opened)#token-and-timing-observation resolves (model-contract.md:326 (not opened)), so it is not dangling, but the HTTP reference should define the fields it uses. Fix: one sentence at docs/api.md:991-992 — "return_token_timestamps requires return_token_ids: true; it places per-token instants in choices[0].token_timestamps_ns, aligned with choices[0].token_ids, and, on buffered responses, a top-level performance object" — then let the new paragraph point at it (see SUB3).
Subtract / Simplify
Net ≈180 lines removable (~9% of the ~1,180 added source/test/doc lines once #548's contribution is set aside), ~110 of them in one test file. No finding asks to remove the option itself: #551 is a reproducible client gap and the charter merges PRs that fix one.
SUB1 — should fix, ~110 lines: helios/src/server/runtime/phase_tests.rs:4731-4850
Two new HTTP-level tests re-assert rules already decided and pinned at the encoder, and re-implement the plumbing.
- Already asserted by
per_request_metrics_follow_vllm_placement_and_null_rules(helios/src/server/protocol/tests.rs:2346-2449): the six exact values and the carrier frame (:2375-2389), top-level JSON placement (:2391-2398), no carrier withoutinclude_usage(:2400-2406), Messages omitted (:2408-2414),n>1→nulland several prompts → omitted (:2416-2430), single-token and no-instant nulls (:2432-2448). per_request_metrics_reach_completions_and_responses_where_vllm_places_them(:4731-4777) re-asserts the usage-chunkchoices == [](:4762),response.incomplete(:4764), body placement (:4765) and the content-TTFT null (:4774); its only timing claim,generation >= 3.0(:4771), is made rigorously by the kept test at:4719-4721.per_request_metrics_are_absent_without_the_option_and_null_for_several_choices(:4780-4850): the first loop (:4782-4794, ~13 lines) is the one genuinely new fact —state.per_request_metricsreachesEncoder::enable_request_metrics(helios/src/server/http.rs:387-389). The second half (:4795-4849, ~55 lines) hand-buildshttp_state_forstate, acquires an ingress slot, spawnshttp::generate, receives the group, writesFinishedwith hand-madeRequestTimes, then splits SSE — all of whichserved_through_worker(:4563-4610) does, parameterised byper_request_metrics, path, body and samples — to re-prove theSuppressedarm.
Smaller version (~125 → ~25 lines): delete both tests and keep the flag's reach with one test over the existing helper:
#[tokio::test]
async fn per_request_metrics_reach_the_encoder_only_when_enabled() {
for enabled in [false, true] {
let (_, values) = served_through_worker(
|| Fixture::new().text_inputs(), enabled, "/v1/completions",
json!({"model":"qwen-worker-phases","prompt":"a","max_tokens":2}), &[1, 2]).await;
assert_eq!(values[0].get("metrics").is_some(), enabled);
}
}
Keep performance_reports_the_first_scheduled_model_step (:4613-4647) and per_request_metrics_report_the_runtime_instants_of_a_stopped_reasoning_answer (:4685-4728): they are the only tests proving the instants land in the right worker step (within() bounds at :4717-4726). Nothing is lost: placement and null rules stay where they are decided (encode.rs:232-275).
SUB2 — should fix, ~30 lines, shared with #548: docs/api.md:305-386
Four paragraphs walk every histogram series (flare_request_queue_seconds, flare_request_prefill_seconds, flare_request_inference_seconds, flare_inter_token_latency_seconds, the token histograms, flare_request_preemptions, flare_model_step_tokens, …) with the same populations the Prometheus HELP strings already ship on every scrape (helios/src/server/metrics.rs:1548-1642 (not opened), e.g. request_queue_seconds at :1557, request_prefill_seconds at :1562, inter_token_latency_seconds at :1591) and that the new correspondence table maps one-to-one (docs/api.md:475-517). Reduce to ~8 lines naming the groups plus the single exclusion rule ("successful completions only; only flare_time_to_first_response_seconds can observe a response that later fails"), and let the HELP strings and the table carry the per-series text. Because the block arrives with #548, this is one cut for the stacked pair, not two.
SUB3 — nit, ~10 lines: docs/api.md:1040-1050
:1040-1043first sentence ("All six fields are always present, and a field is null when… such asmean_itl_ms…") restates the table rows at:1020and:1022. Keep the second sentence (ngreater than one →null; several prompts → omitted) — that is the only place this rule appears in prose — ~3 lines.:1045-1050re-describesperformancefields defined normatively athelios/model-contract.md:344-355(not opened), which the same paragraph links. Replace with one pointer sentence — ~4 lines.
Keep the placement paragraph (:1031-1038) and the step/queue-arrival paragraph (:1025-1029): they are the only place in the docs stating those boundaries.
SUB4 — nit, ~7 lines: helios/src/server/protocol/tests.rs:2334-2344, :2366-2374
metered_generation feeds a Reasoning event, an empty Content event and two more content events, but no assertion in per_request_metrics_follow_vllm_placement_and_null_rules reads the reasoning chunk, the empty chunk or the chunk count — every assertion is about the carrier frame's placement (:2375-2389, :2426) or metrics_value() (:2397, :2405, :2413, :2428), which depends only on times and generated = 4. This shape is leftover from the content-instant work that moved to #562, and the doc comment describes behaviour the test does not check. Fix: reduce to one Content("answer") event plus record_times/finish, and fix the comment. Second, the carriers closure (:2366-2374) clones whole frames to read two fields; collect (&Value, &Value) (as phase_tests.rs:4751-4758 already does) and compare *metrics to &expected.
SUB5 — nit, ~12 lines, marginal: helios/src/server/config.rs:727-739
The for invalid in [json!(1), json!("true"), json!(null)] rejection loop (:734-739) guards a key whose only writer passes a literal boolean (flare-cli/src/main.rs:355-357), and the CLI flag is already covered by flare-cli/src/cli.rs:1378-1401. Keep the parse at :353-357 and the absent→false assertion at :727; drop the loop. Marginal because this is the only place the error text is exercised — cut it only if the test file is being trimmed anyway.
SUB6 — optional, ~9 lines: helios/src/server/protocol/encode.rs:67-79, :232-241
Absent/suppressed/single are equally expressible as Option<Timing> plus a suppressed: bool, dropping the RequestMetrics::Suppressed variant (:69-70) and both match arms (:244, :252-255); flattening Timing's three fields onto Encoder removes the wrapper struct (:73-79) and its single constructor site (:239). Two lenses argue for the current shape (the three-state enum reads better than Option<Option<Timing>>; Encoder::streaming is written only by set_logprobs, so folding in the streaming parameter would couple placement to that field), so take this only if the maintainer wants the smaller surface. Do not delete generate_observed/enqueue (runtime.rs:837-844): they are pre-existing on main (main runtime.rs:828-835) and outside this diff.
Nits
N1. The Cost sentences should name #548's commit and say "per step, shared by its lanes"
The description's "This PR adds no clock read; the one monotonic read per scheduled model step comes from #548" is accurate — verified: commit 66245920 ("Reuse GraphKind::samples for model-step metrics and stamp scheduled time after packing") is in pr/548 history and in this branch, and helios/src/server/runtime.rs:2272 is its line — but a reviewer reading this PR's diff against main sees the call arrive. Name the commit, and say the read is per step, shared by every lane through get_or_insert (runtime.rs:2273-2285), so the cost is neither over- nor under-stated. docs/api.md:1025-1026 already says this about completion instants.
N2. mean_itl_ms is not exactly vLLM's on speculative cores
encode.rs:266-268 divides first→last by generated - 1. A speculative step commits several tokens that share one completion instant (docs/api.md:1025-1026), so the true interval count is smaller and the mean is understated relative to vLLM. The count already exists (RequestRecord::tokens_committed, helios/src/server/runtime.rs:1798-1802), but since the table row at docs/api.md:1022 already defines the field as the code computes it, the cheaper fix (and the subtractive one) is one clause in that row — "intervals are counted per generating step, so a speculative step is one interval" — rather than carrying a new field.
N3. first_scheduled_ns now follows image conditioning, and still precedes a submission that can fail
The stamp moved after pack_vision/conditioned_inputs_ready (helios/src/server/runtime.rs:2228-2268, stamp at :2272), which is right for the failed-pack case but changes what the instant means on the vision path: queue_time_ms (encode.rs:265) now includes image conditioning, and time_to_first_token_ms (:262) starts after it — while docs/api.md:1018 defines queue time as "Model-queue arrival to the first model step that includes the request". The stamp also now precedes only submit's guards (runtime.rs:2289-2299), which can still fail for that step, so the comment at :2269-2271 covers the pack but not the submit. Either stamp before the vision pack (documenting that a failed pack leaves it null anyway) or say in api.md/model-contract.md (not opened) that for image requests the instant follows image conditioning.
N4. Three copies of the placement/null rule, two of them in the encoder
encode.rs:232 (pointer), :242-243 (restates the signature) and :248-250 (restates placement, the six-key rule and the content null) repeat what docs/api.md:1015-1043 states and what enable_request_metrics states executably at :233-241. Keep one pointer line each — "The metrics object or its omission, per docs/api.md#per-request-metrics" — so the rule changes in one place. AGENTS.md:190-192 (not opened) does not count comment expansion as a contribution.
N5. timed_pass adds a third copy of the step-generates predicate
helios/src/server/runtime/phase_tests.rs:4541-4543:
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 authoritative semantics live in the scheduler, so if the sampling graph set changes, three test loops silently disagree with production — including the one this PR's evidence relies on. Extract one helper beside completion (:372) and call it from all three sites, or have timed_pass reuse budget_pass's predicate.
Verified sound (recorded so it need not be redone)
- Placement. Non-stream bodies get
response["metrics"]only when!streamingand the encoder has a value (helios/src/server/http.rs:606-615); Chat/Completions put it on the final usage chunk (encode.rs:712-719), Responses onresponse.completed/response.incomplete(encode.rs:731-744); Messages never, becauseenable_request_metricssetsself.metrics = NoneforProtocol::Messages(encode.rs:235-236). The gate ishttp.rs:387-389onstate.per_request_metrics, defaulting false (helios/src/server.rs:148(not opened),:333). first_scheduled_nsfold.http.rs:538isfirst_scheduled_ns.into_iter().chain(times.first_scheduled_ns).min()— earliest value, so the previous last-writer-wins concern is gone; the response-levelperformanceathttp.rs:605-611matchesObservationOptions::finish(observation.rs:58-74).- Lifetime through preemption.
RequestTimesispub(metrics.rs:326(not opened)) and exported besideSnapshot(server.rs:33(not opened));recordtravels withIncomingthrough park/readmission (runtime.rs:196-198,:2116-2157), so instants survive preemption andlast_token_nsspans the park. - Option-off wiring.
http.rs:384-389:enable_request_metricsis never called,record_timesnever runs, and the only added work is copying aCopy17-byteRequestTimesand au64into the fourFinishedsites (runtime.rs:302-307,:1891-1899,:2070-2078). GraphKind::samples()(helios/src/execution/manifest.rs:90-101(not opened)) reproduces the previous inline seven-variantmatches!exactly (Init,Restore,Snapshot,Visionexcluded in both) atruntime.rs:1727-1729.- Configuration plumbing.
[server] per_request_metricsfollowsthinking_token_budgetone-for-one:flare/src/configuration.rs:34(not opened),flare/src/settings.rs:32(not opened)/:224,flare/src/controller.rs:2566(not opened),flare-cli/src/config.rs:73-75,flare-cli/src/main.rs:355-357, andBootstraprejects a non-boolean rather than dropping it (helios/src/server/config.rs:353-357, test:727-739) — the "accept and quietly drop" failure is gone. The stacked-diff attribution ofmetrics.rs(not opened)/latency.rs(not opened)/scheduler.rs(not opened) and thedocs/api.md:305-386block to #548 is confirmed. - Event shape.
Finishedgains twoCopyfields rather than a new event variant, so the event budget (runtime.rs:62-84) andemit'spublishesclassification (:365-389) need no change. - Docs honesty.
docs/api.md:1025-1038records theinclude_usagegap, thatqueue_time_msincludes the channel send and worker pickup, and that Flare has no--enable-force-include-usagecounterpart — documenting a limitation rather than hiding it is whatAGENTS.md:57-60(not opened) asks, and the description now carries it too.
Open questions / not verified
- Authorization (S1) — one maintainer line on #551 closes it.
- Whether Orbit should read
[server] per_request_metricsis a design call; the doc fix in S3 stands either way. - Whether the phase-test carrier assertions were deliberate end-to-end drift guards — settles the size of SUB1 (if yes, it shrinks to the
n = 2block plus the plumbing). - Magnitude of the extra span in
queue_time_ms(group validation + channel send + worker pickup) is a measurement question; the docs state the boundary without asserting a size. - Not verified by me: no GPU, no exported core, no live server, no llama-swap, no Windows or multi-GPU build, no
cargo test, noignitionrun; CI on head046aaefreports no checks. The PR's live matrix and CPU numbers are taken at face value. Every finding above is read from the code and docs at046aaef. - #548 remains open, so this PR's own delta is the encoder, the four
Finishedemit sites, the config chain and the docs; re-base and re-review after #548 lands.