Recommendation: Ready To Merge
Head f2d03bc resolves the Round 1 review items—rebasing onto main 8da73911 (which includes the #624 fix for the pre-existing Python CPU tests failure), recording the unrun served flare run A/B and live RDMA/ARM64 checks in docs/TODO.txt:1-6, and strengthening the Linux adaptive allocator with Mems_allowed_list NUMA filtering, two-consecutive-compact_stall confirmation, and full single-VMA anchoring when both mapping endpoints are PMD-aligned. Independent verification of eos/src/unix.rs, selene/src/offload.rs, helios/src/offload/mod.rs, and helios/src/runtime_core/model.rs confirms the RAII MappingGuard, errno propagation, single-VMA merge geometry, public API compatibility, and startup timing/progress wiring are sound with no remaining blockers or regressions; confirm green CI on f2d03bc before merging.
Merge Risk
Level: Medium
- Shared host-slab allocator (
eos/src/unix.rs): Every contiguous host prefix-cache slab (selene/src/slab.rs:164) and remote pool staging buffer (selene/src/pool/shm.rs:78, called fromselene/src/pool/net.rs:95) allocates througheos::map_host, and non-EINVAL/ENOSYSpopulation errors now abort startup cleanly viaMappingGuardunmap instead of falling back to volatile writes. The adaptive thresholds are compile-time heuristics without a runtime override, though they run only at startup/channel setup (never on the inference hot path) and preserve the single-VMA contract required bycuMemHostRegister_v2andibv_reg_mr. - Deferred end-to-end hardware checks: Standalone
eos::map_host+ discrete SM120cuMemHostRegister_v2A/B benchmarks and SM121 CUDA DMA checks were verified prior to the rebase onto8da73911(with unchanged allocator VMA/DMA behavior), while fullflare runend-to-end A/B timing, live RDMAibv_reg_mr, and 16 KiB/64 KiB ARM64 kernel runs remain unrun and tracked indocs/TODO.txt:1-6. - Cross-PR coordination: Open PRs #576 (
eos/src/unix.rs), #628 (helios/src/offload/mod.rs,helios/src/runtime_core/model.rs,docs/prefix-cache-offload.md), and #621 (docs/TODO.txt,docs/prefix-cache-offload.md) touch overlapping files and will require standard rebase coordination depending on merge order (#323is now closed).
Walkthrough
eos/src/unix.rs:88-766, 830-1354: Rewritesmap_hostaroundmap_host_with(:737-747) and RAIIMappingGuard(:139-181, rejectingbytes == 0withEINVALand unmapping on population failure), retriesMADV_POPULATE_WRITEonEINTRwith page-strided volatile fallback only onEINVAL/ENOSYS(:511-537), bounds all Unix prefault calls to 64 MiB chunks (:88, 539-555), and adds Linux THP sysfs policy inspection (:184-264, 442-465) selecting among base/opportunistic chunking, eagerMADV_HUGEPAGE, and adaptive PMD-aligned chunking (:566-702) withanon_vmapre-anchoring,/proc/self/statusMems_allowed_listNUMA-filtered/proc/buddyinforeserve checks (:270-386, 468-481), latency + two-consecutive/proc/vmstatcompact_stallfallback (:398-439, 650-681), and a final whole-rangemadviseVMA merge (:693-700). Adds 11 new unit and live/proc/self/smapstests (:854-1353).selene/src/offload.rs:331-340, 368, 415-480, 573-789: AddsPrepareTimings(slab_populate,cuda_register,disk_scan) toPrepared, introducesprepare_with_inputs_budget_with_progress(:595) while keepingprepare_with_inputsandprepare_with_inputs_budgetintact (:562-592), shares the contiguous populate/register path for split-by-rank fallback (:702-730), emits step labels before split allocation, contiguous population, CUDA registration, and disk scanning, and appendsallocate/populate/register/scanelapsed durations insidePrepared::summary()while preserving restore-only and disabled summaries unchanged (:415-475).selene/src/offload/tests.rs:1107-1380: Adds four isolated unit tests verifying emitted step sequences,PrepareTimings, andPrepared::summary()across split-by-rank, split-to-contiguous fallback, contiguous + disk, and degraded/sharded restore-only paths.helios/src/offload/mod.rs:30-33, 82-120&helios/src/runtime_core/model.rs:966-979: Re-exportsPrepareTimings, delegates existingprepare_with_inputs_budgetto newprepare_with_inputs_budget_with_progress, and wires|step| phase.detail(step)inNativeModel::prepare_offloadwhile keeping thePrepare host prefix cachelabel andStartupStageunchanged.docs/prefix-cache-offload.md:517-536, 990-996&docs/TODO.txt:1-6: Documents Unix bounded chunking, Linux THP policy-aware slab population, single-VMA merging, and live step/timing reporting; records deferredflare runA/B, live RDMAibv_reg_mr, 16 KiB/64 KiB ARM64 kernel checks, and theselene-manager/src/arena.rsMADV_HUGEPAGEaudit indocs/TODO.txt.
Pre-merge Checks
- [PASS] Security / malicious screen: Read-only
/sys/kernel/mm/transparent_hugepage/*,/proc/self/status,/proc/buddyinfo, and/proc/vmstatreads plus standardmmap/madvise/munmapsyscalls; no new dependencies, env switches, network I/O, or unsafe untrusted input handling. - [PASS] Charter & value fit: Fixes reproducible bug #616 (caused by #589) in the shared runtime allocator layer without adding CLI switches or model-specific logic, preserves core/ABI compatibility, and records unrun checks in
docs/TODO.txt:1-6perAGENTS.md:57-58(standalone SM120 A/B backs the allocator speedup; servedflare runA/B per #210 /docs/design-review.md:109-115is explicitly deferred and tracked). - [WARN] Related / duplicate / conflict check: Not duplicated on
main(selene-manager/src/arena.rs:93audit tracked indocs/TODO.txt:5-6); rebase/merge-order coordination needed with open #576 (eos/src/unix.rs), #628 (helios/src/offload/mod.rs,helios/src/runtime_core/model.rs,docs/prefix-cache-offload.md), and #621 (docs/TODO.txt,docs/prefix-cache-offload.md). - [WARN] Tests & verification evidence: Full
--locked --releaseCPU test suites (eos12,selene552+1,helios1,748+62,flare245,flare-cli227) andselene --tests --features rdmacompile check are reported passing onf2d03bc, and all new tests are well-isolated with faithful stubs; however, CI job status onf2d03bccould not be inspected from available tools and the end-to-endflare runA/B + live RDMA checks are deferred indocs/TODO.txt:1-6.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Collapse
PopulationMode::KernelDefaultOpportunisticinto one unadvised variant (eos/src/unix.rs:116-121, 254-258, 709-712, 997-999, 1240):KernelDefaultOpportunisticandBasePagesexecute the identical unadvisedpopulate_chunksarm inpopulate_linux(:710) and share the identical no-op arm in tests (:1240). Collapsing both into a single variant (e.g.,NoAdvice/Unadvised) with a short comment inselect_population_modeexplaining bothenabled=neverandenabled=always(defrag=madvise|defer+madvise) removes a dead runtime state while keeping the distinction clear. - Drop mirrored alignment arithmetic in
map_host_advises_hugepages_and_prefaults_zeroed_pages(eos/src/unix.rs:1204-1242): Lines:1218-1238re-implementpopulate_adaptive_with'saligned_start/aligned_endcalculation to guard anhg || nhcheck across 4/16/64 KiB page sizes, whileadaptive_mid_mapping_fallback_merges_into_single_vma(:1249-1306) andpopulate_linux_applies_eager_and_base_page_policies(:1310-1352) already assert exactVmFlagsdeterministically. Keeping only the zeroed-page and single-VMA assertions (:1183-1203, 1244) removes ~38 lines of test-to-implementation coupling.
Nits
- Confirm CI passes on
f2d03bc(following the rebase onto8da73911/ #624) before merging, and note that the standalone SM120 A/B and SM121 CUDA DMA checks in the PR description predate the rebase (allocator VMA/DMA contract unchanged) while fullflare runA/B verification is tracked indocs/TODO.txt:1-6.
Dropped on verification
- Correctness #1 (
eos/src/unix.rs:695-700, closingmadvisescope onfell_back == false/fell_back == true): Dropped as factually flawed on both halves. Onfell_back == falsewithfallback_needs_nohugepage == true, every page is already populated writable and immediately pinned bycuMemHostRegister_v2(SlabPool::register/Region::register), so later swap-in compaction faults do not occur (andenabled=always, defrag=alwaysalready compacts on default faults regardless). Onfell_back == true, Linuxmadvise(2)has no "clear THP hint" operation, so merging sub-VMAs back into one VMA requires uniformMADV_HUGEPAGEorMADV_NOHUGEPAGE;MADV_NOHUGEPAGEpreserves already-allocated huge pages (FIXED_119G:AnonHugePages=43,454 MiBwithVmFlags nh) while stoppingkhugepagedfrom scanning the base-page tail, and the candidate's own suggestedif fell_back || fallback_needs_nohugepagefix did not even alter the fallback branch. - Correctness #2 (
selene/src/offload.rs:702-728,slab_populatespan excludes failed split-by-rank probe): Dropped as low-signal and contrary to intended timing semantics.try_map_device_host_parts(helios/src/cuda.rs:596-611) returnsOk(None)immediately on unsupportedHOST_NUMAVMM before mapping memory, and resetting the timer beforeSlabPool::sizedintentionally isolates host slab population time from CUDA driver queries;PrepareTimingsis startup diagnostic reporting rather than an admission-pricing metric. - Correctness #3 (
selene/src/offload.rs:706-736/helios/src/startup.rs:250-266, 325-328, static progress label during populate): Dropped as factually inaccurate and scope creep.StartupProgressredraws every 125 ms on TTYs (helios/src/startup.rs:250-251; 10 s applies only to non-TTY redirected logs), and emitting step details before split allocation, contiguous population, CUDA registration, and disk scanning matches both the PR description anddocs/prefix-cache-offload.md:990-996without threading progress callbacks intoeos::map_host. - Correctness #4 (
eos/src/unix.rs:450-465, per-call sysfs probing /OnceLock/ THP mode token insummary()): Dropped as low-signal and counterproductive.eos::map_hostruns only at startup (SlabPool::new) and pool staging setup (Region::anonymous), never on the request hot path; caching sysfs policy in aOnceLockwould break dynamic sysfs changes and complicate tests to save microseconds once at startup, and routingUnknownsysfs toAdaptiveHugepage { fallback_needs_nohugepage: true }is the safe conservative choice. - Subtraction S2 (
helios/src/offload/mod.rs:82-99, "new 17-line forwarder"prepare_with_inputs_budget): Dropped as factually false.pr_diffconfirmshelios::offload::prepare_with_inputs_budgetalready existed as apub fnonmain(and is still called byprepare_with_inputsat:79); forwarding it toprepare_with_inputs_budget_with_progresspreserves public API backwards compatibility. - Subtraction S3 (
eos/src/unix.rs:266-303, 343-347, 468-481, 723, deleteMems_allowed_listNUMA filtering): Dropped as factually inverted. Summing/proc/buddyinfoacross disallowed NUMA nodes errs in the unsafe direction (overestimating available huge pages for a NUMA-pinned process and triggering unnecessary compaction stalls on its allowed node before latency/stall fallback engages);read_mems_allowed_list()executes once permap_hostcall outside the chunk loop and is cleanly tested. - Value Prop scope-split suggestion (splitting timing plumbing into a second PR): Dropped as Round 2+ scope churn; both changes directly satisfy #616's explicit operator requests ("fall back promptly to base pages" and "separate startup timings for slab population and CUDA registration") and were not raised as a blocker in Round 1.