PR #669: Fall back to host-backed CUDA VMM when registered host memory lacks identity addressing

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/87e1221f-ed3a-45cf-ba4d-c1ee625881b6

Opened by a workflow run, Dec 1, 2026 5:55 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: kbenkhaled (CONTRIBUTOR; 1 merged PR #592, 2 open; no Discord handle given) Motivation: Mapped host buffers (offload/embedding mailboxes) need the CPU and GPU to share one virtual address. On Jetson Orin the Tegra driver cannot do that with cuMemHostRegister, so export and replay fail; the fix reuses the Windows host-backed CUDA VMM path on Linux, chosen by device capability rather than OS. Scale: +417 / −71 lines in 7 files Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #669 "Fall back to host-backed CUDA VMM when registered host memory lacks identity addressing"

Charter alignment. Good on intent, weaker on execution. The problem is concrete and reproducible: on 8 GiB Orin Nano the VMM ceiling is 0x18_23c0_0000 (96.56 GiB), so the 72–120 GiB SM87 default window and the 12 TiB HOST_BASE cannot be reserved. SM87 is an officially served target (docs/cli-design.md:6) and already had an SM87-only layout branch before this PR, so this falls inside "What gets merged" (reproducible bug / measured memory issue). The mechanism is capability-based — attributes 99/91, no hardware-name checks — matching "smallest footprint in shared code / no per-model special cases." Against that: no linked issue, roadmap line, or maintainer ack; hardcoded 8 GiB window, 1 GiB alignment and 12/1 GiB thresholds (allocator.rs:386-392, :526-530) bump against "No magic defaults"; and only SM87 + SM110 were exercised, though the MappedHost path is shared by SM103/120/121, Windows, and discrete Linux GPUs.

Novelty & status. Neither obsolete nor superseded: nothing on main fixes this, and #658 only retunes the address floor without delivering the host-VMM fallback. But #658 collides head-on — both rewrite the same five lines in core_storage.py:66-71 in opposite directions, #658 carries a test asserting DEVICE_BASE == 0x1200000000 that #669 breaks, and the two cite contradictory GA10B apertures (plausibly 8 GiB Nano vs 64 GiB AGX) without reconciling. It also contradicts merged #589 while leaving helios/src/cuda.rs:552-557, selene/src/offload.rs:693-695 and docs/prefix-cache-offload.md:588-590 still asserting GA10B lacks HOST_NUMA_VMM — two detection idioms now coexist.

Value vs cost. Beneficiaries are real: Orin owners and the mailbox features that cannot export there today (#664, #431/#507/#566). Evidence is the weak link — hardware-local, self-reported, reproducible only through an #[ignore]d fixture needing FLARE_EVENT_TEST_CORE; no CI on head, no reviews. The diff also carries undeclared surface (pub mod host, public host_numa_properties, a platform-wide power-of-two granularity tightening, an unaliased WindowsHostRegion rename), a layout["host_vmm"] hard-index that raises KeyError on a stale flare_heliopause, and a capability hole where 99/91 == 0 with 141 == 0 commits to host_vmm and hard-fails without naming the missing 141. This is the third rework of the MappedHost seam in two weeks, from a contributor's first Rust/CUDA-VMM change, with the area owner (author of #589 and #658) uninvolved.

Verdict: Worth it with changes. Required: reconcile with #658 into one address-layout change stating board-specific apertures; unify with #589's detection and update its docs/comments; keep or explicitly diagnose the no-141 case; guard the ABI change (version handshake or alias); name the magic constants; and provide CI-reproducible evidence covering the currently untested branches.

Full report Decide Value: yes (99%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, performance, enhancement, area:memory, area:preparation

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +performance, +enhancement, +area:memory, +area:preparation

Subtraction and simplicity

Subtraction/simplicity review of PR #669 (7 files, +417/−71). Verdict: no new flags, env switches, config knobs or speculative extension points were added, and the new named CUDA attribute constants are a net win — but roughly 120 of the +417 lines are removable duplication, one dead fallback branch, and unreachable re-validation, and the capability decision is spread over four places where one would do.

  1. host::use_host_vmm should own its own attribute queries (high). It takes (windows, host_register_supported, can_use_host_pointer), and both callers re-implement the same two query blocks to feed it: helios/src/runtime_core/mod.rs:364-386 (~23 lines) and heliopause/src/allocator.rs:465-480 plus the six-element tuple at :448-455. Folding into unsafe fn use_host_vmm(driver, device) -> Result<bool> in host.rs (which already owns host_numa_properties) removes ~45 lines and stops passing cfg!(windows) through a library API. Also delete helios/src/runtime_core/host.rs:202-221, which asserts the function equals a copy of its own body plus four constant definitions.

  2. Delete the HOST_NUMA_VMM == 0 fallback rather than re-check it in Python (high). heliopause/src/allocator.rs:518-561 has two identical else arms; the inner one keeps host_vmm = true with a plain host window when 141 is absent, deferring failure to export. Erroring there makes the per-region re-query at ignition/preparation/core_storage.py:499-502 dead — delete it with tests/preparation/test_core_storage.py:130-139, restoring import torch / tensor_from_pointer to the top of __init__ beside HostRegion.__init__ (:438-439).

  3. vmm_host_window is a parallel copy of window_host_layout's placement logic (medium). The "round up past the device span" arithmetic at allocator.rs:405-413 duplicates :320-347; two functions and two tests assert one contract. Extending window_host_layout with a reserve-probe callback and a low floor removes ~57 lines plus the 8-argument call site at :531-555 and its #[allow(clippy::too_many_arguments)].

  4. Unreachable re-validation and a duplicated floor constant (medium). allocator.rs:377-381 (power-of-two granule) cannot fire after host.rs:91-95 and allocator.rs:495-502; :521-525 and :540-542 are redundant usize guards; :526-530 restates ignition's EXTERNAL_FLOOR (core_storage.py:42, :69) and infers which value applies from a hardcoded base < 0x40_0000_0000.

  5. Prose budget went to the wrong file (low). docs/runtime-core-design.md:104-113 gained attribute-level implementation detail while docs/windows.md:212-217, docs/prefix-cache-offload.md:588-590, helios/src/cuda.rs:552-557 and selene/src/offload.rs:693-695 still say host-VMM is Windows/WDDM-only and that GA10B lacks it.

Open questions: whether the quarterly GA10B aperture in #658 conflicts with the 96.56 GiB measurement here; whether any out-of-tree code imports WindowsHostRegion (rename at core_storage.py:492 kept no alias); whether the pub mod host widening (helios/src/runtime_core/mod.rs:22) is intended as permanent public API.

Full report · Notes

Correctness and contracts

Review of PR #669 (host-backed CUDA VMM fallback on Linux) for correctness, contracts and system-level consequences. The mechanism is coherent and the two support module changes (use_host_vmm, host_numa_properties) are correct, but the placement of the new host-VMM window is decided, probed and then discarded at allocator-init time, which produces a new total-export-outage mode and a TOCTOU hazard on exactly the narrow apertures the PR targets.

Findings, most important first:

  1. Blocker — vmm_host_window's Err is propagated with ? out of flare_core_initialize_window, which every export runs (ignition/preparation/core_storage.py:96-97), so "no reservable … range" now aborts all exports on a 99/91==0 device, including models with no MappedHost (heliopause/src/allocator.rs:516-561, 415-417).
  2. Major — the probe reserves and immediately frees the chosen range (allocator.rs:544-553); only the device window is held. The 40..48 GiB host window sits above the sealed floor (12 GiB) and can be taken by context/cuBLAS allocations before HostVmmRegion re-reserves it (core_storage.py:489-520), giving intermittent hard export failures.
  3. Major — new unconditional cuDeviceGetAttribute(99/91) via driver.check(...)? turn an unrecognized attribute into a hard init/load failure, on every platform (helios/src/runtime_core/mod.rs:364-389, allocator.rs hunk @@ -384,15 +445,46 @@).
  4. Major — two disagreeing capability gates: the snapshot reports host_vmm: true from 99/91 alone while HostVmmRegion rejects on 141 == 0 (core_storage.py:499-502), so a 141-less Linux device fails with "requires host-backed CUDA VMM" and loses the old registration path with no message naming 141.
  5. Major — undeclared contract changes: device granularity tightened from != 0 to is_power_of_two() on all platforms (allocator.rs:497), mod host widened to pub mod host exposing pub unsafe host_numa_properties (mod.rs:23, host.rs:57).
  6. Major — hard dependency on a new snapshot key (layout["host_vmm"], core_storage.py:103, inconsistent with the neighbouring .get) plus the WindowsHostRegion→HostVmmRegion rename with no alias (core_storage.py:492).
  7. Major — the host backing mode is re-derived from local attributes at load (mod.rs:364-389) and never recorded in the core, yet the allocator test asserts cross-board interchange; no test covers loading a core produced in the other mode.
  8. Minor–Major — the probe flattens every cuMemAddressReserve status into "not reservable" (allocator.rs:544-553), so the final error has no cause (charter #397). Also: magic 8 GiB / 1 GiB / 12 GiB constants with the floor duplicated across Python and Rust (allocator.rs:526-530 vs core_storage.py:69) — which already conflicts with #658's 36 GiB floor; and #589's "no HOST_NUMA_VMM on GA10B" claims left stale.

Verified sound: the if !self.host_vmm MappedHost rework in helios, the #[cfg(unix)]-free teardown, and the cuMemRelease status check.

Open questions: which board #658's 72..120 GiB measurement came from; whether a 99/91==0 and 141==0 Linux device exists; and no CI/device log backs the Orin/Thor runs.

Full report · Notes

Final review

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

Full report Decision to Test: no (99%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes