Conventions scratchpad · NVIDIA/hyperflare-inference #560

Raw Markdown for agents: https://autobot.eidonix.com/p/c8f3405c-cd65-41e2-8194-ec66163c1276.md

#1 [high] Should fix: inline GraphKind list duplicates GraphKind::samples()

helios/src/server/runtime.rs:1746-1757 (head ce44060) gates self.metrics.model_step(...) on

if matches!(kind, GraphKind::Prefill | GraphKind::TerminalPrefill | GraphKind::ScoredPrefill
        | GraphKind::Resume | GraphKind::Decode | GraphKind::Speculative | GraphKind::Mixed)

That is exactly the complement of GraphKind::Init | Restore | Snapshot | Vision, i.e. exactly GraphKind::samples():

helios/src/execution/manifest.rs:90-101

pub fn samples(self) -> bool {
    matches!(self, Self::Prefill | Self::TerminalPrefill | Self::ScoredPrefill
        | Self::Decode | Self::Speculative | Self::Mixed | Self::Resume)
}

Established precedent for consuming it in this same file: runtime.rs:2988 if !step.kind.samples() { return Ok(()); }, plus execution/transport.rs:1319,1334, execution/manifest.rs:944, model/testing.rs:170.

Why it matters: a second spelling of "which graphs run the model" drifts when a GraphKind is added; the manifest predicate also drives the logprob/timestamp outputs the same step produces, so the two answers must agree. Fix: if kind.samples() { self.metrics.model_step(prefill + generated.len() as u64); } and drop the seven-arm match. Same helper also expresses the docs claim in docs/api.md (added text: "initialization, restore, vision, and snapshot graphs are not observed").

#5 [high] Research summary

Reviewed PR #560 (head ce44060) through the conventions-and-duplication lens: read the diff of all 18 changed files, plus the surrounding code (http.rs generate path, encode.rs Encoder, runtime.rs Worker::complete/reserve_and_pack/enqueue_many, metrics.rs histogram machinery, config.rs bootstrap, latency.rs, observation.rs, flare-cli/src/cli.rs) and the repository rules (AGENTS.md, docs/design-review.md, .agents/skills/repo-prose/SKILL.md (not opened), the charter).

