Subtractive report · NVIDIA/hyperflare-inference #560

Raw Markdown for agents: https://autobot.eidonix.com/p/0d553d5f-c01a-45b6-a955-e4b367480cdb.md

Key findings

The mechanism is right-sized: one branch on the serving path (helios/src/server/http.rs:387-389), no clock read (the instants are copied into GenerationEvent::Finished from values #548 already reads, helios/src/server/runtime.rs), and nothing allocated when the option is off (RequestRecord is Default). The feature addresses a reproducible client gap (issue #551: llama-swap reports -1 prompt/decode rates, internal/server/metrics.go (not opened) at v250), so it is in scope under the charter's "PRs that address … a reproducible bug". Nothing below proposes removing the option.

What is not minimal is the packaging: ~200 lines are removable, ~165 of them this PR's own, and they sit in one test file, one configuration layer and the documentation prose rather than in the mechanism. The largest single cut is two tests that re-prove at the HTTP layer what one encoder unit test already decides.

Verdict: make it smaller first. Findings ranked by lines saved.


1. Should fix — ~100 lines. helios/src/server/runtime/phase_tests.rs:4730-4850

Two new phase tests re-assert the placement and null rules already pinned by per_request_metrics_follow_vllm_placement_and_null_rules (helios/src/server/protocol/tests.rs:2346-2449: carrier frame and the six exact values 2375-2389, top-level body placement 2391-2398, no carrier without include_usage 2400-2406, Messages omitted 2408-2414, n>1 → null and several prompts → omitted 2416-2430, single-token and no-instants nulls 2432-2448).

Replacement (~125 lines → ~25) reuses the existing served_through_worker helper (:4563-4610):

#[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);
    }
}

Nothing is lost: placement and the null rules stay tested where they are decided (helios/src/server/protocol/encode.rs:232-275), and the runtime-instant proof stays in the two tests kept at :4612-4644 (first_scheduled_ns falls inside the first step) and :4685-4728.

Related nit inside the same file: Fixture::text_inputs (:61-73, 13 lines) is called only from new (:31), reasoning (:58) and the two tests above; folding the retain loop back into with_template saves ~5 more.

2. Should fix — ~37 lines. The [server] per_request_metrics file key is outside Ignition's schema

The documented key (docs/api.md:1007, docs/cli-design.md:736, :1318, :1349) is not in Ignition's configuration schema: ignition/cli/config.py:23-24 lists the server section as exactly host, port, api_key, thinking_token_budget, scheduler_checkpoint_extra_work_fraction, and Configuration._validate rejects any other key (ignition/cli/config.py:108-118, raised from load at :97-98) — behaviour pinned by tests/cli/test_config.py:151-177. _BUILT_IN (ignition/cli/config.py:37-53) has no entry either, and ignition/cli/serve.py:486-487 forwards only thinking_token_budget and scheduler_checkpoint_extra_work_fraction into the runtime options JSON. So the documented config.toml (not opened) key makes every ignition command fail with unknown key per_request_metrics in [server], and the Python serving path could not enable the option even if the schema allowed it. The Rust side tolerates it silently (flare/src/configuration.rs:26-35 has #[serde(default)] and no deny_unknown_fields), so the incompatibility is directional.

The only consumer without the flag is the desktop controller (flare/src/controller.rs:2566), and flare-winui has no control or bridge field for it (search over flare-winui/ returns nothing).

Smallest consistent version: keep --enable-per-request-metrics (flare-cli/src/cli.rs:649) and the runtime toggle, drop the file key — flare/src/configuration.rs:34; flare/src/settings.rs:32, its test :76-87, and :224; flare/src/controller.rs:2566; flare-cli/src/config.rs:73-75 and its test :222-234; the three docs/cli-design.md rows and the docs/api.md:1007 clause. Keep flare-cli/src/main.rs:355-356 (the flag still writes the JSON key the runtime reads) and helios/src/server/config.rs:353-356. The alternative — adding the key to _SECTIONS + _BUILT_IN and forwarding it in serve.py:486-487 — is an addition, outside this lens, but it is the other consistent state; the finding is that the PR currently ships neither.

3. Should fix — ~35 lines (shared with stacked #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 that the Prometheus HELP strings already ship on every scrape (helios/src/server/metrics.rs:1548-1642) and that the new 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.

4. Nit — ~12 lines. helios/src/server/config.rs:734-739

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

5. Nit — ~9 lines. helios/src/server/protocol/encode.rs:67-72 and :232-241

RequestMetrics::Suppressed (:69-70) exists only so metrics_value can return Some(Value::Null) (:252-255). metrics: Option<Timing> plus a suppressed: bool drops the two-variant enum and its two match arms. enable_request_metrics(&mut self, streaming: bool) (:233) takes a value already stored in Encoder::streaming (:91, set from decoded.stream at :184-187) — the sole caller passes decoded.stream at helios/src/server/http.rs:388 two lines after passing the same decoded.stream to set_logprobs (:375-379). Drop the parameter and read self.streaming. Three states (absent / null / single) remain representable and behaviour is unchanged.

6. Nit — ~7 lines. docs/api.md:1040-1050

:1040-1043's first sentence ("All six fields are always present, and a field is null when the request did not reach the instants it spans…") restates the table rows at :1020 and :1022; keep only the n>1 / several-prompts sentence (~3 lines). :1045-1050 re-describes the performance fields defined normatively at helios/model-contract.md:344-355, which the same paragraph links; replace with a one-sentence pointer (~4 lines). 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.


Checked and already minimal (no cuts found)

Left behind

None. No pre-existing path becomes dead. With the option off the only added work is one branch (helios/src/server/http.rs:387-389) and copying instants into the terminal event.

Totals

~200 lines removable, ~165 of them this PR's own (~14% of its +1757), ~35 shared with #548. Per file: phase_tests.rs ~100/535, api.md ~42/174 (~35 of it #548's), the config layer ~37, config.rs ~12/18 (test only), encode.rs ~9/68.

Open questions / limits