Verdict: worth merging — the change belongs in Flare; the remaining items are cheap polish, not gates
Head bca7358, +202/−34 across 8 files, no new commits since the last review round. The only new material is WynnD's live-validation table (2026-11-28 03:26) and a bot review asking for "Changes Requested" with 0 blockers, 2 should-fix items, ~55 deletable lines and 7 nits. I re-verified the counter's invariant from the code at this head (not from the description) and re-checked the fit against the charter; the verdict is unchanged: merge it, ideally after folding in the one doc sentence and the reviewer's two should-fix items.
Charter fit — this is on the merge list, at the right layer
It closes a reported, reproducible defect. #537 (hyperflare-inference v0.3.2 c0c4f79) shows that with the shipped gauges an operator can only bracket KV use: 1 − (free + snapshot_backing)/total ≈ 16 % as an upper bound, 1 − (free + cached + snapshot_backing)/total ≈ 0 % as a lower bound, versus ≈9 % on vLLM for the same load. Two mechanisms cause it — a request admitted on a prefix hit shares the checkpoint's pages in place, so they stay inside flare_cached_kv_pages; and reserved growth pages leave free_pages at admission while appearing in no gauge at all. The charter's "What gets merged" list explicitly includes "a reproducible bug … or bad docs", and this is the KV half of a monitoring story #541 is already shipping. It is not a speculative feature request.
Solve it in the right place, with the smallest footprint. The counter lives where the quantity lives: PrefixCheckpointCache maintains request_pinned_pages as pins change (helios/src/cache.rs:536–566, reported at 851), the scheduler adds its live slots' private_pages and reserved_pages in the loop that already counted active_requests (helios/src/scheduler.rs:1200–1221), and the renderer emits two gauges with help text (helios/src/server/metrics.rs:1309–1318). No flag, env var, per-model branch, backend abstraction or new switch — nothing touching a non-goal, nothing near the "no configuration switches / no per-model special cases" rules. This is a runtime-observability concern, which is exactly helios's remit.
It respects the invariant it could have broken. The cache keeps ready_checkpoints/unready_checkpoints/tail_pages specifically so stats never walks nodes (helios/src/cache.rs:257–275, 825–861). The new counter follows that pattern instead of introducing a per-scrape graph walk the code forbids. That is the strongest architectural argument for this PR over the obvious alternative.
No duplication and no simpler route. #537's own second proposal — split cached_kv_pages into pinned and idle — needs identical bookkeeping and yields a number you must combine with private pages anyway. A ready-made flare_kv_cache_usage_ratio would hide the reserved term and freeze arithmetic that #548's metric-mapping work wants to state in prose. Nothing already in the tree reports request-referenced pages: flare_free_kv_pages, flare_cached_kv_pages, flare_snapshot_backing_pages and flare_active_requests are the whole existing set.
Correctness, re-derived at this head
- Pin bookkeeping.
pin_with/unpin_with(cache.rs:519–570) fold plain and request pins into one chain walk;request_pinscounts a node's tail pages only on the 0→1 crossing (539) and subtracts on 1→0 (565);direct_request_pinsguards the release so a mispair errors instead of underflowing (547–549). Compaction carries the count into the heir:debug_assert_eq!(node.request_pins, child.request_pins)(636) is entailed, because a request pin impliesdirect_pins > 0while compaction requiresdirect_pins == 0(632), so the ancestor holds no direct request pin. Eviction predicates (667–673) only remove nodes withpins == 0, hencerequest_pins == 0, souncountnever has to touch request pages. The scalar therefore stays equal to the scan even though tail-page lengths change under compaction — and the test atcache/tests.rs:331–360pins that down numerically (3 → 2 across the merge → 0). - Pairs are complete.
request.prefixis assigned at exactly three places — direct-hit admission (scheduler.rs:1636–1639, viapin_prefixwithrequest_pin = inbound.is_none()), inbound waiters (1882), and boundary publication (2970,2990) — and each is paired withpin_request; no code path setsprefix = None, and the only request-pin release is inretire(3144–3148). The ticket-parent pin at admission when a restore is being created stays a plain pin and is released with a plainunpin(1864,1900) — so ticket parents, host copy-outs and exports do not leak into the gauge, as the description claims. - No double counting. At boundary publication the request's private pages are drained into the published checkpoint before
prefixmoves to it (scheduler.rs:2975–2979), so a page is either inprivate_pagesor in a pinned checkpoint's tail, never both. - Retirement ordering. The pin is released at
3144–3148, beforerequest.take()at3150— the fix from round two holds, so a failed release leaves the request inspectable rather than leaking a pin behind a half-destroyed slot. - The "no scheduling change" claim stands.
CopyoutResourcesembedsSchedulerStatswhole and derivesPartialEq(runtime.rs:1053–1059), so decode crossing a page boundary would have re-offered deferred host copy-outs; the three lines at2441–2450zero both fields in the key, with a comment saying why. Slightly awkward shape (a stats struct partially nulled for a cache-resource comparison), but documented and cheap. - Checked on every read. The test-only assertion at
cache.rs:827–846compares the scalar with a full scan of request-pinned nodes on everystats()call, so the whole cache and scheduler suite exercises the invariant, not just the new tests.
Who benefits, and how much
Operators who migrated vLLM/Grafana dashboards, and #541's KV panel, which today can only show bounds. flare_request_kv_pages is the valuable half — it makes (request + reserved) / total the documented vLLM-comparable figure (docs/api.md:298–310). flare_reserved_kv_pages is the cheap half but accounts for the only pages that vanish from every other gauge at admission, and it keeps the documented arithmetic honest. The audience is real but modest: this is a focused local-inference prototype, not a fleet server, so the benefit is one dashboard-grade number, not an SLO primitive.
Cost
Two u64 per Checkpoint, one usize on the cache, one add/sub per pin on a chain already walked, and per stats one loop over at most slot-count live requests. No GPU work, no allocation, no scheduling decision, no new test infrastructure. The description states the cost was read from code rather than measured, which is the right disclosure for a visibility-only change. The one structural cost worth naming: SchedulerStats now doubles as the deferred-copy-out key, so every future field must be judged for key-worthiness — mitigated by the commented exception, and worth a follow-up only if the struct keeps absorbing fields.
Evidence — adequate, honestly scoped, weaker than it looks on KV pressure
Four-part description with a Discord: line and an explicit not-run list (Windows build, full helios suite, exported core → CI). The new live table adds a second hardware configuration and a shared-prefix case: 54–80 request pages and 16–22 reserved of 20,480 pages at 16 concurrent streams, and 399–402 / 2–3 of 21,504 on two-GPU DeepSeek-V4.1-Flash with two chats; 809 tests, one unrelated template test requiring FLARE_TEST_TEMPLATE_DIR.
My honest reservation, which does not change the verdict: those request-page numbers are ~0.4 % and ~1.9 % of the pool, so the live data proves the gauges move, are monotone with load, and satisfy the implied bound — it does not reproduce #537's ≈16 %-vs-≈9 % heavy-context gap, where a vLLM dashboard would actually mislead. A scrape during a long-context run at high page occupancy would be the data that closes that loop, and it is cheap to add. Also note the validation image mixes #549 with #548 and #560, so the scrape does not isolate this PR's effect (though the unit tests do).
What I would ask for, none of it a gate
- One doc sentence (the reviewer's main should-fix): the two gauges are Prometheus-only;
Snapshot(metrics.rs:70–129), which is theformat=jsonbody and the table atdocs/api.md:330–360, does not carry them. The paragraph atdocs/api.md:298–310should say so, and the existing "Beyond the JSON fields below, the text includes …" sentence at292–296could name them. This matters because the JSON table is otherwise the authoritative field list, even thoughflare_snapshot_backing_pagesis already a gauge with no table row. - The reviewer's second should-fix and the ~55 subtractable lines — micro-scale (helper shape, one guard, folded test assertions). They improve the patch; they do not change whether the patch is right.
- Follow-up, not this PR: adding the two fields to
Snapshotwould let the terminal dashboard plot them (dashboard.rs:514–529currently prints cached/free/total only).
Bottom line: this is a defect-driven, correctly layered, honestly evidenced observability change whose bookkeeping cost the cache was already designed to absorb, and whose whole point is a number the project currently cannot compute. Worth merging; ask for the JSON sentence and let CI cover the Windows build and full suite the description already flags. #549 and #548 touch disjoint regions of metrics.rs, so merge order does not matter.