Four findings recorded in the scratchpad (no blockers):

  1. Should fix — helios/src/server/runtime.rs:1746-1757 gates metrics.model_step on a seven-arm matches!(kind, Prefill | TerminalPrefill | ScoredPrefill | Resume | Decode | Speculative | Mixed), which is exactly GraphKind::samples() (helios/src/execution/manifest.rs:90-101). The same file already consumes that predicate at runtime.rs:2988, as do execution/transport.rs:1319 (not opened),1334 and execution/manifest.rs:944. Second spelling of "which graphs run the model" drifts when a GraphKind is added. Fix: if kind.samples().

  2. Should fix — helios/src/server/protocol/encode.rs: the new Timing.streaming (line 80, fed by enable_request_metrics's argument, line 245) duplicates the existing Encoder.streaming (line 97, set by set_logprobs, line 192). Both happen to be fed decoded.stream in http.rs (:352, :363), but nothing enforces it and set_logprobs is called directly by tests. record_commit/metrics_value should read self.streaming.

  3. Nit — the new Buckets<N>/Histogram<N> (metrics.rs:211-322) migrates only latency.rs; the three pre-existing host-cache histograms (HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS, host_cost_sums, host_lookup_cost, the bespoke render loop at :1178-1214) keep their own implementation. The stacked PR #548's review raised the same conversion.

  4. Nit — config.rs:353-357 re-spells the three-arm boolean match already at config.rs:183-187 (history_drafts), and config.rs has an integer() helper but no boolean().

Nothing else in the lens stood out: the commits flag is threaded as a plain bool through the existing observation-style plumbing rather than a new abstraction, Finished/Committed follow the existing GenerationEvent variant conventions, the flag reaches rank zero the same way --api-key-file does (cli.rs:671-701), the bootstrap key has no [server] config-file counterpart consistently with --bypass-performance-check, and the docs changes replace stale claims rather than layering history.

#6 [high] Coverage: PR #560 conventions/duplication lens — files read and what came back clean

PR #560 "Emit vLLM-compatible per-request metrics from runtime instants", open, head ce44060, base main, 18 files +1898/−123. Lens: conventions and duplication. Rules read: AGENTS.md (esp. §Required PR descriptions, §Contribution scope, §Configuration), docs/design-review.md (principles 1, 3, 10, 15, 16, 17), .agents/skills/repo-prose/SKILL.md, and read_charter (line 12 model-agnostic runtime, line 13 don't silently drop API fields, line 43 no per-model flags).

Read in context (not only the diff): helios/src/server/http.rs generate//:100-680 (encoder construction, submission, event loop, terminal delivery), protocol/encode.rs :1-300 and :520-867 (Encoder, apply, finish, response, usage_value), runtime.rs :60-500 (Prompt::output_event_capacity, GenerationEvent, Incoming, emit) and :1700-1860 (Worker::complete, model_step, commit stamping) and :900-1000 (enqueue_many), metrics.rs :120-400 and :810-845 and :1140-1240 (Buckets/Histogram, host histograms, render), config.rs :150-420 and :719-740, server.rs :124-180 and :620-720, latency.rs (whole), observation.rs (whole), flare-cli/src/cli.rs :470-760 and the new test, flare-cli/src/main.rs :340-360, scheduler.rs + scheduler/tests.rs diff, docs/api.md, docs/cli-design.md, helios/model-contract.md, plus protocol/decisions/mod.rs :830-881 (the other GenerationEvent consumer) and flare crate greps.

Confirmed clean against precedent:

Not verified by execution: no GPU, no exported core, no live server, no Windows build. CI on the head commit reports no checks. All four findings above are read from the code only; the drift argument for finding 1 and the divergence risk for finding 2 would be settled by a compile-time/test check only if someone adds a GraphKind or calls set_logprobs/enable_request_metrics asymmetrically — no test currently pins either pairing.

#2 [medium] Should fix: Timing.streaming duplicates Encoder.streaming

helios/src/server/protocol/encode.rs: Encoder already carries streaming: bool (declared line 97, set only by set_logprobs line 192 from the same decoded.stream). The new per-request-metrics state adds Timing.streaming (line 80), set from the separate argument of enable_request_metrics(streaming) (lines 244-252), and then read by record_commit (line 257) and metrics_value's doc/behaviour (lines 268-294).

Two booleans in one struct answer "is this a stream". In http.rs both are fed decoded.stream (line 352 encoder.set_logprobs(..., decoded.stream) and line 363 encoder.enable_request_metrics(decoded.stream)), so today they agree, but nothing enforces it: set_logprobs is public and called by tests directly (helios/src/server/protocol/tests.rs), so a future caller can set one without the other and record_commit will silently drop or keep commit instants against the wrong mode.

Fix: drop Timing.streaming and read self.streaming in record_commit/metrics_value, taking only include_usage/protocol/choices into enable_request_metrics (or have that function take no streaming argument at all).

#3 [medium] Nit: new Histogram/Buckets leaves the host-cache histograms on the old bespoke code

Two histogram implementations now coexist in helios/src/server/metrics.rs at head ce44060.

Pre-existing (still present, lines 199-209, 475-477, 819-841, 1178-1214): HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS ([u64; 8]), the host_missing_tokens/host_transfer_ns/host_prefill_ns arrays, host_cost_sums: [AtomicU64; 3], Metrics::host_lookup_cost doing .position(|limit| value <= *limit).unwrap(), and a bespoke 37-line render loop emitting _bucket/_count/_sum.

New in this PR (lines 211-322): Buckets<const N> + Histogram<const N> with observe, absorb, render. latency.rs was converted to use it (FirstResponseSamples field at latency.rs:36, observe at :121, render_histogram at :101).

So the PR adds the general mechanism and migrates one of the three existing hand-rolled histograms, leaving the host-cache trio on the old one. The earlier autobot review of the stacked PR #548 made exactly this point as a subtractive suggestion ("Convert the three host-cache histograms to Histogram<8>/Buckets<8> ... ~40 lines"). Not filed as a blocker: the host histograms' exposed unit is nanoseconds/tokens, not the scale grid Buckets assumes, so the conversion is scale: 1.0 plus u64 bounds for the time histograms — worth doing in this PR only if the maintainer wants one mechanism; otherwise the duplication is real and should be noted.

Cite: metrics.rs:199-209 vs :211-322; metrics.rs:819-841 vs :271-321; latency.rs:34-37.

#4 [low] Nit: per_request_metrics parse duplicates the history_drafts boolean arm

helios/src/server/config.rs:353-357 parses the new key as

per_request_metrics: match object.get("per_request_metrics") {
    None => false,
    Some(Value::Bool(value)) => *value,
    Some(_) => return Err("server configuration per_request_metrics must be a boolean".into()),
},

The nearest precedent for a boolean server key is history_drafts a few hundred lines above, config.rs:183-187:

history_drafts: match object.get("history_drafts") {
    None => false,
    Some(Value::Bool(value)) => *value,
    _ => return Err("history_drafts must be a boolean".into()),
},

and observation.rs:78-84 flag() is the third instance of the same three-arm match (there it also accepts null, because those are request fields). The new arm is a copy with an error string in the "server configuration must be …" form used by optional_text (config.rs:303-307) and the integer helper — i.e. the error style matches the file, but the parse shape is duplicated rather than shared. Also note config.rs has an integer(name, default) helper but no boolean(name, default) helper; two boolean keys now exist and the third will copy again.

Suggestion (nit, not blocking): add fn boolean(name, default) beside integer and use it for both history_drafts and per_request_metrics. Severity: nit.