Explore scratchpad · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/67f605d9-9659-49c4-9caa-3ea6234d1252.md

#1 [high] Change: what PR #549 does, size, files

PR #549 "Report KV pages held by active requests", author WynnD (association NONE), open, draft, opened 2026-11-26, head 5ed7af8, base main, 7 files +218/-10, no reviews, no CI checks on head, no comments at all (pr_comments empty).

Files: 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).

Substance:

Claimed: visibility only, no allocation/eviction/scheduling change. Test evidence: Linux x86_64 release --lib -- cache:: scheduler:: server::metrics: 508 passed. Live scrape on two-GPU DeepSeek-V4.1-Flash with #536, base AzallazA fork 5ffe4d54 (needs engram, upstream #482). Closes #537.

#2 [high] Why: issue #537 (the motivating request) detail

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 (same day as PR #549 opened; PR closes it). No comments on the issue.

Content: vLLM vllm:kv_cache_usage_perc = fraction of KV blocks held by running requests; prefix blocks with ref_count 0 count free. Existing Flare gauges total/free/cached/snapshot_backing give only bounds: 1-free/total very high (idle prefix + snapshot backing count as used); 1-(free+cached+snapshot)/total ~0% with active requests (lower bound); 1-(free+snapshot)/total ~16% (upper bound); vLLM same hw/load ~9%. Root cause cited at v0.3.2 (c0c4f79): scheduler.rs:1697-1703 + Cache::pin cache.rs:499-522 — prefix-hit requests pin the chain and share tail pages in place, so those pages stay in flare_cached_kv_pages while in use; mid-request checkpoint capture moves private prompt pages into cache (scheduler.rs:2887-2911 shared_pages.extend(private_pages.drain(..pages))). Proposal: (1) flare_request_kv_pages distinct pages referenced by active requests (each once) so ratio vs total_kv_pages matches vLLM; OR (2) split cached into pinned vs idle; optionally a ready-made flare_kv_cache_usage_ratio.

PR #549 implements proposal (1) plus an extra flare_reserved_kv_pages; it does NOT implement (2), the ratio gauge, nor the JSON snapshot field. Referred to by: PR #541 (Grafana example mentions), #548 (mentions), #549 (closes). Wanted-ness: single issue, one reporter, no comments, opened the same day the PR was opened — no long-standing demand visible in the local copy.

#3 [high] Change: verification of what the diff does and does not do

Verified against the head (5ed7af8):

#4 [high] Related work: #460 is the direct predecessor of the cache counter approach

PR #460 "Keep checkpoint cache counts instead of scanning for stats" by yatesdr (COLLABORATOR), merged 2026-11-23, +52/-3 in helios/src/cache.rs and cache/lifecycle_tests.rs. Commit 6d6fe0c6 / main history. It created exactly the machinery #549 extends: kept ready_checkpoints/unready_checkpoints/tail_pages counters updated at publication, advance_completed, retire_leaf, compact_ancestor, plus the #[cfg(test)] assertion in stats comparing them to a full scan. #460's reason: the runtime loop reads stats on every pass (host-store copy-out retry key and the 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 Selene cache holding 500-900 checkpoints. Consequence for #549: the design constraint "stats must not scan nodes" has a measured owner (yatesdr) and a measured justification; #549 honours it for the runtime build (counters only) but pin_request/unpin_request add an O(chain depth) walk per pin, and stats under cfg(test) still scans. This is the same file/area, so yatesdr is the natural reviewer and #549 is a direct follow-on to #460. #460 also references #459.

#5 [high] People: new contributor with two parallel metrics PRs, no engagement yet

WynnD = commit author "Wynn Drahorad" (commit 5ed7af86 "Report KV pages held by active requests"). GitHub association with the repo: NONE. In the last 180 days: 0 merged, 0 closed, 2 open — #548 (latency histograms/process metrics, closes #536) and #549 (this one, closes #537). Both opened 2026-11-26, both drafts, both signed "Discord: oystersmiles", both use the same evidence method (Linux x86_64 release lib tests + live scrape on a local two-GPU DeepSeek-V4.1-Flash llama-swap entry built from the repo Dockerfile on top of AzallazA fork commit 5ffe4d54, which carries the engram encoding from upstream PR #482 — an open PR by another author). Both descriptions explicitly say they and the other "merge in either order" and touch different regions of helios/src/server/metrics.rs. No prior history in this repo, so no standing as a priority contributor (charter names @voipmonitor, @original-el8, @lukealonso). People who own these areas: helios/src commits in last 180d — Luke Alonso (207), Martin Vit (47), yatesdr (47); docs — Luke Alonso (367). cache.rs/metrics.rs page-count work is yatesdr's (#92, #141, #168, #400, #415, #429, #460, #351); scheduler pin/prefix-cache pressure work is voipmonitor's (#298, #299). Engagement on #549 so far: none — no comments, no reviews, no reactions, and unlike #548 and #541 no flare-autobot case-file comment was posted on #549.

#6 [high] Related work: #537's other proposals unimplemented; #541 and #148/#149 connect

#7 [high] Claims and evidence: what the numbers actually show, and the gap that remains

Verified by reading the code (not by running it):

#8 [high] Claims and evidence: test suite claimed, CI absent, live run not reproducible

Not executed by me — recorded as claimed, with what backs it:

#9 [high] Project fit: charter evidence bar and "smallest footprint" vs the chosen of two issue options

Facts, both where it lines up and where it does not:

#10 [high] Process and reach: draft, no CI, no intake comment, operator-only, no compat break

#12 [high] Research summary

Case file assembled for PR #549 ("Report KV pages held by active requests", WynnD, draft, 7 files +218/−10, head 5ed7af8, no CI, no comments or reviews). Ten scratchpad entries cover every angle.

Key things a reader cannot get from the description: (1) the live-scrape evidence shows flare_request_kv_pages at 399/402 against 21504 total with 3885 pages still unaccounted by free+cached, so the gauge does not close the gap issue #537 set out to close; (2) #537 offered a cheaper alternative (split cached_kv_pages into pinned/idle, reusing the existing pin counts) that the PR did not take or explain; (3) the "compaction asserts" claim is a debug_assert only and "a checkpoint leaves nodes only at zero pins" is pre-existing behaviour, not new enforcement; (4) the docs prose was added but the JSON-field↔Prometheus table in docs/api.md was not extended; (5) no CI ran on the head commit and no automated intake comment appeared, unlike sibling PRs #548/#541.

The change is a direct successor to merged PR #460 (yatesdr), which created the very counters and drift assertion it extends; that also supplies the measured reason stats must not scan nodes. Related: #548 (same author, same day, different region of metrics.rs, stated to merge in either order), #541 (its review text still tells readers request-held pages appear in no gauge), #537 (the issue), #148/#149 (earlier vLLM-compatible KV-load request, closed unmerged). Project fit: description has all four charter parts and no model branch/flag/dependency, but the charter's evidence bar and "smallest footprint" rule are the tension points. Reach is operator-only: JSON snapshot, terminal dashboard and qualification clients are untouched.

#17 [high] Amendment: new head 9cca87ac "Keep page gauges out of the copy-out retry key" — what changed and what did not

New head since report #16: 9cca87ac "Keep page gauges out of the copy-out retry key" (Wynn Drahorad, 2026-11-26), on top of 5ed7af86. PR now 8 files, +246/−16, still draft, no CI evidence, no review on the new head (last comment is the author's 2026-11-27 04:56 "review the pushed changes"; the autobot review of 2026-11-26 22:38 is against the old head). Cited PR: https://github.com/NVIDIA/hyperflare-inference/pull/549

FIXED:

  1. Blocker (copy-out retry key) — fixed. CopyoutResources { scheduler: SchedulerStats { request_pages: 0, reserved_pages: 0, ..self.scheduler.stats() } } (runtime.rs:2441-2453). Key is now byte-equivalent to pre-PR semantics; sound because every movement of request/reserved pages (admission, commit scheduler.rs:2433-2438, retirement) also moves free_pages/cached_pages/active_requests, which stay in the key. SchedulerStats PartialEq is used only here (runtime.rs:1053-1059, 2455).
    • BUT: no test for the fix (phase_tests.rs untouched), the Evidence section still reports the pre-fix 508-test run, and the PR description's "What changed" still lists only cache.rs / scheduler.rs / metrics.rs / docs/api.md — runtime.rs (+8/−1) is undocumented, and "No allocation, eviction, or scheduling decision changes" is still stated without recording that the gauges had briefly perturbed deferred copy-outs.
  2. docs/api.md "gauges read from scheduler state on each scrape" replaced with worker-publishes wording (:302-303). Done.
  3. Ratio paragraph rewritten (:303-312): reserved outside numerator, request + reserved = comparable figure, request-pinned tail pages in both gauges, excludes retirement-draining and in-flight restore pages. Done.
  4. cache.rs:548-550 doc comment now states the cache's half only ("a request's own private pages are counted by the scheduler"). Done.
  5. Pin-release-before-take: retirement now releases unpin_request at scheduler.rs:3149-3157 before request.take() (:3157), so a failed release leaves the request inspectable. Semantics preserved (record_publication moved too, queues an id only).

NOT DONE / NEW PROBLEMS:

#19 [high] Amendment addendum: the copy-out fix sits outside the claimed test filter

Correction/completion of entry #17 (same commit 9cca87ac, PR #549):

The fix's own file is outside the claimed test filter. The commit's only source change is helios/src/server/runtime.rs (+8/−1). The PR's Evidence section still reports cargo test --lib -- cache:: scheduler:: server::metrics, a name filter that does not select server::runtime::*; nothing in the new commit adds a test, and helios/src/server/runtime/phase_tests.rs is untouched by it. So the copy-out-key fix has no claimed coverage at all. Existing tests that could incidentally catch a regression: local_copyout_defers_without_a_pin_until_pending_admission_headroom_returns (phase_tests.rs:6357), local_copyout_rechecks_headroom_after_each_queued_pin (:6408), completed_copyout_retries_capacity_waiters_without_a_new_model_fence (:5890) — they assert copyout_headroom_deferrals counts, but only catch the regression if a page-boundary-crossing decode happens between deferred-copy-out retries, which I did not verify. Recommendation: one test that decodes across a page boundary while a copy-out is deferred and asserts the deferral count does not move.

Pin release moved but the failure mode it protects is now reachable earlier. retire (scheduler.rs:3094) now calls record_publication(prefix) and cache.unpin_request(prefix) at :3149-3156, before self.slots[..].request.take() at :3157. Previously a failed unpin_request lost the request; now it returns Err with the slot intact and retire is retryable (cancel/finish/fail_ticket/release_after_shutdown all re-enter it). record_publication dedups through offered_publications, so a retry cannot double-offer. Semantics equivalent otherwise; the terminal flush of self.publications order changed only in that the prefix id is now queued before the Created-terminal bookkeeping block (:3160-3168) — no reader depends on that order (store pulls the whole list).

Equivalent-quality nit in new prose (docs/api.md:309-310): "Dividing either gauge by flare_total_kv_pages …" — dividing the reserved gauge alone has no meaning; only request, or request+reserved, divides usefully. The sentence lists both because the previous one names request+reserved; a one-word fix ("Dividing that sum or the request gauge …").

#21 [high] Amendment: engagement changed — bot review now exists with Changes Requested

Supersedes report #16's "no autobot intake comment / no engagement" line for PR #549:

#22 [high] Research summary

Amended the #549 case file for the new event (head 5ed7af86 → 9cca87ac, "Keep page gauges out of the copy-out retry key"). Notes 17–21 hold the detail.

Closes / strike from the old report: the copy-out retry-key blocker is fixed (runtime.rs:2441-2453) and I verified the zeroing is sound, not merely expedient — every transition the key no longer sees moves no cache resource, and SchedulerStats' PartialEq is used only there. Also done: the "read on each scrape" prose, the whole ratio paragraph, the cache.rs:548-550 doc comment, and the retire pin-release reordering before request.take() (retire is now re-enterable, record_publication dedups). The "no automated intake comment" observation is stale: a flare-autobot Changes Requested review exists (2026-11-26 22:38) plus the author's re-review request; still no human engagement.

Stands, with new detail: the subtract item was answered by adding code — pin_prefix/unpin_prefix plus a request_pin boolean at only three of five sites, leaving two idioms and the ~90 removable lines untouched. Two new prose inaccuracies: test internals (cfg(test) drift assertion) leaked into the operator contract, and "publishes on every scheduler pass" is wrong (progress-gated, plus start and shutdown). The ledger gap, the untaken cheaper #537 option, the unextended field↔Prometheus table and the debug_assert claim all stand unchanged.

New finding: the fix lives in helios/src/server/runtime.rs, which the PR's claimed test filter (cache:: scheduler:: server::metrics) does not select, and no test was added — the copy-out fix has no claimed coverage. Series context: the author now has four open drafts in two days (#548, #549, #552, #553) and #553's auto-review was halted on charter-alignment grounds, the same value gate #549 faces, which #549 answers only through the independently filed issue #537.

#23 [high] Amendment block for the report: what to replace, strike and add for #549 after 9cca87ac

Delivered to the reader as amendments to case file run 1349. Detail lives in notes #17 (what changed/what did not), #18 (series), #19 (fix outside the claimed test filter), #20 (zeroing soundness), #21 (engagement). Order to present:

Replace in the Scale/scope section: head 5ed7af86 → 9cca87ac "Keep page gauges out of the copy-out retry key" (Wynn Drahorad, 2026-11-26); 8 files, +246/−16 (was 7 / +218/−10), still draft. New diff file helios/src/server/runtime.rs (+8/−1); docs/api.md +16; scheduler.rs now +51/−14. The description's "What changed" still omits runtime.rs and still asserts "No allocation, eviction, or scheduling decision changes" without noting the gauges had briefly perturbed deferred copy-outs (docs/api.md's own text also still frames the numbers as scrape-time, see below).

