Architecture report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/be413d2d-8cb8-4520-9787-416317f75bd8.md

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:

  1. 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.
  2. A fourth histogram convention in one module. Buckets/Histogram now 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 three host_* 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


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:

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:

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

  1. Unversioned upstream reference. docs/api.md:477-478 names "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).
  2. The documented token hit rate is biased low by construction. docs/api.md:368-372 says flare_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 at scheduler.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)/n per request" or stop presenting it as a hit rate.
  3. The first-response histogram is rendered outside Metrics::render. state.first_response.render_histogram(&mut text) at helios/src/server.rs:671, while every other family is formatted inside Metrics::render (metrics.rs:1178 onward). The split is forced by ownership — the histogram lives in FirstResponseSamples (latency.rs:36, :101-108) and Metrics has no handle to it — so this is placement only; noting it because it is the one family an author reading Metrics::render will not find.
  4. Queue-interval start is under-described. docs/api.md:329-336 says 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 and flare_request_prefill_seconds therefore 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)

What I could not settle

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