Final review report · NVIDIA/hyperflare-inference #669

Raw Markdown for agents: https://autobot.eidonix.com/p/0fe9966b-f41e-4cac-9310-44afe6d424ae.md

Recommendation: Changes Requested

The core mechanism—reusing the existing host-backed CUDA VMM (HOST_NUMA) path on Linux whenever a device lacks HOST_REGISTER_SUPPORTED (99) or CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM (91), while keeping capable Linux GPUs on mmap + cuMemHostRegister and Windows WDDM off speculative probes—is clean, capability-driven, and memory-safe in helios/src/runtime_core/{host,mod}.rs. However, four verified issues need resolution before merging: a head-on GA10B address-layout conflict with open PR #658 compounded by a duplicated EXTERNAL_FLOOR heuristic in Rust, a TOCTOU gap where the probed host VMM range is freed inside the narrow unsealed external allocation band, init-time probe failure propagation that swallows CUDA error statuses and breaks non-MappedHost exports on tight windows, and stale contradictory docs/comments across the repo. No CI has run on ea65cb2 yet.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Reconcile the GA10B address layout with open PR #658 and eliminate the duplicated EXTERNAL_FLOOR heuristic (ignition/preparation/core_storage.py:66-71, heliopause/src/allocator.rs:526-530):

    • core_storage.py:66-71 keeps EXTERNAL_FLOOR = 0x300000000 (12 GiB) and lowers DEVICE_BASE to 0x0c00000000 (48 GiB, [48 GiB, 96 GiB)). Open PR #658 modifies the exact same lines to raise EXTERNAL_FLOOR to 0x900000000 (36 GiB) because static cuRAND precalc_xorwow_offset_matrix tables contain 64-bit patterns in [0x3_0000_0000, 0x3_0300_0000] that trigger false-positive export pointer matches, while keeping DEVICE_BASE = 0x1200000000 (note: both measurements are consistent—64 GiB AGX Orin has a 128 GiB VMM ceiling and exported cores only reserve used GiB-aligned spans, whereas exporting directly on 8 GiB Orin Nano reserves the full 48 GiB RESERVATION_BYTES and hits the 96.56 GiB cap).
    • Independently, heliopause/src/allocator.rs:526-530 duplicates Python's EXTERNAL_FLOOR via an address heuristic (if integrated != 0 && base < 0x40_0000_0000 { 0x3_0000_0000 } else { 0x40_0000_0000 }). Once EXTERNAL_FLOOR moves (e.g., to 36 GiB per #658), Rust silently uses the stale 12 GiB floor and can place HOST_BASE inside seal_low_window()'s sealed range (e.g., for world >= 2, before = 32 GiB < 36 GiB), and even for world == 1 only 4 GiB ([36 GiB, 40 GiB)) remains for external library allocations.
    • Fix: Coordinate a single GA10B window layout with #658 (keeping EXTERNAL_FLOOR clear of cuRAND's [0x3_0000_0000, 0x3_0300_0000] while fitting direct export inside Orin Nano's 96.56 GiB VMM ceiling), and pass self.EXTERNAL_FLOOR explicitly from CoreStorage into flare_core_initialize_window as min_host_base rather than hardcoding a second copy in Rust.
  2. Hold the probed host VMM range instead of freeing it before host_allocate() (heliopause/src/allocator.rs:543-553, ignition/preparation/core_storage.py:109-110, 513-518):

    • flare_core_initialize_window probes [40 GiB, 48 GiB) with cuMemAddressReserve and immediately releases it with cuMemAddressFree (allocator.rs:544-550). Immediately afterward, CoreStorage._reserve_low_window() (core_storage.py:109-110) seals only [4 GiB, EXTERNAL_FLOOR), leaving [EXTERNAL_FLOOR, DEVICE_BASE) open for cuBLAS handles, PyTorch non-pool allocations, and CUDA driver storage.
    • HostVmmRegion.__init__ (core_storage.py:513-518) only re-reserves HOST_BASE later when host_allocate() runs (e.g., ignition/preparation/collectives.py:77 (not opened) or mailbox setup). On a narrow 96.56 GiB aperture, any intervening external CUDA allocation landing in [40 GiB, 48 GiB) turns export into a load-order-dependent "cannot reserve mapped host CUDA address" failure.
    • Fix: Reserve the selected host VA span once during initialization and keep it held, having HostVmmRegion map/unmap physical HOST_NUMA handles directly inside that pre-reserved range without calling cuMemAddressReserve/cuMemAddressFree (mirroring DeviceRegion at ignition/preparation/core_storage.py:608-655), or reserve/protect the span before external allocations run.
  3. Do not fail allocator init on host-VMM probe failure for non-MappedHost exports, and preserve the failing CUDA status (heliopause/src/allocator.rs:415-417, 518-555):

    • vmm_host_window(...) propagates Err out of flare_core_initialize_window (allocator.rs:555), even though most models never call host_allocate(). Notice allocator.rs:556-558 already falls back to (default_host_base, default_host_extent) when HOST_NUMA_VMM == 0 so non-MappedHost models can still export, whereas when HOST_NUMA_VMM == 1, a tight custom device_window or multi-rank layout where no 8 GiB host slice fits aborts export before model loading even begins.
    • At allocator.rs:544-553, every non-zero cuMemAddressReserve status (e.g., CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_NOT_SUPPORTED) is flattened into Ok(false), and vmm_host_window returns "no reservable CUDA VMM address range for mapped host storage" with no CUDA error code or probed ranges.
    • Fix: Record the last non-zero CUDA status and attempted ranges in the failure diagnostic, and either defer host-VMM range placement/reservation until the first host_allocate() call or keep initialization non-fatal when no MappedHost storage is allocated (surfacing the recorded error if host_allocate() is subsequently invoked).
  4. Update stale docs and comments that now contradict the new Linux host-VMM path:

    • docs/windows.md:212-217 still states that "Linux registers host pages for mapped graph storage. Windows uses host-backed CUDA VMM…", contradicting docs/runtime-core-design.md:107-110.
    • docs/same-process-tp.md:38-45 still states host ranges always span 1 TiB at 0x0c00_0000_0000 / 0x2000_0000_0000.
    • helios/src/cuda.rs:552-554, selene/src/offload.rs:693-695, and docs/prefix-cache-offload.md:588-590 still assert that HOST_NUMA VMM is unsupported on "Windows WDDM and integrated Tegra/GA10B GPUs", which this PR empirically disproves on JetPack 6 / CUDA 12.6 GA10B (and Windows WDDM already uses HOST_NUMA VMM for HostVmmRegion).
    • Fix: Update these five sites to match the capability-based behavior (HOST_NUMA VMM support depends on driver/device capability rather than being categorically absent on GA10B/WDDM, and Linux can fall back to host-VMM and narrower host windows).

