Pre test report report · NVIDIA/hyperflare-inference #742

Raw Markdown for agents: https://autobot.eidonix.com/p/be658c43-1639-488e-94d4-44c7bb2bf578.md

Hardware test plan — PR #742 selene,helios: bound pool-only capture buffer to max_sequence_pages

Head to test: 5021b7a3 (one squashed commit on main f46a9922, 9 files, +105/−21). The head moved f26d8a8 → 5021b7a since my last plan; the delta is refactor + tests only — private prepare_offload now takes NonZeroU64 (helios/src/runtime_core/model.rs:1119-1126, called :1047-1053), one guarded helper max_sequence_pages(context, page_tokens) (memory.rs:563-568, called :1006-1012), and one shared capture_chain_pages() used by capture_growth (:1502) and planned_offload_host (:1568). The sizing behaviour to validate is unchanged, so the plan is the same and only the SHA you build changes.

Recommendation: ~60–75 min wall clock, of which ~30 min GPU on cn5 and ~10 min on cn7. Run 4 short phases on cn5 and 1 smoke on cn7 — and nothing else. The change is a startup-only sizing clamp; only three things deserve GPU time: (a) the capture slab really shrinks vs main, (b) GPU KV pages are not throttled and startup succeeds where main failed, (c) a long chain still publishes to the pool and restores with an identical answer.

Note there is no speedup claim to measure: the PR claims a host-memory reduction (18.74–19.06 GiB → 7.83–8.04 GiB RSS via an 11.8 GiB capture buffer instead of ~70.7 GiB), measured on a v0.6.0 build carrying the patch, not A/B on head. Throughput/latency benchmarking would answer a question nobody asked.


1. What the change does, and therefore what is measurable

In single-process pool-only mode Selene registers a CPU-readable capture buffer to export checkpoints to a selene-manager pool. Before this PR it was sized to the whole GPU page capacity; after it:

Site Expression at head
selene/src/offload.rs:164-181 (headroom_inner) chain_pages = max_sequence_pages.map_or(pages, |l| pages.min(l.get())); chain = chain_pages + layout.row_slots(); ERR "host budget cannot hold a full pool capture" when chain > budget; slots = chain.max(intake_slots(layout, max_active)).min(budget)
selene/src/offload.rs:227-229 intake_slots = 2·max_active·row_slots + 128 — deliberately uncapped
helios/src/runtime_core/memory.rs:563-568, 1006-1012 MSP = ceil(max_sequence_tokens / contract.cache.page_tokens), guarded against zero page size / zero context
memory.rs:1146-1148 Some(MSP) into the pre-registration headroom_with_inputs_for_budget (with minimum_pages)
memory.rs:1502, 1568 capture_chain_pages(pages, MSP) in the capacities() growth callback and in planned_offload_host
memory.rs:1604-1608 → model.rs:1047-1053, 1169-1173 PlannedHostBudgets::max_sequence_pages → prepare_offload → PrepareInputs, so planning and attach cannot disagree

Three preconditions, or the test measures nothing:

  1. Single process — capture needs pool_only() (offload.rs:117-119: pool set, --prefix-cache-memory 0, no --prefix-cache-disk) and cluster().is_none() (memory.rs:1014). Any --rank, --hosts, --rendezvous disables it. TP4 within one process is fine.
  2. Default --kv-cache-limit memory (flare-cli/src/cli.rs:926-939). Under context/concurrency, page_ceiling already caps pages at ≈MSP (memory.rs:576-607), so the new min() is provably inert there.
  3. kv_pages ≫ MSP, else the clamp cannot bind. Prefer a small-context TP1 core on one Blackwell card (biggest ratio, cheapest prompt) over the PR's own 1M-context rig.

2. Pre-flight (no GPU, ~10–15 min)

2a. Secure a core — the real blocker. Every model on both hosts is listed at 0 GiB (not cached). flare run also downloads a prepared core (flare-cli/src/cli.rs:44-46; flare models download, :128-129), so acquisition is possible without exporting from a checkpoint — but it needs network, publisher trust (--dangerously-accept-publisher + key approval, docs/cli-design.md:747,970; see FLARE_TEST_PUBLISHER_KEYS, tests/server/test_prefix_cache_offload.py:82-83), and disk outside the 16 GiB scratch.

flare models list                       # what is actually local, with sizes
df -h ~ /var/tmp; df -h /dev/shm        # core, cargo target, manager regions

Pick the rig from the core's own metadata. The JSON document has model, cache, and ranks[] (flare-cli/src/inspect.rs:1530-1594; consumers :751-753, 801-826, 1030-1076) — it has no top-level deployments for the JSON form, so parse model/cache/ranks:

