Lens D — simplicity: what can be deleted?
I read all 21 changed files in context (not only the diff), followed the callers of every function whose behaviour changed, and checked each finding in the code before writing it. Five of the six findings are places where this PR leaves the old path compiled in beside the new one, or adds code that proves nothing.
Repo rules this is judged against
AGENTS.md(not opened) ~9-14: "Look for the smallest footprint in shared code, or a way to solve it without new code at all."AGENTS.md(not opened) ~188: "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement. … Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost."AGENTS.md(not opened) ~194: "Require focused, meaningful validation. Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness."docs/design-review.md(not opened) principle 1 "Keep Helios as simple as possible" and principle 4 (avoid interchangeable backends or portability layers).- Charter: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error." (relevant to finding 2's
Ok(None)narrowing.)
Key findings
| # | Severity | Where | One line |
|---|---|---|---|
| 1 | should fix | selene/src/offload.rs:497-534, :600-619; helios/src/offload/mod.rs:72-129 |
The post-KV-alloc re-query this PR removes survives as the None default of host_budget: Option<u64>, kept alive by a shim with no production caller. |
| 2 | should fix | helios/src/cuda.rs:667-676; selene/src/registrar.rs:26-37; helios/src/offload/registrar.rs:27-38; selene/src/slab.rs:261-270 |
map_device_host_parts is unreachable, yet map_split stays a required trait method forcing ~12 boilerplate impls. |
| 3 | should fix | eos/src/unix.rs:206-248; helios/src/execution/roce.rs:511-523 |
Two new tests guard their assertion behind an if, so they pass without asserting anything on the machines they run on. |
| 4 | should fix | helios/src/runtime_core/memory.rs:646-683 vs :878-909 |
The integrated-memory accounting is written twice, ~200 lines apart, and the two copies already disagree. |
| 5 | should fix (stale doc) | helios/src/frontend/mod.rs:1400-1402 |
The comment still describes the old unscaled "2 GiB plus one twentieth" reserve that this PR replaced. |
| 6 | nit | selene/src/offload.rs:852-886 |
host_pool_budget_with_reserve(future, apply_reserve) has exactly one caller and always true. |
Findings
1. should fix — the fixed defect's old path survives as the None default
Files/lines: selene/src/offload.rs:497-520 (prepare_with_inputs shim), :522-534 (prepare_with_inputs_budget signature, host_budget: Option<u64>), :603-619 (the match host_budget { Some(..) => …, None => options.headroom_with_inputs(..) }); mirrored in helios/src/offload/mod.rs:82-129.
What is wrong. The whole point of the change is that on unified memory the host budget must be computed before KV allocation and then reused, because prepare_offload re-evaluating host_pool_budget post-KV-alloc is the bug. That re-evaluation is still compiled in as the None arm:
let (_, host) = match host_budget {
Some(budget) => options.headroom_with_inputs_for_budget(…, budget)?,
None => options.headroom_with_inputs(…) ?, // offload.rs:612-618 — the old behaviour
};
The only production caller always passes Some: helios/src/runtime_core/model.rs:967-977 forwards planned_host_budget, which is Some whenever the prefix cache is enabled (helios/src/runtime_core/memory.rs:1102-1112), and prepare_offload returns early at model.rs:933 when it is not enabled. So the None arm is unreachable from production but is the default for every other caller, and it keeps headroom_with_inputs alive as a second, divergent sizing path — exactly the two-way accounting this PR was meant to collapse.
Second layer of the same thing. prepare_with_inputs (selene/src/offload.rs:497, helios/src/offload/mod.rs:82) now exists only to pass None. Verified callers: selene/src/offload.rs:492 (from prepare), selene/src/offload/tests.rs:33/70/164/508/670, selene/src/offload/sharded/tests.rs:108 (not opened)/247/375/537, selene-manager/tests/client.rs:3204 (not opened), and helios/src/offload/pool/tests.rs:124. No production caller in the workspace. Two #[allow(clippy::too_many_arguments)] attributes (selene/src/offload.rs:522, helios/src/offload/mod.rs:105) exist to carry the duplicated 10-argument signature.
Fix (smaller version). One entry point taking host_budget: u64; delete the Option, delete the None arm, delete the prepare_with_inputs shim in both crates and the second too_many_arguments allow. model.rs:931/:967 then pass a plain u64 (it becomes non-optional once the None case is gone, since prepare_offload already returns early when the cache is disabled). Callers that genuinely want the meminfo-derived budget call headroom_with_inputs themselves, once, at the same place memory.rs already does. ~40 lines fewer, one buggy path fewer.
2. should fix — map_device_host_parts is unreachable and map_split is a required trait method with no production caller
Files/lines: helios/src/cuda.rs:667-676 (map_device_host_parts), helios/src/offload/registrar.rs:27-29 and :31-38, selene/src/registrar.rs:26 (required map_split) and :32-36 (default try_map_split that forwards to it), selene/src/slab.rs:189-252 (try_sized_by_rank) and :261-270 (sized_by_rank).
What is wrong. map_device_host_parts turns try_map_device_host_parts's Ok(None) back into an error. Its only caller is CudaRegistrar::map_split (helios/src/offload/registrar.rs:28). map_split is only reachable through the default body of HostRegistrar::try_map_split (selene/src/registrar.rs:36), and CudaRegistrar overrides try_map_split (registrar.rs:31-38), which is what production reaches via SlabPool::try_sized_by_rank (selene/src/slab.rs:215). A workspace-wide search finds no other caller of map_device_host_parts: it is dead code held alive only because map_split remains the trait's required method.
Because it is required, every implementor must write it anyway: selene/src/registrar.rs:26, helios/src/offload/registrar.rs:27, selene/src/pool/builder.rs:311 (not opened), selene/src/pool/startup.rs:223, selene/src/pool/net.rs:976 (not opened), selene/src/pool/engine/tests.rs:155 (not opened), selene/src/pool/engine/net_tests.rs:44 (not opened), selene/src/testing.rs:453 and :490, selene/src/offload/tests.rs:800, selene-manager/tests/client.rs:1100 (not opened), :1298, :3147 — ~12 stubs of a method the production path no longer calls, several of which are unimplemented!-style placeholders that would now be unnecessary.
SlabPool::sized_by_rank (selene/src/slab.rs:261-270) has the same shape: production uses try_sized_by_rank (selene/src/offload.rs:631); the remaining callers are the ignored GPU benchmark helios/src/offload/transfer.rs:1723 and the unit test selene/src/slab.rs:631.
Fix (smaller version). Make try_map_split the trait's single required method (drop the defaulted/required pair), delete map_split from the trait and from all ~12 impls, and delete map_device_host_parts from cuda.rs together with the doc comment at cuda.rs:667-668. Drop sized_by_rank; slab.rs:631 and transfer.rs:1723 call try_sized_by_rank(...).unwrap() / ?+ok_or, one line each. Small bonus in the same function: cuda.rs now repeats the same five-line let status = call(…); if is_host_numa_unsupported(status) { return Ok(None); } driver.check(name, status)?; pattern four times (:576-589, :641-650, :652-660 and neighbours) — one helper taking (name, status) halves those lines and makes it impossible for the next edit to miss one.
3. should fix — two new tests pass without asserting anything
Files/lines: eos/src/unix.rs:206-248 (map_host_advises_hugepages_and_prefaults_zeroed_pages), helios/src/execution/roce.rs:511-523 (lazy_libibverbs_loader_resolves_symbols_or_reports_install_hint).
What is wrong.
- The eos test's
hgVmFlags assertion sits behind four nestedif lets (smaps readable, address found, next VMA found,VmFlags:present) plus ~30 lines of hand-rolled VMA-block scanning that recovers the block end by re-counting hex lines. Any miss and the test asserts nothing and passes — on exactly the hosts where smaps parsing is fragile. The zeroed-page check above it does assert, so the test name promises behaviour it may not check. - The roce test is
if status != 0 { assert!(hint) }. Whenlibibverbs.so.1is installed — the normal case on GPU hosts and on any runner withlibibverbs-dev—status == 0and the body is empty. It cannot fail either way, so it establishes neither of the two outcomes its name claims.
AGENTS.md (not opened) ~194 asks for tests that "exercise the affected behavior or contract". selene/src/offload/tests.rs shows the pattern done right (the new budget tests do call prepare_with_inputs_budget and prepare).
Fix (smaller version). eos: hoist the smaps lookup into a helper returning Option<&str> for the block, then .expect("mapping VMA in /proc/self/smaps") — the length re-counting collapses to .lines().skip_while(..).take_while(..), and the test fails loudly when it cannot check. roce: assert the applicable branch (0 => assert!(handle resolves a symbol), _ => assert!(hint)), or delete it — release.yml:110-121's clean-container smoke check already proves the no-libibverbs1 path, and a loaded-library run is covered by any RoCE hardware run. Either way ~40 lines and one vacuous green check go away.
4. should fix — integrated-memory accounting computed twice in one function
Files/lines: helios/src/runtime_core/memory.rs:646-683 (integrated_state) vs :878-909 (the per-rank loop inside the same function).
What is wrong. Three computations appear twice, ~200 lines apart: the min free over integrated ranks (:648-654 vs :880-886), the fixed_bytes(core, true) + embedding_host_bytes fold (:662-673 vs :889-901), and fixed.max(initial - free) (:681 vs :904). The two copies already disagree: :655-661 takes min total over integrated ranks while :887 uses observations[index].total; :674-681 takes a max observed drop over integrated ranks while :904 uses initial[index]. Whatever the intended semantics, two live expressions of it in one function is the shape that produced the original budgeting bug.
Fix (smaller version). Compute per-integrated-rank state once into a Vec<(MemorySnapshot, u64)> right after observations (:640-645) and index it in both the host_budget_for closure (:684-694) and the loop (:877-909). ~20 lines fewer and one place to change the rule.
5. should fix (stale doc) — the reserve comment this PR obsoleted
File/line: helios/src/frontend/mod.rs:1400-1402: "…the headroom host_pool_budget (selene/src/offload.rs) leaves unallocated: HOST_SERVICE_HEADROOM_BYTES (2 GiB) plus one twentieth of total memory."
That formula is no longer what host_pool_budget does: this PR replaced it with host_service_headroom_bytes — 64 MiB at <= 16 GiB, min(2 GiB, total / 32) above — and host_reserve_bytes (selene/src/offload.rs), and it updated the prose in docs/prefix-cache-offload.md:1141-1144 accordingly. This file was not touched, so the code comment now contradicts the code it documents, in the one place a maintainer looks to size a second encoding.
Fix. One-line edit to point at host_service_headroom_bytes / host_reserve_bytes and drop the numbers, or repeat the new formula.
6. nit — host_pool_budget_with_reserve's bool has one caller and one value
File/line: selene/src/offload.rs:852-886. host_pool_budget(future) is host_pool_budget_with_reserve(future, true); nothing else in the workspace calls the two-argument form (search: only :853). The false case is served by the separately named host_pool_budget_from(available, total, future, apply_reserve) that helios/src/runtime_core/memory.rs needs.
Fix. Let the meminfo-reading helper be the sole in-crate user of apply_reserve = true and delete host_pool_budget_with_reserve, or reduce it to a private free function with no flag. Keeps the public surface to the two names the PR actually needs.
Clean in this lens (checked, nothing to report)
helios/src/cuda.rscopy fallback (+57/−22 beyond finding 2): two driver symbols, both used —copy_dtodkeepscuMemcpyDtoDAsync_v2forcopy_dtod_async(offload/transfer/gpu_codec.rs:525(not opened),:620),copy_asyncserves the batch fallback. No dead branch, no third path.helios/native/roce_proxy_dlopen.c(+236): the 17 trampolines are forced, not a speculative portability layer — the vendoredhelios/native/roce_proxy.c:6-8must stay byte-identical, so#define ibv_*rewriting is the only way to redirect without editing it.helios/build.rs(+3/−2): net deletion (-libverbs→-libdl), one extrarerun-if-changed..github/workflows/release.yml(not opened) (+54/−28): theruntime-packagesmatrix key, the "apt install libibverbs1 then smoke test" step, and the runner-installed build path are removed, not duplicated; the build-in-container plus two ELF checks (nolibibverbs.soDT_NEEDED, noGLIBC_above 2.35) replace them in ~15 lines of script.helios/src/runtime_core/model.rs(+7/−5): theOption<u64>threaded throughallocate_caches→prepare_offloadis the same coupling as finding 1; not reported separately because it becomes a plainu64once finding 1 is applied.selene/src/offload/tests.rs(+159): the new budget/HOST_NUMA-fallback tests do exercise production entry points (prepare_with_inputs_budget,prepare) and the OOM-propagation case — the opposite of finding 3.eos/src/unix.rsprefault beyond the test:MADV_POPULATE_WRITEwith a page-stridewrite_volatilefallback is the documented prefault, cfg-split by OS only, not a parallel path.- New selene helpers
host_service_headroom_bytes/host_reserve_bytes/host_pool_budget_from: a server-side deletion of a duplicated formula (memory.rspreviously had its own integrated-host calculation). - Cargo.toml comment fixes (
flare,flare-cli,helios) and docs (multi-host.md,release.md,runtime-core-design.md,prefix-cache-offload.md): edits to existing paragraphs, no new pages, no new options.
Open questions / not verified
- Whether
HostRegistrar::map_split(selene/src/registrar.rs:26) is part of a contract for out-of-tree consumers. The crates arepublish = falseand no non-test caller exists in the workspace, so finding 2 is safe on the code — but only a maintainer can confirm no external consumer implements the trait. - Finding 2's
Ok(None)narrowing: mapping raw status 1 (CUDA_ERROR_INVALID_VALUE) to "unsupported" also swallows a genuinely invalid argument tocuMemCreate/cuMemSetAccessand silently downgrades the pool to a registered anonymous mapping (charter: fix the root cause, don't swallow). I could not settle from code whether GA10B/WDDM can return 1 for a valid request; a hardware test that a bad-granularity call still errors on GA10B/WDDM would. - Whether
prepare_offload'sOptionis everNonein practice beyond the disabled case:memory.rs:1102-1112showsSomefor bothcaptureandcfg.enabled(), andmodel.rs:933returns early when disabled, soNonelooks unreachable — but that is a claim about the current two call sites, not a type-level guarantee, which is why finding 1's fix is to make it unrepresentable. - Untested hardware paths (aarch64 native build,
ubuntu-24.04-armCI, discrete CUDA 12.x, GA10B, Windows WDDM) remain untested, as the PR itself states; nothing in this lens depends on them.