Repository navigation
Coalesce shared ancestor reads across concurrent Selene disk fetches - #496
Conversation
|
A case file has been opened for 496. The case file is kept up to date with all findings, and should be read by agents working on this code base. To opt out, include #autobot:ignore in the PR or any comment. |
Autobot ReviewFull Review for Agents. Recommendation: Changes RequestedThe approach belongs in the repo — a measured, served-workload win with no new flags, no format change, failure isolation preserved, and the shared-window lifetime work holds up. One result in the PR's own evidence must be settled first; the rest is metering, docs and duplication. Blockers:
Should fix:
Nits:4 nits — Full evidence, per-angle detail and the list of what was checked and found sound are in the case file. To opt out, include #autobot:ignore in your post or comment. |
f9c9191 to
0c04b1e
Compare
|
Updated this branch to
Ready for another look at |
|
A case file has been opened for 496. To opt out, include #autobot:ignore in the PR or any comment. |
Autobot ReviewFull Review for Agents. Recommendation: Changes RequestedNon-blocking: no blocker remains, but five should-fix items (one layering, one maintainability, one arithmetic, one docs, one process sign-off) are worth landing before or with the merge. Blockers:None. Should fix:
Nits:5 nits Full report, with citations, severity rationale, what was resolved since the last head To opt out, include #autobot:ignore in your post or comment. |
Autobot ReviewFull Review for Agents. Autobot ReviewFull Review for Agents. Recommendation: Ready To MergeNo new commits since the last review — Blockers:
Should fix:
Nits:10 nits — Full report — per-finding requests, resolutions since the last head, the verified-sound list and open questions — is in the case file. No toolchain, GPU or test run was available: every finding is established from source at To opt out, include #autobot:ignore in your post or comment. |
Why When concurrent requests restore distinct branch checkpoints sharing a disk-resident ancestor prefix, Helios deduplicates inbound restore tickets by endpoint key, so each branch submits its own GPU restore (`Staged::fetch`) in `selene/src/disk_store.rs`. Before this change, each restore opened every ancestor record file independently and staged private 64-page windows, repeating `O_DIRECT` opens, reads, and checksum verification once per branch. Published record files are immutable and stay pinned in `DiskStore` across every referencing restore. Coalescing belongs in `Staged` rather than `DiskThread` because `DiskThread` sees only file offsets and raw buffers and finishes once direct I/O completes, whereas shared `SlabPool` staging slots and v4 `ReadPacked` payload buffers must remain pinned until every attached follower's asynchronous `Copier` decode or GPU upload completes. What - Separate private host and shared GPU read paths (`selene/src/disk_store.rs`): caller-owned host reads (`Staged::read_into` using `plan_windows(..., false)`, and `Staged::read_into_packed` storing `(Header, Arc<Vec<u8>>)` in `completed_packed_reads` for `CompositeStore`) remain on a private `HostInbound` path. GPU restores (`Staged::fetch`, `plan_windows(..., true)`) slice on 64-page (`WINDOW_PAGES`) file boundaries and share one open file handle per `SegmentKey` (`Arc<Path>`, `HeaderIdentity(Arc<Header>)`) and one `SharedWindow` per `WindowKey` (`O(1)` `window_index` lookup) across both raw v1-v3 `SlabPool` staging windows and v4 `packed` `ReadPacked` windows (which allocate zero `SlabPool` slots and retain `Arc<Vec<u8>>` until all followers' `Copier` decode and upload jobs finish). - Exhaustive `Header` and `packed::Layout` hashing (`selene/src/shared/packed.rs`, `selene/src/shared/record.rs`, `selene/src/disk_store.rs`): implement `Eq` and `Hash` on `packed::Layout` with exhaustive destructures over `Layout`, `PackedOffer`, and `PackedUnit`; derive `Hash` on `RankSizes`; implement `Hash` on `Header` beside `PartialEq` (omitting only encoding `version`); and delegate `HeaderIdentity::hash` to `Header::hash` while retaining the `Arc::ptr_eq` fast path on `PartialEq`. - Reference-counted windows and demand indexing (`selene/src/disk_store.rs`): active restores attach via `has_window_credit` / `attach_pending` within their two-window (`WINDOWS_IN_FLIGHT`) credit before finished windows release; `pick_next_pending_plan` sizes raw windows with `Layout::record_slots` and requires zero slots for v4 `packed` segments; `build_pending_demand` short-circuits when at most one restore is active; and the last segment user waits for disk close (`disk_settled`) before emitting `Fetched`. - Out-of-band physical `inbound_rate` and logical `bytes_in` (`selene/src/disk_store.rs`, `selene/src/shard.rs`): record one `(bytes, elapsed)` sample per completed shared window read in `Staged::inbound_samples`, drain it out of band via `DiskTransport::drain_inbound_samples` (forwarded on rank 0 in `Sharded`, discarded on peers in `Peer::forward`), and observe it in `DiskStore` without adding a variant to `TransportEvent` or incrementing `StoreStats.progress`. `CompositeStore` continues to update its end-to-end `disk_inbound_rate` from `read_into` and `read_into_packed` completions. - Failure isolation and docs (`docs/prefix-cache-offload.md`): private child or transient follower GPU upload errors fail only that restore; shared open, read, or packed-payload content errors (`is_packed_content_error`, converted via `with_record_read()`) fail all attached restores after in-flight I/O drains so `DiskStore::apply` drops the corrupt endpoint's lookup row. `Staged::close` reports abandoned transport jobs separately from leaked shared staging entries. Diagnostic counters are gated under `test-support`, and `docs/prefix-cache-offload.md` (sections 2.4 and 4) documents raw and v4 packed coalescing and rate accounting. No core re-export, record format, or `TransportEvent` variant change is required. Result Overlapping GPU restores open a shared ancestor file once and read each aligned 64-page raw or v4 packed window once while staged (windows already released before a later restore attaches are read again). As an expected bound, single-restore callers skip demand indexing (`device_inbound.len() <= 1`) and pay at most one extra partial window per segment when `skip_pages % 64 != 0`. Live `flare run` A/B on NVIDIA GB10 (SM121) comparing pre-`NVIDIA#504` `main` (`c0c4f798`) against `0c04b1e2` with `--lossless-kv-compression` off (identical raw physical windowing, I/O, and upload schedule to this rebased commit when compression is `off`) and `--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk` (`--max-concurrency 16 --prefix-cache-disk-limit 40G` on `Qwen3.8-27B-NVFP4`; `--max-concurrency 8 --prefix-cache-disk-limit 24G` on `Qwen3.8-Flash-Next`). Each trial warms one ~61K-token shared prefix plus 8 child branches (~256 unique tail tokens each) to disk, restarts `flare run` so GPU memory starts empty, and sends 8 concurrent `/v1/chat/completions` follow-ups (ingress-to-first-token TTFT; read-reduction ratios are ratios of tabulated means): - `Qwen3.8-27B-NVFP4` (TP1, `60.5K`, 2 interleaved repeats): physical NVMe reads drop `18,177.5 -> 4,306.7 MB` (`2,274 MB` single restore — `472` pages at `128` tokens/page plus `101 MB` continuation row, so `18,177.5 MB` is `8x` full copies; `4.22x`, `-76.3%`), median TTFT `7,974.6 -> 5,662.8 ms` (`-29.0%`) simultaneous; and `18,194.2 -> 4,843.6 MB` (`3.76x`, `-73.4%`), TTFT `6,883.6 -> 5,951.9 ms` (`-13.5%`) at `+25 ms` stagger. `inbound_rate` stays physical (`6.07 GB/s` single vs `6.02-7.71 GB/s` 8-way). - `Qwen3.8-Flash-Next` (TP1, `61.0K`): NVMe reads drop `7,944.9 -> 1,981.1 MB` (`4.01x`, `-75.1%`, TTFT `3,327.5 -> 3,225.0 ms`) simultaneous, and `7,958.0 -> 2,251.5 MB` (`3.53x`, `-71.7%`, TTFT `3,137.7 -> 3,049.9 ms`) at `+25 ms` stagger (`inbound_rate` `7.17-9.01 GB/s` single). Recommended merge order with companion PR `NVIDIA#497`: merge `NVIDIA#497` first, then rebase `NVIDIA#496` onto `main` so `Staged::pump_all` retains `MAINTENANCE_DEFER_LIMIT = 8` and runs `host_inbound` and `pump_device_inbound` ahead of `outbound` and `maintenance`. Evidence - Verified at this commit over `main` (`6d74db3a`): on x86_64 Linux WSL (`O_DIRECT` + `io_uring`, `rustc 1.100.0`), `cargo check --locked --release --manifest-path selene/Cargo.toml --all-targets` (`0` warnings with and without `test-support`), `cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support` (`513 passed, 0 failed` unit + `1 passed` in `mixed_codec_root`, covering 4-way v4 `packed` ancestor coalescing and corrupt-packet `record_read` propagation in `concurrent_packed_fetches_coalesce_opens_and_read_packed_windows`, `packed::Layout` and `Header` hash-equality agreement in `header_eq_implies_same_hash`, out-of-band `drain_inbound_samples` / `progress` preservation, misaligned follower partial-tail+row parity, private vs shared failure isolation, and `Staged::close` draining), `cargo check --locked --manifest-path helios/Cargo.toml --features runtime-core,server --all-targets`, and `pytest tests/preparation/test_core_boundary.py tests/test_design_review_hook.py` (`22 passed, 0 failed`). On Windows IOCP (`stable-x86_64-pc-windows-msvc`), `12` coalescing, window-planning, and header-hashing tests plus `mixed_codec_root` passed. - Verified at pre-rebase commit `0c04b1e2` against `main` (`c0c4f798`, raw v3 records / `--lossless-kv-compression` off): `selene --features test-support` passed `476` tests on ARM64 Linux (DGX Spark GB10); `helios` `offload::` (`FLARE_RUN_CUDA_TESTS=1 --include-ignored`) passed all `21` single-GPU SM121 tests (`split_pools` requires 2 local GPUs); live SM121 parity across 5 cold-VRAM restart repeats (`seed = 1234..1238`, `60,534` tokens, `top_logprobs = 5`) on `Qwen3.8-27B-NVFP4` TP1 produced identical FP32 `top-5 logprobs` and token IDs vs `main` (`c0c4f798`) on all 5 repeats (`6/9, 8/9, 7/9, 9/9, 4/9`, matching in-VRAM GPU step-0 `top-5 logprobs`; cross-seed variation reflects positive-temperature sampling, as `helios` clamps request `temperature` into the core's positive sampling range and Flare does not support greedy `temperature = 0`); and 4 concurrent decode streams spilling checkpoints over 30 s on `Qwen3.8-Flash-Next` TP1 had `0` errors (`100.0 -> 100.6 tok/s`). - Not covered: live SM121 `--lossless-kv-compression` (`cpu`/`gpu`) serving (v4 `packed` window coalescing is covered by `selene` unit tests), rerunning the raw SM121 `flare run` A/B after rebasing onto `6d74db3a`, multi-host RoCE serving, 2-GPU `split_pools`, discrete PCIe GPUs, Windows serving, and live warm-plus-disk (`--prefix-cache-memory > 0`) or `PooledStore` HTTP serving (`CompositeStore` + `DiskStore` CUDA transfers are covered in `helios` `offload::`). Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4 Carbon); design-review=eb2f Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
0c04b1e to
cb3db46
Compare
…head Why Disk-only prefix-cache offload (`--prefix-cache-memory 0` with `--prefix-cache-disk`, default `--lossless-kv-compression off`) incurred five host and coordination costs: (1) opening a raw v1-v3 record file (`selene/src/disk.rs`) issued two sequential `O_DIRECT` reads (4 KiB header, then page checksums); (2) `xxh3` page hashing ran serially on the single disk thread across up to 64 pages (`268 MB` at `4.19 MB`/page); (3) `Staged::pump_all` (`selene/src/disk_store.rs`) submitted unlinks/truncates and outbound writes ahead of interactive restores; (4) while waiting on an inbound restore with an idle GPU, Helios's worker (`helios/src/server/runtime.rs`) slept up to `2 ms` and multi-host disk peers (`selene/src/shard.rs`) slept `1 ms` instead of waking on socket readability; and (5) on integrated-memory GPUs (`CU_DEVICE_ATTRIBUTE_INTEGRATED`), disk-only offload scaled registered host intake with concurrency (`2 * max_active * row_slots + 128`, up to `8.2 GiB` needed on `Qwen3.8-27B-NVFP4` at `--max-concurrency 16`), carving GPU KV cache out of shared RAM even though paged disk streaming stages at most two windows (`2 * (64 + row_slots)` slots). What - Single-read raw open (`selene/src/disk.rs`): preserve `NVIDIA#504`'s v4 packed `Header::read_metadata` open branch, and on raw v1-v3 `O_DIRECT` opens read the 4 KiB header and expected checksum segment in one transfer when `expected.tail_pages <= MAX_TAIL_PAGES` (`CHECKSUM_SCRATCH_BYTES = 1 MiB`), falling back to a 4 KiB header-only read on failure while preserving retry I/O errors, truncated-file checks, and shared scratch span helpers. - Scoped parallel page hashing (`selene/src/disk.rs`): cache `parallel_cpus` once at `Worker::new` and hash raw batches of >= `HASH_PARALLEL_MIN_PAGES` (`4`) pages across `parallel_cpus.min(MAX_HASH_THREADS).min(buffers.len())` `std::thread::scope` threads (`MAX_HASH_THREADS = 4`) when `parallel_cpus >= HASH_PARALLEL_MIN_CPUS` (`4`), with `0` idle helper threads, Linux `SCHED_BATCH` inheritance via `clone`, inline recomputation on helper spawn or unwind failure, and fault hooks folded into `Faults` under `cfg(any(test, feature = "test-support"))` (zero test-only parameters on shipped signatures). - Bounded restore-first submission and wakeup (`disk_store.rs`, `helios/src/server/runtime.rs`, `shard.rs`): order `Staged::pump_all` as inbound restores, then outbound writes, then maintenance while submitting one reserved maintenance job ahead of inbound and outbound after `MAINTENANCE_DEFER_LIMIT` (`8`) consecutive passes where queued maintenance lost free disk-queue space; poll `Worker::idle_wait` at `50 us` during active/waiting inbound restores; and wake Unix disk peers via `libc::poll` (`POLLIN`). - Bounded integrated disk-only intake (`selene/src/offload.rs`, `helios/src/offload/mod.rs`, `helios/src/runtime_core/{memory,model}.rs`, `docs/prefix-cache-offload.md`): pass explicit `PrepareInputs` (no `Default` or unused `prepare`/`core` wrappers), unify `disk_enabled()`, `headroom_inner`, private `target_intake_slots`, and parameterless `Prepared::intake_warning()` (`required_intake` + `sized_concurrency`), and target `intake_slots(layout, 1)` (`2 * (64 + row_slots)`) on integrated disk-only hosts without shrink warnings while preserving `NVIDIA#504` lossless KV compression. No core re-export or record-format change is required. Result Live `flare run` A/B on NVIDIA GB10 (SM121) measured `NVIDIA#497` standalone (`cd5a366b`) against pre-`NVIDIA#504` `main` (`c0c4f798`) with `--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk` and default `--lossless-kv-compression off` (the raw v3 `.ckpt` path, whose runtime execution is unchanged by rebasing onto `6d74db3a` and removing test-only signature plumbing; ingress-to-first-token TTFT; bandwidth is rank-0 `flare_host_cache_inbound_bytes_per_second`): - `Qwen3.8-27B-NVFP4` (TP1, `--max-concurrency 16 --prefix-cache-disk-limit 40G`, 3 interleaved repeats): intake drops `7.3 GiB` (`1,877` slots, shrink warning) -> `1.0 GiB` (`252` slots, `0` warnings), raising GPU KV cache `64.4 -> 71.6 GiB` (`+7.2 GiB` / `+235.5K` tokens); median single-restore bandwidth and TTFT improve `7.05 -> 8.02 GB/s` (`348.0 -> 301.7 ms`, `-13.3%`; wall `353.5 -> 306.5 ms`) at `30.0K` and `6.28 -> 8.68 GB/s` (`+38.2%`, `551.8 -> 447.6 ms`, `-18.9%`; wall `561.7 -> 455.4 ms`) at `61.1K`; `NVIDIA#497` standalone 8-way `61.1K` cold-restart burst mean median TTFT drops `8,156.1 -> 6,963.4 ms` (`-14.6%`, 2 interleaved repeats; the `NVIDIA#496 + NVIDIA#497` combination is unmeasured). - Isolated `std::thread::scope` `xxh3` (`cd5a366b` with `MAX_HASH_THREADS = 1` at `selene/src/disk.rs:157` and no other change vs unmodified `cd5a366b` with `MAX_HASH_THREADS = 4`, 3 interleaved repeats on `Qwen3.8-27B-NVFP4`): parallel hashing alone improves median TTFT `486.8 -> 447.6 ms` (`-8.1%`, `7.73 -> 8.68 GB/s`, `+12.3%`, faster on all 3 repeats: `[447.6, 432.7, 451.2]` vs `[479.9, 557.5, 486.8] ms`) at `61.1K` and `322.4 -> 301.7 ms` (`7.55 -> 8.02 GB/s`) at `30.0K`. `HASH_PARALLEL_MIN_PAGES = 4` and `HASH_PARALLEL_MIN_CPUS = 4` assign at least one page per thread at the 4-thread cap and leave cores for serving threads on narrow hosts (not swept separately). - `Qwen3.8-Flash-Next` (TP1, `--max-concurrency 8 --prefix-cache-disk-limit 24G`, `cd5a366b` vs `c0c4f798`): intake drops `1.9 -> 0.3 GiB` (`2,288 -> 398` slots), raising GPU KV cache `23.28 -> 24.98 GiB` (`+1.70 GiB` / `+127.0K` tokens); bandwidth improves `5.67 -> 7.05 GB/s` (`372.1 -> 355.6 ms`) at `30.0K` and `6.65 -> 8.35 GB/s` (`+25.6%`, `458.0 -> 413.8 ms`, `-9.7%`) at `61.0K`; `NVIDIA#497` standalone 8-way burst median TTFT drops `3,327.5 -> 3,078.5 ms` (`-7.5%`). What it costs: up to three short-lived scoped `xxh3` helpers during >=4-page raw batches (`0` idle helpers), `50 us` `Worker::idle_wait` polling during active/waiting inbound restores (`969.9 -> 1,069.2 ms/s` `/proc/<pid>/stat` server CPU across 8-way `Qwen3.8-27B-NVFP4` bursts: `+99.3 ms/s` / ~`0.10` of 20 Grace cores combined; the `50 us` poll's CPU share and latency contribution are unisolated from scoped `xxh3` helpers), two-window serialization for concurrent unique-prefix restores and outbound stores on integrated disk-only hosts, and up to `8` passes of maintenance deferral. Companion PR (NVIDIA#496): merge `NVIDIA#497` first, then rebase `NVIDIA#496` onto `main` so `Staged::pump_all` retains `MAINTENANCE_DEFER_LIMIT = 8` (submitting one reserved maintenance job first after `8` deferred passes) and runs `host_inbound` + `pump_device_inbound` ahead of `outbound` and `maintenance`. Evidence - Rebased crate and Python checks over `origin/main` (`6d74db3a`): `selene --features test-support` (`510` lib + `1` integration passed, `0` warnings), `selene-manager --test client --test offload` (`85 + 2` passed), `helios --features runtime-core,server` (`0` warnings; `phase_tests::idle_wait` and `offload::pool::tests` passed), `6` targeted Windows IOCP `selene` tests, and `pytest tests/preparation/test_core_boundary.py`. - Prior SM121 GPU unit and live checks (at `cd5a366b`, `--lossless-kv-compression off`): `helios` `offload::` (`FLARE_RUN_CUDA_TESTS=1 --include-ignored`, `21` single-GPU SM121 tests passed; `split_pools` requires 2 local GPUs); corrupting a multi-page `.ckpt` payload on `Qwen3.8-27B-NVFP4` incremented `fetch_failed_total` (`1`), launched `0` `restore` graphs, and recomputed identical `top-5 logprobs` and tokens; under `--prefix-cache-disk-limit 6G` (`4` concurrent restores + `3` fresh `30K` stores), disk bytes peaked at `6.38 GB` (`<= 6 GiB`) and settled at `6.37 GB` with `0` `retry_abandoned` and `0` `io_error` drops (`2` normal `end_of_chain` evictions); four concurrent decode streams spilling checkpoints over 30 s on `Qwen3.8-Flash-Next` had `0` errors (`100.0 -> 95.9 tok/s`). - Not covered: live `--lossless-kv-compression` (`cpu`/`gpu`) serving, post-rebase SM121 `flare run` re-measurement, isolated `50 us` `Worker::idle_wait` A/B, `NVIDIA#496 + NVIDIA#497` combined serving, multi-host RoCE serving, 2-GPU `split_pools`, discrete PCIe GPUs, Windows serving, and live warm-plus-disk (`--prefix-cache-memory > 0`) or `PooledStore` HTTP serving (`CompositeStore` + `DiskStore` CUDA transfers are covered in `helios` `offload::`). Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4 Carbon); design-review=eb2f Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
|
Rebased onto
Verification at
Ready for another look at |
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeAll prior blocker and should-fix items are resolved in code at
Have your agent review the Full Review for complete findings, To opt out, include |
yatesdr
left a comment
There was a problem hiding this comment.
Thanks for the thorough work here and for porting the coalescing path cleanly onto post-#504 v4 packed records.
Design sign-off: Placing the shared-segment / shared-window coalescing lifecycle in Staged (rather than DiskThread) is the right boundary and I'm signing off on that choice — SlabPool staging slots and v4 packed_buf: Arc<Vec<u8>> must remain pinned across every follower's async Copier decode/upload, failure isolation preserves #343's is_record_read() semantics, and waiting for disk_settled() on the last segment user preserves DiskStore's index-pin invariant.
Before merging, there are a few unintended consequences that need to be addressed:
1. Worker-thread CPU stall from per-poll eager build_pending_demand and uncached packed::Layout hashing (blocker)
In selene/src/disk_store.rs, HeaderIdentity::hash (:1442) delegates directly to Header::hash (selene/src/shared/record.rs:165-202), which hashes the full packed::Layout (selene/src/shared/packed.rs:94-134 — every PackedUnit in offer.units, offsets, and pages). Three hot paths in pump_device_inbound() hash WindowKey repeatedly:
- Eager demand-map rebuild on every
poll()(disk_store.rs:2460-2468):if self.resources.free_slots() > 0 || any_packedbuildsdemandeven when zero active fetches have window credit (active.len() == WINDOWS_IN_FLIGHT), which is almost every poll tick (especially paired with#497's 50 µsidle_wait). Line2479already lazily callsdemand.get_or_insert_with(|| self.build_pending_demand())insidewhile self.has_window_credit(id). - Full
packed::Layoutre-hashing per lookup: On a large v4 packed ancestor (e.g., 1,024 pages × TP8 = 8,192PackedUnits, >600 KB of heap data), each lookup inbuild_pending_demand,find_best_existing_window_for, andpick_next_pending_planre-hashes the entire layout on the main Helios worker thread (and on every peer'sPeer::runloop).
Requested fix:
- Cache a precomputed deterministic
u64hash once inHeaderIdentity::new(Arc<Header>)(e.g., viaDefaultHasher::new(), which uses fixed keys soa == b => hash(a) == hash(b)) and hash only that cachedu64inHeaderIdentity::hash. - Remove the eager
build_pending_demand()block (:2460-2468) and rely onlet mut demand = None;+ the existing lazyget_or_insert_withat:2479.
2. Switching DiskStore::inbound_rate to rank-0 disk-read-only breaks worth_fetching() / restore_wait.defer() pricing (blocker)
DiskStore::inbound_rate feeds DiskStore::hit() (:4394) -> HostHit::estimated_seconds -> worth_fetching() and restore_wait.defer() in helios/src/server/runtime.rs. Changing it from end-to-end restore wall time to rank-0 per-window DiskThread reply.elapsed via inbound_samples / drain_inbound_samples has several unintended effects:
- v4 packed records (
--lossless-kv-compression cpu|gpu):disk::Worker::read_packeduses bufferedFile::open+read_exact_at(notO_DIRECT). Page-cache hits report RAM-copy speeds while omitting CPU/GPU codec decode and GPU H2D upload completely. BecauseRateonly decays upward toward its seed and never downward (selene/src/levels.rs:69-75), inflated rates stick and systematically underprice restores. - Raw v1–v3: Excludes
Open(header + checksums), slot queueing, and GPU H2D upload (for instance, in the PR's ownQwen3.8-27Btable,inbound_ratereports7.71 GB/s/ ~295 msestimated for a2,274 MBrestore during a5.66 smedian-TTFT burst). Shardedmulti-host:Peer::forward(selene/src/shard.rs:1213-1214) discards peer samples andSharded::drain_inbound_samples(:1005-1012) only drains rank 0's localStaged, leavingworth_fetching()blind to slow or degraded peer NVMe/links.- 3-sample median noise & split with
CompositeStore: Emitting one sample per window lets tiny partial tail or 4 KiB row-only windows dominateRate's 3-sample median, whileCompositeStore::disk_inbound_ratestill measures end-to-endread_into/read_into_packedtime.
Requested fix: Keep DiskStore::inbound_rate measuring end-to-end restore latency (including Open, codec decode, GPU upload, and all Sharded ranks) rather than disk-thread-only window reads. To avoid inflating the estimate on late-attaching followers that ride already-staged windows, only observe end-to-end (bytes, job.started.elapsed()) for restores that did not ride pre-existing windows (or measure elapsed from the earliest attached shared window's start). That also eliminates the drain_inbound_samples plumbing across DiskTransport, Sharded, and Peer, and keeps docs/prefix-cache-offload.md §4 consistent with CompositeStore.
3. pick_next_pending_plan skipping shared windows on tight pools (interaction with #497)
In pick_next_pending_plan (disk_store.rs:2320), skipping any unstarted plan whose layout.record_slots(plan.count, plan.row) > free allows a fetch to grab leftover slots for a small private child tail (peer_demand = 0) instead of waiting for a 64-page shared ancestor (peer_demand > 0).
Under #497's 2 * (64 + row_slots) integrated-GPU pool (e.g., 178 slots when row_slots ≈ 25), as soon as the first sibling finishes uploading a 64-page ancestor window while slower siblings still pin it (free = 50), that sibling skips the next 64-page shared ancestor window and spends its window credit + slots on its private tail (29 slots). That fragments the pool, delays 64 + row_slots windows, and can desynchronize siblings so they miss coalescing the next shared ancestor window.
Requested fix: Avoid bypassing a higher-peer_demand shared window just to run a lower-demand (peer_demand == 0) private window when free is temporarily below a full window; wait for slots to free so siblings stay synchronized on the shared ancestor.
Minor / maintainability & validation notes
selene/src/disk_store.rsgrows from ~8K to ~10.8K lines withpump_device_inboundat ~538 lines in one function; consider extracting the shared device-inbound state machine into a private submodule (e.g.,disk_store/coalesce.rs) and splittingpump_device_inbound's passes into small methods.- Please add unit coverage for
#496 + #497-style tight2 * (64 + row_slots)pool coalescing and multi-rankShardedcoalescing, and verify live serving with--lossless-kv-compression(cpu/gpu) once #1 and #2 are updated.
|
Following up with empirical measurements of all three items on NVIDIA GB10 (DGX Spark, ARM64 Cortex-X925, 1. Per-
|
| v4 Packed Ancestor | fetches = 1 (mean / p99) |
fetches = 8 (mean / p99) |
Slowdown |
|---|---|---|---|
TP1, 512 pages (513 PackedUnits) |
0.9 µs / 0.9 µs |
1.47 ms / 2.23 ms |
1,634× |
TP8, 512 pages (4,104 PackedUnits) |
0.4 µs / 0.6 µs |
9.73 ms / 9.74 ms |
24,335× |
TP8, 1024 pages (8,200 PackedUnits) |
0.4 µs / 0.4 µs |
49.33 ms / 49.59 ms |
123,325× |
Every poll() on the Helios worker thread (and on each Peer::run loop) stalls for 1.5–49.3 ms doing wasted hashing while disk/GPU work is in flight.
2. DiskStore::inbound_rate vs worth_fetching() pricing
- v4 packed (buffered
ReadPacked+ omitted decode/upload): Restoring a 128-page (33.6 MBraw /414 KBcompressed) v4 checkpoint with a150 msdecode/upload delay took166.1 mswall time (202.5 MB/seffective), while PR Coalesce shared ancestor reads across concurrent Selene disk fetches #496 reportedinbound_rate = 14,057.7 MB/s(69.4× inflation) andhit.estimated_seconds = 2.39 ms. Against a100 msprefill (worth_fetchingthreshold50 ms),worth_fetching()returnedtruedespite the real restore being slower than prefill. - Raw
Sharded(omittedOpen+ upload + peer sync): Over a local TCPSharded+Peerpair (with zero artificial peer read delay), a 128-page (2.1 MB) restore took17.0 msend-to-end (123.7 MB/s), while rank 0'sinbound_ratereported1,669.7 MB/s(13.5× inflation,hit.estimated_seconds = 1.26 ms).
3. Tight #497 pool (2 * (64 + row_slots)) skips shared ancestor and drops coalescing
With intake_slots(&layout, 1) = 130 slots (row_slots = 1) and a 3-window shared ancestor + 2 branches (1-page + row private tails):
- Minor upload skew on
W0caused Job 1 to skip shared ancestorW2(peer_demand = 1) and start its private child tailC1(peer_demand = 0), droppingfree_slotsto0. - Job 2 then read and swept
W2while Job 1's credits were occupied, forcingW2to be re-read from disk (disk_window_reads = 6vs5ideal;coalesced_windows = 2vs3ideal).
Happy to re-run these checks and validate on GB10 once the fixes are pushed.
Why
When concurrent requests restore distinct branch checkpoints sharing a
disk-resident ancestor prefix, Helios deduplicates inbound restore tickets by
endpoint key, so each branch submits its own GPU restore (`Staged::fetch`) in
`selene/src/disk_store.rs`. Before this change, each restore opened every
ancestor record file independently and staged private 64-page windows, repeating
`O_DIRECT` opens, reads, and checksum verification once per branch.
Published record files are immutable and stay pinned in `DiskStore` across every
referencing restore. Coalescing belongs in `Staged` rather than `DiskThread`
because `DiskThread` sees only file offsets and raw buffers and finishes once
direct I/O completes, whereas shared `SlabPool` staging slots and v4
`ReadPacked` payload buffers must remain pinned until every attached follower's
asynchronous `Copier` decode or GPU upload completes.
What
- Shared device-inbound state machine (`selene/src/disk_store.rs`,
`selene/src/disk_store/coalesce.rs`):
- Before: `Staged` ran every host and GPU inbound read through an isolated
per-fetch `InboundRecord`, opening each segment and staging private 64-page
windows independently.
- After: caller-owned host reads (`Staged::read_into` using
`plan_windows(..., false)` and `Staged::read_into_packed` storing
`(Header, Arc<Vec<u8>>)` in `completed_packed_reads` for `CompositeStore`)
stay on private `HostInbound`. Device fetches (`Staged::fetch`,
`plan_windows(..., true)`) delegate to `DeviceCoalescer` in
`selene/src/disk_store/coalesce.rs`, slicing on `WINDOW_PAGES` (64-page)
file boundaries and sharing one open file handle per `SegmentKey` and one
`SharedWindow` per `WindowKey` (`O(1)` `window_index` lookup) across both
raw v1-v3 `SlabPool` staging windows and v4 `packed` `ReadPacked` buffers
(which allocate zero `SlabPool` slots and retain `Arc<Vec<u8>>` until every
follower's `Copier` decode and upload completes).
- Exhaustive `Header`/`packed::Layout` hashing with cached digest and lazy
demand indexing (`selene/src/shared/packed.rs`, `selene/src/shared/record.rs`,
`selene/src/disk_store/coalesce.rs`):
- Before: `Header` and `packed::Layout` had no `Hash` implementation; hashing
an entire `packed::Layout` (up to 8,200 `PackedUnit`s on TP8 1,024-page
records) or eagerly rebuilding `demand` on full-credit `poll()` ticks
would stall the worker thread.
- After: `packed::Layout` implements `Eq` and exhaustive `Hash` over `Layout`,
`PackedOffer`, and `PackedUnit`; `RankSizes` derives `Hash`; `Header`
implements exhaustive `Hash` beside `PartialEq` (omitting only encoding
`version`); `HeaderIdentity::new(Arc<Header>)` precomputes a deterministic
`u64` digest once with `DefaultHasher::new()`, `HeaderIdentity::hash`
hashes only that cached `u64`, and `HeaderIdentity::eq` short-circuits on
digest mismatch and `Arc::ptr_eq` before comparing full `Header` values;
and `start_new_windows` builds `demand` lazily only when a fetch holds free
window credit and needs to start a new window (skipping demand indexing
when at most one fetch is active).
- Tight-pool shared-ancestor holdback (`selene/src/disk_store/coalesce.rs`):
- Before: skipping any unstarted plan whose `Layout::record_slots` exceeded
currently free slots allowed a sibling on a tight `2 * (64 + row_slots)`
pool to grab leftover slots for a small private tail instead of waiting for
a 64-page shared ancestor window, fragmenting slots and forcing re-reads.
- After: `pick_next_pending_plan` computes `reachable_free = free +
self.staged_slots() + outbound_slots` and holds back lower-demand windows
whenever a higher-`peer_demand` shared window fits within `reachable_free`.
Because in-flight staged windows drain without allocating new slots,
waiting never deadlocks when no staged slots can free or under external
pool retention.
- End-to-end `DiskStore::inbound_rate` and per-fetch `bytes_in`
(`selene/src/disk_store.rs`):
- Before: `DiskStore::inbound_rate` observed every completed fetch's
`(bytes, started.elapsed())`, which would let staggered coalesced followers
riding pre-existing windows overstate bandwidth.
- After: `StoreStats.bytes_in` continues counting per-fetch payload bytes
restored across completed fetches (raw bytes for v1-v3 records and
compressed payload bytes for v4 packed records, credited once per completed
fetch including coalesced followers), while `StoreStats.inbound_rate`
observes end-to-end uncompressed checkpoint bytes
(`layout.record_bytes(chain.pages)`) over full fetch wall time (covering
`Open`, slot queueing, disk read, codec decode, GPU upload, and all
`Sharded` ranks) in the same units as `HostHit::estimated_seconds` and
`worth_fetching()`. Restores submitted while an in-flight restore already
reads a shared segment (`rode_preexisting`) skip `inbound_rate.started()`
and observe `inbound_rate` only downward (when `(logical_bytes / elapsed) <
inbound_rate.get()`), so fast coalesced followers never inflate bandwidth
while continuous overlapping streams, mid-stream slowdowns, and bursts
whose leader fails still push `inbound_rate` down without drifting to the
3.0 GB/s seed, and slow disks can still recover upward when throughput
improves. No `DiskTransport` or `shard.rs` rate-sampling plumbing and no
`TransportEvent` change are added.
- Failure isolation and docs (`selene/src/disk_store/coalesce.rs`,
`docs/prefix-cache-offload.md`): private child or transient follower GPU
upload errors fail only that restore; shared open, read, or packed-payload
content errors (`is_packed_content_error`, marked with `with_record_read()`)
fail all attached restores after in-flight I/O drains so `DiskStore::apply`
drops the corrupt endpoint's lookup row. The last user of a shared segment
waits for disk close (`disk_settled`) before emitting `Fetched`, and
`Staged::close` reports abandoned transport jobs separately from leaked
shared staging entries. Diagnostic counters are gated under `test-support`,
and `docs/prefix-cache-offload.md` (sections 2.4 and 4) documents raw and v4
packed coalescing, tight-pool holdback, and end-to-end rate accounting. No
core re-export, record format, wire protocol, or `TransportEvent` change is
required.
Result
Overlapping GPU restores open a shared ancestor file once and read each aligned
64-page raw or v4 packed window once while staged (windows already released
before a later restore attaches are read again). As an expected bound,
single-restore callers skip demand indexing (`device_inbound.len() <= 1`) and
pay at most one extra partial window per segment when `skip_pages % 64 != 0`.
On x86_64 Linux (`--release` `selene` tests over `io_uring` + ext4, `rustc
1.100.0`, 1,000 full-credit polls), full-credit (2/2) `Staged::poll()` mean
latency with 8 concurrent v4 packed fetches drops from `1,354.937 us` ->
`0.693 us` (`1,955x`, p99 `0.701 us`, credit-regained demand pass `31.396 us`)
at TP1 512 pages (`513` `PackedUnit`s), `10,347.821 us` -> `0.664 us`
(`15,584x`, p99 `0.679 us`, demand pass `31.298 us`) at TP8 512 pages (`4,104`
`PackedUnit`s), and `44,447.427 us` -> `0.745 us` (`59,661x`, p99 `1.392 us`,
demand pass `39.897 us`) at TP8 1,024 pages (`8,200` `PackedUnit`s), with zero
demand rebuilds at full credit. Single-fetch full-credit mean latency stays at
`0.252-0.256 us` (`23.8-26.6 us` demand pass).
Live `flare run` A/B on NVIDIA GB10 (SM121) comparing `main` before v4 packed
records (`c0c4f798`) against `0c04b1e2` with `--lossless-kv-compression` off
and `--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk`
(`--max-concurrency 16 --prefix-cache-disk-limit 40G` on `Qwen3.8-27B-NVFP4`;
`--max-concurrency 8 --prefix-cache-disk-limit 24G` on `Qwen3.8-Flash-Next`).
Each trial warms one ~61K-token shared prefix plus 8 child branches (~256
unique tail tokens each) to disk, restarts `flare run` so GPU memory starts
empty, and sends 8 concurrent `/v1/chat/completions` follow-ups (ingress-to-
first-token TTFT; read-reduction ratios are ratios of tabulated means):
- `Qwen3.8-27B-NVFP4` (TP1, `60.5K`, 2 interleaved repeats): physical NVMe reads
drop `18,177.5 -> 4,306.7 MB` (`2,274 MB` single restore — `472` pages at
`128` tokens/page plus `101 MB` continuation row, so `18,177.5 MB` is `8x`
full copies; `4.22x`, `-76.3%`), median TTFT `7,974.6 -> 5,662.8 ms`
(`-29.0%`) simultaneous; and `18,194.2 -> 4,843.6 MB` (`3.76x`, `-73.4%`),
TTFT `6,883.6 -> 5,951.9 ms` (`-13.5%`) at `+25 ms` stagger.
- `Qwen3.8-Flash-Next` (TP1, `61.0K`): NVMe reads drop `7,944.9 -> 1,981.1 MB`
(`4.01x`, `-75.1%`, TTFT `3,327.5 -> 3,225.0 ms`) simultaneous, and `7,958.0 ->
2,251.5 MB` (`3.53x`, `-71.7%`, TTFT `3,137.7 -> 3,049.9 ms`) at `+25 ms`
stagger.
Recommended merge order with companion PR `NVIDIA#497` (Selene pipeline
prioritization and tighter `2 * (64 + row_slots)` intake pools): merge `NVIDIA#497`
first, then rebase `NVIDIA#496` onto `main` so `Staged::pump_all` retains
`MAINTENANCE_DEFER_LIMIT = 8` and runs `host_inbound` and `pump_device_inbound`
ahead of `outbound` and `maintenance`.
Evidence
- Verified on x86_64 Linux (`O_DIRECT` + `io_uring`, ext4, `rustc 1.100.0`) on
the exact archived tree over `main` (`6d74db3a`; merges cleanly against
`origin/main` `9031847a`):
- `cargo check --locked --release --manifest-path selene/Cargo.toml
--all-targets` (`0` warnings, with and without `test-support`).
- `cargo test --locked --release --manifest-path selene/Cargo.toml --features
test-support`: `522` lib + `1` `mixed_codec_root` passed, `0` failed,
including `HeaderIdentity` cached-digest equality, full-credit large packed
header `poll()` latency and zero-demand-rebuild verification (reproducible
with `--lib
poll_at_full_window_credit_with_large_packed_header_avoids_demand_rebuild_and_rehashing
-- --nocapture`), end-to-end `inbound_rate` and `worth_fetching()` pricing
on delayed v4 packed and multi-rank `Sharded` + `Peer` restores, staggered
follower non-inflation, continuous overlapping shared-stream aging,
mid-stream slowdown, and slow-to-fast upward recovery, leader private
failure with slow follower rate update and `worth_fetching()` rejection,
tight `2 * (64 + row_slots)` pool shared-ancestor holdback
(`disk_window_reads == 5`, `coalesced_windows == 3`) and deadlock freedom
under external pool retention and concurrent outbound stores, multi-rank
`Sharded` + `Peer` coalescing, 4-way v4 packed coalescing and
corrupt-packet `record_read` invalidation, misaligned follower
partial-tail+row parity, private vs shared failure isolation, and
`Staged::close` draining.
- `cargo test --locked --release --manifest-path selene-manager/Cargo.toml
--test client --test offload`: `85 + 2` passed, `0` failed.
- `cargo check --locked --manifest-path helios/Cargo.toml --features
runtime-core,server --all-targets`: passed (`0` warnings in touched crates).
- `pytest tests/preparation/test_core_boundary.py
tests/test_design_review_hook.py`: `22` passed, `0` failed.
- Prior SM121 GPU evidence at `0c04b1e2` against `main` before v4 packed
records (`c0c4f798`, raw v3 records / `--lossless-kv-compression` off):
`helios` `offload::` (`FLARE_RUN_CUDA_TESTS=1 --include-ignored`) passed all
`21` single-GPU SM121 tests (`split_pools` requires 2 local GPUs); live SM121
parity across 5 cold-VRAM restart repeats (`seed = 1234..1238`, `60,534`
tokens, `top_logprobs = 5`) on `Qwen3.8-27B-NVFP4` TP1 produced identical FP32
`top-5 logprobs` and token IDs vs `main` (`c0c4f798`) on all 5 repeats; and 4
concurrent decode streams spilling checkpoints over 30 s on
`Qwen3.8-Flash-Next` TP1 had `0` errors (`100.0 -> 100.6 tok/s`).
- Not covered: live SM121 `--lossless-kv-compression` (`cpu`/`gpu`) serving,
post-fix SM121 `flare run` re-measurement, multi-host RoCE serving, 2-GPU
`split_pools`, discrete PCIe GPUs, Windows serving, and live warm-plus-disk
(`--prefix-cache-memory > 0`) or `PooledStore` HTTP serving (`CompositeStore`
+ `DiskStore` CUDA transfers are covered in `helios` `offload::`).
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=eb2f
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
cb3db46 to
ba1c73f
Compare
…head Why Disk-only prefix-cache offload (`--prefix-cache-memory 0` with `--prefix-cache-disk`, default `--lossless-kv-compression off`) incurred five host and coordination costs: (1) opening a raw v1-v3 record file (`selene/src/disk.rs`) issued two sequential `O_DIRECT` reads (4 KiB header, then page checksums); (2) `xxh3` page hashing ran serially on the single disk thread across up to 64 pages (`268 MB` at `4.19 MB`/page); (3) `Staged::pump_all` (`selene/src/disk_store.rs`) submitted unlinks/truncates and outbound writes ahead of interactive restores; (4) while waiting on an inbound restore with an idle GPU, Helios's worker (`helios/src/server/runtime.rs`) slept up to `2 ms` and multi-host disk peers (`selene/src/shard.rs`) slept `1 ms` instead of waking on socket readability; and (5) on integrated-memory GPUs (`CU_DEVICE_ATTRIBUTE_INTEGRATED`), disk-only offload scaled registered host intake with concurrency (`2 * max_active * row_slots + 128`, up to `8.2 GiB` needed on `Qwen3.8-27B-NVFP4` at `--max-concurrency 16`), carving GPU KV cache out of shared RAM even though paged disk streaming stages at most two windows (`2 * (64 + row_slots)` slots). What - Single-read raw open (`selene/src/disk.rs`): preserve `NVIDIA#504`'s v4 packed `Header::read_metadata` open branch, and on raw v1-v3 `O_DIRECT` opens read the 4 KiB header and expected checksum segment in one transfer when `expected.tail_pages <= MAX_TAIL_PAGES` (`CHECKSUM_SCRATCH_BYTES = 1 MiB`), falling back to a 4 KiB header-only read on failure while preserving retry I/O errors, truncated-file checks, and shared scratch span helpers. - Scoped parallel page hashing (`selene/src/disk.rs`): cache `parallel_cpus` once at `Worker::new` and hash raw batches of >= `HASH_PARALLEL_MIN_PAGES` (`4`) pages across `parallel_cpus.min(MAX_HASH_THREADS).min(buffers.len())` `std::thread::scope` threads (`MAX_HASH_THREADS = 4`) when `parallel_cpus >= HASH_PARALLEL_MIN_CPUS` (`4`), with `0` idle helper threads, Linux `SCHED_BATCH` inheritance via `clone`, inline recomputation on helper spawn or unwind failure, and fault hooks folded into `Faults` under `cfg(any(test, feature = "test-support"))` (zero test-only parameters on shipped signatures). - Bounded restore-first submission and wakeup (`disk_store.rs`, `helios/src/server/runtime.rs`, `shard.rs`): order `Staged::pump_all` as inbound restores, then outbound writes, then maintenance while submitting one reserved maintenance job ahead of inbound and outbound after `MAINTENANCE_DEFER_LIMIT` (`8`) consecutive passes where queued maintenance lost free disk-queue space; poll `Worker::idle_wait` at `50 us` during active/waiting inbound restores; and wake Unix disk peers via `libc::poll` (`POLLIN`). - Bounded integrated disk-only intake & `NVIDIA#589` unified-memory budget integration (`selene/src/offload.rs`, `helios/src/offload/mod.rs`, `helios/src/runtime_core/{memory,model}.rs`, `docs/prefix-cache-offload.md`): pass explicit `PrepareInputs` (`max_active`, `input_staging`, `shard`, `integrated`) into `headroom_with_inputs`, `headroom_with_inputs_for_budget`, `prepare_with_inputs`, and `prepare_with_inputs_budget` (deleting unused `prepare` and dead `core: &Path`), unify `disk_enabled()`, `headroom_inner`, private `target_intake_slots`, and parameterless `Prepared::intake_warning()` (`required_intake` + `sized_concurrency`), preserve `options.pool_only()` so a degraded disk directory under `--prefix-cache-pool --prefix-cache-memory 0` remains restore-only against `NVIDIA#589`'s `planned_offload_host`, and target `intake_slots(layout, 1)` (`2 * (64 + row_slots)`) on integrated disk-only hosts without shrink warnings across `NVIDIA#589`'s small-SoC headroom scaling, explicit `--memory-limit` budgets, pre-planned post-KV `planned_offload_host`, and `HOST_NUMA` split-mapping fallback while preserving `NVIDIA#504` lossless KV compression. No core re-export or record-format change is required. Result Live `flare run` A/B on NVIDIA GB10 (SM121) measured `NVIDIA#497` standalone (`cd5a366b`) against pre-`NVIDIA#504` `main` (`c0c4f798`) with `--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk` and default `--lossless-kv-compression off` (the raw v3 `.ckpt` path, whose default GB10 disk-only execution is unchanged by rebasing onto `ba3afb13` / `NVIDIA#589` because GB10 128 GiB exceeds the 16 GiB small-SoC threshold and disk-only intake targets the same two-window floor; ingress-to-first-token TTFT; bandwidth is rank-0 `flare_host_cache_inbound_bytes_per_second`): - `Qwen3.8-27B-NVFP4` (TP1, `--max-concurrency 16 --prefix-cache-disk-limit 40G`, 3 interleaved repeats): intake drops `7.3 GiB` (`1,877` slots, shrink warning) -> `1.0 GiB` (`252` slots, `0` warnings), raising GPU KV cache `64.4 -> 71.6 GiB` (`+7.2 GiB` / `+235.5K` tokens); median single-restore bandwidth and TTFT improve `7.05 -> 8.02 GB/s` (`348.0 -> 301.7 ms`, `-13.3%`; wall `353.5 -> 306.5 ms`) at `30.0K` and `6.28 -> 8.68 GB/s` (`+38.2%`, `551.8 -> 447.6 ms`, `-18.9%`; wall `561.7 -> 455.4 ms`) at `61.1K`; `NVIDIA#497` standalone 8-way `61.1K` cold-restart burst mean median TTFT drops `8,156.1 -> 6,963.4 ms` (`-14.6%`, 2 interleaved repeats; combining this change with concurrent ancestor-restore read coalescing in companion PR `NVIDIA#496` is unmeasured). - Isolated `std::thread::scope` `xxh3` (`cd5a366b` with `MAX_HASH_THREADS = 1` at `selene/src/disk.rs:157` and no other change vs unmodified `cd5a366b` with `MAX_HASH_THREADS = 4`, 3 interleaved repeats on `Qwen3.8-27B-NVFP4`): parallel hashing alone improves median TTFT `486.8 -> 447.6 ms` (`-8.1%`, `7.73 -> 8.68 GB/s`, `+12.3%`, faster on all 3 repeats: `[447.6, 432.7, 451.2]` vs `[479.9, 557.5, 486.8] ms`) at `61.1K` and `322.4 -> 301.7 ms` (`7.55 -> 8.02 GB/s`) at `30.0K`. `HASH_PARALLEL_MIN_PAGES = 4` and `HASH_PARALLEL_MIN_CPUS = 4` assign at least one page per thread at the 4-thread cap and leave cores for serving threads on narrow hosts (not swept separately). - `Qwen3.8-Flash-Next` (TP1, `--max-concurrency 8 --prefix-cache-disk-limit 24G`, `cd5a366b` vs `c0c4f798`): intake drops `1.9 -> 0.3 GiB` (`2,288 -> 398` slots), raising GPU KV cache `23.28 -> 24.98 GiB` (`+1.70 GiB` / `+127.0K` tokens); bandwidth improves `5.67 -> 7.05 GB/s` (`372.1 -> 355.6 ms`) at `30.0K` and `6.65 -> 8.35 GB/s` (`+25.6%`, `458.0 -> 413.8 ms`, `-9.7%`) at `61.0K`; `NVIDIA#497` standalone 8-way burst median TTFT drops `3,327.5 -> 3,078.5 ms` (`-7.5%`). - Expected interaction with `NVIDIA#589` (`ba3afb13`): on unified-memory GPUs with an explicit `--memory-limit`, disk-only intake remains bounded at `intake_slots(layout, 1)` so unlocked unified RAM expands GPU KV cache rather than concurrency-scaled staging, while warm+disk (`--prefix-cache-memory > 0`) and pool-only capture retain `NVIDIA#589`'s pre-planned host budget and small-SoC scaling. What it costs: up to three short-lived scoped `xxh3` helpers during >=4-page raw batches (`0` idle helpers), `50 us` `Worker::idle_wait` polling during active/waiting inbound restores (`969.9 -> 1,069.2 ms/s` `/proc/<pid>/stat` server CPU across 8-way `Qwen3.8-27B-NVFP4` bursts: `+99.3 ms/s` / ~`0.10` of 20 Grace cores combined; the `50 us` poll's CPU share and latency contribution are unisolated from scoped `xxh3` helpers), two-window serialization for concurrent unique-prefix restores and outbound stores on integrated disk-only hosts, and up to `8` passes of maintenance deferral. Companion PR (NVIDIA#496, concurrent ancestor-restore open and window coalescing): merge `NVIDIA#497` first, then rebase `NVIDIA#496` onto `main` so `Staged::pump_all` retains `MAINTENANCE_DEFER_LIMIT = 8` (submitting one reserved maintenance job first after `8` deferred passes) and runs `NVIDIA#496`'s private `host_inbound` and shared `pump_device_inbound` queues ahead of `outbound` and `maintenance`. Evidence - Rebased crate and Python checks over `origin/main` (`ba3afb13`, `NVIDIA#589`) on x86_64 Linux (`O_DIRECT` + `io_uring`): `selene --features test-support` (`514` lib + `1` `mixed_codec_root` integration passed, `0` warnings; also `cargo check --release` without `test-support`, `0` warnings), `selene-manager --features test-support --test client --test offload` (`85 + 2` passed, `0` warnings), `helios --features runtime-core,server --lib -- offload:: runtime_core::memory::tests runtime_core::model::tests server::runtime::phase_tests` (`144` passed, `14` GPU-only ignored, `0` warnings in touched files, covering `NVIDIA#497` + `NVIDIA#589` small-SoC, `--memory-limit`, and degraded-disk restore-only pool coexistence), and `pytest tests/preparation/test_core_boundary.py tests/test_design_review_hook.py` (`22` passed). - Prior SM121 GPU unit and live checks (at `cd5a366b`, `--lossless-kv-compression off`): `helios` `offload::` (`FLARE_RUN_CUDA_TESTS=1 --include-ignored`, `21` single-GPU SM121 tests passed; `split_pools` requires 2 local GPUs); corrupting a multi-page `.ckpt` payload on `Qwen3.8-27B-NVFP4` incremented `fetch_failed_total` (`1`), launched `0` `restore` graphs, and recomputed identical `top-5 logprobs` and tokens; under `--prefix-cache-disk-limit 6G` (`4` concurrent restores + `3` fresh `30K` stores), disk bytes peaked at `6.38 GB` (`<= 6 GiB`) and settled at `6.37 GB` with `0` `retry_abandoned` and `0` `io_error` drops (`2` normal `end_of_chain` evictions); four concurrent decode streams spilling checkpoints over 30 s on `Qwen3.8-Flash-Next` had `0` errors (`100.0 -> 95.9 tok/s`). - Not covered: live `--lossless-kv-compression` (`cpu`/`gpu`) serving, post-rebase SM121 `flare run` re-measurement, live Jetson Orin GA10B / `--memory-limit` GPU serving, isolated `50 us` `Worker::idle_wait` A/B, `NVIDIA#496 + NVIDIA#497` combined serving, multi-host RoCE serving, 2-GPU `split_pools`, discrete PCIe GPUs, Windows serving, and live warm-plus-disk (`--prefix-cache-memory > 0`) or `PooledStore` HTTP serving (`CompositeStore` + `DiskStore` CUDA transfers were covered at `cd5a366b` in `helios` `offload::`). Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4); design-review=c3a9 Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
|
@yatesdr Thank you for the detailed review, the empirical GB10 trial, and the confirmation on keeping coalescing in 1. Per-
|
Shape (PackedUnits) |
Concurrent Fetches | Before Mean / p99 (cb3db468) |
After Mean / p99 (ba1c73fd) |
Speedup (Mean) | Credit-Regained Demand Pass (ba1c73fd) |
|---|---|---|---|---|---|
TP1, 512 pages (513) |
1 |
0.283 µs / 0.323 µs |
0.252 µs / 0.274 µs |
1.12x |
26.642 µs |
TP1, 512 pages (513) |
8 |
1,354.937 µs / 1,561.375 µs |
0.693 µs / 0.701 µs |
1,955x |
31.396 µs |
TP8, 512 pages (4,104) |
1 |
0.278 µs / 1.507 µs |
0.256 µs / 0.274 µs |
1.09x |
23.816 µs |
TP8, 512 pages (4,104) |
8 |
10,347.821 µs / 11,234.217 µs |
0.664 µs / 0.679 µs |
15,584x |
31.298 µs |
TP8, 1,024 pages (8,200) |
1 |
0.310 µs / 1.361 µs |
0.253 µs / 0.274 µs |
1.23x |
25.612 µs |
TP8, 1,024 pages (8,200) |
8 |
44,447.427 µs / 48,825.259 µs |
0.745 µs / 1.392 µs |
59,661x |
39.897 µs |
2. End-to-end DiskStore::inbound_rate (v4 packed and Sharded inflation)
- Fix (
selene/src/disk_store.rs,selene/src/shard.rs,docs/prefix-cache-offload.md):- Removed
DiskTransport::drain_inbound_samples,Staged::inbound_samples,DiskStore::observe_inbound_samples,Sharded::drain_inbound_samples, andPeer::forwardsample discarding (selene/src/shard.rsis back to0diff againstmain). - Restored end-to-end
DiskStore::inbound_rateonInbound:DiskStore::fetchcapturesstarted = Instant::now()beforeself.transport.fetch(...), recordsread_nodes(segments withpages > 0 || row) andlogical_bytes = self.layout.record_bytes(chain.pages as u64)(uncompressed checkpoint bytes matchingHostHit::bytesandHostHit::estimated_seconds = bytes / inbound_rate.get()for both raw and v4 packed records), and marksrode_preexistingwhen any currently in-flightInboundshares a node inread_nodes. - Restores with
rode_preexisting == trueskipself.inbound_rate.started()and observeself.inbound_ratedownward only ((job.logical_bytes as f64 / elapsed.as_secs_f64()) < self.inbound_rate.get()). Fast coalesced followers riding pre-existing staged windows never inflate bandwidth; continuous overlapping streams, mid-stream slowdowns, and bursts whose leader fails still pushinbound_ratedown without lettingRate::get()drift upward to the3.0 GB/sseed; and keepingstarted()skipped onrode_preexistingpreserves normal2x / 10 supward recovery when a slow disk recovers during overlapping traffic. StoreStats.bytes_incontinues counting per-fetch payload bytes restored across completed fetches (raw bytes for v1–v3 records and compressed payload bytes for v4 packed records, credited once per completed fetch including coalesced followers). Updateddocs/prefix-cache-offload.md§4 to matchCompositeStore::disk_inbound_rateand document both metrics accurately.
- Removed
- Tests (
selene/src/disk_store/coalesce/tests.rs):packed_restore_inbound_rate_includes_decode_delay_and_worth_fetching_rejects: 128 × 256 KiB logical v4 packed restore with a 150 msDelayedCopieryields end-to-end ~200 MB/s,estimated_seconds >= 0.14, andworth_fetching()rejects against a 100 ms prefill.sharded_inbound_rate_reflects_end_to_end_multi_rank_wall_time: local-TCPSharded+Peerwith an 80 ms delay on Peer rank 1 reflects full multi-rank wall time (estimated_seconds >= 0.075) and rejects against a 100 ms prefill.coalesced_restores_keep_inbound_rate_end_to_end_and_bytes_in_logical: verifies end-to-end rate with an 80 ms upload hold and confirms simultaneous and staggered late followers riding pre-existing windows do not inflateinbound_ratewhilebytes_incredits per-fetch payload bytes.overlapping_shared_stream_tracks_slowdown_and_recovers_without_drift: verifies continuous daisy-chained overlapping restores (rode_preexisting = true) prevent upward drift to3.0 GB/safter aginginbound_rate, track mid-stream slowdowns (worth_fetching()rejects), prevent fast coalesced followers from inflatinginbound_rate, and preserve2x / 10 supward recovery when throughput improves.leader_private_failure_with_slow_follower_updates_inbound_rate_and_rejects: corrupts only the leader's private child on a coldDiskStorewhile a slow coalesced follower (150 ms) succeeds, verifyinginbound_ratedrops from3.0 GB/sandworth_fetching()rejects against a100 msprefill.
3. Shared-ancestor holdback on tight 2 * (64 + row_slots) intake pools
- Fix (
selene/src/disk_store/coalesce.rs,selene/src/disk_store.rs,docs/prefix-cache-offload.md):pick_next_pending_plannow computesreachable_free = free + self.staged_slots() + outbound_slotsand tracksmax_reachable_shared_demandacross unstarted plans withpeer_demand > 0 && needed <= reachable_free. It returns a fitting lower-demand plan only whenbest_demand >= max_reachable_shared_demand; otherwise it returnsNoneand waits for in-flight staged slots to drain.- Because
staged_slots + outbound_slotsbelong to in-flight windows that complete without allocating new slots—and whenstaged_slots + outbound_slots == 0,reachable_free == free—holding back never deadlocks, including under external warm-slot retention (CompositeStore/MemoryStore). - Documented this rule in
docs/prefix-cache-offload.md§2.4.
- Tests (
selene/src/disk_store/coalesce/tests.rs):tight_pool_waits_for_shared_ancestor_instead_of_starting_private_tail: exercises bothrow_slots = 1(130-slot pool, 1-page + row private tails) androw_slots = 8(144-slot pool, 4-page + row private tails) underW0upload skew, verifying Job 1 waits instead of starting privateC1, finaldisk_opens == 3,disk_window_reads == 5,coalesced_windows == 3, and byte-exact GPU pages/rows.tight_pool_wait_never_deadlocks_without_releasable_staged_slots: covers both external retention holding120/130slots (staged_slots + outbound_slots == 0, private tails still make progress and the shared ancestor coalesces once slots release) and a concurrent65-slot outboundstorealongside two tight-pool shared-ancestor fetches on a130-slot pool (coalesced_windows == 2, zero deadlock).
4. Submodule extraction, Sharded coalescing coverage, and verification
- Extracted the device-inbound coalescing state machine out of
selene/src/disk_store.rs(10,856 -> 8,062lines) intoselene/src/disk_store/coalesce.rs(1,416lines) andselene/src/disk_store/coalesce/tests.rs(3,217lines), breakingDeviceCoalescer::pumpinto 9 single-purpose pass methods (reap_completed_uploads,detach_unwinding_windows,attach_existing_windows,sweep_shared_windows,start_new_windows,submit_pending_reads,submit_pending_uploads,close_idle_segments,complete_finished_fetches). - Added
sharded_concurrent_fetches_coalesce_across_rank_zero_and_peer: runs local-TCPSharded+Peervia productionshard::servewith 4 concurrent branches sharing a 3-window ancestor, confirming coalescing on Rank 0 (disk_opens == 5,disk_window_reads == 7,coalesced_windows == 9), simultaneous live slab-address sharing on Peer Rank 1 viaCoalesceProbeCopier, and byte-exact GPU pages/rows on both ranks. - Verified on exact
git archive ba1c73fd6c0b0d08c612dd947ed47ceaee8ce457(x86_64 LinuxO_DIRECT+io_uring,ext4,rustc 1.100.0):cargo check --locked --release --manifest-path selene/Cargo.toml --all-targets(0warnings with and withouttest-support)cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support:522lib +1mixed_codec_rootpassed,0failed,0ignoredcargo test --locked --release --manifest-path selene-manager/Cargo.toml --test client --test offload:85 + 2passed,0failed,0warningscargo check --locked --manifest-path helios/Cargo.toml --features runtime-core,server --all-targets: passed (0warnings in touched crates)pytest tests/preparation/test_core_boundary.py tests/test_design_review_hook.py:22passed,0failedgit merge-tree --write-tree 9031847aacbc0037ac54c3ef854083c43b34124a ba1c73fd6c0b0d08c612dd947ed47ceaee8ce457: clean (exit=0)
Remaining limits
- I have not yet re-run live SM121
flare runmeasurements onba1c73fd(or live SM121--lossless-kv-compressioncpu/gpuserving, multi-host RoCE, 2-GPUsplit_pools, discrete PCIe GPUs, Windows serving, or warm+disk /PooledStoreHTTP serving); the live SM121 A/B and parity numbers in the PR body remain explicitly scoped to0c04b1e2againstmainbefore v4 packed records (c0c4f798). A combined merge test with companion PR#497(ca863852) was last run at54c70eca(prior to the 6-line downward-only rate observation guard inDiskStore::apply, which does not touchStaged::pump_all).
I have updated the PR description as well so it stands on its own. Could you please take another look at ba1c73fd6c0b0d08c612dd947ed47ceaee8ce457?
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeAll three empirical GB10 blockers from the 2026-11-29 review (
Walkthrough
Merge Risk: Medium · up to
|
…head (#497) Why Disk-only prefix-cache offload (`--prefix-cache-memory 0` with `--prefix-cache-disk`, default `--lossless-kv-compression off`) incurred five host and coordination costs: (1) opening a raw v1-v3 record file (`selene/src/disk.rs`) issued two sequential `O_DIRECT` reads (4 KiB header, then page checksums); (2) `xxh3` page hashing ran serially on the single disk thread across up to 64 pages (`268 MB` at `4.19 MB`/page); (3) `Staged::pump_all` (`selene/src/disk_store.rs`) submitted unlinks/truncates and outbound writes ahead of interactive restores; (4) while waiting on an inbound restore with an idle GPU, Helios's worker (`helios/src/server/runtime.rs`) slept up to `2 ms` and multi-host disk peers (`selene/src/shard.rs`) slept `1 ms` instead of waking on socket readability; and (5) on integrated-memory GPUs (`CU_DEVICE_ATTRIBUTE_INTEGRATED`), disk-only offload scaled registered host intake with concurrency (`2 * max_active * row_slots + 128`, up to `8.2 GiB` needed on `Qwen3.8-27B-NVFP4` at `--max-concurrency 16`), carving GPU KV cache out of shared RAM even though paged disk streaming stages at most two windows (`2 * (64 + row_slots)` slots). What - Single-read raw open (`selene/src/disk.rs`): preserve `#504`'s v4 packed `Header::read_metadata` open branch, and on raw v1-v3 `O_DIRECT` opens read the 4 KiB header and expected checksum segment in one transfer when `expected.tail_pages <= MAX_TAIL_PAGES` (`CHECKSUM_SCRATCH_BYTES = 1 MiB`), falling back to a 4 KiB header-only read on failure while preserving retry I/O errors, truncated-file checks, and shared scratch span helpers. - Scoped parallel page hashing (`selene/src/disk.rs`): cache `parallel_cpus` once at `Worker::new` and hash raw batches of >= `HASH_PARALLEL_MIN_PAGES` (`4`) pages across `parallel_cpus.min(MAX_HASH_THREADS).min(buffers.len())` `std::thread::scope` threads (`MAX_HASH_THREADS = 4`) when `parallel_cpus >= HASH_PARALLEL_MIN_CPUS` (`4`), with `0` idle helper threads, Linux `SCHED_BATCH` inheritance via `clone`, inline recomputation on helper spawn or unwind failure, and fault hooks folded into `Faults` under `cfg(any(test, feature = "test-support"))` (zero test-only parameters on shipped signatures). - Bounded restore-first submission and wakeup (`disk_store.rs`, `helios/src/server/runtime.rs`, `shard.rs`): order `Staged::pump_all` as inbound restores, then outbound writes, then maintenance while submitting one reserved maintenance job ahead of inbound and outbound after `MAINTENANCE_DEFER_LIMIT` (`8`) consecutive passes where queued maintenance lost free disk-queue space; poll `Worker::idle_wait` at `50 us` during active/waiting inbound restores; and wake Unix disk peers via `libc::poll` (`POLLIN`). - Bounded integrated disk-only intake & `#589` unified-memory budget integration (`selene/src/offload.rs`, `helios/src/offload/mod.rs`, `helios/src/runtime_core/{memory,model}.rs`, `docs/prefix-cache-offload.md`): pass explicit `PrepareInputs` (`max_active`, `input_staging`, `shard`, `integrated`) into `headroom_with_inputs`, `headroom_with_inputs_for_budget`, `prepare_with_inputs`, and `prepare_with_inputs_budget` (deleting unused `prepare` and dead `core: &Path`), unify `disk_enabled()`, `headroom_inner`, private `target_intake_slots`, and parameterless `Prepared::intake_warning()` (`required_intake` + `sized_concurrency`), preserve `options.pool_only()` so a degraded disk directory under `--prefix-cache-pool --prefix-cache-memory 0` remains restore-only against `#589`'s `planned_offload_host`, and target `intake_slots(layout, 1)` (`2 * (64 + row_slots)`) on integrated disk-only hosts without shrink warnings across `#589`'s small-SoC headroom scaling, explicit `--memory-limit` budgets, pre-planned post-KV `planned_offload_host`, and `HOST_NUMA` split-mapping fallback while preserving `#504` lossless KV compression. No core re-export or record-format change is required. Result Live `flare run` A/B on NVIDIA GB10 (SM121) measured `#497` standalone (`cd5a366b`) against pre-`#504` `main` (`c0c4f798`) with `--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk` and default `--lossless-kv-compression off` (the raw v3 `.ckpt` path, whose default GB10 disk-only execution is unchanged by rebasing onto `ba3afb13` / `#589` because GB10 128 GiB exceeds the 16 GiB small-SoC threshold and disk-only intake targets the same two-window floor; ingress-to-first-token TTFT; bandwidth is rank-0 `flare_host_cache_inbound_bytes_per_second`): - `Qwen3.8-27B-NVFP4` (TP1, `--max-concurrency 16 --prefix-cache-disk-limit 40G`, 3 interleaved repeats): intake drops `7.3 GiB` (`1,877` slots, shrink warning) -> `1.0 GiB` (`252` slots, `0` warnings), raising GPU KV cache `64.4 -> 71.6 GiB` (`+7.2 GiB` / `+235.5K` tokens); median single-restore bandwidth and TTFT improve `7.05 -> 8.02 GB/s` (`348.0 -> 301.7 ms`, `-13.3%`; wall `353.5 -> 306.5 ms`) at `30.0K` and `6.28 -> 8.68 GB/s` (`+38.2%`, `551.8 -> 447.6 ms`, `-18.9%`; wall `561.7 -> 455.4 ms`) at `61.1K`; `#497` standalone 8-way `61.1K` cold-restart burst mean median TTFT drops `8,156.1 -> 6,963.4 ms` (`-14.6%`, 2 interleaved repeats; combining this change with concurrent ancestor-restore read coalescing in companion PR `#496` is unmeasured). - Isolated `std::thread::scope` `xxh3` (`cd5a366b` with `MAX_HASH_THREADS = 1` at `selene/src/disk.rs:157` and no other change vs unmodified `cd5a366b` with `MAX_HASH_THREADS = 4`, 3 interleaved repeats on `Qwen3.8-27B-NVFP4`): parallel hashing alone improves median TTFT `486.8 -> 447.6 ms` (`-8.1%`, `7.73 -> 8.68 GB/s`, `+12.3%`, faster on all 3 repeats: `[447.6, 432.7, 451.2]` vs `[479.9, 557.5, 486.8] ms`) at `61.1K` and `322.4 -> 301.7 ms` (`7.55 -> 8.02 GB/s`) at `30.0K`. `HASH_PARALLEL_MIN_PAGES = 4` and `HASH_PARALLEL_MIN_CPUS = 4` assign at least one page per thread at the 4-thread cap and leave cores for serving threads on narrow hosts (not swept separately). - `Qwen3.8-Flash-Next` (TP1, `--max-concurrency 8 --prefix-cache-disk-limit 24G`, `cd5a366b` vs `c0c4f798`): intake drops `1.9 -> 0.3 GiB` (`2,288 -> 398` slots), raising GPU KV cache `23.28 -> 24.98 GiB` (`+1.70 GiB` / `+127.0K` tokens); bandwidth improves `5.67 -> 7.05 GB/s` (`372.1 -> 355.6 ms`) at `30.0K` and `6.65 -> 8.35 GB/s` (`+25.6%`, `458.0 -> 413.8 ms`, `-9.7%`) at `61.0K`; `#497` standalone 8-way burst median TTFT drops `3,327.5 -> 3,078.5 ms` (`-7.5%`). - Expected interaction with `#589` (`ba3afb13`): on unified-memory GPUs with an explicit `--memory-limit`, disk-only intake remains bounded at `intake_slots(layout, 1)` so unlocked unified RAM expands GPU KV cache rather than concurrency-scaled staging, while warm+disk (`--prefix-cache-memory > 0`) and pool-only capture retain `#589`'s pre-planned host budget and small-SoC scaling. What it costs: up to three short-lived scoped `xxh3` helpers during >=4-page raw batches (`0` idle helpers), `50 us` `Worker::idle_wait` polling during active/waiting inbound restores (`969.9 -> 1,069.2 ms/s` `/proc/<pid>/stat` server CPU across 8-way `Qwen3.8-27B-NVFP4` bursts: `+99.3 ms/s` / ~`0.10` of 20 Grace cores combined; the `50 us` poll's CPU share and latency contribution are unisolated from scoped `xxh3` helpers), two-window serialization for concurrent unique-prefix restores and outbound stores on integrated disk-only hosts, and up to `8` passes of maintenance deferral. Companion PR (#496, concurrent ancestor-restore open and window coalescing): merge `#497` first, then rebase `#496` onto `main` so `Staged::pump_all` retains `MAINTENANCE_DEFER_LIMIT = 8` (submitting one reserved maintenance job first after `8` deferred passes) and runs `#496`'s private `host_inbound` and shared `pump_device_inbound` queues ahead of `outbound` and `maintenance`. Evidence - Rebased crate and Python checks over `origin/main` (`ba3afb13`, `#589`) on x86_64 Linux (`O_DIRECT` + `io_uring`): `selene --features test-support` (`514` lib + `1` `mixed_codec_root` integration passed, `0` warnings; also `cargo check --release` without `test-support`, `0` warnings), `selene-manager --features test-support --test client --test offload` (`85 + 2` passed, `0` warnings), `helios --features runtime-core,server --lib -- offload:: runtime_core::memory::tests runtime_core::model::tests server::runtime::phase_tests` (`144` passed, `14` GPU-only ignored, `0` warnings in touched files, covering `#497` + `#589` small-SoC, `--memory-limit`, and degraded-disk restore-only pool coexistence), and `pytest tests/preparation/test_core_boundary.py tests/test_design_review_hook.py` (`22` passed). - Prior SM121 GPU unit and live checks (at `cd5a366b`, `--lossless-kv-compression off`): `helios` `offload::` (`FLARE_RUN_CUDA_TESTS=1 --include-ignored`, `21` single-GPU SM121 tests passed; `split_pools` requires 2 local GPUs); corrupting a multi-page `.ckpt` payload on `Qwen3.8-27B-NVFP4` incremented `fetch_failed_total` (`1`), launched `0` `restore` graphs, and recomputed identical `top-5 logprobs` and tokens; under `--prefix-cache-disk-limit 6G` (`4` concurrent restores + `3` fresh `30K` stores), disk bytes peaked at `6.38 GB` (`<= 6 GiB`) and settled at `6.37 GB` with `0` `retry_abandoned` and `0` `io_error` drops (`2` normal `end_of_chain` evictions); four concurrent decode streams spilling checkpoints over 30 s on `Qwen3.8-Flash-Next` had `0` errors (`100.0 -> 95.9 tok/s`). - Not covered: live `--lossless-kv-compression` (`cpu`/`gpu`) serving, post-rebase SM121 `flare run` re-measurement, live Jetson Orin GA10B / `--memory-limit` GPU serving, isolated `50 us` `Worker::idle_wait` A/B, `#496 + #497` combined serving, multi-host RoCE serving, 2-GPU `split_pools`, discrete PCIe GPUs, Windows serving, and live warm-plus-disk (`--prefix-cache-memory > 0`) or `PooledStore` HTTP serving (`CompositeStore` + `DiskStore` CUDA transfers were covered at `cd5a366b` in `helios` `offload::`). Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4); design-review=c3a9 Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Merging NVIDIA#497 onto main changed `Staged::pump_all` to prioritize interactive inbound restores ahead of background writes and starvation-guarded maintenance, and added tests referencing `Staged::inbound`, which this branch split into `device` (`pump_device_inbound`) and `host_inbound` (`pump_host_inbound`). - Resolved the `Staged::pump_all` conflict in `selene/src/disk_store.rs` by retaining NVIDIA#497's maintenance starvation guard and pumping `pump_device_inbound()` and `host_inbound` ahead of `outbound` and `maintenance`. - Updated the three `staged.inbound[&JobId(12)]` assertions (and comment) in NVIDIA#497's `staged_pump_all_prioritizes_inbound_ahead_of_outbound_and_maintenance` test to `staged.host_inbound`. Both interactive coalesced device restores and host-buffer reads now keep priority ahead of background writes and maintenance without starving maintenance or breaking compilation. Validated on Linux (GB10 `cn6`): - `cargo check --manifest-path selene/Cargo.toml --all-targets --features codec,rdma`: passed with 0 warnings. - `cargo test --release --manifest-path selene/Cargo.toml --features codec`: 534/534 lib + 1/1 `mixed_codec_root` passed. - `cargo test --release --manifest-path selene-manager/Cargo.toml --test offload --test packed`: 2/2 `offload` + 9/9 `packed` passed. Design-Signed-Off-By: derek <derek.yates@live.com>; design-review=2e5b
yatesdr
left a comment
There was a problem hiding this comment.
All three review concerns are addressed, and the post-#497 merge in Staged::pump_all and staged_pump_all_prioritizes_inbound_ahead_of_outbound_and_maintenance is resolved and verified (selene --features codec 534/534 + 1/1, selene --features codec,rdma 0 warnings, selene-manager offload 2/2 + packed 9/9). Merging now.
Why
When concurrent requests restore distinct branch checkpoints sharing a disk-resident ancestor prefix, Helios deduplicates inbound restore tickets by endpoint key, so each branch submits its own GPU restore (
Staged::fetch) inselene/src/disk_store.rs. Before this change, each restore opened every ancestor record file independently and staged private 64-page windows, repeatingO_DIRECTopens, reads, and checksum verification once per branch.Published record files are immutable and stay pinned in
DiskStoreacross every referencing restore. Coalescing belongs inStagedrather thanDiskThreadbecauseDiskThreadsees only file offsets and raw buffers and finishes once direct I/O completes, whereas sharedSlabPoolstaging slots and v4ReadPackedpayload buffers must remain pinned until every attached follower's asynchronousCopierdecode or GPU upload completes.What
selene/src/disk_store.rs,selene/src/disk_store/coalesce.rs):Stagedran every host and GPU inbound read through an isolated per-fetchInboundRecord, opening each segment and staging private 64-page windows independently.Staged::read_intousingplan_windows(..., false)andStaged::read_into_packedstoring(Header, Arc<Vec<u8>>)incompleted_packed_readsforCompositeStore) remain on privateHostInbound. Device fetches (Staged::fetch,plan_windows(..., true)) delegate toDeviceCoalescerinselene/src/disk_store/coalesce.rs, slicing onWINDOW_PAGES(64-page) file boundaries and sharing one open file handle perSegmentKeyand oneSharedWindowperWindowKey(O(1)window_indexlookup) across both raw v1–v3SlabPoolstaging windows and v4packedReadPackedbuffers (which allocate zeroSlabPoolslots and retainArc<Vec<u8>>until every follower'sCopierdecode and upload completes).Header/packed::Layouthashing with cached digest and lazy demand indexing (selene/src/shared/packed.rs,selene/src/shared/record.rs,selene/src/disk_store/coalesce.rs):Headerandpacked::Layouthad noHashimplementation; hashing an entirepacked::Layout(up to8,200PackedUnits on TP8 1,024-page records) or eagerly rebuildingdemandon full-creditpoll()ticks would stall the worker thread.packed::LayoutimplementsEqand exhaustiveHashoverLayout,PackedOffer, andPackedUnit;RankSizesderivesHash;Headerimplements exhaustiveHashbesidePartialEq(omitting only encodingversion);HeaderIdentity::new(Arc<Header>)precomputes a deterministicu64digest once withDefaultHasher::new(),HeaderIdentity::hashhashes only that cachedu64, andHeaderIdentity::eqshort-circuits on digest mismatch andArc::ptr_eqbefore comparing fullHeadervalues; andstart_new_windowsbuildsdemandlazily only when a fetch holds free window credit and needs to start a new window (skipping demand indexing when at most one fetch is active).selene/src/disk_store/coalesce.rs):Layout::record_slotsexceeded currently free slots allowed a sibling on a tight2 * (64 + row_slots)pool to grab leftover slots for a small private tail instead of waiting for a 64-page shared ancestor window, fragmenting slots and forcing re-reads.pick_next_pending_plancomputesreachable_free = free + self.staged_slots() + outbound_slotsand holds back lower-demand windows whenever a higher-peer_demandshared window fits withinreachable_free. Because in-flight staged windows drain without allocating new slots, waiting never deadlocks when no staged slots can free or under external pool retention.DiskStore::inbound_rateand per-fetchbytes_in(selene/src/disk_store.rs):DiskStore::inbound_rateobserved every completed fetch's(bytes, started.elapsed()), which would let staggered coalesced followers riding pre-existing windows overstate bandwidth.StoreStats.bytes_incontinues counting per-fetch payload bytes restored across completed fetches (raw bytes for v1–v3 records and compressed payload bytes for v4 packed records, credited once per completed fetch including coalesced followers), whileStoreStats.inbound_rateobserves end-to-end uncompressed checkpoint bytes (layout.record_bytes(chain.pages)) over full fetch wall time (coveringOpen, slot queueing, disk read, codec decode, GPU upload, and allShardedranks) in the same units asHostHit::estimated_secondsandworth_fetching(). Restores submitted while an in-flight restore already reads a shared segment (rode_preexisting) skipinbound_rate.started()and observeinbound_rateonly downward (when(logical_bytes / elapsed) < inbound_rate.get()), so fast coalesced followers riding pre-existing staged windows never inflate bandwidth while continuous overlapping streams, mid-stream slowdowns, and bursts whose leader fails still pushinbound_ratedown without lettingRate::get()drift upward to the3.0 GB/sseed, and slow disks still recover upward when throughput improves. NoDiskTransportorshard.rsrate-sampling plumbing and noTransportEventchange are added.selene/src/disk_store/coalesce.rs,docs/prefix-cache-offload.md): private child or transient follower GPU upload errors fail only that restore; shared open, read, or packed-payload content errors (is_packed_content_error, marked withwith_record_read()) fail all attached restores after in-flight I/O drains soDiskStore::applydrops the corrupt endpoint's lookup row. The last user of a shared segment waits for disk close (disk_settled) before emittingFetched, andStaged::closereports abandoned transport jobs separately from leaked shared staging entries. Diagnostic counters are gated undertest-support, anddocs/prefix-cache-offload.md(sections 2.4 and 4) documents raw and v4 packed coalescing, tight-pool holdback, and end-to-end rate accounting. No core re-export, record format, wire protocol, orTransportEventchange is required.Result
Overlapping GPU restores open a shared ancestor file once and read each aligned 64-page raw or v4 packed window once while staged (windows already released before a later restore attaches are read again). As an expected bound, single-restore callers skip demand indexing (
device_inbound.len() <= 1) and pay at most one extra partial window per segment whenskip_pages % 64 != 0.On x86_64 Linux (
--releaseselenetests overio_uring+ext4,rustc 1.100.0, comparingcb3db468vsba1c73fd, reproducible withcargo test --locked --release --manifest-path selene/Cargo.toml --features test-support --lib poll_at_full_window_credit_with_large_packed_header_avoids_demand_rebuild_and_rehashing -- --nocapture), full-credit (2/2)Staged::poll()latency across 1,000 polls drops:PackedUnits)cb3db468)ba1c73fd)ba1c73fd)513)10.283 µs/0.323 µs0.252 µs/0.274 µs1.12x26.642 µs513)81,354.937 µs/1,561.375 µs0.693 µs/0.701 µs1,955x31.396 µs4,104)10.278 µs/1.507 µs0.256 µs/0.274 µs1.09x23.816 µs4,104)810,347.821 µs/11,234.217 µs0.664 µs/0.679 µs15,584x31.298 µs8,200)10.310 µs/1.361 µs0.253 µs/0.274 µs1.23x25.612 µs8,200)844,447.427 µs/48,825.259 µs0.745 µs/1.392 µs59,661x39.897 µsPrior live
flare runA/B on NVIDIA GB10 (SM121) comparingmainbefore v4 packed records (c0c4f798) against0c04b1e2with--lossless-kv-compressionoff and--prefix-cache-memory 0 --prefix-cache-disk /tmp/selene-disk(--max-concurrency 16 --prefix-cache-disk-limit 40GonQwen3.8-27B-NVFP4;--max-concurrency 8 --prefix-cache-disk-limit 24GonQwen3.8-Flash-Next), warming one ~61K-token shared prefix plus 8 child branches (~256 unique tail tokens each), restartingflare runfor empty VRAM, and sending 8 concurrent/v1/chat/completionsfollow-ups (ingress-to-first-token TTFT; read-reduction ratios are ratios of tabulated means):Qwen3.8-27B-NVFP4(TP1,60.5K, 2 interleaved repeats): physical NVMe reads drop18,177.5 -> 4,306.7 MB(2,274 MBsingle restore —472pages at128tokens/page plus101 MBcontinuation row, so18,177.5 MBis8xfull copies;4.22x,-76.3%), median TTFT7,974.6 -> 5,662.8 ms(-29.0%) simultaneous; and18,194.2 -> 4,843.6 MB(3.76x,-73.4%), TTFT6,883.6 -> 5,951.9 ms(-13.5%) at+25 msstagger.Qwen3.8-Flash-Next(TP1,61.0K): NVMe reads drop7,944.9 -> 1,981.1 MB(4.01x,-75.1%, TTFT3,327.5 -> 3,225.0 ms) simultaneous, and7,958.0 -> 2,251.5 MB(3.53x,-71.7%, TTFT3,137.7 -> 3,049.9 ms) at+25 msstagger.Recommended merge order with companion PR
#497(Selene pipeline prioritization and tighter2 * (64 + row_slots)intake pools): merge#497first, then rebase#496ontomainsoStaged::pump_allretainsMAINTENANCE_DEFER_LIMIT = 8and runshost_inboundandpump_device_inboundahead ofoutboundandmaintenance.Evidence
O_DIRECT+io_uring,ext4,rustc 1.100.0) on exactgit archive ba1c73fd6c0b0d08c612dd947ed47ceaee8ce457(tree0f5524389c086223a243a59388d58bd9ad17458b, base6d74db3a; merges cleanly againstorigin/main9031847a,selene/src/shard.rsdiff0bytes):cargo check --locked --release --manifest-path selene/Cargo.toml --all-targets: passed,0warnings (both with and without--features test-support).cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support:522lib +1mixed_codec_rootpassed,0failed,0ignored, including:header_identity_caches_digest_and_matches_header_equalityandpoll_at_full_window_credit_with_large_packed_header_avoids_demand_rebuild_and_rehashingpacked_restore_inbound_rate_includes_decode_delay_and_worth_fetching_rejects,sharded_inbound_rate_reflects_end_to_end_multi_rank_wall_time,coalesced_restores_keep_inbound_rate_end_to_end_and_bytes_in_logical,overlapping_shared_stream_tracks_slowdown_and_recovers_without_drift, andleader_private_failure_with_slow_follower_updates_inbound_rate_and_rejectstight_pool_waits_for_shared_ancestor_instead_of_starting_private_tail(row_slots = 1/130slots androw_slots = 8/144slots, assertingdisk_opens == 3,disk_window_reads == 5,coalesced_windows == 3) andtight_pool_wait_never_deadlocks_without_releasable_staged_slotssharded_concurrent_fetches_coalesce_across_rank_zero_and_peer(local TCPSharded+Peerviashard::serve, confirming Rank 0disk_opens == 5/disk_window_reads == 7/coalesced_windows == 9and Peer Rank 1 simultaneous live slab-address sharing)record_readinvalidation, misaligned follower partial-tail+row parity, private vs shared failure isolation, andStaged::closedraining.cargo test --locked --release --manifest-path selene-manager/Cargo.toml --test client --test offload:85 + 2passed,0failed,0warnings.cargo check --locked --manifest-path helios/Cargo.toml --features runtime-core,server --all-targets: passed (0warnings in touched crates).pytest tests/preparation/test_core_boundary.py tests/test_design_review_hook.py:22passed,0failed.0c04b1e2againstmainbefore v4 packed records (c0c4f798, raw v3 records /--lossless-kv-compressionoff):heliosoffload::(FLARE_RUN_CUDA_TESTS=1 --include-ignored) passed all21single-GPU SM121 tests (split_poolsrequires 2 local GPUs); live SM121 parity across 5 cold-VRAM restart repeats (seed = 1234..1238,60,534tokens,top_logprobs = 5) onQwen3.8-27B-NVFP4TP1 produced identical FP32top-5 logprobsand token IDs vsmain(c0c4f798) on all 5 repeats; and 4 concurrent decode streams spilling checkpoints over 30 s onQwen3.8-Flash-NextTP1 had0errors (100.0 -> 100.6 tok/s).flare runre-measurement onba1c73fd, live SM121--lossless-kv-compression(cpu/gpu) serving, multi-host RoCE serving, 2-GPUsplit_pools, discrete PCIe GPUs, Windows serving, and live warm-plus-disk (--prefix-cache-memory > 0) orPooledStoreHTTP serving (CompositeStore+DiskStoreCUDA transfers are covered inheliosoffload::).Discord: Dooner