flare inspect <CORE|MODEL> --json > core.json (not opened)
python3 - <<'PY'
import json; j=json.load(open('core.json (not opened)'))
m=j['model']; c=j['cache']; r=j['ranks']
kv=[a for a in r[0]['capacity_allocations'] if a['name']=='kv']
ctx=m['max_sequence_tokens']; pt=c['page_tokens']
print('world',len(r),'ctx',ctx,'page_tokens',pt,'MSP',-(-ctx//pt),
      'max_active',m['max_active'],'kv_pages_max',kv[0]['maximum'] if kv else None,
      'unit_bytes',kv[0]['unit_bytes'] if kv else None)
PY

Choice, in priority order:

  1. cn5, 1 rank, smallest max_sequence_tokens — a 27B-class TP1 core on one 96 GiB card leaves ~60 GiB of KV: with a 128K context at 64 tokens/page, MSP = 2,048 against tens of thousands of pages → 10–25× gap, one GPU, and a prompt short enough to prefill in a minute.
  2. Fallback on cn5: GLM-5.3-Flash-NVFP4, TP4 (--gpus 0,1,2,3) — this is the PR's own measured configuration (MSP = 16,384, ~6× gap). Usable for Phases 1–2; its context is too long for Phase 3's near-cap probe.
  3. cn7 (GB10, arm64, 60 GiB unified) cannot load a TP4 core — use a 1-rank GB10 core (google/gemma-4-E4B-it, nvidia/Qwen3.8-27B-NVFP4, nvidia/Qwen3.8-Flash-Next-FP4-Local, …). Its small context is what makes Phase 3 affordable.

If no obtainable core has MSP < kv_pages, stop — the clamp is inert and there is nothing to test.

2b. Build once, reuse everywhere (16 GiB scratch is too small for target/):

git fetch origin && git checkout 5021b7a3
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-head
git checkout f46a9922                       # main = the A/B control
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-main
cargo build --locked --release --manifest-path selene-manager/Cargo.toml
cp selene-manager/target/release/selene /workspace/selene

Optional CPU-only sanity before GPU time (CI already reports 3,659 passing, 96 ignored): cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server pool_capture_growth_caps and … --manifest-path selene/Cargo.toml (not opened) --features test-support pool_only_sizes_registered_capture.


3. Manager (shared by every run — start it first)

mkdir -p /run/selene
/workspace/selene --socket /run/selene/pool.sock --memory 24G --staging 16G \
  --metrics 127.0.0.1:9108 &

Sizing rules that will otherwise look like PR bugs (selene-manager/docs/operating.md:56-118):


4. Phase 1 — the claimed win, A/B on ONE GPU (cn5, ~5 min GPU)

Same command, same core, same GPU, two binaries, narrow concurrency so the chain term dominates the uncapped intake floor:

run() { # $1=label $2=port
  /workspace/flare-$1 run <CORE> --gpus 0 --host 127.0.0.1 --port $2 \
      --prefix-cache-pool unix:/run/selene/pool.sock --prefix-cache-memory 0 \
      --mtp-draft-tokens 0 --max-concurrency 1 --kv-cache-limit memory \
      > /workspace/$1.log 2>&1 &
  pid=$!
  until curl -sf http://127.0.0.1:$2/health >/dev/null; do sleep 0.2; done
  curl -s http://127.0.0.1:$2/metrics > /workspace/$1.metrics
  grep -E 'VmHWM|VmRSS|VmPeak' /proc/$pid/status > /workspace/$1.rss
  kill -TERM $pid; wait $pid
}
run main 8031
run head 8032

--max-concurrency 1 is always legal (accepted range is 1..=prepared max_active, helios/src/runtime_core/selection.rs:148-155).

Collect:

Observable Source
pool only: capture buffer X GiB (N slots, populate …, register …) selene/src/offload.rs:433-461, phase Prepare host prefix cache
Plan cache … · <pages> KV pages … memory.rs:1533-1577
flare_host_cache_slots_total, …_intake_slots, …_slots_in_use helios/src/server/metrics.rs:1384-1397
flare_total_kv_pages (per-rank), flare_kv_page_tokens metrics.rs:1469-1477
per-process host high-water mark /proc/<pid>/status VmHWM (docker stats / cgroup memory.peak in a container)

Pass criteria (all must hold):

Check Expected
Capture path engaged both logs contain pool only: capture buffer; flare_host_cache_intake_slots == 0 on both
Head slot count slots_head == min(kv_pages, MSP) + row_slots, with row_slots = slots_main − kv_pages derived from the main run (do not guess it)
Head < main slots_head < slots_main, and slots_main / slots_head ≈ kv_pages / MSP
Bytes page_record_bytes = bytes_main / slots_main; bytes_head ≈ slots_head × page_record_bytes matches the logged GiB
RSS VmHWM_main − VmHWM_head ≈ (slots_main − slots_head) × page_record_bytes (±1 GiB — the slab is prefaulted and CUDA-registered eagerly: eos/src/unix.rs:750-779, selene/src/offload.rs:744-753)
No KV throttling flare_total_kv_pages (head) ≥ (main); equality expected when the host budget was not binding

Caveat while reading that gauge: the metric is documented as per-rank (metrics.rs:1469-1471) while the buffer uses the largest rank page capacity (offload.rs:700). They agree on a uniform core; on a non-uniform one, compare against the largest rank's number from the log line.

Phase 1b — the documented caveat, one extra run (~1 min). Repeat flare-head with the core's default (wide) --max-concurrency. Expected: slots rise toward the uncapped intake floor 2·max_active·row_slots + 128, i.e. the win shrinks. Record it; do not fail on it — this is the intentional, disclosed limitation and it is the number that tells the maintainer how much of the win survives a wide deployment.

Phase 1c — start with NO prefix-cache flags (~1 min). memory.rs:1012 now computes max_sequence_pages unconditionally in allocate_caches, even with offload disabled. Start flare-head with no --prefix-cache-*; confirm /health and that no flare_host_cache_* series appear. This is the only new work on the always-on path.


5. Phase 2 — the reproduction the PR exists for: starved host RAM (cn5, ~5 min GPU)

The budget is host-wide MemAvailable, not a cgroup: host_pool_budget() reads /proc/meminfo and subtracts future plus an implicit reserve of min(2 GiB, total/32) + 5 % of total (selene/src/offload.rs:932-997). At 125 GiB that reserve is ≈8.25 GiB.

⚠️ Do not use systemd-run -p MemoryMax=…: a cgroup does not reduce MemAvailable, so the instance computes the same large budget and is merely OOM-killed when the slab is touched — a different failure than the one this PR fixes. Starve the host instead:

# burn host RAM with touched pages until MemAvailable ≈ 40 GiB
python3 -c "b=bytearray(78<<30); b[::4096]=b'\\x01'*len(b[::4096]); import time; time.sleep(900)" &
grep MemAvailable /proc/meminfo

Then run main and head with identical core/GPU/flags:

Pass criteria: main fails with that exact message (record it if you instead get an OOM or an unexplained panic — that is a different finding); head reaches /health with flare_total_kv_pages equal to its Phase 1 value. If main also succeeds, the win is real but small on this core/GPU — say so rather than forcing a failure. Kill the hog before Phase 3.


6. Phase 3 — the risk this PR introduces: a long chain still publishes and restores (~10 min GPU, highest value)

The cap is only safe if nothing storable exceeds one sequence chain. Unit tests prove the arithmetic; only hardware proves record → pool → restore. On flare-head, pool-only:

  1. Send one prompt that builds a long chain for this core — ~0.95 × max_sequence_tokens on a small TP1 core; the largest affordable prefill on GLM. Put the answer in the middle: "…Item 211 records code 596… What code does item 211 record?" and require the exact number (generator: tests/server/test_prefix_cache_offload.py:111-114).
  2. Drain: poll until flare_host_cache_outbound_in_flight == 0 and …_inbound_in_flight == 0 (metrics.rs:1364,1374).
  3. Evict that checkpoint from GPU (send ceil(flare_snapshot_capacity / 2) + 8 distinct short requests — metrics.rs:1334; pattern in tests/server/test_minimax_m3_cache.py:126-137), then resend the identical prompt.

Pass criteria:

Metric Expectation
flare_host_cache_stored_total > 0 after step 1 — the chain fit the slab
flare_host_cache_store_reasons_total{reason="slabs"} 0 — non-zero means the slab is too small for one chain
flare_host_cache_retry_abandoned_total{reason="slabs"} 0 — non-zero means publications are refused for slot space
flare_host_cache_dropped_total{tier="dram",reason="oversize"} 0 (tier labels are only dram/nvme, metrics.rs:835 — there is no pool tier here)
flare_host_cache_root_pages_total{tier="pool",reason="first"} grows by ≈ the chain's page count (metrics.rs:822-833) — proves a real multi-page root
flare_host_cache_hits_total, …_reused_tokens_total, …_fetched_total increase after step 3; usage.prompt_tokens_details.cached_tokens > 0; answer identical to the cold run
flare_host_cache_fetch_failed_total, …_store_failed_total 0

This is the only check that exercises PlannedHostBudgets::max_sequence_pages reaching prepare_offload on real geometry, and the one that would catch an under-sized slab (whose failure mode is silent slabs deferral with the GPU checkpoint pinned, not a startup error).


7. Phase 4 — cn7 GB10 smoke (arm64, unified memory, 1 GPU, ~10 min, no A/B)

cn7 exercises the other branches: integrated > 0 (memory.rs:1140-1146) and integrated host budgeting instead of host_pool_budget. One flare-head run on a 1-rank core:

GB10 is unified memory and this PR does not change device unified-memory accounting — a failure here that also fails on main is pre-existing. Skip cn7 entirely if Phase 1 shows MSP ≥ kv_pages: the clamp is inert on both hosts.


8. Failure vs expected

Do not merge on this evidence if: head slots ≠ min(kv_pages, MSP) + row_slots; head slots ≥ main's; logged GiB ≠ slots × page_record_bytes; flare_total_kv_pages lower on head than on main (the clamps may only relax throttling); any slabs store deferral/abandon or oversize drop on a long chain; a restore that answers differently from the cold run; a head startup failure that main does not also produce with identical flags and the same MemAvailable.

Expected, not failures: the uncapped intake floor dominating the buffer at wide concurrency; startup succeeding where main failed; a core/GPU pair where MSP ≥ kv_pages and nothing changes.


9. Do not spend GPU time on


10. Honest limits