#1 [high] Research summary
Architecture & scope review — PR #549 (KV pages held by active requests)
Scope verdict: in scope, approach acceptable, with wording/robustness issues. The change touches only shared runtime layers (cache accounting, scheduler stats, Prometheus text, docs). No per-model branches, no flags, no environment switches, no allocation/eviction policy change — it keeps layers in their roles (AGENTS.md "Keep the runtime small and model-agnostic" / design-review principles 1, 3, 10). It is justified by issue #537 as a missing-capability/bad-docs contribution, which AGENTS.md "What gets merged" admits, though #537 is user-filed rather than an explicit maintainer request. The counters are bounded work on the pin/unpin paths, so the "don't scan nodes in stats" constraint is respected.
Findings recorded (all verified in code):
- Should fix —
docs/api.md:298-305says both gauges are "read from scheduler state on each scrape"; they are not.Metrics::render(helios/src/server/metrics.rs:666, gauges at 1309-1318) only loadsAtomicU64s, whichMetrics::schedulerrefreshes fromworker.scheduler.stats(), and the worker loop calls that only when it made progress (helios/src/server/runtime.rs:1148-1149, plus 722/745). A scrape is served from the HTTP side and never touches the scheduler. Fix: say the values are published by the worker each time scheduling state advances. - Should fix —
docs/api.md:298-305omits thatflare_request_kv_pagesoverlapsflare_cached_kv_pages.request_pinned_pagescounts tail pages of checkpoints that are still innodesand therefore still summed intocached_pages(helios/src/cache.rs:258-275, 816-852), so the pinned portion of cached pages appears in both gauges. The text only says "idle cached prefixes ... are outside that share", which invites an operator to add or subtract the two. State the overlap explicitly. Related: the PR description's consistency check (request + reserved < total - free - cached) compares against what is effectively snapshot-backing pages, not a superset of request pages, so it does not validate the gauge it claims to validate. - Nit — the admission pin API is selected by a boolean in three mirrored blocks (
helios/src/scheduler.rs:1643-1649,1657-1663,1684-1690), each pairingpin_request/unpin_requestagainstpin/unpinoninbound.is_none(). Theelsearm is reachable only for the ticket-creating admission, wherepinnedis the lookup checkpoint. This is the kind of optional path the review standards discourage; a helper that returns which API it used, or a small enum, would remove the risk that a future edit pairs mismatched calls — which would now surface as a hard error fromunpin_request(helios/src/cache.rs:565-568) rather than a stale gauge. - Nit —
unpin_request's error becomes a retirement failure.RequestScheduler::retirereleases the prefix withunpin_request(helios/src/scheduler.rs:3159), so an accounting slip would abort request retirement instead of being detected as a metric drift. The only verification of the new counters in production code paths is the#[cfg(test)]drift assertion (helios/src/cache.rs:818-837); consider adebug_asserton the release path to match how the existing pin invariants are checked (cache.rs:623-627). - Nit — smallest-footprint alternative.
LiveRequestalready carriesshared_pages,private_pages, andreserved_pages(helios/src/scheduler.rs:253-255), soSchedulerStatscould derive a distinct request-page count from live slots without adding five fields and a new invariant toPrefixCheckpointCache. The cache-side approach is defensible only because of the "each shared page once" requirement, which a per-slot union with a set also satisfies. Worth a sentence in the rationale.
Positive checks: request_pinned_pages accounting survives compaction and leaf retirement (cache.rs:594-646, 658-691) — request-pinned nodes are excluded from leaf eviction by pins != 0, and compaction moves pages into an heir with the same request_pins, leaving the total unchanged; every path that stores request.prefix pairs it with pin_request (1900-1902, 2971-2979, 2991-2996) and the ticket-parent pins that keep the plain API (1882, 1918) never become request.prefix. Reserved pages are popped from free_pages at admission (1732-1735), so the "neither free, cached, nor written" wording holds.
Could not verify: the sibling-PR reference in the description ("#536") does not match the related-items list, which pairs this PR with #548 by the same author; likely a wrong cross-reference.
#2 [high] Should fix: docs/api.md claims gauges are read from scheduler state on each scrape
File: docs/api.md:298-305 (added by PR #549). Claim in docs: "Both are gauges read from scheduler state on each scrape." Reality verified in code:
Metrics::render(helios/src/server/metrics.rs:666, gauge table entries at 1309-1318) only doesAtomicU64::load(Relaxed)forrequest_pagesandreserved_pages. It never callsRequestScheduler::stats().- The values are stored by
Metrics::scheduler(stats)(helios/src/server/metrics.rs:476, store loop 514-518) fromSchedulerStats. - The only producer in serving is the worker loop: helios/src/server/runtime.rs:1148-1149
if progress { self.metrics.scheduler(self.scheduler.stats()); ... }, plus 722 (startup) and 745 (after shutdown drain). So a scrape neither reads scheduler state nor triggers a scheduler read; it reports the last progress-published values, and with an idle scheduler it reports values that may be arbitrarily old. Fix: state that the worker publishes both gauges when scheduling state advances, not that a scrape reads the scheduler. Severity: should fix (documentation accuracy; AGENTS.md requires docs state implemented behavior, and PR prose must not claim more than the code does).
#3 [high] Should fix: request_kv_pages overlaps cached_kv_pages but docs say only "idle cached prefixes" are excluded
File: docs/api.md:298-305 (added by PR #549).
Problem: flare_request_kv_pages = active slots' private_pages + cache.request_pinned_pages (helios/src/scheduler.rs:1216-1222), where request_pinned_pages is the tail pages of checkpoints in nodes with request_pins > 0 (helios/src/cache.rs:548-580, 838-842). Those same checkpoints are still in nodes, so their tail pages are also included in cached_pages (count/uncount at helios/src/cache.rs:258-275; stats at 816-852). Pages enter the cache when a boundary capture moves the request's private pages into the checkpoint (helios/src/scheduler.rs:2965-2979), and the request keeps referencing them.
Therefore a pinned checkpoint's pages appear in BOTH flare_request_kv_pages and flare_cached_kv_pages. The doc only says "idle cached prefixes and snapshot backing pages are outside that share", which reads as though the rest of cached is disjoint from request. An operator computing request/total or trying to reconcile free + cached + request will double-count.
Fix: state explicitly that the pinned tail pages of cached checkpoints are counted in both gauges, and that request is not a disjoint partition alongside cached.
Knock-on: the PR description's live check that request + reserved < total - free - cached holds is not evidence of correctness, because total - free - cached is roughly snapshot-backing pages (owned snapshots excluded from the free list) and is not a superset bound on request pages. The invariant that would actually validate the gauge is request_pinned_pages <= cached_pages plus per-node agreement with a scan.
Severity: should fix (documentation accuracy; the derived ratio is the whole point of the metric per issue #537).
#5 [high] Report of 2026-11-27, run on head 9cca87a (post-fix re-review)
Architecture & scope review — PR #549, head 9cca87a
Previous findings, re-checked
- Old "should fix: gauges read from scheduler state on each scrape" — FIXED. docs/api.md:302-303 now says "The worker publishes both on every scheduler pass and a scrape reads the last published values."
- Old "should fix: cached/request overlap hidden" — FIXED. docs/api.md:303-306 now states request-pinned checkpoint pages also appear in
flare_cached_kv_pagesand that the request gauge adds private pages. - Old nit "three mirrored if inbound.is_none() blocks" — FIXED by
pin_prefix/unpin_prefixhelpers (helios/src/scheduler.rs:2025-2040) selected once viarequest_pin(1643). - Old nit "unpin_request after request.take()" — FIXED: retire releases the request pin before taking the slot (helios/src/scheduler.rs:3149-3157).
- Other reviewer's blocker (new gauges leak into CopyoutResources retry key) — patched at runtime.rs:2443-2450 by zeroing both fields in the key.
Verdict this pass: should-fix (one prose defect) + 3 nits. Scope and approach remain right.
Scope: still confined to helios/src/cache.rs, scheduler.rs, server/metrics.rs, docs/api.md. No per-model branch, no flag, no policy path, no allocation/eviction/scheduling change. Satisfies charter lines 12, 34; docs/design-review.md principles 1, 3, 10, 12, 15, 16; AGENTS.md:165-200. Deriving the count on the pin/unpin paths keeps Cache::stats free of a nodes scan, which is the constraint the PR states.
Should fix
- docs/api.md:307-310 contradicts itself and gives no workable ratio. Line 308 says
flare_request_kv_pages + flare_reserved_kv_pages"is the figure comparable to another runtime's used KV cache", then line 309 says "Dividing either gauge byflare_total_kv_pagesexcludes idle cached prefixes and snapshot backing pages." "Either gauge" cannot both be true:flare_reserved_kv_pagesis a small growth reservation (live scrape: 2-3 pages of 21504) and dividing it by total says nothing about KV in use; the comparable ratio is(request + reserved) / total. Also "excludes idle cached prefixes" cannot describe a division that hastotalas its denominator — the exclusion is a property of the numerator. Fix: state one ratio,(flare_request_kv_pages + flare_reserved_kv_pages) / flare_total_kv_pages, and state what the numerator leaves out (idle cached prefixes, snapshot backing pages, pages draining through retirement or an in-flight restore ticket).
Nits
- docs/api.md:311-312 documents a
#[cfg(test)]assertion. An operator-facing API page now says "the test-only assertion inCache::statscompares the maintained request-pinned count with a full scan of every checkpoint on each read" (verified true at helios/src/cache.rs:818-837). This is validation evidence, which belongs in the PR description under design-review principle 16, not in the present-state API spec (repo-prose skill: documentation is a present-state specification, evidence goes in the commit/PR text). Drop it from api.md or move it to the PR body. - docs/api.md:302 "on every scheduler pass". The worker publishes only when a pass reports progress: helios/src/server/runtime.rs:1148-1149
if progress { self.metrics.scheduler(self.scheduler.stats()) }(plus startup runtime.rs:722 and post-shutdown drain 745). Say "when scheduling state advances" so the freshness claim matches the code. - Metric fields still feed a scheduling decision key.
CopyoutResourcesembeds the wholeSchedulerStats(helios/src/server/runtime.rs:1053-1059) and is compared to decide whether deferred host copy-outs retry (2455-2465). The head commit zeroesrequest_pages/reserved_pagesat 2446-2450, which fixes today's behaviour but leaves the coupling: any gauge added toSchedulerStatslater silently changes copy-out scheduling and the zeroing list has to be remembered. Fix: giveCopyoutResourcesonly the cache fields copy-out depends on (free_pages,free_snapshots,cached_pages,snapshot_backing_pages, ...), so metrics cannot enter the key.
Positive checks
- request/total overlap with cached is now documented, and
request_pinned_pagesreally is the tail pages of nodes withrequest_pins > 0(helios/src/cache.rs:551-580, 818-837). - reserved pages are popped from
free_pagesat admission (helios/src/scheduler.rs:1721-1724) and consume intoprivate_pagesat commit (2439-2444), so "neither free, cached, nor written" holds. - retirement and in-flight ticket pages are genuinely outside both gauges (finish_inbound only pins waiters after the restore completes, 1887-1899; retired pages are in
self.retired, 3177-3191). - New gauges stay out of the JSON
Snapshot(helios/src/server/metrics.rs:70-129), matching the description. - request pin/unpin pairing covers every place that assigns
request.prefix(helios/src/scheduler.rs:1891, 2985, 3002) and the ticket-parent pins that keep the plain API (1871, 1907) never becomerequest.prefix. unpin_requestrejects a checkpoint with no request pin (cache.rs:565-568), so the API choice is now checkable rather than silent.
#6 [high] Research summary
Re-reviewed PR #549 at head 9cca87a through the architecture-and-scope lens. Scope and approach still hold: the change stays inside shared runtime layers (cache accounting, scheduler stats, Prometheus text, docs/api.md), with no per-model branch, flag, or allocation/eviction/scheduling change, and maintaining the count on pin/unpin keeps Cache::stats free of a nodes scan as the PR requires.
Four of my earlier findings are fixed by the pushed commits: the docs no longer claim scrape-time reads of scheduler state, the overlap between flare_request_kv_pages and flare_cached_kv_pages is now stated, the three mirrored pin-kind conditionals became pin_prefix/unpin_prefix selected once, and retire releases the request pin before emptying the slot. The other reviewer's blocker is patched by zeroing the two new fields when building the copy-out retry key.
Remaining: one should-fix documentation defect — docs/api.md:307-310 both claims request + reserved is the comparable figure and says dividing "either gauge" by total yields the KV share, which cannot both be true (reserved is 2-3 pages in the author's own scrape) and misdescribes what the ratio excludes. Three nits: a #[cfg(test)] drift assertion is documented in the operator-facing API page; "on every scheduler pass" overstates the publish cadence (runtime.rs:1148-1149 publishes only on progress); and CopyoutResources still embeds the whole SchedulerStats, so the head commit's zeroing is a per-field patch on a coupling that will recur. Full detail in scratchpad entry #5.
#7 [high] Superseded notes #2 and #3 — do not carry their findings into the report
Entry #2 ("gauges are read from scheduler state on each scrape") and entry #3 ("docs say only idle cached prefixes are excluded, hiding the request/cached overlap") describe the state of docs/api.md before commit 9cca87a. Both are FIXED at head 9cca87a:
- api.md:302-303 now reads "The worker publishes both on every scheduler pass and a scrape reads the last published values."
- api.md:303-306 now reads "Pages of request-pinned checkpoints also appear in
flare_cached_kv_pagesbecause those checkpoints stay cached; the request gauge adds the requests' private pages to them."
The final report must present them as resolved, not as open findings. Entries #1 and #4 are the earlier research summary and the earlier report; #5 is the current state and the authoritative source for the report.
One element of old #3 is still worth carrying, but reframed as an evidence critique rather than a docs defect: the PR description's live consistency check request + reserved < total - free - cached does not validate the gauge, because total - free - cached is dominated by snapshot-backing pages (flare_snapshot_backing_pages, helios/src/server/metrics.rs:1294-1298) and is not a superset bound on request pages. The invariant that does attest the gauge is the in-repo #[cfg(test)] scan comparison at helios/src/cache.rs:818-837. Head 9cca87a moved that assertion into api.md:311-312, which is where the new nit about documenting test-only evidence comes from (see #5).
#9 [high] Report of 2026-11-28, run 1545 — re-review at head bca7358
Architecture & scope review — PR #549, head bca7358
Scope/approach verdict unchanged: in. Change stays in shared runtime layers only — helios/src/cache.rs (accounting), scheduler.rs (stats + pin API), server/metrics.rs (Prometheus text), server/runtime.rs (copy-out key), docs/api.md. No per-model branch, no flag/env switch, no allocation/eviction/scheduling decision change; the count is maintained on pin/unpin so Cache::stats (cache.rs:825-861) does not scan nodes, which is the constraint the PR states. Charter lines 12, 34; AGENTS.md:165-200; design-review.md principles 1, 3, 12, 15, 16 satisfied. Issue #537 option 1 ("flare_request_kv_pages ... each page counted once") is exactly what is implemented, so need is demonstrated (AGENTS.md:165-169).
Prior findings, verified fixed at head bca7358
- Ratio contradiction (was api.md:307-310) — FIXED. api.md:308-310 now gives one ratio,
(request + reserved) / total, comparable to vLLMkv_cache_usage_perc, and states idle cached prefixes and snapshot backing pages are outside it. Verified at docs/api.md:308-310. - Test-only assertion documented in the operator page — FIXED; removed from api.md (no mention of
Cache::statsscan remains in the paragraph, api.md:298-310); the assertion still exists in code at cache.rs:826-846. - "on every scheduler pass" overstatement — FIXED. api.md:305-307 now says "publishes both when a scheduler pass makes progress, and again at startup and after the shutdown drain", matching runtime.rs:1148-1149 (
if progress { self.metrics.scheduler(...) }), startup runtime.rs:722, shutdown drain runtime.rs:743-746. - Mirrored pin-kind conditionals — FIXED, now
pin_prefix/unpin_prefix(scheduler.rs:2019-2033) selected once viarequest_pin = inbound.is_none()(scheduler.rs:1636). retirereleases the request pin before emptying the slot — scheduler.rs:3142-3149.
Remaining nit (only finding)
Nit — CopyoutResources still embeds the whole SchedulerStats (helios/src/server/runtime.rs:1053-1059). It is compared to decide whether deferred host copy-outs retry (runtime.rs:2455-2456). bca7358/9cca87a zeroes request_pages/reserved_pages when building the key (runtime.rs:2443-2450, with an explanatory comment), which fixes today's behaviour but leaves the coupling: any future gauge added to SchedulerStats silently perturbs copy-out scheduling unless the zeroing list is extended. Fix: give CopyoutResources only the cache fields copy-out depends on (free_pages, free_snapshots, cached_pages, snapshot_backing_pages, ...) so metrics cannot enter the key at all. Design-review principle 15 / AGENTS.md:188-193 (reject coupling without a concrete requirement). Not blocking.
Correctness checks that came out positive at this head
- Count maintenance is exact:
pin_with/unpin_withadd/subtract a checkpoint'stail_pages.len()on the 0→1 and 1→0 request-pin crossings along the whole chain (cache.rs:519-570); tail pages of a node exclude its ancestors' pages, so each page is counted once; the drift assertion compares against a fullnodesscan on everystatsread (cache.rs:826-846). - Compaction keeps the count:
debug_assert_eq!(node.request_pins, child.request_pins)then the ancestor's tail pages move into the heir (cache.rs:632-641), so the survivor's contribution is unchanged; leaf retirement only happens at zero pins (eviction_candidates cache.rs:667-673), so a retired node never held a counted contribution. - Every place that sets
request.prefixtakes a request pin (scheduler.rs:1882+1884, 2970+2978, 2990+2995) and the plain pins that legitimately remain are the host-admission ticket parent (scheduler.rs:1637-1638 withrequest_pin=false, released at 1864/1900) and the copy-out pinspin_checkpoint/unpin_checkpoint(scheduler.rs:2037-2043).unpin_withrejects a release with no request pin (cache.rs:547-549), making the API choice checkable rather than silent. - New gauges stay out of the JSON
Snapshot(metrics.rs:68-129), matching the description; they are Prometheus-text only (metrics.rs:1309-1318), fed from atomics at metrics.rs:517-518.
Notes for the report (not findings)
- Evidence critique carried from before: the PR body's live inequality
request + reserved < total - free - cacheddoes not attest the gauge, becausetotal - free - cachedis dominated by snapshot-backing pages (metrics.rs:1294-1298). The in-repo drift assertion (cache.rs:826-846) is the real evidence and should be cited in the body. The body's other bound,request + reserved <= total - free, is the one the definitions imply and is stated correctly. - Authorization is via a user-filed issue (#537, opened by Napuh) that demonstrates a concrete metric gap; under AGENTS.md:165-169 that is a demonstrated defect, but confirm with owners whether an explicit maintainer request exists.
#10 [high] Research summary
Re-reviewed PR #549 at head bca7358 through the architecture-and-scope lens. Scope and approach still hold: the change is confined to shared runtime layers (cache accounting in helios/src/cache.rs, scheduler stats and the request-pin API in scheduler.rs, Prometheus text in server/metrics.rs, docs/api.md), with no per-model branch, flag, environment switch, or allocation/eviction/scheduling decision, and the count is maintained on the pin/unpin paths so Cache::stats never scans nodes — the constraint the PR states. Charter lines 12 and 34, AGENTS.md:165-200, and design-review principles 1, 3, 12, 15, 16 are satisfied, and issue #537 states exactly the gauge implemented.
All four findings from my previous round are fixed at this head: the self-contradictory ratio in docs/api.md is replaced by one ratio, (request + reserved) / total (api.md:308-310); the #[cfg(test)] drift assertion has been removed from the operator page (the assertion itself still exists at cache.rs:826-846); the publish cadence now matches the code at runtime.rs:1148-1149, 722 and 743-746; and the pin-kind conditionals are folded into pin_prefix/unpin_prefix with retire releasing the request pin before the slot is emptied.
One nit remains, recorded in scratchpad entry #9: CopyoutResources still embeds the whole SchedulerStats (runtime.rs:1053-1059) and is compared to decide copy-out retries (2455-2456), so zeroing request_pages/reserved_pages at 2443-2450 is a per-field patch on a coupling that will recur with the next added gauge; giving the key only the cache fields would remove it. No blocking or should-fix issues found. No probes of my own beyond reading the code; the author's live measurements are not reproducible here.
#11 [high] Verdict summary for the final report at bca7358 — all changed files read, one nit open
Use entry #9 as the authoritative body of the final report for this round; entries #5 and #8 are the previous rounds (superseded on the four items they raise, still valid for the positive checks).
Verdict: no blocking, no should-fix, one nit. Link: https://github.com/NVIDIA/hyperflare-inference/pull/549
Per changed file, state at head bca7358 (8 files, +202/−34):
- docs/api.md (+14, lines 298-310) — clean. One ratio,
(request + reserved)/total(308-310); overlap withflare_cached_kv_pagesstated (301-302); exclusions (retirement drain, restore-ticket in-flight pages) stated (302-304); publish cadence "when a scheduler pass makes progress, and again at startup and after the shutdown drain" matches runtime.rs:1148-1149, 722, 743-746. The phrase "requests owning a model slot" is accurate: inbound-ticket waiters hold no prefix pin — pins are taken only infinish_inboundafter the restore completes (scheduler.rs:1880-1892). - helios/src/cache.rs (+73/−5) — clean.
pin_with/unpin_with(519-570), publicpin/unpinunchanged (572-578),pin_request/unpin_request(583-589), compaction agreement (632-641), drift assertion (826-846),CacheStats::request_pinned_pages(851). - helios/src/scheduler.rs (+49/−19) — clean. Stats folded into the existing live-slot pass (1200-1230);
request_pinchosen once (1636),pin_prefix/unpin_prefix(2019-2033); request pins at 1882, 2970, 2990; plain pins retained only for the host-admission ticket parent (1637, 1864, 1900) and copy-out viapin_checkpoint/unpin_checkpoint(2037-2043); retire releases before the slot empties (3142-3149). - helios/src/server/metrics.rs (+18) — clean. Atomics 265-266, stored 517-518, rendered as gauges 1309-1318, absent from
Snapshot(68-129), test expectations 1787-1792 / 1832-1834. - helios/src/server/runtime.rs (+8/−1) — one nit (entry #9): the zeroing at 2443-2450 patches a
CopyoutResourcesthat still embeds all ofSchedulerStats(1053-1059) and feeds the retry comparison (2455-2456). - helios/src/cache/tests.rs, cache/lifecycle_tests.rs, scheduler/tests.rs — clean. Two overlapping tests folded into one each (
branching_pins_ancestors_and_prevents_direct_ancestor_unpin,branching_requests_own_distinct_tail_pages_and_terminal_snapshots); fixture mirrors the new fields so the test-only drift assertion runs on lifecycle tests too.
Report-only notes (not findings): the PR body's live inequality request + reserved < total − free − cached does not attest the gauge because total − free − cached is dominated by snapshot-backing pages (metrics.rs:1294-1298); the in-repo drift assertion (cache.rs:826-846) is the real evidence and should be cited in the body instead. Authorization rests on a user-filed issue (#537) that demonstrates a concrete metric gap (AGENTS.md:165-169); owners may still want to confirm whether an explicit maintainer request exists.