Architecture & scope review — PR #548 (Add per-request histograms and vLLM-parity request metrics), head 6624592
Key findings
Through the architecture-and-scope lens this change belongs in the repository and is put in the right layer: every new histogram is observed from Metrics::request_completed, which now holds the only completed.fetch_add in helios/src (metrics.rs:558), so counters and distributions cannot diverge; per-request state is one RequestRecord on Incoming that survives preemption; no flag, no model branch, no JSON/Snapshot change, no Cargo change. Nothing here violates the runtime/preparation boundary, and the newest commit (reusing GraphKind::samples(), stamping the scheduled instant after packing) removes a duplicated classification that could drift from the manifest's own definition.
There is no blocking defect. Two should-fix items remain, both about this PR's own framing and internal consistency rather than correctness:
- Scope authorization. The PR closes #536, whose two deliverables are request histograms and four
process_*metrics; the process half was deleted in 54e06b30 but the closing keyword was kept, and a new 42-line, unversioned table mapping ~40 vLLM metric names to Flare series makes competitor parity the organizing justification. AGENTS.md:165-169, :188-193 and :201-203 and the charter's "Alternatives / Competitors" authorize the defect framing (tail latency, queue delay, prefill time, decode rate unobservable from a scrape), not a cross-project parity contract. - A fourth histogram convention in one module.
Buckets/Histogramnow sits beside two[u64; 8]bucket tables, a push-based selene mirror and a hand-written 37-line render loop in the same file. The new type is the better one; adopt it as the observe-based convention and migrate the threehost_*lookup histograms onto it, which also deletes a.position(...).unwrap().
Nits: four minor documentation/placement items, listed at the end.
The PR is still an open draft with no human reviews and no CI checks on the head commit, so all of this is cheap to fix before merge — none of it is a post-merge objection.
Rules I judged against
- Charter (read in full). "What gets merged": PRs that address a maintainer request, a roadmap item, a reproducible bug, a measured performance/memory issue, or bad docs. "Keep the runtime small and model-agnostic … Helios (the runtime) handles scheduling, caches, and requests." "Supported matrix & compatibility: check interactions across every supported model, cache scheme, parallel layout…". vLLM appears under the competitor list, alongside SGLang, TensorRT-LLM and llama.cpp (not opened).
- 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, agent-generated suggestions, and lint findings alone do not establish a need for a change."
- AGENTS.md:188-193 — "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost."
- 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:194-199 — validation must exercise the affected behaviour and identify unrun checks explicitly.
- docs/design-review.md (not opened) principle 1 (single way to do a thing) and :97-105 (disclose what was not measured).
Should fix
1. Scope: "Closes #536" no longer matches the issue, and a competitor-parity table is now the organizing justification
Where: PR description ("Closes #536"); docs/api.md:475-515, the new ### Correspondence with vLLM metrics section, whose opening sentence reads "Flare exports no vllm: names. The table gives the Flare series that measure each metric in vLLM's production metric list, named here without the vllm: prefix, and the metrics Flare does not provide" (docs/api.md:477-482).
What is wrong. Two separate things:
- The closing keyword is now false. Issue #536 asks for request histograms and "standard process metrics" (
process_cpu_seconds_total,process_resident_memory_bytes,process_open_fds,process_start_time_seconds) — its title is "add request latency histograms and process metrics for monitoring parity with vLLM". Commit 54e06b30 deletedhelios/src/server/metrics/process.rs(not opened) and everyprocess_*family:list_filesatpr/548shows onlymetrics.rsandmetrics/scheduler.rs(not opened) underserver/metrics, and searchinghelios/srcanddocs/api.mdforprocess_cpu|process_resident|process_open_fds|process_start_timereturns nothing. Closing #536 with this PR marks it resolved while one of its two stated deliverables is neither delivered nor deferred to a tracked issue. The description itself concedes they are out of scope, so the keyword is the only inconsistency. - The authorization gap got larger, not smaller. A previous pass asked for a maintainer decision on #536 or a reframing around the observable defect; the new commits do neither and instead add a 42-line table that makes vLLM parity the PR's purpose.
AGENTS.md:165-169accepts a maintainer request, a demonstrated defect, a measured problem, or bad docs; the charter lists vLLM as a competitor, not a compatibility target;AGENTS.md:188-193bars "speculative compatibility".
Why it matters. It converts the repository into maintaining a contract with another project's release notes. Concretely, docs/api.md:477-478 names "vLLM's production metric list" with no version, link or commit, so every one of the ~40 rows is coupled to an upstream release and will silently rot; and at least eight rows assert that Flare does not provide something (repetition at :498, corrupted_requests at :511, KV page residency at :512, FLOP/byte estimates at :513, LoRA/watermark/sleep at :514, KV connectors at :515, the single kv_cache_usage_perc ratio at :490) — negative claims about future releases of this repository that no test guards.
Fix. Drop "Closes #536" and reference it as partial, or split the process metrics into their own follow-up issue and say so. Keep the Flare-side series documentation, which is genuinely useful; drop the mapping table, or move it to an issue/PR comment where it can be discussed without becoming a maintained cross-project contract. If a mapping is kept, cite the vLLM version it was read from. The description's own defect framing ("a scrape cannot show tail latency, queue delay, prefill or decode time…") is what the rules can authorize — lead with that.
2. A fourth histogram convention now coexists with three others in one module
Where: helios/src/server/metrics.rs. New: Buckets (:213) and Histogram (:257) with f64 bounds ending at f64::INFINITY, plus the REQUEST_SECONDS/TOKEN_SECONDS/… presets from :199 down. Existing, in the same file:
HOST_TIME_BUCKETSandHOST_TOKEN_BUCKETSas[u64; 8]ending atu64::MAX(metrics.rs:199-209), observed bylimits.iter().position(|limit| value <= *limit).unwrap()insidehost_lookup_cost(metrics.rs:819-841, theunwrapat:838), rendered by a hand-written 37-line loop (metrics.rs:1178-1214) with a parallelhost_cost_sumsarray for_sum;flare_host_cache_retirement_seconds, whose bucket counts are pushed from selene (Metrics::store,metrics.rs:854-876) and rendered by hand frompaths/elapsed_ns;- and the single-value
counter/gaugefamilies formatted throughmetrics::metric.
Why it matters. Three different ways to declare, observe and render a histogram in one module, with nothing telling the next author which to use, is precisely the "single way to do a thing" failure that AGENTS.md:188-193 targets, and the older .position(...).unwrap() is a latent panic the new Histogram::observe (which uses unwrap_or(N-1) and an INFINITY terminal bound) already solves. Note the diff does not touch :199-209, :819-841 or :1178-1214 — the duplication is a consequence of where the new code landed, not an edit to existing lines.
Fix. Adopt Histogram/Buckets as the single observe-based convention and migrate the three host_* lookup histograms (:819-841 observe, :1178-1214 render) onto it, deleting the two u64 tables, host_cost_sums and the unwrap. Do not migrate flare_host_cache_retirement_seconds — it is push-based from store counters and legitimately cannot use observe. Justification under AGENTS.md:192-193: the requested behaviour is the new observe-based histograms, so standardizing the existing observe-based ones on the same type directly supports it and removes a demonstrated panic source. Alternative, if the author prefers not to touch existing code: one paragraph in metrics.rs stating which convention new histograms must use and why the two u64 families are frozen.
Nits
- Unversioned upstream reference.
docs/api.md:477-478names "vLLM's production metric list" with no version, link or commit; every row is silently coupled to an upstream release. Cite the version or drop the table (see should-fix 1). - The documented token hit rate is biased low by construction.
docs/api.md:368-372saysflare_cache_lookup_tokens_total/flare_cache_reused_tokens_total"is the token hit rate". The denominator is the full prompt length —scheduler.rs:1601(let looked_up = if spec.prompt_logprobs { 0 } else { spec.prompt.len() as u64 };), accumulated atscheduler.rs:1802— while a prefix lookup can never supply the final prompt token (a checkpoint must leave at least one token to compute). So the ratio can never reach 1 for a fully-cached prompt. Either say "at most(n-1)/nper request" or stop presenting it as a hit rate. - The first-response histogram is rendered outside
Metrics::render.state.first_response.render_histogram(&mut text)athelios/src/server.rs:671, while every other family is formatted insideMetrics::render(metrics.rs:1178onward). The split is forced by ownership — the histogram lives inFirstResponseSamples(latency.rs:36,:101-108) andMetricshas no handle to it — so this is placement only; noting it because it is the one family an author readingMetrics::renderwill not find. - Queue-interval start is under-described.
docs/api.md:329-336says the queue interval ends at "the first model step that includes the request, which can be a vision step". The stamp is unconditional over graph kinds, so for an ordinary text request that step is the Init graph andflare_request_prefill_secondstherefore spans Init→first token, i.e. it includes graph-launch/init time as well as prefill. One clause naming init would settle it.
Verified sound (recorded so it need not be re-derived)
- Counter/histogram coherence. The only
completed.fetch_addinhelios/srcis metrics.rs:558 insiderequest_completed(:545), called fromruntime.rs:1866and:2029; the previous two direct increments are gone. - State survives preemption. A park moves the whole
Incomingintoself.parkedand readmission reuses it, soRequestRecordtimestamps,max_tokens(set once underif !incoming.readmitted,runtime.rs:1566-1570) and accumulated inter-token intervals reach completion intact. Preemption is counted at the real preemption site (runtime.rs:2101) and not at the reasoning-budget park (:1991). The park/readmit test asserts queue and prefill counts each 1, prompt-token sum 1 (phase_tests.rs:576-583). - Inter-token intervals are per committing step, not per token (
if position == 0+tokens_committed,runtime.rs:1791-1796), matching the description. - Bucket/render correctness.
Histogram::observeuses first-matchexposed <= boundwithunwrap_or(N-1), every preset ends atf64::INFINITY,_countequals the cumulative+Infbucket, and rendering emits+Inffor the infinite bound — consistent with Prometheus text 0.0.4 and with the pre-existing host-histogram convention. format=jsonunchanged.Snapshotgained no fields, so the compatibility claim holds.- Cancellation/failure exclusion.
!count && !encoder.tool_limit_reachedgates the e2e observation (http.rs:606-612), so token counting and tool-limit stops add none; admission rejections are recorded at exactly the four sites (server.rs:816,http.rs:240,runtime.rs:869,:945) thatdocs/api.md:377-382describes. - The newest commit.
kind.samples()(runtime.rs:1721-1723) is exactly the seven-kind set (execution/manifest.rs:90-101) and already carries this meaning atexecution/transport.rs:1319,:1334,execution/manifest.rs:944,model/testing.rs:170andserver/runtime.rs:2948; the stamp move to after packing keeps one clock read per submission, still covers requests driven straight throughreserve_and_pack, and leaves the stamp unset only when pack fails — a case the commit is retained for retry (phase_tests.rs:1323-1354) anddocs/api.md:331already covers.
What I could not settle
- Cost. The description now discloses "Read from the code; no benchmark was run" and itemises per-step, per-request, per-admission and per-scrape cost, which satisfies
AGENTS.md:194-199/docs/design-review.md:97-105(not opened); I re-derived the scrape arithmetic (17 histograms = 6×21 + 2×19 + 5×21 + 6 + 9 + 21 + 21; 326 bucket loads; 394 exposition lines) and it reconciles. Whether one extramonotonic_ns()per model step is material under high-throughput decode is only answerable by the benchmark the author says was not run — not a finding, just the one open number. - Multi-GPU cores and the Windows build are unrun per the description. Nothing in the diff is model- or device-specific, and the diff no longer contains platform-gated OS access, so I see no architectural exposure — but I did not verify it.
Coverage
Read in context at head 6624592: all nine changed files — docs/api.md (metrics section :296-395, the new mapping table :465-516), helios/src/server/metrics.rs (:196-230, :686-715, :819-880, :1170-1215 and the surrounding families), server/runtime.rs (:1540-1592, :1590-1760, :1955-2135, :2200-2387), runtime/phase_tests.rs (:355-450, :540-600, :1300-1370), scheduler.rs (:1591-1610, :1795-1812), scheduler/tests.rs (not opened), http.rs (:110-160, :200-265, :560-625), latency.rs, server.rs (:630-690) — plus execution/manifest.rs:85-102, execution/transport.rs:1290-1350, the charter, AGENTS.md:160-205 and docs/design-review.md (not opened).
Link: https://github.com/NVIDIA/hyperflare-inference/pull/548