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:
- The new
docs/api.mdparagraph says both gauges are "read from scheduler state on each scrape". They are not:Metrics::renderonly loads atomics, which the serving worker stores only on iterations where it made progress. - The documented
flare_request_kv_pages / flare_total_kv_pagesratio paragraph enumerates every exclusion except the reserved pages it introduced one sentence before. - 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.
- 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:
- helios/src/server/runtime.rs:1148-1153 —
if progress { self.metrics.scheduler(self.scheduler.stats()); ... } - helios/src/server/runtime.rs:722 — once at worker start
- helios/src/server/runtime.rs:745 — once after shutdown
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_pagesbyflare_total_kv_pagesgives 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_pagescounts 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:
- helios/src/scheduler.rs:1704-1706 —
let pages: Vec<_> = (0..inbound.pages).map(|_| self.free_pages.pop_first().unwrap()).collect(); - helios/src/scheduler.rs:1707-1723 — those pages go into the
Ticketand the returnedInboundTicket. - helios/src/scheduler.rs:1736-1737 and 1802-1803 — the live request is created with
phase = Inbound,shared_pages = Vec::new(),private_pages = Vec::new(). - helios/src/scheduler.rs:1859 — only at
finish_inbounddo they becometail_pagesof a published checkpoint, i.e. enterrequest_pinned_pages.
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
nodesonly 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
- The description's "why" is causal, not a task list: it names the operational gap (operators cannot compute the KV share; reserved pages are invisible), the reason the obvious implementation is rejected (
Cache::statsdeliberately avoids scanningnodes), and the substitute (maintain the count as pins change). Confirmed: the full scan lives only under#[cfg(test)]in helios/src/cache.rs:806-840, while the shipped counters are maintained incrementally incount/uncountandpin_request/unpin_request. - The claim that the drift assertion now covers the new counter is accurate —
request_pinned_pagesis added to the test-only full-scan comparison, so everystats()call in the test build checks it. - The evidence section invents nothing: the live scrape is labelled as one two-GPU instance, the base commit and its dependency on upstream PR #482 are named, the gauges' measured values and the ratio are given with the concurrent traffic disclosed, and "No comparison with another runtime is claimed" is stated. It also states what was not run.
- The merge-order note about #548 is allowed after the technical explanation (AGENTS.md:121) and is consistent with #548 touching a different region of
metrics.rs. - The doc sentences "each page counted once even when several requests reference it" (api.md:300) and "idle cached prefixes and snapshot backing pages are outside that share" (api.md:305) are correct against cache.rs:553-561 and scheduler.rs:1216-1229.
- New code comments (helio/src/cache.rs:82-85 (not opened), 187-189, 221-224 and scheduler.rs:130-133 on the pin split) state invariants and reasons rather than change history, which is what the prose skill asks for.
- The Discord line is present, last, and formatted correctly.
Open questions and what I could not verify
- Commit message body.
search_historyreturns only the subject for 5ed7af86, "Report KV pages held by active requests", so I reviewed the PR description but not the commit body. AGENTS.md:38-41 requires the message to pass the same check; if the body repeats the shared-ancestor sentence or the zero-pins sentence, findings 4 and 6 apply there verbatim. - Intended semantics of the inbound ticket pages. Nothing in the doc or description says whether they are meant to be excluded. Either the prose needs the exception (finding 3) or the counters need to cover them; a test asserting both gauges during
RequestPhase::Inboundsettles it. - Whether
request + reservedis the intended operator figure. The doc should say something about reserved pages in the ratio (finding 2), but whether to point operators at the sum or at a single combined gauge is the author's design call; the omission is the defect, not the choice. - The live-scrape numbers themselves are outside this lens; I did not attempt to reproduce them.