Architecture report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/70856b67-f2e8-41f8-ba81-83bbd7394ffa.md

Key findings

Reviewed through the architecture-and-scope lens against the project charter, AGENTS.md, docs/design-review.md and the surrounding Helios code. All eight changed files were read in context (metrics.rs, metrics/process.rs, runtime.rs, http.rs, latency.rs, server.rs, phase_tests.rs, docs/api.md), plus eos/src/unix.rs, helios/src/runtime_core/protection.rs, docs/design-review.md and the scheduler's arrival accounting.

No blocking architectural violation. The approach is the right one for the problem: fixed-bound histograms recorded where the completed-request counter is already incremented, no per-request storage, no new snapshot/JSON fields, no flags, no model-specific branches, no crossing of the preparation/runtime boundary.

Two items should gate merge:

  1. Layering. New helios/src/server/metrics/process.rs does raw procfs/sysconf/getrlimit work inside the serving metrics module, against AGENTS.md:21-22, duplicating both eos/src/unix.rs primitives and an existing /proc/self/fd counter in helios/src/runtime_core/protection.rs.
  2. Authorization. The PR rests on issue #536, an outside request framed as vLLM dashboard parity; that is not one of the charter's merge criteria and vLLM is a listed competitor, not a compatibility target.

Then: a documentation/code semantics mismatch in docs/api.md, two duplicated mechanisms inside metrics.rs/process.rs, and an unmeasured serving-cost claim with self-inconsistent live-scrape arithmetic in the description. One nit about where the TTFR histogram is rendered.

Order below: verdict → scope → layering → docs semantics → duplication → evidence → nit → what was verified sound → what I did not cover.


1. Should fix — procfs/OS access belongs in eos/, and the /proc/self/fd read already exists in Helios

File: helios/src/server/metrics/process.rs:51-133 (whole render_linux), with :59-77 holding the OS calls.

The new module reads /proc/self/stat, /proc/stat (btime), and /proc/self/fd, and calls libc::sysconf(_SC_CLK_TCK), libc::sysconf(_SC_PAGESIZE) and libc::getrlimit(RLIMIT_NOFILE) directly from inside the serving metrics code.

Why it matters. The repository states the opposite home for this:

This is exactly the charter's first working rule — "Solve the right problem in the right place… Good ideas in the wrong place will be declined, and we'll point you to where they belong" (charter, "How We Work"), backed by AGENTS.md:21-22. It is also the avoidable kind of duplication AGENTS.md:188-193 pushes back on.

Fix. Move the procfs/rlimit reading into eos/src/unix.rs as small Linux-gated typed accessors (page_size exists; add clock ticks and monotonic-free stat/btime/max_fds readers), have runtime_core::protection::open_descriptors and the metrics renderer both call them, and leave process.rs responsible only for metric formatting. This also removes most of the #[cfg(target_os = "linux")] / let _ = text split from process.rs:8-14.


2. Should fix — scope authorization: "monitoring parity with vLLM" is not a merge criterion

Where: PR description ("Closes #536"), and issue #536 "Metrics: add request latency histograms and process metrics for monitoring parity with vLLM", which asks to move existing vLLM Grafana dashboards.

The rules that bear on it:

Nothing here is architecturally wrong — the concern is purely that the need is asserted from outside rather than established on this repository's terms. Note also that flare_request_queue_seconds etc. do not match vLLM's names (vllm:time_to_first_token_seconds, vllm:e2e_request_latency_seconds), so "parity with vLLM dashboards" is not even achieved literally; the claimed benefit is generic tail-latency observability.

Fix. Get a maintainer decision recorded on #536 (or on this PR) that metrics parity is wanted, or reframe the description around the defect — tail latency, queue delay, prefill time and decode rate are currently unobservable from a scrape — which is a "measured problem" of the kind the charter accepts for observability work. Either is cheap; relying on an outside issue is the part that will be contested.


3. Should fix — docs/api.md describes semantics the code does not implement

File: docs/api.md:296-318 (the new paragraphs).

3a. flare_request_prefill_seconds silently includes vision/init time

docs/api.md:306-308 says queue time runs "from model-scheduler arrival to the first model step that includes the request", and prefill "from that step to the request's first committed generated token".

first_scheduled_ns is stamped in Worker::reserve_and_pack (helios/src/server/runtime.rs:2187-2203) on every submitted step — the code does not filter by step.kind or lane kind, even though step.lane_kind(row).is_prefill() is already used elsewhere in the same file (runtime.rs:1665-1673, :2281) — and the surrounding context at runtime.rs:2208 shows GraphKind::Vision steps flow through the same function. first_token_ns is stamped only when a token is actually committed (runtime.rs:1774-1775 region, in Worker::complete).

