#1 [high] PR #742 mechanism and code sites
PR #742 head f26d8a8, base f46a9922, +105/-21 in 9 files. Fixes pool-only capture-buffer oversizing.
Sizing chain (verified by reading head):
- selene/src/offload.rs:163-181 headroom_inner: capture = local_pages.filter(|_| self.pool_only()); chain_pages = inputs.max_sequence_pages.map_or(pages, |l| pages.min(l.get())); chain = chain_pages + layout.row_slots(); budget = host_budget/page_record_bytes; if chain > budget -> Err("host budget cannot hold a full pool capture"); intake = chain.max(intake_slots(layout,max_active)).min(budget).
- intake_slots (offload.rs:226-228) = 2max_activerow_slots + 2*WINDOW_PAGES(64) [UNCAPPED by design]
- pool_only() (offload.rs:116-118) = pool.is_some() && memory_bytes==0 && !disk_enabled()
- helios/src/runtime_core/memory.rs:562-569 new fn max_sequence_pages(context, page_tokens) -> Result (guards 0 page size/0 context)
- memory.rs:1002-1008 context from server_config["max_sequence_tokens"], filter >0; page_ceiling; max_sequence_pages; minimum_pages = active*ceil(8192/page_tokens) under KvCacheLimit::Memory (memory.rs:713, 1008)
- memory.rs:1009 capture = options.prefix_cache.pool_only() && self.cluster().is_none() (single-process only!)
- memory.rs:1133-1145 passes Some(max_sequence_pages) + capture.then_some(minimum_pages) into headroom_with_inputs_for_budget
- memory.rs:1494-1497 capture_growth(..., pages.min(max_sequence_pages.get()), ...) inside capacities
- memory.rs:1561-1566 planned_offload_host chain_bytes = pages.min(max_sequence_pages)+row_slots * page_record_bytes, Some(tier_host.max(chain_bytes))
- memory.rs:1599-1604 PlannedHostBudgets{offload_host, max_sequence_pages, async_transfer_host_caps}
- model.rs:1047-1053 prepare_offload(..., Some(planned.max_sequence_pages)); model.rs:1125,1167-1173 -> PrepareInputs
- Startup log line (from selene/src/offload.rs:432-460 summary()): "pool only: capture buffer X GiB (N slots, populate …, register …)"; emitted via helios/src/runtime_core/model.rs:1130 phase "Prepare host prefix cache" + phase.finish(summary).
IMPORTANT bug-class caveat for planning (from code-correctness lens, later dropped on verification): memory.rs:1143 passes capture.then_some(minimum_pages) (NOT allocated pages) into headroom_inner; final slab at offload.rs:699 uses geometry page_capacity (allocated). Reviewer verified this is fine because the 1133 call only computes the pre-registration tier_host reservation and the real slab is built at offload.rs:702-754 from bytes derived again from headroom_inner with local_pages = allocated capacity (offload.rs:699). Still: the actual slab size at startup is min(allocated page_capacity, max_sequence_pages)+row_slots.
Gov/doc: docs/prefix-cache-offload.md:1593-1609 documents ceiling min(GPU page capacity, ceil(max_sequence_tokens/page_tokens)) + one row. Bypass risk: with --kv-cache-limit context|concurrency, page_ceiling caps maximum_pages near max_sequence_pages, so the min() is a no-op; A/B must use default --kv-cache-limit memory.
#2 [high] Hardware test plan facts for PR #742 (pool-only capture bound)
Mode gate: capture requires options.prefix_cache.pool_only() (selene/src/offload.rs:116-118: pool.is_some() && memory_bytes==0 && !disk_enabled()) AND self.cluster().is_none() (helios/src/runtime_core/memory.rs:1009) AND local_pages.is_some() && shard.is_none() (selene/src/offload.rs:699-700). So: --prefix-cache-pool ADDR, --prefix-cache-memory 0, NO --prefix-cache-disk, single process (no --rank/--hosts). Must use default --kv-cache-limit memory (flare-cli/src/cli.rs:926-939): with context|concurrency, page_ceiling caps maximum pages ≈ ceil(context/page_tokens) (memory.rs:585-607) so the new min() is a no-op and A/B shows nothing.
Expected slab slots (chain-dominated, max_concurrency small): slots = min(allocated page_capacity, MSP) + layout.row_slots(), MSP = ceil(max_sequence_tokens/page_tokens) (memory.rs:562-569, 1007). intake floor (uncapped): intake_slots = 2max_activerow_slots + 2*64 (selene/src/offload.rs:226-228); on main slots = max(pages+row_slots, intake); with wide --max-concurrency the cap can be invisible (intake dominates) — doc example: 1,664 intake slots /11.0 GiB vs 7.1 GiB chain.
Observables: startup log line "pool only: capture buffer {GiB} ({N} slots, populate …, register …)" (selene/src/offload.rs:432-460, emitted in phase "Prepare host prefix cache", helios/src/runtime_core/model.rs:1130); startup error "host budget cannot hold a full pool capture" (selene/src/offload.rs:175-176). Metrics gauges: flare_host_cache_slots_total (host_slots[1]) & flare_host_cache_intake_slots (=0 in capture mode) & flare_host_cache_slots_in_use, flare_total_kv_pages, flare_kv_page_tokens (helios/src/server/metrics.rs:1334-1400,1467-1501). Failure signals if the cap under-sizes: flare_host_cache_dropped_total{reason="oversize"} and flare_host_cache_retry_abandoned_total{reason="slabs"} (metrics.rs:861-873, 905-912), plus flare_host_cache_stored_total (must be >0) and flare_host_cache_hits_total/reused_tokens for restore.
page_record_bytes can be derived from the startup log (bytes/slots) or cache.kv_page_bytes in flare inspect CORE --json (models: max_sequence_tokens, max_active; cache: page_tokens, pages, max_pages).
RSS: /proc//status VmHWM; cgroup memory.peak for the failure-mode run.
Hardware fit: cn5 (SM120, 4×96 GiB, 125 GiB RAM, amd64) is the right host — single-process TP1 or TP4, default --memory-limit gives ~99k pages on 96 GiB so pages >> MSP for any 128K-context core (large gap). cn7 (GB10, 1 GPU, 60 GiB unified, arm64, SM121) exercises the integrated branch (integrated_offload_host_budget, sized_concurrency 1) — smoke only.
Risk: model entries on both hosts are listed at 0 GiB, so a prepared signed core may not exist; flare models / flare inspect must confirm before any GPU run (exporting would need the full checkpoint).
Not worth GPU time: throughput/isolation benchmarks (no hot-path change; qualify/host_cache_isolation.py), full helios --ignored GPU suite, tests/server/test_prefix_cache_offload.py (does not exercise pool-only), Kani/TLA+.
#4 [high] PR #742 head 5021b7a — test-plan deltas and hardware fit for cn5/cn7
Head moved f26d8a8 -> 5021b7a3 (base main f46a9922), 9 files +105/-21. Diff is refactor+test only vs f26d8a8: prepare_offload now takes NonZeroU64 (model.rs:1119-1126, called model.rs:1047-1053), max_sequence_pages(context: NonZeroU64, page_tokens: usize) helper with zero-page guard (memory.rs:563-568, call site :1006-1012), capture_chain_pages() shared by capture_growth (:1502) and planned_offload_host (:1568), PlannedHostBudgets{offload_host,max_sequence_pages,async_transfer_host_caps} (:32-36, :1604-1608). No behaviour change -> previous test plan stands, only the SHA to build changes.
Capture-path gate (unchanged, re-verified at head): selene/src/offload.rs:164-181 chain_pages = max_sequence_pages.map_or(pages,|l| pages.min(l.get())); chain = chain+row_slots; err "host budget cannot hold a full pool capture" :176-177; intake = chain.max(intake_slots).min(budget). pool_only() = offload.rs:117-119. intake_slots = 2max_activerow_slots + 128 (offload.rs:227-229). Single-process gate memory.rs:1014 (pool_only && cluster().is_none()); local_pages/shards offload.rs:700.
Hardware fit (models listed, all 0 GiB = not yet downloaded; flare models download / flare run MODEL fetches prepared cores: docs/cli-design.md:126-132, flare-cli/src/cli.rs:44-49,72-73):
- cn5 (4x96 GiB SM120, 125 GiB RAM): only KV-bearing host core is GLM-5.3-Flash-NVFP4 (TP4) -> fits exactly one process on 4 GPUs; PR's own measured config (99,008 pages vs MSP 16,384 at 64 tok/page, 1M ctx) => ratio ~6x. dinov2 entries are vision, no KV.
- cn7 (1 GB10 60 GiB unified, arm64): TP4 core will not load; need a TP1 GB10 core (Qwen3.8-27B-NVFP4, gemma-4-E4B-it, Qwen3.8-Flash-Next-FP4-Local ...) confirmed via
flare inspect --jsontensor_parallel==1. Integrated branch memory.rs:1140-1145, sized_concurrency offload.rs. - Constraint: 16 GiB scratch on both; core download + cargo target must go elsewhere (home/workspace); check
df -h+df -h /dev/shmfirst.
Observables verified in helios/src/server/metrics.rs:
- gauges: flare_host_cache_slots_total (:1389, host_slots[1]), flare_host_cache_intake_slots (:1394 -> must be 0 in capture mode), flare_host_cache_slots_in_use (:1384), flare_total_kv_pages (:1469), flare_kv_page_tokens (:1474), flare_snapshot_capacity (:1334), flare_cached_checkpoints (:1349), flare_snapshot_evictions_total (:1191), flare_host_cache_outbound_in_flight/inbound_in_flight (:1364,:1374).
- counters: flare_host_cache_stored_total (:1236), flare_host_cache_fetched_total (:1251), flare_host_cache_hits_total (:1206), flare_host_cache_reused_tokens_total (:1211), flare_host_cache_fetch_failed_total (:1256), flare_host_cache_store_failed_total (:1246), flare_host_cache_root_pages_total{tier="pool",reason="first"} (:830), flare_host_cache_retry_abandoned_total{reason,incl "slabs"} (:907), flare_host_cache_store_reasons_total{reason,incl "slabs","oversize"} (:925), flare_host_cache_dropped_total{tier=dram|nvme,reason} (:870 — tier labels are dram/nvme only, so prefer store_reasons_total for the capture slab).
- startup markers: "pool only: capture buffer X GiB (N slots, populate .., register ..)" selene/src/offload.rs:433-461 (emitted in phase "Prepare host prefix cache", model.rs:1130); "Plan cache ... N KV pages" memory.rs:1577; env gate for gpu_tests FLARE_OFFLOAD_TEST_CORE (gpu_tests.rs:64-74).
Inspect fields for pre-computing expectations (flare-cli/src/inspect.rs:1030-1076, :801-807): model.max_sequence_tokens, model.max_active, cache.page_tokens, cache.pages, cache.max_pages, cache.kv_page_bytes, cache.state_row_bytes, cache.snapshots.
Phase-2 reproduction lever (no privileges needed): host budget = MemAvailable - future - reserve, reserve = min(2GiB,total/32) + 5% total (selene/src/offload.rs:932-997) => on 125 GiB cn5 reserve ~8.25 GiB; hog host RAM with a touched-memory process until MemAvailable ~75 GiB so main's whole-chain charge (~70-109 GiB) exceeds budget -> clean "host budget cannot hold a full pool capture", while head's ~12 GiB chain still admits. cgroup (systemd-run MemoryMax) / ulimit -v are fallbacks and produce different error text. Manager sizing rule: /dev/shm must hold --memory + --staging (selene-manager/docs/operating.md:115-118); a GPU export needs staging reserved for the whole export (operating.md:71-90) => staging must exceed chain bytes (~12 GiB for 1M ctx) or the put fails NO_WINDOWS. Also worth one cheap regression start with NO prefix-cache flags: head now computes max_sequence_pages unconditionally in allocate_caches (memory.rs:1012) even when offload is disabled. Not worth GPU time: tests/server/test_prefix_cache_offload.py (never passes --prefix-cache-pool, gate at :26-31), --kv-cache-limit context|concurrency A/B (page_ceiling caps pages ~MSP, memory.rs:576-607), throughput benchmarks, full helios --ignored suite, Kani/TLA+/RoCE/Windows.
#5 [high] Corrections to my earlier cn5/cn7 plan for PR #742
Corrections vs my earlier plan (entry #3), all verified at head:
-
Head is 5021b7a3 (base f46a9922). Diff vs f26d8a8 is refactor/test only (non-optional prepare_offload param model.rs:1119-1126; max_sequence_pages helper memory.rs:563-568; capture_chain_pages memory.rs:676-678 used at :1502 and :1568). Sizing behaviour identical → same plan, new SHA to build.
-
cn5 has 4x96 GiB, and the ONLY KV-bearing core there is GLM-5.3-Flash-NVFP4 (TP4) = exactly the PR's own configuration (16,384 MSP + 91 row_slots = 16,475 slots / 11.8 GiB vs ~99,099 slots / ~70.7 GiB on main). dinov2 entries are vision encoders, no KV. So TP4 on GPUs 0-3, single process → satisfies cluster().is_none() gate.
-
cn7 is ONE GB10, so the TP4 core cannot load there. Need a TP1 core (gemma-4-E4B-it, Qwen3.8-27B-NVFP4, Qwen3.8-Flash-Next-FP4-Local, MiniMaxAI/MiniMax-M3.1-Flash ...) confirmed with
flare inspect --jsontensor_parallel==1. Best place for the near-boundary publish/restore test because a small model on 60 GiB unified leaves a context small enough to prefill in minutes. -
Cores are listed at 0 GiB = not in the local cache.
flare runalso downloads a prepared core (cli.rs:44-46) andflare models downloadexists (cli.rs:128-129) → fetching is feasible, but needs network + publisher trust (docs/cli-design.md:747,970) and disk outside the 16 GiB scratch. -
Phase-2 lever FIXED: /proc/meminfo MemAvailable is host-wide, so systemd-run MemoryMax would NOT shrink the computed budget (host_pool_budget reads meminfo, selene/src/offload.rs:968-997) — it would only cause an OOM at slab touch. Correct lever = burn host RAM with a touched allocation to drive MemAvailable down. cn5 budget = MemAvailable − reserve, reserve = min(2GiB, total/32) + total/20 ≈ 8.25 GiB at 125 GiB. So main (needs ~72.6+8.25 ≈ 81 GiB) must fail while head (~11.8+8.25 ≈ 20 GiB) passes whenever MemAvailable sits between ~20 and ~80 GiB → target 40 GiB, a very wide window.
-
Metric-label fix: flare_host_cache_dropped_total tier labels are dram|nvme only (metrics.rs:835), not "pool". For a too-small capture slab watch flare_host_cache_store_reasons_total{reason="slabs"}, flare_host_cache_retry_abandoned_total{reason="slabs"}, and flare_host_cache_dropped_total{tier="dram",reason="oversize"}. Root copies to the pool: flare_host_cache_root_pages_total{tier="pool",reason="first"} (metrics.rs:822-833).
-
Plan diff = +Phase 1c: head started with NO prefix-cache flags, because memory.rs:1012 now computes max_sequence_pages unconditionally on every model load (cheap regression cover for the new startup work).
-
Honest scope cut: a 0.95x1M-token prompt on the GLM core costs hours of prefill, so the exact-MSP boundary is NOT covered on hardware; it is covered by unit tests (memory.rs:2456-2490) plus the fact that the cap is derived from the prepared ceiling while ModelConfig::fit_context only ever lowers the runtime ceiling (helios/src/model.rs:261-273) → the cap can never under-size. Hardware instead proves: pool stores/restores a multi-page chain with zero oversize/slabs drops and an identical answer.
#6 [medium] Final pre-report verification notes (5021b7a)
Final verifications at head 5021b7a (all read this turn):
flare inspect --jsondocument shape: keys arecore(path, ranks, cluster, publisher),model(max_sequence_tokens, max_active, prefill_chunk_size, max_active...),cache(page_tokens, pages, max_pages?, state_rows, snapshots, regions[].stride_bytes),ranks[](architecture [10,3], capacity_allocations[] with {name:"kv", capacity:"KV_PAGES", unit_bytes, maximum}). Fixture: flare-cli/src/inspect.rs:1530-1594; consumers :751-753, :801-826, :1030-1076. "deployments" exists only in another renderer (:257) and is absent from that JSON fixture -> parsemodel/cache/ranks, notdeployments.- TP indicator from JSON:
len(json["ranks"])(world) orcore.cluster. --max-concurrencyaccepted range is 1..=prepared max_active (helios/src/runtime_core/selection.rs:148-155) ->--max-concurrency 1is ALWAYS valid; earlier caveat about smallest accepted value is unnecessary.flare_total_kv_pageshelp text = "per-rank KV pool" (helios/src/server/metrics.rs:1469-1471), while the capture buffer uses the LARGEST rank page capacity (selene/src/offload.rs:700 local_pages = max over ranks) -> with a uniform core min/max agree; otherwise compare against the largest rank.- No throughput/speedup claim anywhere in the PR (docs/verification.md:15 asks for a live trace for a memory-cost claim) -> the measurable claim is host slab bytes + process RSS; Phase 1 is the A/B, and a throughput benchmark answers an unasked question.
- Numeric sanity: row_slots can be derived as slots_main - kv_pages from the main run; then slots_head should equal min(kv_pages, MSP) + row_slots, and GiB = slots*page_record_bytes. PR's published figures (16,475 slots / 11.8 GiB vs ~99k slots / 70.7 GiB on GLM-5.3-Flash TP4) should be reproduced to within rounding on that rig; exact agreement depends on row_slots/page_record_bytes, so the formula is authoritative.