Case file: PR #549 — "Report KV pages held by active requests"
Author WynnD, opened 2026-11-26 as a draft, head 5ed7af8, base main, 7 files, +218/−10. No reviews, no comments, no CI checks on the head commit, and — unlike its sibling PRs — no automated intake comment. Closes issue #537.
Key findings
- The PR's own evidence does not show the problem solved. The motivating issue (#537) is that an operator cannot compute a vLLM-style KV-usage ratio. In the PR's live scrape,
flare_request_kv_pagesreads 399 and 402 againstflare_total_kv_pages21504, while free (15582/15400) and cached (2037/2043) leave ~3,885 pages unaccounted for — an order of magnitude more than the new gauge reports. The new metric is a correct, deduplicated count of page ids that live requests hold; it is not the term that closes the ledger. The description only claims the weaker statement that request+reserved stayed below total−free−cached. - #537 offered a cheaper design that this PR neither took nor discussed. The issue proposed (1) a distinct-pages gauge, (2) splitting
flare_cached_kv_pagesinto pinned vs idle using the existingpins/direct_pinscounts, and optionally (3) a ready-made ratio gauge. The PR implements (1) plus an extra reserved gauge, silently drops (2) and (3), and adds a second bookkeeping dimension on every checkpoint plus a new pin API pair — the more invasive of the offered options (charter asks for the smallest footprint). - Two claimed mechanisms are weaker than the description reads.
compact_ancestorgainsdebug_assert_eq!(node.request_pins, child.request_pins)(cache.rs:627) — a debug-build assertion, not release enforcement; and "a checkpoint leavesnodesonly at zero pins" is pre-existing behaviour (eviction_candidatesalready requiresdirect_pins == 0, cache.rs:658-663), not something this PR adds. - Documentation is half-done.
docs/api.md:298-305gains prose, but the field↔Prometheus table atdocs/api.md:325-355— the one-row-per-field contract — was not extended for the two new gauges, which also deliberately do not appear in the JSON snapshot. - A single unreproducible evidence base. One local two-GPU scrape on a container built on a fork commit (
AzallazA5ffe4d54, carrying engram encoding from still-open upstream #482), self-admittedly polluted by the agent's own traffic, plus a partial test run (508 tests,--lib -- cache:: scheduler:: server::metrics) whose Windows and full-suite halves are deferred to a CI that has not run. - Direct successor to merged work. #460 (yatesdr, merged 2026-11-23) created exactly the counters and the test-only drift assertion that #549 extends, and supplies the measured reason
statsmust not scannodes(49–58% of runtime samples). #549 is a follow-on in yatesdr's own series, which also makes yatesdr the natural reviewer.
The change
What it does, in plain terms. The runtime's prefix cache tracks pin counts per checkpoint so it can tell which cached pages are still referenced. This PR adds a second pin dimension: pins taken on behalf of an active request. Because a request pin is propagated up the ancestor chain, a checkpoint knows how many live requests reference it; when that count rises from zero, its tail pages are added to a maintained request_pinned_pages total, and subtracted when it falls back to zero (helios/src/cache.rs:551-580, verified). The scheduler then sums two things for the HTTP /metrics route: its live slots' private pages plus the cache's request-pinned pages (request_pages, scheduler.rs:1216-1222), and its live slots' reserved pages (reserved_pages, scheduler.rs:1223-1228). Those numbers are rendered as two Prometheus gauges (metrics.rs:1309-1318).
Size and files (from pr_files):
| File | Lines |
|---|---|
docs/api.md |
+9 |
helios/src/cache.rs |
+60/−1 |
helios/src/cache/lifecycle_tests.rs |
+3 |
helios/src/cache/tests.rs |
+24 |
helios/src/scheduler.rs |
+38/−9 |
helios/src/scheduler/tests.rs |
+66 |
helios/src/server/metrics.rs |
+18 |
Verified against the head — what the diff actually does:
Checkpointgainsdirect_request_pinsand transitiverequest_pins, explicitly subsets of the existingdirect_pins/pins;PrefixCheckpointCachegains the maintainedrequest_pinned_pages(cache.rs:222-224 area; exposed viaCacheStats::request_pinned_pages, cache.rs:188-189, 842).pin_requestcalls the ordinarypinfirst, then walks the chain incrementingrequest_pinsand addingnode.tail_pages.len()at the 0→1 crossing (cache.rs:551-563).unpin_requestmirrors it and errors whendirect_request_pins == 0(cache.rs:565-568) — a new failure mode, though only reachable through misuse.- Every request-owned scheduler pin was indeed swapped: admission when no host admission is in flight (scheduler.rs:1645) with matching releases on both error paths (1660, 1686); inbound ticket waiters (1900); boundary-publication created plus old-parent release (2971, 2973); existing-ready resume (2991, 2992); retirement release (3159). Plain
pin/unpinare kept for the ticket parent, and forpin_checkpoint/unpin_checkpoint(scheduler.rs:2038-2044), whichruntime.rsuses for host-store copy-out/export. No undeclared request-pin path was found, andrequest.prefixis only set on the request-pin paths, so the retirement release cannot fire without a matching pin. SchedulerStatsgainsrequest_pagesandreserved_pages; slots hold at most oneLiveRequest, which is what "at most one slot per active request" means.- Gauge plumbing: two
AtomicU64s stored alongsidecached_pagesin the per-workerMetrics::schedulersnapshot (metrics.rs:514-518) and rendered in the text exposition (metrics.rs:1309-1318). The JSONSnapshot(metrics.rs:90-129,snapshot():355-393) is untouched — as the description says. - The test-only drift assertion was extended: under
cfg(test), everyCache::stats()call now comparesrequest_pinned_pagesto a full scan filteringrequest_pins > 0(cache.rs:818-837). This is real and covers the whole cache/scheduler suite's stats reads.
What the description says that the change does not do (or says more strongly than the code):
- "Compaction asserts that the removed ancestor and its heir agree on request pins" — it is a
debug_assert(cache.rs:627), compiled out of release builds. - "a checkpoint leaves
nodesonly at zero pins" — pre-existing (eviction_candidates, cache.rs:658-663); the PR enforces nothing new here. - "Visibility only … No allocation, eviction, or scheduling decision changes" — verified true in the sense that no decision path reads the new counts. Strictly,
pin_requestadds an extra O(chain-depth) walk (and a secondchain()call) per request pin/unpin, so per-request admission and retirement work does grow slightly.
The why
- Issue #537, "Metrics: KV cache usage cannot be computed with vLLM semantics (pages held by active requests are not exposed)", by Napuh, opened 2026-11-26 09:07 — the same day the PR was opened. No comments.
- The issue's argument, in its own terms: vLLM's
vllm:kv_cache_usage_percis the fraction of KV blocks held by running requests, with zero-refcount prefix blocks counting as free. Flare's existing gauges (total/free/cached/snapshot_backing) give only bounds:1−free/totalis very high (idle prefixes and snapshot backing look used);1−(free+cached+snapshot)/totalis ≈0% with requests active;1−(free+snapshot)/total≈16% versus ≈9% for vLLM on the same hardware and load. - Root cause it cites at v0.3.2 (
c0c4f79): scheduler.rs:1697-1703 plusCache::pin(cache.rs:499-522) — prefix-hit requests pin the chain and share tail pages in place, so those pages remain counted inflare_cached_kv_pageswhile in use; and mid-request checkpoint capture moves private prompt pages into the cache (shared_pages.extend(private_pages.drain(..pages)), scheduler.rs:2887-2911), which the PR's boundary path still does (2976-2978). - How long / how widely wanted: weakly. In the local copy there is one reporter, no comments, no reactions, and the issue and the PR are from the same day. The only earlier trace of the same need is #148 (closed as duplicate of #149), where cache-aware gateways wanted vLLM/sglang-compatible load gauges; #149's
/v1/loadsroute is closed and not on main. So: a real, twice-expressed operator need, but no visible queue of requesters.
Related work
- #460 "Keep checkpoint cache counts instead of scanning for stats" (yatesdr, merged 2026-11-23, +52/−3 in cache.rs and lifecycle_tests.rs) — the direct predecessor. It built
ready_checkpoints/unready_checkpoints/tail_pages, kept them current at publication,advance_completed,retire_leafandcompact_ancestor, and added the#[cfg(test)]full-scan assertion instatsthat #549 extends. Its justification is the reason #549 cannot scan: the runtime loop readsstatson every pass (host-store copy-out retry key and metrics refresh), and the scan was 49–58% of runtime-thread samples on a 4×RTX PRO 6000 GLM-5.3-Flash TP4 box with a 500–900-checkpoint Selene cache. #549 honours that constraint in release builds. - #548 "Add request latency histograms and process metrics" (open, same author, same day, closes #536) — sibling, not competitor. The two descriptions both state they touch different regions of
helios/src/server/metrics.rs(page gauges besidecached_pages; histograms beside the completion counter) and "merge in either order". Verified: the regions are distinct, and #548 does not addSchedulerStatsfields. - #541 "Add a Prometheus and Grafana monitoring example" (open, jere357) — its automated review twice tells the author that "request-held pages appear in no gauge (issue #537)" and asks for reworded KV panel text. Merging #549 makes that reasoning stale; conversely #541 is where an operator would actually consume these gauges.
- #537's unimplemented alternatives: the pinned/idle split of
cached_kv_pagesand the ready-madeflare_kv_cache_usage_ratioare not implemented; #549 leaves the ratio to the operator and documents the division (docs/api.md:303-305). A reader of the issue might expect any of the three. - #351 (merged, yatesdr) established
free + cached + snapshot_backing = poolfor its conservation check. #549 changes none of those terms and adds no JSON field, so those checks are unaffected. - #148/#149 (closed) — earlier vLLM-compatible KV-load exposure, different proposal (
/v1/loads), not superseded by this but adjacent evidence. - Not relevant, checked: #542 (TP dispatch/PreparedAllToAll), #540 (cost-refresh/SAM drafts), #520, #505, #404, #306, #301 touch
scheduler.rsin graph/cost/slot regions, not pin accounting or stats. #429/#400/#415/#358/#141/#92 touchmetrics.rsfor host-cache counters, different series. #482 (open, engram/EXL3) matters only because the live evidence is built on the fork carrying it.
Recent activity
- Nothing on
mainsince this branch point (f377dc8) touches any of the PR's files (orientation packet). - Recent
helios/srcwork:ba35da3f#538 cold pure-prefill discovery (2026-11-26),c915b5f0#532 16-SM green context,c36a6a02#527 Latent576 page-split KV codec,225758fe#525 rANS parallelism,3d8640c6#523 kv-codec disk conversion,716df00f#504 pure-CUDA KV compression,e30d55db#522 GPU confidence calibration. - Only the KV-codec work (#527, #504) touches what a "page" is: page-split encoding means a logical page can hold compressed per-layer data while
total_pages/page_tokensstay logical (docs/api.md:348"including compressed storage", metrics.rs:1405-1408). #549 inherits this — no conflict, but the documented ratio is a page ratio, not a byte ratio, which matters more now that pages can hold compressed data. - The work this builds on:
6d6fe0c6/ #460 (counters + drift assertion, yatesdr, 2026-11-23);f646bebc/ #507 (persistent worker counter schema, Luke Alonso, 2026-11-24 — different region of metrics.rs);21a40f05/ #429 (host-cache linking, yatesdr — touched metrics.rs and scheduler.rs but not these pin paths).
People
- Author: WynnD, commit author "Wynn Drahorad". GitHub association with the repository: NONE. Last 180 days: 0 merged, 0 closed, 2 open — #548 and #549, both opened 2026-11-26, both drafts, both signed "Discord: oystersmiles" (the project's contributor-contact convention, not engagement). No prior standing in the project.
- Area owners:
helios/srccommits in 180 days — Luke Alonso (207), Martin Vit (47), yatesdr (47);docs— Luke Alonso (367). The cache/metrics page-count series specifically is yatesdr's (#92, #141, #168, #351, #400, #415, #429, #460); scheduler pin and prefix-cache pressure work is @voipmonitor's (#298, #299). Charter also names @original-el8 and @lukealonso as maintainer contacts. - Who has engaged: nobody. No comments, reviews or reactions on #549; no maintainer has commented on #537 either.
Community
- Zero engagement:
pr_commentsreturns nothing; orientation packet records no reviews and no reactions. - Notably, no flare-autobot case-file comment on #549, whereas #548 and #541 each received one within roughly 30–60 minutes of opening. Recorded as fact; a plausible explanation is the draft state or intake timing, which I did not verify as a gating rule.
- Interest in the underlying problem is traceable to #537 (one reporter), #541 (a reviewer citing #537 as a gap), and the older #148/#149 pair. No maintainer reaction on record.
Project fit
Where it lines up:
- The description has all four parts the charter asks for (why / what changed / claimed result / evidence), and AGENTS.md's guidance on connecting claims to evidence is mostly respected — the PR is disciplined about scope ("Visibility only").
- It adds no per-model branch, no flag, no dependency, no JSON API field, and no configuration or default, so it does not trip the model-agnostic, "pin everything", or don't-silently-ignore-API-fields rules. It is observability of an existing subsystem, in the runtime rather than in a model recipe — the split the charter describes.
- Charter's "what gets merged" includes PRs addressing a filed report; #537 is a filed issue in this repository.
Where it does not:
- The charter's evidence bar ("Bring real evidence… showing an actual speedup over
main… 'hypothetical users' aren't enough") is met weakly: one local scrape on a fork-based container, polluted by the agent's own traffic, no repeatable script, Windows and full suite unrun, and no CI result on the head. - "Solve the right problem in the right place… look for the smallest footprint in shared code" — the issue named a cheaper option (split
cached_kv_pagesinto pinned/idle, reusing existing pin counts) that needs no per-node subset counters and no new pin API; the PR takes the larger option without saying why. - Roadmap coverage: the charter's roadmap (SDK #6, Engram #267, FlashInfer #215) does not cover observability, so this is not a roadmap item.
- Docs contract:
docs/api.md's health-and-metrics section is the documented/metricscontract; the prose is added but the field/metric table (:325-355) is not extended, and the JSON omission is only implicit in the surrounding text (:316-323).
Claims and evidence
| Claim | What backs it |
|---|---|
"508 passed" on Linux x86_64 release, --lib -- cache:: scheduler:: server::metrics |
Description only. No CI checks on head 5ed7af8. Windows build and full helios suite explicitly not run, deferred to "CI covers". Compare #460, same machinery, which reported the full helios library (1,542 passed) plus a revert check. |
| The counter cannot silently drift | True in test builds: the cfg(test) assertion in stats compares request_pinned_pages with a full scan on every stats read (cache.rs:818-837), so all cache/scheduler tests exercise it. Release builds have no such check — an accounting bug would only surface as a wrong gauge. |
request_pins_count_each_shared_page_once (cache/tests.rs:320-341) |
Present as described: parent with two children over pages 0/1/2, both pinned for requests, count 3 not 4; plain pins leave it unchanged; releasing the parent without a request pin errors; count returns to zero. |
request_kv_pages_count_shared_prefix_pages_once (scheduler/tests.rs:971-1032) |
Present, but it cancels its two requests rather than completing them, so the terminal-publication path (retire with publish) is only covered indirectly through shared unpin_request code. |
counters_expose_fixed_names_without_request_payloads |
Covers both gauges' types and values as described. |
| "No allocation, eviction, or scheduling decision changes" | Consistent with the diff: nothing reads the new counts except stats and Metrics. Caveat: an extra O(chain) walk per pin as noted above. |
| Live scrape: request 399/402, reserved 3/2, free 15582/15400, cached 2037/2043, total 21504 | Single two-GPU DeepSeek-V4.1-Flash run on a container built from the repo Dockerfile with #536's counterpart, swapped into a llama-swap entry, base AzallazA fork 5ffe4d54 (needs the engram encoding that exists only in still-open upstream #482). The instance also served the agent's own traffic. Not reproducible by a reviewer; no other runtime compared. |
| Gauge definition: "each page counted once even when several requests reference it" | Verified for the cache half: a checkpoint's tail pages are counted once if any request pins it (cache.rs:558-560). Verified for the slot half: each private page belongs to one slot. request.shared_pages (the chain a request actually reads) is never used directly — it is covered through the pinned checkpoints after the boundary publication drains prompt pages into shared_pages (scheduler.rs:2976-2978). Net: the definition holds; the two halves are not cross-deduped, but no scenario was found where a page appears in both. |
| Reported ratio 0.0186 / 0.0187 | Arithmetic checks out (399/21504, 402/21504). |
| "request+reserved stayed below total−free−cached" | True, but this is a weak claim: the same numbers show 21504 − 15582 − 2037 = 3885 pages still unexplained by free+cached, roughly ten times the new gauge's value. |
Why reserved_pages is additive rather than overlapping (relevant because it is the one genuinely new term): at admission the scheduler pops reserved_count page ids out of free_pages into request.reserved_pages (scheduler.rs:1732-1735, rebound for vision windows at 2183-2197), and only later moves them into private_pages (scheduler.rs:2434-2438, and 3170 on retirement). A reserved page is by construction not free, not in any checkpoint's tail_pages, and not yet in private_pages — which is exactly the docs' "neither free, cached, nor written" (docs/api.md:301-302). The residual in the live scrapes is unattributed, but #351's conservation identity points at flare_snapshot_backing_pages as the largest missing term; the scrape did not report it. Also outside the four gauges: ticket pages held for in-flight host restores (scheduler.rs:1704-1706) and retired pages awaiting a fence (scheduler.rs:843-847).
Reach
- Who is affected: operators only. Two new Prometheus gauges; no JSON change, so
flare_helios::server::Snapshotconsumers, the terminal dashboard (dashboard.rs), and qualification clients (tests/server/test_cache_memory.py:34readsflare_free_kv_pagestext;scripts/qualify_worker_failure.py:143(not opened)) are untouched.free/cached/totalsemantics are unchanged, so #351's conservation identity still holds. - Gauge semantics worth knowing before comparing to GPU memory:
- Per rank, not per deployment.
total_kv_pagesis the per-rank pool (metrics.rs:1400-1402, docs/api.md:347) andSchedulerStatsis built per worker (runtime.rs:1149, 722, 745), so the documented ratio pairs correctly on one rank but the gauges are not additive across ranks. - Refreshed only on progress (
if progress { … }, runtime.rs:1148-1153); a fully stalled worker keeps serving its last values, and worker start/shutdown also refresh. - Logical holds, not physical reclamation. Finished responses awaiting delivery hold no live KV (docs/api.md:278-279) and cancel/preempt retire the slot immediately (scheduler.rs:3051-3052) though pages are freed later, so both gauges drop at retirement rather than at fence completion.
reserved_pagesdrops at the same moment. - Requests still waiting for admission hold nothing; inbound-waiting requests hold only their reservation until
finish_inboundpins them (scheduler.rs:1898-1909).
- Per rank, not per deployment.
- Compatibility / configuration: no config, default, flag or dependency change. Stated (and verified as plausible) to merge with #548 in either order — different regions of
metrics.rs, and #548 adds noSchedulerStatsfields. - Cost: the metric read is O(slots) and safe on the runtime thread, which matters because
statsruns on every progress pass and #460 exists to keep it cheap; the new cost is the extra chain walk per request pin/unpin. - Docs: docs/api.md:298-305 only.
docs/prefix-cache-offload.md:747lists the SchedulerStats host fields but never listedcached_pageseither, so its omission is not a regression.
Process
- Draft, opened and last updated 2026-11-26 (same day as its issue and its sibling PR). Head
5ed7af8; no commits onmaintouching its files since it branched. - No CI on the head commit, no reviews, no comments, no intake comment. Age at review time: same day — nothing has had time to accumulate, and the draft state means no review has been requested.
- The description's own caveat — "the Windows build and the full helios suite … CI covers", plus "the instance also served this agent session's own requests" — is honest but leaves the two strongest evidence items (multi-platform build, full suite) unverified.
Open questions / could not be found
- What accounts for the ~3,885-page residual in the PR's own scrape? #351's identity suggests snapshot backing; the scrape does not report
flare_snapshot_backing_pages, and I did not attempt to reconcile further. Until that is attributed, it is unclear whetherflare_request_kv_pagesgives an operator a ratio they can trust against vLLM's number — the thing #537 was about. - Why was #537's cheaper option rejected? Nothing in the description says. The existing
pins/direct_pinscounts already distinguish pinned from idle checkpoints, which is option (2); the PR chooses a second bookkeeping dimension instead. - Is the missing intake comment a draft gate or a queue artefact? Not verified.
- Multi-rank/TP and multi-host Selene behaviour of the gauges is untested by the author and not exercised by the new tests; the per-rank semantics above are read from code, not measured.
- Would the maintainers accept a new public miss path?
unpin_requestreturns an error when no request pin exists (cache.rs:566-568). It was unreachable in the paths I traced, but it is a new failure mode on the retirement path where previously an unpin could not fail that way.
Nothing found under an angle that is absent above: all ten angles produced entries (#1–#11, #13–#15), with the summary at #12.