Code review summary report · NVIDIA/hyperflare-inference #560

Raw Markdown for agents: https://autobot.eidonix.com/p/1cb8da22-85ab-44e1-bf29-1fa0f54a5c61.md

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 at metrics.rs:326 (not opened), server.rs:33 (not opened); Timing::streaming and record_commit are gone — Timing is {arrival_ns, times, generated}, encode.rs:73-79, with record_times at :243-247 its only writer), 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 — it survives only as nit N1. 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

  1. Blocker — the documented way to enable the feature fails every Ignition command. docs/api.md:1007-1008 and docs/cli-design.md:1318,1349 tell users to write [server] per_request_metrics = true, but ignition/cli/config.py:23-24 has no such key and :112-114 raises unknown key per_request_metrics in [server]. Every Ignition command loads and validates that same file.
  2. Should fix — authorization is still unconfirmed, though the evidence gap is now closed. #551 is a reproducible defect report (llama-swap showing -1 rates) and the PR carries a live 40-check matrix, 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.
  3. Should fix — the flag cannot express an explicit false, so a [server] per_request_metrics = true file or a saved Orbit group cannot be overridden for one run, contrary to docs/cli-design.md:1321-1322 and :1337-1338.
  4. Should fix — three documentation claims are wrong or unreadable from the document that makes them: the docs/cli-design.md:736 default for a flag shared by flare orbit run (which has no configuration path), the docs/api.md:1040-1043 null paragraph (a permanently-null field described as an unreached instant; the n > 1 null overstated), and docs/api.md:1045-1050 referencing a performance/token_timestamps_ns shape the file never defines.
  5. ~180 lines removable with no behaviour lost, ~110 of them in phase_tests.rs: two new HTTP-level tests re-assert encoder rules and hand-roll plumbing served_through_worker already provides. A further ~37 lines are available if maintainers prefer the other consistent state for the config key (see B1, option 2).
  6. Verified sound: placement for all four protocols, the first_scheduled_ns earliest-value fold, RequestTimes lifetime through preemption, GraphKind::samples() equivalence, the option-off wiring, and the Finished-field-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 block); ignition/cli/config.py:21-33 (_SECTIONS, server entry at :23-24), :37-53 (_BUILT_IN), :108-120 (_validate), :183-215 (write_initial). Loaders: ignition/cli/serve.py:127 (not opened),174,264,431,590; ignition/cli/bench.py:144 (not opened); ignition/cli/publishing.py:31 (not opened),73,174,194.

What is wrong.

Why it matters. This is not a doc typo: the enable path the PR documents is unusable for anyone who also prepares cores with Ignition, which is the supported workflow (docs/cli-design.md:1311-1313). The neighbouring keys show the required chain, and the new key copies only the Rust half: thinking_token_budget spans schema :23, built-in :39, validator, serve.py:486 (not opened) and template :192; scheduler_checkpoint_extra_work_fraction spans schema :24, built-in :40, validator :119-120, serve.py:487 (not opened) and docs/cli-design.md:1348. tests/cli/test_config.py:152-171 (not opened) already parametrizes unknown-key rejection, so CI would catch the omission the moment the key is added to the template without the schema entry — and catches nothing today. A repository-wide search finds per_request_metrics only in docs/, flare-cli/src/, flare/src/ and helios/src/: zero hits under ignition/ or tests/cli/. CI on the head commit reports no checks.

Requested change (one of two consistent states; the first is smaller in effort, the second in code).

  1. Add "per_request_metrics": bool to _SECTIONS["server"] (ignition/cli/config.py:23-24), "server.per_request_metrics": False to _BUILT_IN (:37-53), the commented line to write_initial (:188-192), options["per_request_metrics"] = … beside ignition/cli/serve.py:486-487 (not opened), and one positive load test beside the existing negatives (tests/cli/test_config.py:152-171 (not opened)). This introduces the first [server] key Ignition accepts but does not consume, so add the sentence that says so. Reproduce with one ignition export while the config carries the documented line.
  2. Or delete the file key rather than extending the strict reader: drop flare/src/configuration.rs:34 (not opened), flare/src/settings.rs:32 (not opened) and :224 (plus its test :76-87), flare/src/controller.rs:2566 (not opened), flare-cli/src/config.rs:73-75 (plus its test :222-234), the docs/cli-design.md:736,1318,1349 rows and the docs/api.md:1007 clause, keeping flare-cli/src/main.rs:355-357 (not opened) and helios/src/server/config.rs:353-357 (not opened) (the flag still writes the value the runtime reads). That is ~37 fewer lines and also dissolves the file half of S2, but it removes the only non-CLI path — the desktop controller through flare settings, which the description names — hence a product call, not a pure simplification.

Should Fix

S1. A maintainer still has to confirm that per-request response metrics are in scope

Where: charter "What gets merged"; AGENTS.md:165-169 (not opened), :188-193, :201-205; #551; #536; #548; #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 describes a reproducible defect — llama-swap v250 reads prompt/decode rates 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 (GitHub association NONE) on 2026-11-27 with zero comments, and the maintainer-authored issue in this area, #536, asks for Prometheus latency histograms and process_* collectors, 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; #552 likewise), and the charter's roadmap (in-process Rust SDK #6, Engram tables #267, FlashInfer fix #215) does not include response-body metrics. vLLM appears 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 field parity.