Subtract / Simplify

  1. Fold the duplicated HOST_REGISTER_SUPPORTED / CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM queries into host::use_host_vmm (helios/src/runtime_core/host.rs:12-18, 202-221, helios/src/runtime_core/mod.rs:364-386, heliopause/src/allocator.rs:448-480, 511-515):
    • Both NativeResources::initialize (mod.rs:364-386) and flare_core_initialize_window (allocator.rs:465-480) duplicate the identical ~20-line pair of cuDeviceGetAttribute calls solely to feed booleans + cfg!(windows) into host::use_host_vmm.
    • Change use_host_vmm to pub unsafe fn use_host_vmm(driver: &super::driver::Driver, device: i32) -> Result<bool> (matching sibling host_numa_properties), removing ~40 lines of duplicated FFI plumbing and shrinking the allocator.rs:448-455 init tuple back from 6 variables to 4. Also drop the tautological boolean loop in host.rs:209-219 (which only compares use_host_vmm against a literal copy of its own 1-line body).
  2. Delete unreachable granularity re-validation and redundant usize conversion in heliopause/src/allocator.rs:366-381, 521-525, 1633-1634:
    • vmm_host_window's if !granule.is_power_of_two() guard (allocator.rs:377-381) cannot fire from its production caller because granule is already validated with is_power_of_two() at allocator.rs:497 and host_granularity is already validated with is_power_of_two() at helios/src/runtime_core/host.rs:91-95 (making the two assertions at allocator.rs:1633-1634 dead-input tests).
    • host_granule (allocator.rs:520) is granule.max(host_granularity as u64) where both inputs came from usize, so usize::try_from(host_granule) (allocator.rs:521-525) is redundant. Grouping the device/default window parameters into a small struct also removes #[allow(clippy::too_many_arguments)] (allocator.rs:366).

Nits

Dropped on verification