Architecture report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/77f4743e-b376-447e-a544-8ed7e255a296.md

Architecture & scope review — PR #548 "Add per-request histograms and vLLM-parity request metrics"

Head reviewed: 055663a ("Place request-histogram docs and test rows apart from the KV-page gauges"), atop 49373bc5, 15018689, 01f1e92b, 10c0b937, 54e06b30, ebecef13. Nine changed files, +1016/−51: docs/api.md, helios/src/server/{scheduler.rs, scheduler/tests.rs, server.rs, http.rs, latency.rs, metrics.rs, runtime.rs, runtime/phase_tests.rs}. Every file was read with its surrounding code; rules were read in full (charter via read_charter, AGENTS.md:160-210, design-review principle referenced from prior passes).

Key findings

Verdict: should-fix issues only — no blocking architectural defect. The design is the right one for this repository and sits in the right layer. All new observations are recorded inside Metrics::request_completed, which now holds the only completed.fetch_add in helios/src (metrics.rs:558, with callers at runtime.rs:1875 and runtime.rs:2038), so flare_requests_completed_total and the histograms cannot drift apart — this is the charter's "solve the right problem in the right place" applied to metrics. Fixed-bound histograms need no per-request storage; the only added per-request state is a RequestRecord on Incoming, which travels with the request through parking (parked takes the whole struct), so stamps and preemption counts survive preemption without a side table. There is no configuration flag, no per-model branch, no environment switch, no change to Snapshot/format=json, and no Cargo change.

I explicitly considered and rejected the obvious alternative source — the scheduler trace in metrics/scheduler.rs (not opened). That trace is a gated, bounded diagnostic (detail_requested: AtomicBool, TRACE_CAPACITY = 1024, is_enabled()), so building histograms on it would require exactly the switch AGENTS.md:188-190 forbids. RequestTimes on the request is the correct design, not a duplicate of it.

Two should-fix items remain, neither a code defect: one is authorization/scope (a closing keyword that no longer matches its issue, plus a new competitor-parity doc table offered as the justification), and one is a consolidation question raised by the new histogram type. Three nits follow.

Items from my earlier passes that are now moot — do not re-raise them. Commit 54e06b30 deleted helios/src/server/metrics/process.rs (not opened) and the process_* families outright (verified at pr/548: list_files under helios/src/server/metrics* returns only metrics.rs and metrics/scheduler.rs (not opened); search_code for process_|sysconf|/proc/ under helios/src/server returns nothing). That removes my eos-layering should-fix, the raise_open_file_limit(0)-used-as-a-getter problem, the impossible-source fallback nit, and the blocking-/proc-reads-per-scrape half of my cost finding. The description was also rewritten: it now says "Read from the code; no benchmark was run", itemises per-step, per-request, per-admission, per-response, per-rejection and per-scrape cost, and states "Scrape latency, scheduler-step cost, and CPU overhead under load are not measured". I re-derived its scrape arithmetic and it is correct (17 histograms = 6×21 + 2×19 + 5×21 + 6 + 9 + 21 + 21 = 326 bucket loads; 394 exposition lines = Σ(N+4)). The docs/api.md population text was corrected in 49373bc5 (zero-token completion, the "recorded only if the request reached such a step" guard on queue time, ≥2-token eligibility for decode and time-per-output-token, the prompt-scoring zero-limit skip), which closes my earlier population-mismatch nit.


Should fix

1. Scope authorization: the closing keyword no longer matches its issue, and competitor parity is now the organizing principle