S2. The flag cannot express an explicit false

Where: flare-cli/src/cli.rs:646-649 (not opened) (OrbitRun) and :860-863 (Run) — plain bool, no negating form; flare-cli/src/config.rs:73-75; flare-cli/src/cli.rs:698-700 (not opened) (rank_zero_options emits the flag only 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 (and flare-cli/src/orbit/controller.rs:691-692 (not opened) merges saved group options above defaults), 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" (:1321-1322) and "saved group options and explicit flags take precedence" (:1337-1338). 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 (not opened)). Related path: flare-cli/src/main.rs:355-357 (not opened) writes config["per_request_metrics"] only when the flag is true, while flare/src/controller.rs:2566 (not opened) always writes it from settings — so a core whose exported server config says true (helios/src/server/config.rs:353-357 (not opened)) stays on under flare run even when the operator's file says false; latent today only because Ignition cannot emit the key (B1). Fix: tri-state (Option<bool> via num_args(0..=1)) or --no-enable-per-request-metrics with overrides_with, forwarded to rank zero, and write the override unconditionally in main.rs (not opened); at minimum document the limitation beside the flag. flare-cli/src/config.rs:222-234 today tests only omission, true, and false-in-file-turned-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 (not opened)) 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 its value from the flag alone, and the Orbit arm (config.rs:141-151) only sets cache paths. An operator who sets the key, launches flare orbit run, and trusts the table gets no metrics and no error. Fix: write "[server] per_request_metrics for native flare run, otherwise off" in the configuration column, the phrasing :1317-1318 already uses. Secondary, same row: neither --help string names the configuration key (cli.rs:646-648 (not opened), :860-862), so one clause ("default: [server] per_request_metrics") makes --help and the table 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 (not opened), ignition/cli/config.py:183-215, docs/cli-design.md:1385-1387.

debug-serve forwards thinking_token_budget and scheduler_checkpoint_extra_work_fraction from the config into the runtime options (serve.py:486-487 (not opened)) 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 reads a key Ignition's schema previously rejected. Fix: add the key to serve.py (not opened)'s options dict and to the template, and reword that sentence (or, under B1 option 2, drop its premise instead).

S5. docs/api.md:1040-1043 misdescribes a permanently-null field and overstates the n > 1 null

Three problems in one paragraph.

S6. docs/api.md:1045-1050 compares against a shape the HTTP API reference never defines

The 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 (one metadata-only chunk per token on a stream: helios/src/server.rs:915 (not opened), helios/src/server/http.rs:603 (not opened), helios/model-contract.md:328-342 (not opened)), that return_token_timestamps: true is rejected without return_token_ids: true (helios/src/server/observation.rs:37-39 (not opened)), or that performance accompanies only timed responses (observation.rs:70-74 (not opened)). The ../helios/model-contract.md (not opened)#token-and-timing-observation anchor resolves (model-contract.md:326 (not opened)), so nothing dangles, 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 adds a top-level performance object on buffered responses" — then let the new paragraph point at it (see SUB3).


Subtract / Simplify

Net ≈180 lines removable (~9% of the ~1,180 source/test/doc lines once #548's contribution is set aside), ~110 of them in one test file. No item asks to remove the option itself: #551 is a reproducible client gap and the charter merges PRs that fix one. (A further ~37 lines are available through B1 option 2, deleting the config-file key path; that is counted under B1 because it is a choice between two consistent states, not a pure simplification.)

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 plumbing that served_through_worker (:4563-4610) already provides.

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 what only HTTP can show: this on/off gate, the step-bound provenance at :4717-4726/:4767-4772, response.incomplete at :4764 if the end-to-end arm is wanted, and mean_itl_ms == generation_time_ms at :4773. Note the sample vector &[1, 2] holds only if both choices commit in one step — a test run settles it. Nothing is lost: placement and the null rules stay tested where they are decided (encode.rs:232-275), and the runtime-instant proof stays in the two kept tests (:4613-4647, :4685-4728).

SUB2 — should fix, ~30 lines, shared with #548: docs/api.md:305-386

Four new paragraphs (:305-309, :311-326, :328-346, :348-364) walk every histogram series with the same populations the Prometheus HELP strings already ship on every scrape (helios/src/server/metrics.rs:1548-1642 (not opened)) and that the correspondence table maps one-to-one (docs/api.md:475-517). Reduce to ~8 lines naming the groups plus the one rule the HELP strings do not carry ("successful completions only; only flare_time_to_first_response_seconds can observe a response that later fails", :361-364). This block arrives through #548, so it is one cut for the stacked pair rather than this PR's own — agree it with that PR. Materially larger than the subtraction lens's estimate only because the block is #548's prose, not this PR's.

SUB3 — nit, ~10 lines: docs/api.md:1040-1050

:1040-1043's first sentence restates table rows :1018-1022 and the encoder's own nulls; keep only the n > 1 / several-prompts sentence. :1045-1050 re-describes fields defined normatively at helios/model-contract.md:344-355 (not opened), which the same paragraph links; replace with the one-sentence pointer from S6. Keep :1025-1029 and :1031-1038: they are the only place in the docs stating the step-completion instant, the queue-arrival boundary and the include_usage gap. This is S5/S6 expressed as a trim, not as more prose.

SUB4 — nit, ~7 lines: helios/src/server/protocol/tests.rs:2334-2344 and :2366-2374

metered_generation's doc comment says "Feed one generation that reasons and then answers" and it applies Event::Reasoning("think"), an empty Content(String::new()), Content("answer") and Content(" more"), but every assertion in per_request_metrics_follow_vllm_placement_and_null_rules reads only the carrier frame's type/choices/usage or metrics_value(), which depends only on times and generated — the content instant is the constant Value::Null (encode.rs:263) and its measurement moved to #562. One apply(0, vec![Event::Content("answer".into())]) before record_times(1_000_000, times, 4) keeps the fixture honest and deletes a misleading comment. Second cut in the same function: the carriers closure (:2366-2374) clones whole frames (frame.data.clone(), metrics.clone()) to read three fields; collect (&Value, &Value) as phase_tests.rs:4751-4758 already does.

SUB5 — nit, ~12 lines, marginal: helios/src/server/config.rs:727-739 (not opened)

The strict-type rejection loop (1, "true", null) guards a key whose only writer emits a literal true (flare-cli/src/main.rs:355-357 (not opened)). The absent→false assertion and the shipped CLI test (flare-cli/src/cli.rs:1378-1401 (not opened)) already cover the behaviour; the loop tests a path no product reaches. Keep :727-733.

SUB6 — optional, ~9 lines: helios/src/server/protocol/encode.rs:67-79 and :232-241

Absent/suppressed/single are equally expressible as Option<Timing> plus a suppressed: bool, which drops RequestMetrics::Suppressed (:69-70) and its match arm (:252-255); and enable_request_metrics(&mut self, streaming: bool) (:233) takes the value already passed at helios/src/server/http.rs:388 (not opened), two lines after the same decoded.stream went to set_logprobs. 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 it in would couple placement to that field), so take this only if the maintainer wants the smaller surface. Do not delete generate_observed/enqueue (helios/src/server/runtime.rs:837-844 (not opened)): they are identical to main (runtime.rs:828-835 (not opened)) 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 is in pr/548 history and in this branch, and helios/src/server/runtime.rs:2272 (not opened) is its line — but a reviewer reading this PR's diff against main sees the call arrive (runtime.rs:2269-2285 (not opened)), especially since the preceding bullet says performance gains first_scheduled_ns. Name the commit, and say the read is per step, shared by every lane through get_or_insert (runtime.rs:2273-2285 (not opened)), 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 observes one interval per committing step (helios/src/server/metrics.rs:348-362 (not opened), called at runtime.rs:1798-1802 (not opened)) — but since the table row at docs/api.md:1022 already defines the field as the code computes it, the cheaper and subtractive fix 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 in RequestTimes.

N3. first_scheduled_ns now follows image conditioning, and still precedes a submission that can fail

The stamp sits after pack_vision/conditioned_inputs_ready (helios/src/server/runtime.rs:2228-2268 (not opened), stamp at :2272), which is right for the failed-pack case, but it 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 paragraph at :1025-1029 accepts "which can be a vision step" but does not say conditioning precedes the instant). The stamp also precedes only submit's guards (runtime.rs:2289-2299 (not opened)), 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 (a failed pack leaves it null anyway) or state in docs/api.md/helios/model-contract.md:343-355 (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 line), :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. Three copies invite divergence, and AGENTS.md:190-192 (not opened) does not count comment expansion as a contribution. Keep one pointer line each — "The metrics object or why it is omitted. See docs/api.md#per-request-metrics."

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)


