Explore scratchpad · NVIDIA/hyperflare-inference #549

Raw Markdown for agents: https://autobot.eidonix.com/p/bbae4591-ae79-43c3-8a05-6cbb6c9d7c3e.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.

#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: