#1 [high] Repo rules relevant to lens D (simplicity)
AGENTS.md (main):
- line ~9-14: "Solve the right problem in the right place. ... Look for the smallest footprint in shared code, or a way to solve it without new code at all."
- line ~188: "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement. Unsolicited formatting, renaming, comment expansion, annotation sweeps, and file rearrangements are not contributions by themselves. Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost."
- line ~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."
- line ~157 (scope): "Every contribution must address an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation."
- line ~449 Configuration: no env-var behavior switches. docs/design-review.md: principle 1 "Keep Helios as simple as possible." principle 15 reject scope expansion/weakened constraints; principle 4 "avoid interchangeable backends or portability layers."
#2 [high] should fix: the fixed defect's old path survives as the None default (three overlapping entry points)
selene/src/offload.rs:497-534 (prepare_with_inputs -> prepare_with_inputs_budget), :600-619 (match host_budget, None arm re-queries options.headroom_with_inputs), :117-146 (headroom_with_inputs still calls host_pool_budget), helios/src/offload/mod.rs:72-129 (three nested wrappers prepare -> prepare_with_inputs -> prepare_with_inputs_budget).
Only production caller is helios/src/runtime_core/model.rs:967 via prepare_with_inputs_budget with planned_host_budget, which is always Some when it can be non-None (prepare_offload returns early if !cfg.enabled(); allocate_caches returns Some whenever cfg.enabled()). So the None arm is dead in production and preserves exactly the re-query behaviour this PR set out to fix. prepare_with_inputs (selene + helios) is now used only by tests and helios/src/offload/pool/tests.rs:124.
Smaller version: make host_budget a plain u64 parameter of one entry point, delete the Option and the None arm, delete headroom_with_inputs (fold its host_pool_budget call into the callers) or keep it as a thin wrapper used only by external selene callers, and delete the duplicate helios wrapper. Saves ~40 lines and one #[allow(too_many_arguments)] and removes the buggy path from the compiled code. AGENTS.md "smallest footprint", "do not add ... fallback layers ... without a concrete requirement".
#6 [high] should fix: map_device_host_parts is now unreachable code, and map_split is a required trait method nobody calls
helios/src/cuda.rs:667-676 adds map_device_host_parts as a wrapper that turns try_map_device_host_parts's Ok(None) into an error. Its only caller is CudaRegistrar::map_split (helios/src/offload/registrar.rs:27-29). map_split is only reachable through the default body of the new HostRegistrar::try_map_split (selene/src/registrar.rs:32-37), and CudaRegistrar overrides try_map_split (registrar.rs:31-38). So in the workspace nothing ever calls map_device_host_parts: dead code kept alive only because map_split remains a required trait method.
map_split is still the required method, so every implementor must write it: selene/src/registrar.rs (trait), helios/src/offload/registrar.rs:27, selene/src/pool/builder.rs:311, selene/src/pool/startup.rs:223 (ClosedRegistrar), selene/src/pool/net.rs:976, selene/src/pool/engine/tests.rs:155, selene/src/pool/engine/net_tests.rs:44, selene/src/testing.rs:453 and :490, selene/src/offload/tests.rs:800, selene-manager/tests/client.rs:1100, :1298, :3147 -- ~12 impls of a method the production path (selene/src/slab.rs:215) no longer calls.
Smaller version: make try_map_split the trait's single required method (no default), delete map_split from the trait and all 12 impls (each becomes Ok(self.map_split(...).map(Some)) one-liner or, for CudaRegistrar, just the try_ body), and delete map_device_host_parts from cuda.rs. Removes ~10 arms of boilerplate plus 10 lines of cuda.rs. AGENTS.md line ~188 "Do not add ... fallback layers ... without a concrete requirement"; tests should exercise the production entry point (line ~194).
Unrelated nit seen in the same C diff: cuda.rs now repeats the same 5-line "status = call(...); if is_host_numa_unsupported(status) { return Ok(None) } ; check(name, status)" pattern four times (:576-589, :641-650, :652-660 area). One helper taking the call's status + name would be half the lines; four copies invite one of them being missed on the next edit.
Also: mapping raw status 1 (CUDA_ERROR_INVALID_VALUE) to "unsupported" means a genuinely invalid argument in cuMemCreate/cuMemSetAccess silently downgrades the pool to a registered anonymous mapping instead of surfacing a bug (charter: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)"). If the intent is only "platform lacks HOST_NUMA VMM", say what would settle it: a hardware test on GA10B/WDDM that a bad-granularity call still errors.
#8 [high] should fix: two new tests can pass without asserting anything
Two new tests added by this PR pass without asserting anything on the machines where they run in CI:
-
eos/src/unix.rs:206-248
map_host_advises_hugepages_and_prefaults_zeroed_pages: the assertion sits insideif let Ok(smaps) = std::fs::read_to_string("/proc/self/smaps"), thenif let Some(start) = smaps.find(needle), thenif let Some(flags) = ..., thenif let Some(end) = ...— four nestedif lets, 30 lines of hand-rolled VMA-block scanning (finding the next hex-address line by re-counting line lengths). If any lookup misses, the test asserts nothing and passes. The zeroed-page check above it does assert, so the test is named for behaviour it may not check. -
helios/src/execution/roce.rs:511-523
lazy_libibverbs_loader_resolves_symbols_or_reports_install_hint:if status != 0 { assert!(text.contains(...)) }. When libibverbs1 is installed — which is the case on the dev/GPU boxes and on any runner withlibibverbs-dev— status is 0 and the test body is empty. It cannot fail in either direction, so it does not establish either outcome.
AGENTS.md ~line 194: "Require focused, meaningful validation. Tests must exercise the affected behavior or contract ... cannot establish runtime correctness." A test whose assertion is conditional on the environment is exactly that.
Fix for (2): assert the branch that applies, e.g. match status { 0 => assert!(/* dlopen handle usable */), _ => assert!(hint) } — or simply drop it, since the CI container smoke test (release.yml:110-121) already proves loading without libibverbs and a loaded-lib path is covered by any RoCE hardware run. Fix for (1): pull the smaps block out into a helper returning Option<&str> and expect("mapping VMA in /proc/self/smaps"); the length re-counting loop collapses into a .lines() skip_while/ take_while.
Both should fix (they cost 40 lines and prove nothing); nit if reviewers accept them as documentation of intent.
#9 [high] FINAL REPORT lens D (supersedes note #5)
This supersedes note #5. Lens D (simplicity): what can be deleted.
Repo rules
AGENTS.md ~9-14 "Look for the smallest footprint in shared code, or a way to solve it without new code at all"; ~188 "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement"; ~194 "Tests must exercise the affected behavior or contract"; ~157 scope. docs/design-review.md principle 1 "Keep Helios as simple as possible", 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 (#397)".
Findings
-
should fix — the fixed defect's old path survives as the
Nonedefault (three overlapping entry points). selene/src/offload.rs:497-534, :600-619, :117-146; helios/src/offload/mod.rs:72-129. Only production caller is helios/src/runtime_core/model.rs:967 throughprepare_with_inputs_budgetwithplanned_host_budget, which isSomewhenevercfg.enabled()(memory.rs:1102-1112;prepare_offloadreturns early at model.rs:933 when not enabled). So theNonearm at :612 re-queriesoptions.headroom_with_inputs->host_pool_budget, i.e. exactly the post-KV-alloc re-query this PR set out to remove, still compiled in and still the default for every other caller.prepare_with_inputs(both crates) now has only test/helios offload pool test callers (selene/src/offload/tests.rs, sharded/tests.rs, helios/src/offload/pool/tests.rs:124, selene-manager/tests/client.rs:3204). Fix: one entry point takinghost_budget: u64; delete theOption, theNonearm, theprepare_with_inputsshim in both crates, and the duplicated#[allow(clippy::too_many_arguments)]. ~40 lines fewer, one buggy path less. -
should fix —
map_device_host_partsis unreachable andmap_splitis a required trait method with no production caller. helios/src/cuda.rs:667-676; helios/src/offload/registrar.rs:27-38; selene/src/registrar.rs:26-37; selene/src/slab.rs:189-270.map_device_host_partsis called only byCudaRegistrar::map_split, reachable only via the default body oftry_map_split, whichCudaRegistraroverrides; production goes throughtry_sized_by_rank->try_map_split(slab.rs:215).map_splitstays a required method forcing ~12 boilerplate impls (registrar.rs:27, pool/builder.rs:311, pool/startup.rs:223, pool/net.rs:976, pool/engine/tests.rs:155, pool/engine/net_tests.rs:44, testing.rs:453 and :490, offload/tests.rs:800, selene-manager/tests/client.rs:1100/1298/3147). Same story forSlabPool::sized_by_rank(slab.rs:261-270): production usestry_sized_by_rank; remaining callers are the ignored GPU benchmark helios/src/offload/transfer.rs:1723 and the test at slab.rs:631. Fix: maketry_map_splitthe trait's only required method, deletemap_splitfrom trait and impls, deletemap_device_host_parts, and dropsized_by_rank(slab.rs:631 can calltry_sized_by_rank(...).unwrap()), with transfer.rs:1723 doing the same. -
should fix — two new tests assert conditionally, so they pass without proving anything. eos/src/unix.rs:206-248: the
hgVmFlags assertion sits behind four nestedif lets (smaps readable, address found, next VMA found, VmFlags present) and 30 lines of hand-rolled block scanning; any miss => no assertion. helios/src/execution/roce.rs:511-523:if status != 0 { assert!(hint) }— empty when libibverbs1 is installed (the normal case on GPU hosts and on any runner with libibverbs-dev), so it cannot fail either way. Fix: hoist the smaps lookup into a helper returningOption<&str>and.expect(...)it (the line-length re-counting becomes.lines().skip_while().take_while()); for the roce test assert the applicable branch or drop it — release.yml:110-121's clean-container smoke check already proves the no-libibverbs path. -
should fix — integrated-memory accounting computed twice in one function. helios/src/runtime_core/memory.rs:646-683 (
integrated_state) vs :878-909 (per-rank loop): min-free over integrated ranks, thefixed_bytes(core, true)+embedding_host_bytesfold, andfixed.max(initial-free-delta)are written twice, ~200 lines apart, and already disagree (mintotalvsobservations[index].total; max observed drop vs per-index). Fix: build oneVec<(MemorySnapshot, u64)>of per-integrated-rank state and use it in both places. ~20 lines fewer. -
nit —
host_pool_budget_with_reserve's bool has one caller. selene/src/offload.rs:852-886:host_pool_budgetforwards(future, true); nothing else calls the two-argument form. Fix: keephost_pool_budget_from(available, total, future, apply_reserve)(helios needs thefalsecase) and have the meminfo-reading helper be the onlyapply_reserve = trueuser; delete_with_reserve. -
should fix (stale doc) — helios/src/frontend/mod.rs:1400-1402 still documents the reserve as "
HOST_SERVICE_HEADROOM_BYTES(2 GiB) plus one twentieth of total memory". The PR changed it to 64 MiB at <=16 GiB,min(2 GiB, total/32)above, and updated docs/prefix-cache-offload.md:1141-1144 but not this comment. One-line fix.
Clean in this lens
- helios/src/cuda.rs copy fallback:
copy_dtodkeepscuMemcpyDtoDAsync_v2forcopy_dtod_async(used by offload/transfer/gpu_codec.rs:525, :620),copy_asyncfor the batch fallback — two symbols, both needed, no dead branch. - helios/build.rs: dropping
-libverbsfor-libdlis a net deletion;roce_proxy_dlopen.c's 17 trampolines are forced by not being able to edit the vendored file (roce_proxy.c:6-8). - release.yml: the removed
runtime-packagesmatrix key and the "install libibverbs1 then smoke test" step are gone, not duplicated; ELF checks are 15 lines of script. - docs changes are edits to existing paragraphs, no new pages.
Not verified
Whether map_split is part of selene's public contract for out-of-tree consumers (publish = false, so unlikely); a grep in the repo shows no non-test caller.
#10 [high] Research summary
Lens D (simplicity) review of PR #589 complete; all 21 changed files read in context, callers followed, findings checked in the code. Full report is scratchpad entry #9 (supersedes #5); AGENTS.md (not opened)/design-review quotes in #1.
Six findings:
-
should fix — the fixed defect's old path survives as the
Nonedefault.prepare_with_inputs_budget'sOption<u64>(selene/src/offload.rs:523-619, mirrored in helios/src/offload/mod.rs:72-129) keeps aNonearm that re-querieshost_pool_budgetpost-KV-alloc — exactly the behaviour the PR removes — even though the only production caller (helios/src/runtime_core/model.rs:967) always passesSomewhen the prefix cache is enabled.prepare_with_inputsin both crates now has only test callers. One entry point taking a plainu64, deleting the shim and the duplicatetoo_many_argumentsallow, is ~40 lines smaller. -
should fix —
map_device_host_partsis unreachable andmap_splitis a required trait method nobody calls. helios/src/cuda.rs:667-676 is called only byCudaRegistrar::map_split, reachable only through thetry_map_splitdefault thatCudaRegistraroverrides;map_splitstill forces ~12 boilerplate impls across selene/selene-manager/helios. Same forSlabPool::sized_by_rank(slab.rs:261-270), now used only by one ignored GPU benchmark and one test. -
should fix — two new tests can pass without asserting anything. eos/src/unix.rs:206-248 hides the
hgVmFlags assertion behind four nestedif lets plus 30 lines of hand-rolled smaps scanning; helios/src/execution/roce.rs:511-523 is an emptyif status != 0whenever libibverbs1 is installed, so it cannot fail either way. -
should fix — integrated-memory accounting written twice in one function (helios/src/runtime_core/memory.rs:646-683 vs :878-909), and the two copies already disagree on min-total and on the observed-drop basis.
-
nit —
host_pool_budget_with_reserve(future, true)has a single caller (selene/src/offload.rs:852-886). -
should fix (stale doc) — helios/src/frontend/mod.rs:1400-1402 still describes the old unscaled "2 GiB plus one twentieth" reserve that this PR replaced.
The CUDA copy fallback (two driver symbols, both used), the -libverbs → -libdl build change, roce_proxy_dlopen.c, release.yml and the docs edits are clean in this lens — deletions, not new layers.
#11 [high] Coverage: lens-D verdict for each of the 21 changed files
Companion to note #9 (the full report). Every file the PR touches, and its lens-D verdict:
Findings:
- selene/src/offload.rs (+134/-14) -> finding 1 (Option/None arm, prepare_with_inputs shim) and finding 5 (host_pool_budget_with_reserve). New helpers
host_service_headroom_bytes/host_reserve_bytes/host_pool_budget_fromare justified server-side deletions of a duplicated formula (memory.rs previously had its ownintegrated_host_bytes). - helios/src/offload/mod.rs (+27/-1) -> finding 1 (duplicate wrapper crate-side).
- helios/src/cuda.rs (+57/-22) -> finding 2 (unreachable
map_device_host_parts) plus the four-foldis_host_numa_unsupportedrepetition and the status-1-swallowing note in note #6. Thecopy_asyncfallback itself is clean: two driver symbols, both used (copy_dtod stays forcopy_dtod_async, gpu_codec.rs:525/:620). - selene/src/slab.rs (+27/-12) -> finding 2 (
sized_by_ranktest-only). - helios/src/offload/registrar.rs (+8), selene/src/registrar.rs (+11) -> finding 2.
- eos/src/unix.rs (+60/-1) -> finding 3 (vacuous smaps test). The
MADV_POPULATE_WRITE+write_volatilefallback is the documented prefault, not a parallel path: the cfg split is by OS only. - helios/src/execution/roce.rs (+20/-1) -> finding 3 (vacuous loader test).
- helios/src/runtime_core/memory.rs (+152/-22) -> finding 4 (duplicated integrated accounting).
- helios/src/frontend/mod.rs (not in the diff) -> finding 6, stale 2 GiB comment the PR should have updated.
Clean (no simplicity finding):
- helios/src/runtime_core/model.rs (+7/-5): the
Option<u64>threaded allocate_caches -> prepare_offload is the same coupling as finding 1; not reported separately because once finding 1 is applied it becomes a plainu64. - helios/native/roce_proxy_dlopen.c (+236): the 17 trampolines are forced — roce_proxy.c:6-8 requires the vendored file stay byte-identical, so the
#define ibv_*rewrite is the only way to redirect without editing it. Not a spurious portability layer. - helios/build.rs (+3/-2): net deletion (
-libverbs->-libdl), one extra rerun-if-changed. - .github/workflows/release.yml (+54/-28): the removed
runtime-packagesmatrix key and the "apt install libibverbs1 then smoke test" step are gone, not duplicated; the build-in-container and the two ELF checks replace three runner-installed paths with one. - selene/src/offload/tests.rs (+159): new budget/HOST_NUMA-fallback tests do exercise production entry points (
prepare_with_inputs_budget,prepare), unlike finding 3's two. - flare/Cargo.toml, flare-cli/Cargo.toml, helios/Cargo.toml (comment-only corrections, +2/-2 each).
- docs/multi-host.md, docs/release.md, docs/runtime-core-design.md, docs/prefix-cache-offload.md: edits to existing paragraphs, no new pages; prefix-cache-offload.md:1141-1144 is the correctly updated reserve description that frontend/mod.rs failed to mirror.
Not verified: whether map_split (selene/src/registrar.rs:26) is contract for out-of-tree consumers — the crates are publish = false and no non-test caller exists in the workspace.
#3 [medium] should fix: map_device_host_parts / sized_by_rank left as test-only wrappers
helios/src/cuda.rs:667-676 map_device_host_parts and selene/src/slab.rs:261-270 sized_by_rank exist only to turn the new Ok(None) into an error. Production callers now use the try_ variants: helios/src/offload/registrar.rs:28 still impls map_split via map_device_host_parts (only reached through the trait default try_map_split, which CudaRegistrar overrides at :31-37 -> dead), selene/src/slab.rs:631 calls try_sized_by_rank; sized_by_rank remains only in helios/src/offload/transfer.rs:1723 and selene/src/slab.rs:631 (test). Fix: delete map_device_host_parts + the CudaRegistrar::map_split override (keep the trait default or make try_map_split the only method), and delete sized_by_rank (helpers used only by tests stay behind #[cfg(test)]). AGENTS.md rejection criteria: "Do not add ... fallback layers ... without a concrete requirement"; tests should call the production entry point. Severity: should fix (nit if reviewers prefer the by_rank naming preserved for docs).
#4 [medium] nit: host_pool_budget_with_reserve's bool flag has a single caller; stale 2 GiB comment
selene/src/offload.rs:852-886: host_pool_budget now just forwards to host_pool_budget_with_reserve(future, true); the only caller of _with_reserve is host_pool_budget (grep: no other caller). So the bool parameter and the extra public function are unused configuration. Fix: keep one host_pool_budget_from(available, total, future, apply_reserve) (needed by helios), and have the meminfo-reading helper hard-code apply_reserve=true, deleting host_pool_budget_with_reserve.
Also helios/src/frontend/mod.rs:1400-1402 comment still states the reserve is "HOST_SERVICE_HEADROOM_BYTES (2 GiB) plus one twentieth of total memory", which the PR changed to 64 MiB at <=16 GiB / min(2 GiB, total/32) above. Stale comment in untouched file -> should update with this PR (docs/prefix-cache-offload.md:1141-1144 was updated, this one was not).
Severity: nit (function), should fix (stale doc comment).
#7 [medium] should fix: integrated integrated-memory accounting is computed twice in the same function
helios/src/runtime_core/memory.rs:646-683 (integrated_state) and :878-909 (the if rank.integrated arm of the per-rank budget loop) are the same computation written twice, ~200 lines apart:
- min
freeover the integrated ranks (648-654 vs 880-886), - the
fixed_bytes(core, true)fold +embedding_host_bytes(662-673 vs 889-901), fixed.max(initial.free.saturating_sub(free))(674-681 vs 904). They already disagree in two places:totalis the min over integrated ranks in one andobservations[index].totalin the other, and the observed drop is max-over-integrated vs per-index;integrated_offload_host_budgetthen takesmemory.free.min(memory.total)for the same figure. Nothing shows a bug, but two subtly different definitions of "the shared budget" in one function is exactly how the next change diverges.
Smaller version: build one Vec<(MemorySnapshot, u64)> of per-integrated-rank (memory, loaded) once, use integrated_state for the headroom/pool closures and index the same vec in the loop; the initial[index] delta stays per-rank. Deletes ~20 lines. AGENTS.md "smallest footprint in shared code"; docs/design-review.md principle 1 "Keep Helios as simple as possible".