Prose report · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/8c71706e-6379-4e5b-8be7-c1aa108c63ec.md

Prose review — PR #549 "Report KV pages held by active requests"

Key findings

The PR meets the repository's description scheme: all four questions (why, what exactly changed, claimed benefit, evidence) are present in order, the "why" carries the execution constraint that makes the approach valid (Cache::stats must not scan nodes), the measurement is scoped to one two-GPU instance, and the unrun Windows build and full helios suite are disclosed. The Discord line is present and last (AGENTS.md:142-153).

The defects are accuracy inside that scheme, not structure. Six findings, all verified by reading code:

  1. The new docs/api.md paragraph says both gauges are "read from scheduler state on each scrape". They are not: Metrics::render only loads atomics, which the serving worker stores only on iterations where it made progress.
  2. The documented flare_request_kv_pages / flare_total_kv_pages ratio paragraph enumerates every exclusion except the reserved pages it introduced one sentence before.
  3. Both the doc and the description claim the gauges report the pages active requests reference, but a host-store restore in flight holds its destination pages in a ticket that is in neither gauge.
  4. The description's sentence about shared-ancestor counting states the opposite of the implementation and of the PR's own test.

Nits: the JSON-snapshot omission is unstated in api.md, and "a checkpoint leaves nodes only at zero pins" is inaccurate for compaction.

Rules applied: AGENTS.md:43-65 (required prose review), AGENTS.md:72-113 (required PR descriptions, four questions with before/after and evidence-to-claim linkage), AGENTS.md:114-121 (detail hierarchy, merge logistics allowed after the technical explanation), AGENTS.md:142-153 (Discord line), docs/design-review.md:137-152 (principle 16, "Write without hidden context": reject unexplained references and unsupported claims in all changed prose), .agents/skills/repo-prose/SKILL.md:35-46 (not opened) and 56-59 (evidence as conditions/measurement/result/conclusion; quote the passage and supply a rewrite).


Should fix

1. docs/api.md:302-303 — "read from scheduler state on each scrape" is false

New text:

Both are gauges read from scheduler state on each scrape.

The scrape path never touches scheduler state. Metrics::render reads atomics only, including the two gauges at helios/src/server/metrics.rs:1310-1318. The atomics are stored from SchedulerStats by Metrics::scheduler (helios/src/server/metrics.rs:476-522; the two new fields at :517-518). That call happens on the worker thread and only when the loop made progress:

Why it matters: an operator is told the value is fresh at scrape time. In fact a scrape during a long graph, an idle worker, or after the worker stopped reports the last published value. The two neighbouring doc paragraphs are careful about this distinction elsewhere; this one is not.

Fix: "Both are gauges published by the serving worker as it advances, so a scrape reports the value from the worker's most recent scheduler update." Scheduler state cannot be read at scrape time — the scheduler lives on the worker thread behind these atomics.

Settled by reading; no test needed.

2. docs/api.md:303-305 — the documented ratio omits the reserved pages it just introduced

Dividing flare_request_kv_pages by flare_total_kv_pages gives the KV share held by live requests; idle cached prefixes and snapshot backing pages are outside that share.

The reserved set is also outside that share, and it is the one the preceding sentence (api.md:301-302) defines as "pages reserved for active requests' future growth". Code: helios/src/scheduler.rs:1216-1222 — request_pages is live slots' private_pages.len() plus cache.request_pinned_pages; reserved_pages (scheduler.rs:1223-1228) is summed separately and never enters request_pages. The two sets are disjoint.

Why it matters: issue #537 asks for vLLM kv_cache_usage_perc semantics, and vLLM counts blocks it has already allocated to running requests. A reader computing this ratio to compare will be low by exactly the reserved amount, with no hint from the doc that a second gauge is needed.

Fix: name the exclusion and the correction, e.g. "…idle cached prefixes, snapshot backing pages, and pages reserved for live requests' growth are outside that share; flare_request_kv_pages plus flare_reserved_kv_pages covers both." The exact guidance is the author's call, but the omission must be repaired.

Verified in scheduler.rs:1216-1229.

3. docs/api.md:298-300 and the PR description — pages of an inbound restore are in neither gauge

Doc text:

flare_request_kv_pages counts the distinct KV pages that active requests reference: their private pages plus the tail pages of the prefix checkpoints they pin…

