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:
AGENTS.md:165-169: "Every contribution must address an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation. … Hypothetical future consumers … do not establish a need for a change."AGENTS.md:201-203: "An explicit maintainer request covering the work is sufficient authorization … A feature request, passing tests, or a performance gain does not waive an architectural invariant."AGENTS.md:188-193: "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement."- Charter, "What gets merged": maintainer request, roadmap item, reproducible bug, measured performance/memory issue, or bad docs. The description cites #536 (an outside contributor's feature request) and nothing else.
- Charter lists vLLM under "Alternatives / Competitors". Dashboard compatibility with a competitor is not a stated compatibility goal; the compatibility targets the charter names are the OpenAI API, the Anthropic Messages API and JSON Schema.
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):
- Adopt
Histogramas the single observe-based convention and migrate the threehost_*lookup histograms onto it (:819-841and:1178-1214). That deletesHOST_*_BUCKETS,host_cost_sumsand the.position(...).unwrap()at :838, and is justified underAGENTS.md:193as removing a demonstrated defect source. Do not migrateflare_host_cache_retirement_seconds(:851-876): those counts are pushed from the selene store rather than observed, so it legitimately cannot useobserve— a one-line comment saying so would prevent a wrong "cleanup" later. - Or add one sentence to the module doc naming which convention new histograms must use and why the
u64tables remain.
Not blocking; it is the one architectural cleanup the change makes overdue.
Nits
- The upstream list the mapping table is built on is never named.
docs/api.md:477-479: "The table gives the Flare series that measure each metric in vLLM's production metric list, named here without thevllm:prefix" — no link, no version, no commit. A reader cannot check a single row, and the rows cannot be re-verified when vLLM revises the list. One citation sentence, or the restructuring in should-fix 1, settles it. flare_cache_lookup_tokens_totalcannot reach a 100% hit rate by construction, so the documented ratio is biased low.docs/api.md:368-372says the metric "counts the prompt tokens of admitted requests offered to GPU prefix lookups, including readmissions, andflare_cache_reused_tokens_totalcounts the tokens found, so their ratio is the token hit rate". But the increment is the whole prompt —let looked_up = if spec.prompt_logprobs { 0 } else { spec.prompt.len() as u64 };(scheduler.rs:1601), added at scheduler.rs:1802 — while a prefix lookup can never supply the request's final prompt token (a request needs one token left to generate). The ratio is therefore biased low by roughly one token per request. Either subtract the one token that cannot be reused, or say in the doc that the denominator is the offered prompt length and the ratio is a lower bound on reuse. The exact ceiling is set bycache.lookup(&history)'s key derivation and would need that function read to pin precisely; the bias itself is visible at the increment site.- The time-to-first-response histogram is rendered from
server.rsrather than insideMetrics::render.state.first_response.render_histogram(&mut text)athelios/src/server/server.rs:671(not opened), while every other family formats inmetrics.rs. The split is now necessary — the histogram lives inFirstResponseSamples(latency.rs:36,:101-108) andMetricsholds no handle to it — so this is a placement note for whoever later wires it intoMetrics::render, not a defect. Recording it once; no action required.
Verified sound (no finding)
- Counter and histograms cannot diverge. The only
completed.fetch_addinhelios/srcis metrics.rs:558, insiderequest_completed(metrics.rs:545); both former direct increment sites now call it (runtime.rs:1875 text stop, runtime.rs:2038 natural finish). - Stamps and preemption counts survive parking.
RequestRecordlives onIncoming, which is moved wholesale into the parked list and reused on readmission;record.preemptions += 1sits only inpark_if_preempted, not in the reasoning-budgetpark, so a budget cut is not counted as a preemption — matchingdocs/api.md:373-375("after a preemption, a reasoning budget cut, or a host-store restore") and pinned byreasoning_budget_cuts_after_a_multi_token_speculative_completion(phase_tests.rs, assertsle="0"= 1) andexercise_text_preemption(preemption lands inle="1"; parked gauge 1, pending 0).reasoning_budget_cuts_or_plainly_continues_with_exact_history_and_usageasserts, after a forced park,flare_request_queue_seconds_count1,flare_request_prefill_seconds_count1, andflare_request_prompt_tokens_sum1 (_sum, not_count, because the prompt is one token) —phase_tests.rs:576-583. record.max_tokensis taken correctly. Set once underif !incoming.readmittedafterreasoning_cutmay already have been taken on a later admission, so the guard is what makes the value right, and the park path rewritingmax_new_tokenstoremainingcannot lower it.- One instant per committing step. The stamp happens at the request's first token position within the step (
if position == 0), with positions reset per step, so tokens committed by one model step share one instant and a multi-token speculative round yields exactly one inter-token interval.tokens_committedsetsfirst_token_nson the first call and observes withsaturating_subafterwards, so no underflow. - Bucket and render arithmetic.
observeusesexposed <= boundwithposition(...).unwrap_or(N - 1); every bounds array ends at infinity; the cumulative_countequals the+Infline;absorbmerges a request's inter-token histogram into the shared one without losing buckets.unwrap_or(N-1)is unreachable but harmless. - The e2e population is right. The observation is guarded by
!count && !encoder.tool_limit_reachedbeforeyield Delivery::Complete(http.rs:604-613);countis/v1/messages/count_tokensonly andtool_limit_reachedforcesTermination::Cancelled.disabled_parallel_calls_complete_http_and_stop_decodingpins that a tool-limit cancellation leaves the e2e count at 0, across stream, non-stream and all three protocols. response_completedcannot panic onchunks(0):decoded.request.choicesis ≥ 1 whenevergenerateruns, becausegeneration_countrejects a zero product before the request is prepared.- Admission rejections are counted at exactly the three queue-limit sites (
http_slotsserver.rs:816,generation_capacityhttp.rs:240 / runtime.rs:869,request_queueruntime.rs:945); paused admission and an unavailable runtime return 503 without counting, matchingdocs/api.md:377-382.full_runtime_queue_limits_count_admission_rejectionsandfull_http_admission_counts_a_queue_limit_rejectionpin them. flare_model_step_tokensobserves the documented graph set: prefill, resume, decode, speculative and mixed, matchingGraphKind::samples(), excluding init/restore/snapshot/vision.ignored_eos_at_the_output_limit_finishes_for_lengthpins two model steps totalling three tokens andflare_requests_output_limited_total1.flare_request_prefill_computed_tokensexcludes prefix reuse at admission (prefill_computed_tokens_exclude_the_prefix_reused_at_admission: 13 computed over two requests against a 13-token reuse).- The JSON snapshot is unchanged and contains no histograms, as claimed. The terminal dashboard never calls
Metrics::render(it rendersmetrics.scheduler_tracedirectly), soformat=jsonand the dashboard cannot see the new families. - The
stop=completed − output_limiteddecomposition is the right shape. One counter rather than a label on the completion counter (which would change that series' identity) or a reason-labelled counter (which would duplicate the completed, cancelled and failed counts).metrics_route_serves_prometheus_or_json_without_the_api_keyshows the text scrape carrying the first-response histogram and an e2e histogram with no observations. - Nothing in the change touches scheduling, eviction, response bodies, cache state or exported cores, which is the compatibility question the charter's "Supported matrix & compatibility" asks; the diff is additive observations plus one unified counter increment.
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)
- Will a maintainer record authorization on #536, or will the description be reframed around the observability defect (tail latency, queue delay, prefill time, decode rate unobservable from a scrape)? Nothing in the repository settles it.
- Does a cross-project vLLM mapping table belong in
docs/api.mdat all, and if so, against which upstream version is it pinned? - Whether the four
host_*/lookup histograms should be consolidated ontoHistogramnow, or given a written convention instead.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/548