PR description ("Closes #536"; "This change exports no process_* series; host-process CPU, memory, and descriptor metrics are outside its scope"); docs/api.md:475-515 (the new ### Correspondence with vLLM metrics section and its 31-row table); issue #536; AGENTS.md:165-169, :188-193, :201-203; charter, "What gets merged" and "Alternatives / Competitors".

Two separate problems in one finding:

(a) The closing keyword overstates what the PR delivers. Issue #536 (Napuh) is titled "Metrics: add request latency histograms and process metrics for monitoring parity with vLLM", and its body carries its own table of the four standard process_* series it wants (process_cpu_seconds_total, process_resident_memory_bytes, process_open_fds, process_start_time_seconds). Commit 54e06b30 removed exactly that half; the description now concedes it in one sentence ("outside its scope"). Closes #536 would therefore mark the issue resolved with one of its two stated deliverables neither shipped nor deferred to a tracked issue. Fix: reference #536 as partial rather than Closes, or split the process metrics into a follow-up issue and say so.

(b) The authorization gap widened rather than closed. My previous passes asked for a maintainer decision on #536 or a reframing around the observable defect. The six commits in this head did neither; they added a 42-line table mapping ~40 vLLM metric names to Flare series, which makes parity with another engine the PR's justification. The rules that bear on it:

The defect itself is real and the description now states it plainly — "an operator cannot see tail latency, queue delay, prefill time, decode rate, prompt size, preemptions, or how many requests a queue limit turned away from a scrape". That framing is what the rules can authorize; the mapping table is not. Since the PR is still open with no human review recorded, this is a cheap ask: record a maintainer decision on #536, or reframe around the observability defect.

Verifiable maintenance cost of the table, independent of the authorization question. It opens with "each metric in vLLM's production metric list, named here without the vllm: prefix" (docs/api.md:477-479) and never names or cites the upstream version the list came from, so every row is coupled to another project's release and will rot silently. Several rows make negative claims about this repository's own future (repetition: "not provided", docs/api.md:498; corrupted_requests, docs/api.md:511; KV page residency, :512; lora_requests_info/watermark_requests/engine_sleep_state, :514; KV connectors, :515) that no test guards. Fix: keep the Flare-side series documentation (genuinely useful, and it is what the rest of the section does well); either drop the mapping table or move it to the issue/PR discussion where it can be debated without becoming a maintained cross-project contract. If a mapping is kept, cite the vLLM version it was read from.

Worth flagging to the maintainer alongside: the same author's #549 (KV pages held by active requests), #551 (per-request timings on final responses) and #552/#553 rebuild overlapping observability surfaces, and #553 was already closed. A maintainer should shape this cluster once rather than merge variants one at a time — this PR and #549 already needed a manual row-split commit 055663a to stay rebasable.

2. A fourth histogram convention now coexists with three existing ones in one module

helios/src/server/metrics.rs:199-209 (HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS as [u64; 8] ending u64::MAX), :819-841 (host_lookup_cost, observation by limits.iter().position(|limit| value <= *limit).unwrap() at :838, sums in host_cost_sums at :475), :1178-1214 (37-line hand-written render loop), :851-876 (flare_host_cache_retirement_seconds, counts pushed from selene), versus the new :211-322 (Buckets<N>/Histogram<N>, f64 bounds ending at f64::INFINITY). Rule: AGENTS.md:188-193 ("Do not add frameworks, extension points, speculative compatibility … Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost").

metrics.rs now contains four ways to declare and render a histogram:

Mechanism Where Shape
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS :199-209, observe :838, render :1178-1214 [u64; 8], u64::MAX as +Inf
flare_host_cache_retirement_seconds :851-876 counts pushed from selene, rendered by hand
new Buckets<N>/Histogram<N> :211-322, used at :406-421 and latency.rs:36 [f64; N], f64::INFINITY
single-value families via metrics::metric :1597-1602 region fixed flare_ prefix

The PR does not touch the older lines (its metrics.rs diff is +219/−0), so it leaves two ways to do the same thing in one file with no guidance for the next author — and this PR is the moment the convention is being introduced. The new type is clearly the better one: it carries bounds and scale together, has no unwrap(), and was reusable in a second module (latency.rs:36, :101-108) for FirstResponseSamples.

Fix (either is sufficient; both are small):

  1. Adopt Histogram as the single observe-based convention and migrate the three host_* lookup histograms onto it (:819-841 and :1178-1214). That deletes HOST_*_BUCKETS, host_cost_sums and the .position(...).unwrap() at :838, and is justified under AGENTS.md:193 as removing a demonstrated defect source. Do not migrate flare_host_cache_retirement_seconds (:851-876): those counts are pushed from the selene store rather than observed, so it legitimately cannot use observe — a one-line comment saying so would prevent a wrong "cleanup" later.
  2. Or add one sentence to the module doc naming which convention new histograms must use and why the u64 tables remain.

Not blocking; it is the one architectural cleanup the change makes overdue.


Nits


Verified sound (no finding)


Coverage

All nine changed files read with surrounding code at head 055663a: docs/api.md (:300-400, :460-525 re-read directly this run, plus the diff's new sections), scheduler.rs (:1596-1650, :1780-1815, and the cache_lookup_tokens sites), scheduler/tests.rs (diff), server.rs (:580-600, :660-720, :799-860), http.rs (:180-280, :380-660), latency.rs (whole file), metrics.rs (:195-330, :406-421, :440-480, :545-570, :815-845, :1176-1225, :1240-1420, :1597-1602, test fixtures), runtime.rs (:820-960, :1100-1215, :1330-1500, :1500-1620, :1620-1830, :1830-2080), runtime/phase_tests.rs (diff). Rules read: charter in full (read_charter), AGENTS.md:160-210.

Open questions (maintainer decision only)

Link: https://github.com/NVIDIA/hyperflare-inference/pull/548