Final review report · NVIDIA/hyperflare-inference #589

Raw Markdown for agents: https://autobot.eidonix.com/p/826570a7-8067-43ab-bf37-118ca7b96227.md

Recommendation: Changes Requested

The core fixes (CUDA 12 cuMemcpyAsync fallback, lazy libibverbs.so.1 loading with Ubuntu 22.04 release builds, scaled unified-memory host reserves, HOST_NUMA fallback, and Eos MADV_HUGEPAGE ordering) are sound and address real defects without any proven correctness or memory-safety blockers. However, there are four verified issues worth resolving: a clamping/error-masking inconsistency in the duplicated integrated host-budget helper, a contradictory docstring on Stream::copy_batch, three stale docs/comments (including THIRD_PARTY_NOTICES.md bundled in release archives), and the unrun ubuntu-24.04-arm release check for the headline arm64 portability claim.


Blockers

None.


Should Fix

  1. Deduplicate integrated_offload_host_budget / integrated_state and fix clamping & capture-mode error masking (helios/src/runtime_core/memory.rs:195-221, 646-683 vs :267-298, 878-909)

    • In integrated_offload_host_budget, the None arm passes unclamped memory.free (raw /proc/meminfo MemAvailable) to host_pool_budget_from(memory.free, memory.total, future, true), whereas both Some arms (:209-210, :214) and limited_budget (:281) clamp memory.free.min(memory.total). When CUDA reports a smaller total_memory() than Linux MemAvailable, the None arm overstates the host budget relative to limited_budget.
    • When an explicit --memory-limit cap is smaller than loaded, integrated_offload_host_budget saturates to 0 (:216). In non-capture mode the subsequent limited_budget call at :920 still catches and reports "memory limit is {cap} bytes, but loaded model resources require {required} bytes", but in pool-only capture mode (--prefix-cache-pool without local memory/disk) headroom_with_inputs_for_budget (selene/src/offload.rs:170-172) aborts early at :833 with "host budget cannot hold a full pool capture", hiding the actual memory-limit diagnostic.
    • integrated_offload_host_budget repeats limited_budget(memory, loaded, limit, 0, true, future) arm-for-arm (only host_growth at :1022 wants .unwrap_or(0) when pool_host_charge exhausts remaining cap), and integrated_state (:646-683) repeats the integrated-rank snapshot/fixed-bytes fold at :878-909 with slightly different total (min() vs observations[index].total) and observed_drop (max() vs per-rank initial[index].free - memory.free).
    • Fix: Compute the integrated-rank snapshot/fixed bytes once after observations, and route host-budget calculation through limited_budget(memory, loaded, limit, 0, true, future) (using .unwrap_or(0) only for host_growth at :1022).
  2. Update Stream::copy_batch docstring to match the UVA fallback and its callers (helios/src/cuda.rs:781-790 vs :824-833, helios/src/execution/transport.rs:630, 1087-1093)

    • helios/src/cuda.rs:782-784 states: "Every address is a device address, including the device alias of registered host memory. CPU addresses of registrations are not necessarily GPU-accessible."
    • This contradicts both the fallback comment directly below (:826-827: "accepts device addresses, registered host aliases, and raw cuMemHostAlloc(..., flags=0) pointers") and the production caller helios/src/execution/transport.rs:630, 1087-1093, which allocates frame.input with model.host_buffer(...) (cuMemHostAlloc(..., flags = 0)) and passes frame.input.address() to copy_batch.
    • Fix: Update the copy_batch doc comment (:781-790) to document that UVA-accessible pinned host addresses (cuMemHostAlloc(..., flags = 0)) are valid alongside device addresses and registered host device aliases.
  3. Update stale comments and redistributed docs contradicted by this PR (helios/src/frontend/mod.rs:1400-1402, THIRD_PARTY_NOTICES.md:76-78, docs/prefix-cache-offload.md:1483-1485)

    • helios/src/frontend/mod.rs:1400-1402 still documents host_pool_budget as reserving HOST_SERVICE_HEADROOM_BYTES (2 GiB) plus one twentieth of total memory, overstating headroom by ~1.9 GiB on the 8–16 GiB unified-memory SoCs this PR changes to 64 MiB + total / 20 (selene/src/offload.rs:808-820).
    • THIRD_PARTY_NOTICES.md:76-77 (bundled inside every release archive per .github/workflows/release.yml:85 (not opened)) still states "Linux aarch64 builds also link the system libibverbs and pthread interfaces for RoCE." No build links libibverbs anymore (helios/build.rs:67-77 links only dl and pthread and dlopens libibverbs.so.1).
    • docs/prefix-cache-offload.md:1483-1485 (modified in this PR) still says `--all-features` enables the `roce` and `rdma` features, which link libibverbs, contradicting helios/Cargo.toml:26-30 (updated in this PR so roce loads libibverbs.so.1 lazily and only rdma links libibverbs).
    • Fix: Update all three passages to match the new host_reserve_bytes formula and lazy dlopen model.
  4. Run the ubuntu-24.04-arm release check and record unrun hardware validations in docs/TODO.txt (.github/workflows/release.yml:46-49 (not opened), 81-121, docs/TODO.txt)

    • The headline arm64 release portability claim (flare-linux-arm64.tgz glibc ≤ 2.35 and no libibverbs.so DT_NEEDED) was only validated on x86_64 in local Docker; the workflow's runnable ubuntu-24.04-arm leg (workflow_dispatch) was not run.
    • The unrun live-hardware validations disclosed in the PR description (discrete CUDA 12.x copy_batch, Jetson Orin GA10B, Windows WDDM HOST_NUMA fallback) are not recorded in docs/TODO.txt as required by AGENTS.md:57-58.
    • Fix: Run release.yml via workflow_dispatch to verify the arm64 artifact (ELF DT_NEEDED, glibc symbol ceiling, and clean Ubuntu 22.04/24.04 smoke checks), and record the remaining live-GPU checks in docs/TODO.txt.

