Architecture scratchpad · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/4bac799e-00c5-417c-98a8-d037ab3fdeb9.md

#1 [high] Should fix: procfs/OS access added inside helios serving metrics instead of eos

PR 548 adds helios/src/server/metrics/process.rs (+184), which does raw OS work from the serving metrics module: std::fs::read_to_string("/proc/self/stat"), /proc/stat btime, std::fs::read_dir("/proc/self/fd"), libc::sysconf(_SC_CLK_TCK), libc::sysconf(_SC_PAGESIZE), libc::getrlimit(RLIMIT_NOFILE) (process.rs:51-133).

Why it matters — the repository states the opposite home for host-OS operations:

So the change both duplicates an existing helios helper and puts platform/OS code in a layer the project assigns to eos. Fix: move the procfs/rlimit reading into eos/src/unix.rs (Linux-gated, Windows returns None) as small typed accessors, and have both runtime_core::protection::open_descriptors and the metrics renderer call them; keep process.rs to formatting only. This also removes the reason for the manual #[cfg(target_os = "linux")]/let _ = text split.

Cite: AGENTS.md:21-22, eos/src/unix.rs:73,138, helios/src/runtime_core/protection.rs:290-302, helios/src/server/metrics/process.rs:51-133.

#2 [high] Should fix: scope authorization — "monitoring parity with vLLM" is not a merge criterion

The PR's whole justification is issue #536 ("Metrics: add request latency histograms and process metrics for monitoring parity with vLLM", opened by Napuh, not a maintainer in this repo's contributor list), which asks to "move existing vLLM Grafana dashboards" to Flare.

Rules that bear on this:

Nothing here is architecturally wrong; the point for the author is that the PR needs a maintainer decision recorded on the issue, or should be reframed as a defect (e.g. "tail latency is unobservable") rather than as vLLM parity. Also note the observation volume is real work in the hot path (a per-completion histogram update plus an extra render of ~6 families with 21/19 buckets), so "observability only, nothing about serving changes" (PR description) is an unmeasured claim about serving cost, not a proven no-op.

Cite: PR description "Closes #536", issue #536, AGENTS.md:165-169,201-203, charter "What gets merged" and "Alternatives / Competitors".

#3 [high] Should fix: api.md histogram semantics do not match the stamps (prefill includes vision/init; population differs)

docs/api.md:296-313 (new paragraph) states request-histogram semantics that the code does not implement as written. Both cases are user-visible in a scrape, so they are documentation defects, not code defects — but they must be reconciled with either the code or the text.

  1. Prefill time. api.md:307-308 says flare_request_prefill_seconds runs "from that step to the request's first committed generated token". But first_token_ns is stamped in Worker::complete when a token is generated (runtime.rs:1774-1775), and reserve_and_pack stamps first_scheduled_ns on every step, including vision/prefill/decode (runtime.rs:2189-2203: it does not filter by step.kind). So for a request that goes Vision -> Prefill -> Decode, "queue" is arrival to the first Vision/Init step and "prefill" is Vision+Prefill+prefill-queue time to the first generated token. Whether that is intended is arguable, but the doc calls it "the first model step that includes the request", which is accurate for queue and then says prefill is "from that step", i.e. it silently includes all pre-token graph work under the name "prefill". Compare the existing convention in the same file: prefill_tokens "excluding padding and prefix reuse" (api.md:340). Recommend either narrowing the stamp to the first step whose lane kind is prefill (step.lane_kind(row).is_prefill() is already used at runtime.rs:2281 and 1665-1673), or wording the metric as "first model step to first generated token".

  2. "Cancelled and failed requests enter only flare_requests_cancelled_total and flare_requests_failed_total" (api.md:312-313). False for two paths I can see in the code:

    • A successful request whose client disconnects after/generating: Generation::cancel() is called on drop (runtime.rs:175-179) and the runtime takes the finish_cancelled path (runtime.rs:293-300, 1334-1337) which does not count completed; it increments cancelled (runtime.rs:1407). Consistent.
    • But a request whose response is delivered while the batch also had a tool-limit cancel, or a request cancelled after request_completed ran in Worker::complete (runtime.rs:1841-1846) and then retired, will sit in both. That is unavoidable and fine. The real inconsistency is the converse: request_completed is called from Worker::publish (runtime.rs:1993-1998) for every request that reaches the Finishing phase, including ones whose generated_tokens is 0 for reasons other than cancellation (e.g. max_new_tokens exhausted by the reasoning-budget close path, runtime.rs:1940-1947 which calls record_decoded_token + progress, and the EOS-on-first-token path). Those are "completed" in flare_requests_completed_total today too, so the counter semantics are preserved — good — but the doc's claim "one observation per completed generation" then includes prompt-only/generation-less requests in flare_request_prompt_tokens and flare_requests_completed_total while contributing no queue/prefill/decode observation. The bucket counts therefore do not share a denominator across the request families, and histogram_quantile over e.g. flare_request_prefill_seconds is over a different population than flare_requests_completed_total. The doc should say which families skip which requests (it half does: decode "with at least two generated tokens", api.md:308-309) and the code should say why prompt_tokens is observed unconditionally while the others are conditional (metrics.rs:459-479).

Cite: docs/api.md:296-313, helios/src/server/runtime.rs:1774-1775, 1841-1846, 1940-1947, 1993-1998, 2187-2203, helios/src/server/metrics.rs:452-480.

#8 [high] Research summary

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

The mechanics are sound: the two direct completed.fetch_add sites are genuinely gone and both now go through Metrics::request_completed, parked requests keep their Incoming so the timestamps survive preemption, Histogram bucket/render output is correct Prometheus 0.0.4, and format=json is untouched. I recorded that verification so it need not be re-derived.

Findings, six recorded in the scratchpad:

No blocking defect: nothing violates the runtime/preparation boundary, no model-specific branch, no flag, no compatibility break. The blockers are the layering fix and the missing maintainer authorization.

#9 [high] Verdict and ordering for the report

Verdict (architecture and scope lens): the approach is right and the code is careful, but the PR should not merge as it stands. There is no blocking architectural violation — nothing crosses the preparation/runtime boundary (docs/design-review.md:27-30), nothing branches on model identity (AGENTS.md:346-352), no flag or environment switch was added (AGENTS.md:446-456), no captured-graph operation family was introduced (docs/design-review.md:22-25), and staging the change is unaffected: Snapshot gained no fields (helios/src/server/metrics.rs:69-130), so format=json and flare_helios::server::Snapshot deserialization are unchanged, which satisfies the model-core/compat expectations in AGENTS.md:431-444 by not touching prepared metadata at all.

Two items gate it:

  1. Layering — OS/procfs code belongs in eos/, and runtime_core/protection.rs already holds the same /proc/self/fd read (entry 1). This is the one a maintainer will flag first, because AGENTS.md:21-22 states it explicitly and the duplication is avoidable.
  2. Authorization — the work rests on issue #536 (vLLM parity), which is not one of the charter's merge criteria (entry 2).

Then the documentation/semantics reconciliation (entry 3), the duplicated histogram+formatter mechanisms (entry 5), the unmeasured serving-cost claim (entry 6), and one nit (entry 4).

Suggested review order for the final report: verdict → scope/authorization → layering → doc-vs-code semantics → duplication → evidence → nit. Entries 1-7 in the scratchpad hold the file/line citations for each.

What I did not cover, so it is not mistaken for a clean bill: the terminal dashboard path (server/dashboard.rs calls render()), the multi-host/Orbit /metrics?format=json consumer in docs/orbit.md:545, and whether phase_tests covers the streamed-Delivery::Complete e2e path only via the non-streaming case. Those are other lenses or unverified by me.

#5 [medium] Should fix: duplicate histogram and metric-formatting mechanisms in one module

Two net-new mechanisms were introduced where the repository already has the pattern, which AGENTS.md:188-193 asks reviewers to reject ("Do not add frameworks, extension points, speculative compatibility, fallback layers... Refactoring must directly support the requested behavior").

  1. Buckets<const N>/Histogram<const N> (metrics.rs:212-298) is a second histogram implementation alongside the existing HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS arrays + inline cumulative rendering at metrics.rs:1029-1065 and host_lookup_cost at metrics.rs:670-692. The new type is better (it carries bounds and scale together), so the right move is to migrate the three host histograms onto it rather than leaving two ways to declare a histogram in one file. As written the file has two bucket-declaration conventions (u64 boundaries with u64::MAX as +Inf vs f64 bounds with f64::INFINITY) and two render paths, so a future metric author has to pick one without guidance.

  2. process::metric (process.rs:42-49) duplicates metrics::metric (metrics.rs:1597-1602) except for the flare_ prefix, because the process names must not be prefixed. That is a legitimate difference, but it is currently expressed by copying the formatting function into the submodule. A single metric that takes the full name, with flare_ added by the caller, would keep one formatter.

Neither is blocking; both are the kind of "same thing twice in one module" that the design review's principle 1 ("Keep Helios as simple as possible") and the rejection criteria push back on.

Cite: AGENTS.md:188-193, docs/design-review.md:16-25, helios/src/server/metrics.rs:200-298,670-692,1029-1065,1597-1602, helios/src/server/metrics/process.rs:42-49.

#6 [medium] Claim/evidence gap: serving cost of the new observations and procfs scrape is unmeasured

The PR's own "Evidence" section (PR description) claims "Observability only: latency, prompt-size, and process resource distributions become scrapeable, and nothing about serving changes. This claims no performance or memory improvement". Per AGENTS.md:114-121 and docs/design-review.md:97-105, evidence must be connected to claims and limitations disclosed. Points to check, all verifiable in code:

Recommend the description state the observation cost explicitly and either present a scrape latency/pause measurement or say none was taken.

Cite: PR description "Claimed result"/"Evidence", AGENTS.md:114-121, docs/design-review.md:97-105, helios/src/server/runtime.rs:1774-1775,2189-2203, helios/src/server.rs:709, helios/src/server/metrics/process.rs:52-133.

#7 [medium] Verified sound: mechanics of the change (no finding)

Checked and found sound (so other reviewers need not re-derive, and so the author knows what I verified rather than assumed):

No finding recorded from this list.

#10 [medium] Description-evidence specifics (refines entry 6)

Concretely, from the PR description's own numbers (no code needed to see these):

Recommend the description either drop the live-scrape deltas in favour of the unit-test evidence (which does establish bucket boundaries, helios/src/server/metrics.rs:1649-1700) or restate them as a smoke check with the population caveat made explicit.

#4 [low] Nit: TTFR histogram render call sits in server.rs rather than with the other families

helios/src/server.rs:671 renders flare_time_to_first_response_seconds inline via state.first_response.render_histogram(&mut text) while everything else Prometheus-shaped lives in Metrics::render / metrics::metric. The histogram itself was added to FirstResponseSamples (latency.rs:34-37, 107-131), which is the right owner for the data (it is the same clock and the same eligibility rule as the median gauge). So the split is: data in latency.rs, formatting in server.rs, whereas other families format in metrics.rs.

Minor: FirstResponseSamples::render_histogram sits in a second impl FirstResponseSamples block (latency.rs:122-131) separate from the first (latency.rs:63-101) — same-file duplication, harmless.

Worth flagging only because the Histogram::render signature already prefixes flare_ itself (metrics.rs:273-297: "# HELP flare_{name}"), so callers pass bare names; that convention differs from metrics::metric (metrics.rs:1597-1602) which also prefixes. Consistent internally, fine. Not a finding beyond noting the render call site placement.

Cite: helios/src/server.rs:660-709, helios/src/server/latency.rs:34-37,63-131, helios/src/server/metrics.rs:273-297,1597-1602.