So for a multimodal request the sequence Vision → Prefill → Decode means "queue" is arrival→first Vision step and "prefill" is Vision+Prefill work until the first generated token. That may be a defensible metric, but the doc names it "prefill", and the same file uses a narrower convention for prefill_tokens, "excluding padding and prefix reuse" (docs/api.md:340).

Fix: either narrow the stamp to the first step whose lane kind is prefill, or reword docs/api.md:307-308 to "first model step to first generated token (includes any vision/init step that runs first)".

3b. Population differs per family, and "cancelled and failed requests enter only…" is not the whole story

docs/api.md:312-313 states that cancelled and failed requests appear only in flare_requests_cancelled_total and flare_requests_failed_total. The code does route cancellation to cancelled without calling request_completed, so the headline claim holds for the two obvious paths — but the complement is what the doc does not say and what an operator needs:

Metrics::request_completed (helios/src/server/metrics.rs:452-480) observes flare_request_prompt_tokens unconditionally (:460-461), observes queue/prefill only when first_scheduled_ns is Some, and observes decode/per-output-token only when there is a first token and generated_tokens > 1 (:470-472). It is called from Worker::complete (runtime.rs:1841-1846) and Worker::publish (runtime.rs:1993-1998) for every request reaching the finishing phase, including ones that end with no generated token (budget/EOS close paths around runtime.rs:1940-1947).

Consequence: the request histogram families do not share a denominator with each other or with flare_requests_completed_total, so histogram_quantile(...) over flare_request_prefill_seconds and a rate over flare_requests_completed_total describe different populations. Compare the honest disclosure the JSON-side doc already gives for a similar case.

Fix: say in docs/api.md:305-313 which families a prompt-only request skips, and add a one-line comment in metrics.rs:459-479 saying why prompt tokens is unconditional while the timing families are conditional.


4. Should fix — two histogram implementations and two metric formatters now coexist in one module

Files: helios/src/server/metrics.rs:212-298 (Buckets<const N>, Histogram<const N>), alongside metrics.rs:1029-1065 (HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS plus inline cumulative rendering) and metrics.rs:670-692 (host_lookup_cost); helios/src/server/metrics/process.rs:42-49 (fn metric) alongside metrics.rs:1597-1602 (metrics::metric).

AGENTS.md:188-193 rejects "unsupported abstractions and churn… Do not add frameworks, extension points… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost", and docs/design-review.md:16-25 opens with "Keep Helios as simple as possible."

The new Histogram type is genuinely better than what exists — it carries bounds and scale together, selects the bucket with exposed <= bound and a guaranteed f64::INFINITY tail, and renders correct Prometheus 0.0.4 text. That is the argument for migrating the three host histograms onto it in this PR or a follow-up, not for leaving the file with two bucket-declaration conventions (u64 bounds with u64::MAX as +Inf vs f64 bounds with f64::INFINITY) and two render paths, so the next metric author must pick one without guidance.

process::metric is the milder half: it is a copy of metrics::metric minus the flare_ prefix, because process_* names must be unprefixed. A single formatter taking the full name, with callers adding flare_, would keep one implementation.

Fix: either fold the host histograms onto Buckets/Histogram here, or state in the PR that the migration is a follow-up and open the issue; and take a name argument in one shared metric helper instead of copying it into the submodule.


5. Should fix — the serving-cost claim is asserted, not measured, and the live-scrape numbers do not reconcile

Where: PR description, "Claimed result" and "Evidence"; code at helios/src/server/runtime.rs:1774-1775, :2187-2203, helios/src/server.rs:709, helios/src/server/metrics/process.rs:52-133.

docs/design-review.md:97-105 requires honest evidence: "Validate the real path and report evidence honestly… keep raw measurements and disclose unrun checks and material limitations." AGENTS.md:114-121 says the same, and AGENTS.md:194-199 requires each PR to "describe its problem, resulting behavior, validation, and material limitations."

The description says "Observability only… nothing about serving changes" and "This claims no performance or memory improvement". But the change does add serving-path work:

And the numbers in the description do not reconcile:

Fix: keep the unit-test evidence (which does establish the bucket boundaries and the excluded cases) as the primary evidence, restate the live scrape as a smoke check with the population caveat explicit, and state the per-scrape /proc cost as a known, unmeasured cost rather than "nothing about serving changes."


6. Nit — the TTFR histogram is the only family rendered from server.rs

Files: helios/src/server.rs:671 (state.first_response.render_histogram(&mut text)), helios/src/server/latency.rs:34-37, :63-131.

The data and eligibility rule live in FirstResponseSamples in latency.rs, which is the right owner (same clock and same eligibility as the median gauge). But the Prometheus rendering is a one-off in server.rs, while every other family formats via Metrics::render / metrics::metric. Also, render_histogram sits in a second impl FirstResponseSamples block (latency.rs:122-131) separate from the first (latency.rs:63-101). Both are harmless; worth aligning so all histogram output has one home.


What I verified as sound (recorded so it need not be re-derived)

Open questions / not covered