Editorial reconciliation (which lens finding won)


Open questions / not verified

  1. Authorization (S1) — one maintainer line on #551 closes it.
  2. Whether the desktop controller needs the config key decides B1 option 1 versus option 2, and with it whether S2's file half exists at all.
  3. Whether Orbit should read [server] per_request_metrics is a design call; the doc fix in S3 stands either way.
  4. 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 = 2 block plus the plumbing).
  5. Whether helios/model-contract.md (not opened) is the canonical definition of token_timestamps_ns — if so, S6 shrinks to one clause, but the return_token_ids requirement still belongs in docs/api.md, the surface a client reads.
  6. 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.
  7. Not verified here: no GPU, exported core, live server, llama-swap run, Windows or multi-GPU build, no cargo test, no pytest, no ignition invocation; the head commit reports no CI checks. The PR's live matrix (40/40 request checks, 15.4–15.9 s vs 16.0–16.3 s CPU per 16×512-token run) and llama-swap rates are taken at face value. Every finding above is read from the code and docs at 046aaef.
  8. #548 remains open, so this PR's own delta is the encoder, the four Finished emit sites, the config chain and the docs; merge order must be #548 first, and #548's own open items (first_scheduled_ns origin, last_token_ns on reasoning-close) may move these fields — re-review after it lands.