Description text: "the KV pages held by active requests and the pages reserved for their growth become scrapeable".

While an admitted request waits in RequestPhase::Inbound for a host-store restore, its destination pages are held by the inbound ticket:

So during the restore, request_pages counts nothing for that request and reserved_pages does not include the ticket's pages either: they were popped from free_pages, are not a checkpoint, and are not yet written. This is the same invisibility the PR's own rationale names ("neither free, cached, nor written") — but for the ticket rather than for reserved growth. For a large restored prefix this is the biggest block the request holds.

Fix: one clause on the doc sentence and one on the description, e.g. "…flare_request_kv_pages excludes the pages of a host-store restore still in flight, which the restore ticket holds until the request starts from them."

Verified by reading scheduler.rs:1699-1741, 1790-1810, 1848-1880 and 1216-1229. If the author believes the ticket pages are intended to be outside both gauges, that intent needs to be stated; a test asserting both gauges during RequestPhase::Inbound would settle the phase boundary exactly.

4. PR description — the shared-ancestor sentence contradicts the code and the PR's own test

Description, helios/src/cache.rs bullet:

A page shared through a pinned ancestor therefore counts once for every request that references it.

The implementation counts it once in total, not once per request: request_pinned_pages adds node.tail_pages.len() only when node.request_pins rises from 0 (helios/src/cache.rs:553-561), and removes it when the count returns to 0 (cache.rs:572-578). The PR's own test says so explicitly: request_pins_count_each_shared_page_once (helios/src/cache/tests.rs:320-342) pins two children over one shared parent and asserts request_pinned_pages == 3, commented "rather than 4" (tests.rs:331-332); plain pins leave it unchanged (tests.rs:333-334).

Why it matters: this is the sentence a reviewer will use to predict the gauge's behavior. Read literally it promises per-request accounting, so the small numbers in the live measurement (399 and 402 against 21504 total pages) would look like a bug rather than the design.

Fix: "A page in a shared ancestor's tail is counted once in the total, however many requests pin checkpoints below it; per-request totals come from private pages."

This is the strongest of the accuracy defects because the contradiction is inside the description and its own evidence. It also appears in a slightly different form in the doc, where it is correct — api.md:300 says "each page counted once even when several requests reference it", which matches cache.rs:553-561.


Nits

5. docs/api.md:298-306 does not say the gauges are Prometheus-text only

The two paragraphs sit inside the list of what the Prometheus text adds "beyond the JSON fields below" (api.md:292-296), and the section goes on to describe the JSON path at api.md:307-314, but never states that these two gauges have no JSON counterpart. Code: Snapshot (helios/src/server/metrics.rs:68-129) has no request_pages / reserved_pages field, and Metrics::snapshot never sets them; they exist only as atomics rendered in the text (metrics.rs:1310-1318). The PR description says so explicitly ("They are not added to the JSON snapshot"), so the doc is just missing the sentence. Fix: end the paragraph with "Neither appears in the JSON snapshot."

6. Description — "a checkpoint leaves nodes only at zero pins" is wrong for compaction

Compaction asserts that the removed ancestor and its heir agree on request pins, and a checkpoint leaves nodes only at zero pins.

Only leaves do. cancel_publication requires node.pins == 0 (helios/src/cache.rs:650) and leaf eviction picks a candidate with pins == 0 && child_count == 0 (cache.rs:659-663). Compaction instead matches direct_pins == 0 && child_count == 1 (cache.rs:662, 686-690), which permits pins > 0, and the new assertion is debug_assert_eq!(node.request_pins, child.request_pins) (cache.rs:627) — so an ancestor can be removed carrying nonzero pins that the heir continues to hold. The property the change actually guarantees is that folding an ancestor into its heir loses no request pin. Fix: "…folding an ancestor into its heir preserves the request pin count; leaf retirement still requires zero pins."

7. Minor: helios/src/cache.rs:626 comment reads obliquely

// Both nodes are counted or neither is, and the pages move into the counted heir.

Defensible as an invariant statement, but "counted" is doing two jobs (pin counts and page totals) in one clause. Not worth blocking on; "the ancestor's request pins equal its heir's, and its pages move into that heir" would be clearer.


Checked and found sound

Open questions and what I could not verify