Subtractive report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/d3bb5681-a66f-47f1-a627-85f7ff3e9b3b.md

PR #548, head 6624592 (9 files, +1016/−51 per pr_files). Lens: subtraction only. Reviewed against the charter, AGENTS.md (not opened) and the repository's design-review rules.

Key findings

Verdict: make it smaller first. The request-histogram core is right-sized; what is not minimal is the code around it: a histogram abstraction added beside the older hand-rolled histograms it supersedes, two per-response series that duplicate a per-request histogram, docs that restate the HELP text, and one duplicate test assertion. About 139 of the 1016 added lines (~14%) are removable, and the two largest cuts remove mechanisms rather than only lines.

Ranked by saving:

  1. Should fix, ≈55 lines — the three hand-rolled host prefix-store histograms left on the old machinery while the PR adds Histogram/Buckets.
  2. Should fix, ≈50 lines — the per-response choice histogram pair duplicates flare_request_generated_tokens.
  3. Nit, ≈30 lines — docs/api.md restates the HELP strings twice more.
  4. Nit, ≈4 lines — one duplicate test assertion.

Fixed since earlier rounds, not re-raised: the model-step gate now uses the existing kind.samples() (helios/src/server/runtime.rs:1721-1723), the first_scheduled_ns stamp moved after input packing (runtime.rs:2259-2275), the --features server build break is gone (metrics/process.rs (not opened) deleted), the duplicate e2e observation is gone, and the publish locals are hoisted.

1. Should fix, ≈55 lines — new Histogram/Buckets sits beside the three histograms it supersedes

The PR adds Buckets<N> (helios/src/server/metrics.rs:213-253) and Histogram<N> with observe/absorb/render (:257-322) for its 17 new histograms, but leaves the three existing host prefix-store histograms on the older hand-rolled machinery in the same file:

Nothing else reads those fields: search_code for host_missing_tokens|host_transfer_ns|host_prefill_ns|host_cost_sums returns only these sites plus the test asserts at :2089-2091, and no snapshot or JSON reader exists.

Smaller version:

const HOST_TOKENS: Buckets<8> = Buckets { bounds: [64.0, 256.0, 1024.0, 4096.0, 16384.0, 65536.0, 262144.0, f64::INFINITY], scale: 1.0 };
const HOST_NANOSECONDS: Buckets<8> = Buckets { bounds: [1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, f64::INFINITY], scale: 1.0 };

pub(super) fn host_lookup_cost(&self, hit: &flare_selene::HostHit, rate: f64) {
    let missing = hit.consumed_tokens - hit.resident_tokens;
    self.host_missing_tokens.observe(&HOST_TOKENS, missing);
    self.host_transfer_ns.observe(&HOST_NANOSECONDS, (hit.estimated_seconds * 1e9) as u64);
    self.host_prefill_ns.observe(&HOST_NANOSECONDS, (missing as f64 / rate.max(1.0) * 1e9) as u64);
}

for (histogram, name, help, buckets) in [
    (&self.host_missing_tokens, "host_cache_missing_tokens", "…", &HOST_TOKENS),
    (&self.host_transfer_ns, "host_cache_estimated_transfer_ns", "…", &HOST_NANOSECONDS),
    (&self.host_prefill_ns, "host_cache_estimated_prefill_ns", "…", &HOST_NANOSECONDS),
] { histogram.render(text, name, help, buckets); }

Labels, bucket counts and sums stay identical: scale: 1.0 keeps the exposed unit at ns/tokens, and Histogram::observe uses the same position(|b| exposed <= *b).unwrap_or(N-1) rule as the removed .position(..).unwrap(). The only visible change is three # HELP lines. Honest caveat: Histogram::render writes _sum as sum as f64 / scale (:315-319), so ns sums past 2^53 round where today's host _sum is exact u64 — the same trade the PR's own histograms already accept. Do not fold the 19-bound TOKEN_SECONDS request histograms into the 21-bound REQUEST_SECONDS loops; the bounds differ, so that is not lossless.

Charter anchor: AGENTS.md:188-193 (not opened) forbids unsupported abstractions and churn, and a new histogram type beside two older ones is exactly that.

2. Should fix, ≈50 lines — per-response choice pair duplicates the per-request generated-token histogram

Smaller: response_completed(&self, elapsed_ns: u64) observes request_e2e only, and http.rs:606-612 becomes

if !count && !encoder.tool_limit_reached {
    state.model.metrics().response_completed(admitted_at.elapsed().as_nanos() as u64);
}

Why nothing is lost: flare_request_generated_tokens already observes each completed request's count, and the PR's own docs (api.md:325-326) say Flare runs each choice as its own model request, so each of the n choices already enters a histogram with identical TOKEN_COUNTS bounds. flare_request_max_choice_generated_tokens adds only "the max of values already counted individually"; flare_request_choices reports the n parameter that only /v1/completions accepts. #536 — the issue the PR closes — does not ask for either, and nothing in the repo reads them (#541 does not name them). Counter-argument stated honestly: both are names in vLLM's production list, so removal weakens the "parity" framing, though not any consumer that exists today. If the author wants to keep request_choices, dropping only the max-choice series and its Vec still saves ≈25 lines.

3. Nit, ≈30 lines — docs/api.md restates the HELP strings, then the mapping table

docs/api.md:311-346 narrates e2e, queue, prefill, inference, TTFT, decode and inter-token in prose that metrics.rs:1548-1595 already ships as # HELP in every scrape (e.g. api.md:329-331 vs metrics.rs:1557; api.md:340-341 vs :1567, :1586), and api.md:377-386 states the same facts a third time before the correspondence rows at :501-504. Keep only what HELP cannot carry — which requests are excluded from which population, per-response versus per-request, the abandoned-stream rule — and drop the restatement: ≈30 of the +127 doc lines.

4. Nit, ≈4 lines — one duplicate assertion

reasoning_budget_does_not_readmit_eos_or_user_stops (helios/src/server/runtime/phase_tests.rs:944-946) renders /metrics to assert flare_requests_completed_total 1 and flare_requests_output_limited_total 0. The budget_events assertion at :937-940 already pins "stop", the sibling test asserts worker.metrics.completed.load() == 1 directly (:576), and the field→series mapping is asserted in the metrics unit test (:1971-1972). Only the output_limited 0 fact is unique — keep that one line, or fold it into the existing counter assertions.

Dropped after verification (do not raise)

Already minimal — say so plainly

The histogram set and bounds are exactly #536's missing-metrics table; the three RequestTimes stamps (runtime.rs:1789-1796, :2259-2275) are the minimum needed for queue/prefill/decode, and preemption survival costs nothing because parking moves Incoming; request_completed (metrics.rs:545-603) is the only increment of flare_requests_completed_total, which is the stated design; e2e is observed once (http.rs:606-612); publish_gauges (runtime.rs:1202-1211) is a fold of an existing block plus one store; the non-histogram touches — scheduler.rs +4, scheduler/tests.rs +7, server.rs +2 — are at the minimum for cache_lookup_tokens and the rejection counter.

Optional, not counted: latency.rs:101-108 render_histogram pass-through (sole caller server.rs:671, ≈7 lines); flare_request_inference_seconds (metrics.rs:412, :1569-1573, docs:333-334) is exactly prefill + decode on the same 21 REQUEST_SECONDS bounds and could be dropped for ≈20 lines, but vLLM exports request_inference_time_seconds and #536's table lists it — keep.

Open questions / not verified