Strike (closed by this event):

Stands, with new detail:

New finding: the fix's only source change is in helios/src/server/runtime.rs, while the Evidence section still reports --lib -- cache:: scheduler:: server::metrics (does not select server::runtime::*), no test was added, server/runtime/phase_tests.rs is untouched, and the 508-test result predates the fix → the copy-out fix has no claimed coverage. Candidate tests that could catch it only incidentally: phase_tests.rs:5890, 6357, 6408. Ask for one test that decodes across a page boundary with a copy-out deferred and asserts copyout_headroom_deferrals does not move.

Series context: WynnD has four open drafts in two days — #548 (+548/−25, closes #536), #549, #552 (+929/−26, stacked on #548), #553 (+303/−9) — plus issue #551; none merged. #553's auto-review was halted 2026-11-27 05:17: "Review Stopped — It is low value or does not align with the project charter" (value-proposition gate); #549's answer to that gate is the independently filed #537.

#11 [medium] Recent activity: KV-codec page work is the live neighbour; other file-mates do not overlap

#13 [medium] Community: no engagement at all on #549, no automated intake comment

#14 [medium] Claims: reserved_pages is additive by construction; the residual is unattributed

Why flare_reserved_kv_pages is additive rather than overlapping, verified in code: at admission the scheduler pops reserved_count page ids out of self.free_pages into request.reserved_pages (scheduler.rs:1732-1735; also rebound in vision windows at 2183-2197), and only later moves them into private_pages as work is committed (request.private_pages.extend(allocated) at scheduler.rs:2434-2438, and private_pages.extend(reserved_pages) on retirement at 3170). So a reserved page is by construction not free, not in any checkpoint's tail_pages, and not yet in private_pages. That is what makes the docs sentence "neither free, cached, nor written" (docs/api.md:301-302) accurate, and it is why request_pages + reserved_pages can be summed without double counting.

#15 [medium] Reach: how the two gauges behave (per-rank, progress-gated, logical holds)

Facts about how the two gauges behave that bear on any decision, all verified in code:

#18 [medium] Amendment: author's series widened; first charter-alignment "Review Stopped" on a sibling

New context since report #16 (all WynnD, all 2026-11-26/27, none merged):

#20 [medium] Amendment: the copy-out key fix is sound, not just expedient

Verified the zeroing is semantically right, not just expedient (PR #549 head 9cca87ac, runtime.rs:2441-2453):