Subtract / Simplify

  1. Collapse the prepare and headroom_with_inputs wrapper ladders (selene/src/offload.rs:117-206, 484-534, 603-619, helios/src/offload/mod.rs:72-129)

    • helios/src/offload/mod.rs:72-80 (pub fn prepare) has zero callers anywhere in the repository.
    • selene/src/offload.rs and helios/src/offload/mod.rs now carry 3-deep forwarding ladders (prepare → prepare_with_inputs → prepare_with_inputs_budget) with #[allow(clippy::too_many_arguments)] in both crates, plus duplicated enabled()/memory/disk/capture setup between headroom_with_inputs (:117-146) and headroom_with_inputs_for_budget (:151-206). Meanwhile, the post-KV-alloc re-query (host_budget: None at selene/src/offload.rs:612-618) survives as the default path for all callers outside NativeModel::prepare_offload.
    • Folding host_budget: Option<u64> (or a required host_budget: u64 on prepare_with_inputs) directly into headroom_with_inputs / prepare_with_inputs deletes ~50–80 lines of boilerplate and eliminates the unsafe post-KV-alloc default.
  2. Remove the unused host_pool_budget_with_reserve / apply_reserve switch (selene/src/offload.rs:824-836, 851-861, 885)

    • host_pool_budget_with_reserve has a single caller (host_pool_budget at :853), passing true. host_pool_budget_from is also only ever called with true in production (selene/src/offload.rs:885, helios/src/runtime_core/memory.rs:202-207); false appears only in unit tests (selene/src/offload/tests.rs:722-723). Removing the unused boolean switch eliminates dead API surface.
  3. Consolidate HostRegistrar::map_split, cuda::map_device_host_parts, and SlabPool::sized_by_rank (selene/src/registrar.rs:26-37, helios/src/cuda.rs:669-676, selene/src/slab.rs:261-270)

    • Production reaches CudaRegistrar::try_map_split (helios/src/offload/registrar.rs:31-37) via SlabPool::try_sized_by_rank (selene/src/offload.rs:631), leaving CudaRegistrar::map_split and cuda::map_device_host_parts unreachable in production and SlabPool::sized_by_rank test-only (selene/src/slab.rs:631, helios/src/offload/transfer.rs:1723). Because these crates are publish = false with no external workspace callers, replacing map_split with try_map_split as the single trait method lets you delete map_device_host_parts and sized_by_rank.

Nits

  1. Use named CUDA status constants in is_host_numa_unsupported (helios/src/cuda.rs:535-537): Replace bare 1 | 801 with local constants (CUDA_ERROR_INVALID_VALUE / CUDA_ERROR_NOT_SUPPORTED) beside cuda.rs:143-166 (not imported from runtime_core::driver, which is feature-gated). Also note in the docstring at :546-547 that CUDA_ERROR_INVALID_VALUE at cuMemCreate/cuMemSetAccess (:641, 657) triggers fallback too, or narrow those two sites once live GA10B/WDDM error codes are verified.
  2. Avoid silent skips in the Linux smaps check (eos/src/unix.rs:214-246): Once /proc/self/smaps is readable, .expect(...) the VMA header and VmFlags: line rather than silently skipping the hg assertion inside nested if lets, and simplify the manual byte-offset re-summing (:218-237) with line iteration.
  3. Deduplicate the page-stride prefault loop (eos/src/unix.rs:110-116 vs eos/src/windows.rs:179-183): Extract the identical step_by(page_size().max(1)) write_volatile(0) loop into a shared helper in eos/src/lib.rs.
  4. Drop duplicate CopyAsync alias (helios/src/cuda.rs:80-81): type CopyAsync = unsafe extern "C" fn(u64, u64, usize, Handle) -> c_int; is identical to type CopyDtoD on the preceding line.

Verified passes


Dropped on verification