PR #669 review — Correctness, Contracts & System-Level Consequences
PR: https://github.com/NVIDIA/hyperflare-inference/pull/669 · head ea65cb2 · 7 files, +417/−71 · no CI, no reviews.
Reviewed: heliopause/src/allocator.rs (full init/snapshot/probe path), helios/src/runtime_core/{driver,host,mod}.rs (MappedHost allocate/teardown, NativeResources::initialize), ignition/preparation/core_storage.py (window defaults, snapshot consumption, low-window sealing, HostVmmRegion), the two test files and docs/runtime-core-design.md, plus the direct callers ignition/preparation/collectives.py, peer_storage.py, helios/tests/fixed_core_fixture.py, heliopause/src/export/capture.rs.
Key findings
| # | Severity | Finding |
|---|---|---|
| F1 | Blocker | Host-VMM window selection is fatal at allocator init for every export on a 99/91==0 device, including models with no MappedHost |
| F2 | Major | Selected host range is reserved, freed, and not held — re-reserved much later → TOCTOU on the narrow aperture |
| F3 | Major | New unconditional cuDeviceGetAttribute(99/91) goes through driver.check(...)?, so an unknown attribute becomes a hard init/load failure |
| F4 | Major | Two disagreeing capability gates (99/91 vs 141): snapshot says host_vmm: true on a device where Python then fails naming 141 |
| F5 | Major | Undeclared contract changes: device granularity narrowed to is_power_of_two() platform-wide; mod host → pub mod host (new public unsafe API) |
| F6 | Major | Deployment ABI coupling: hard-indexed new snapshot key, WindowsHostRegion→HostVmmRegion rename with no alias, no version handshake |
| F7 | Major | Core format does not record which host backing mode was used; load re-derives it locally, contradicting the PR's cross-board interchange claim |
| F8 | Minor–Major | Every cuMemAddressReserve status is flattened into "no reservable range"; final error carries no cause (charter #397) |
| F9 | Minor | Address floor now lives in two places (Python EXTERNAL_FLOOR, native min_host_base) with no shared channel — already incompatible with #658's proposed 36 GiB floor |
| F10 | Minor | Undeclared 8 GiB / 1 GiB / 12 GiB constants with no config surface (charter "No magic defaults"); merged #589's GA10B/HOST_NUMA_VMM claims left stale in code and docs |
Verified sound (no finding): the if !self.host_vmm MappedHost rework, the unconditional host_mappings drain, the cuMemRelease status check. Details below.
1. Correctness, Safety & Platform Parity
F1 — Blocker: host-VMM window selection is fatal at allocator init for every export, mailbox or not
heliopause/src/allocator.rs:516-561 (hunk @@ -414,8 +506,59 @@):
let (host_base, host_extent) = if !cfg!(windows) && host_vmm {
if let Some((_, host_granularity)) = host::host_numa_properties(&driver, device)? {
...
vmm_host_window(base, extent, world, host_granule, min_host_base,
default_host_base, default_host_extent, |addr, bytes| { ... })?
} else {
(default_host_base, default_host_extent)
}
} else {
(default_host_base, default_host_extent)
};
vmm_host_window ends with (allocator.rs:415-417):
Err(invalid(
"no reservable CUDA VMM address range for mapped host storage",
))
The trailing ? propagates that error out of flare_core_initialize_window, which is the call every export makes before anything else (ignition/preparation/core_storage.py:94-97):
if self.library.flare_core_initialize_window(rank, world, device, *window):
raise self.error or RuntimeError("cannot initialize native core allocator")
host_vmm is true on any Linux device reporting 99==0 or 91==0 (host::use_host_vmm, host.rs:12-18), so on exactly the Orin-class boards this PR targets the probe now runs at init for every model, and a failure is a total export outage — including for cores that use no MappedHost storage at all. Pre-PR the same device initialized on the default host window (on Linux bits is None, so window_host_layout returned (HOST_BASE, 1 TiB) without probing: allocator.rs:299-319) and exported fine; only a MappedHost core failed later, at HostRegion (core_storage.py:461-462 on main). The triggering conditions are ordinary: another process/rank holding 40..48 GiB, an OOM/NOT_SUPPORTED status from the reserve probe, or the multi-rank "after device windows" fallback (base + world*extent + 1 GiB ≈ 97 GiB) exceeding the 8 GiB Nano ceiling of 96.56 GiB.
Impact: a new, model-independent failure mode on the target hardware, with no opt-out and no message tying it to host mailboxes.
Fix: don't decide the host window at init. Export host_vmm plus the device window, and place/probe the host range lazily in the first host-allocation call (i.e. when a MappedHost allocation is actually requested), or keep (default_host_base, default_host_extent) on probe failure and let the MappedHost path fail with a precise error. At minimum, add a regression test that init succeeds with host_vmm == true and can_reserve == Ok(false) when no MappedHost core is exported.
F2 — Major: the host range is probed, freed, and never held (TOCTOU)
heliopause/src/allocator.rs:544-553:
let mut probe = 0;
let status = (driver.reserve)(&mut probe, len, host_align, addr, 0);
if status == 0 {
driver.check(
"cuMemAddressFree(host probe)",
(driver.release_address)(probe, len),
)?;
Ok(probe == addr)
} else {
Ok(false)
}
Nothing holds the selected range afterwards. The device windows are held by the reserve loop that follows (allocator.rs:562-579), and on integrated non-Windows boards only everything below EXTERNAL_FLOOR is sealed (core_storage.py:109-110 → _reserve_low_window/seal_low_window, core_storage.py:129-190, floor 0x300000000 = 12 GiB on SM87 at core_storage.py:69). The chosen host window on Orin is 40..48 GiB (allocator.rs:399-404, validated at allocator.rs:1596-1606), i.e. between the sealed floor and the device window, unprotected, and re-reserved only much later by HostVmmRegion (ignition/preparation/core_storage.py:513-518), after PyTorch's caching allocator, cuBLAS handles and other context storage have been created.
Impact: on the narrow apertures this PR exists for, an intervening CUDA allocation can take the probed address, and export then dies on pointer.value != address — an intermittent, load-order-dependent failure that also defeats the GiB-alignment reasoning the PR added (window_align, allocator.rs:390-392).
Fix: transfer ownership: reserve the host span in the native allocator and expose it in the snapshot (as host_base/host_extent already are, but actually held), and have HostVmmRegion map inside the pre-reserved range; or extend the low-window sealing to cover up to DEVICE_BASE on host-VMM devices so no library allocation can land there.
F3 — Major: the new attribute queries are fatal when the driver does not know them
helios/src/runtime_core/mod.rs:364-389 (hunk @@ -358,8 +358,32 @@):
let mut host_register_supported = 1;
driver.check(
"cuDeviceGetAttribute(HOST_REGISTER_SUPPORTED)",
(driver.device_attribute)(
&mut host_register_supported,
driver::CU_DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED,
device,
),
)?;
flare_core_initialize_window does the same (allocator.rs, same file's hunk @@ -384,15 +445,46 @@, the HOST_REGISTER_SUPPORTED / CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM checks). Driver::check turns any nonzero status into an error, so a driver that does not recognize attribute 99 or 91 makes core load and allocator init fail outright — before the PR neither helios/src/runtime_core nor heliopause queried them (main queried only 18 and 116). The 1/1 initialisers clearly intend "unknown ⇒ assume supported", but check(...)? makes that unreachable.
Impact: narrow but real: a new hard dependency on CUDA-10-era attribute support on every platform and every load, for a feature only relevant when a MappedHost allocation exists. Fix: read the attributes non-fatally (ignore a nonzero status and keep the 1/1 defaults), and only query them where the answer is used.
F4 — Major: two disagreeing capability gates; host_vmm: true on a device without HOST_NUMA_VMM
The allocator derives host_vmm from 99/91 only (allocator.rs:509-513) and exports it verbatim (allocator.rs:861-869, "host_vmm": a.host_vmm). If the same device reports 141 == 0, host_numa_properties returns Ok(None) (host.rs:68-70), the allocator keeps the ordinary 1 TiB default window (allocator.rs:556-558) while still reporting host_vmm: true; Python then selects HostVmmRegion (core_storage.py:356) and fails at core_storage.py:499-502:
supported = C.c_int()
cuda.call("cuDeviceGetAttribute", C.byref(supported), C.c_int(141), C.c_int(device))
if not supported.value:
raise RuntimeError("mapped core storage requires host-backed CUDA VMM")
Helios mirrors it (host.rs:115-116). Consequences: (a) a Linux device with 99/91==0 and 141==0 loses the working mmap+cuMemHostRegister path and now fails hard, where pre-PR it exported and only failed at serve with "requires identical CPU and CUDA addresses" (core_storage.py:461-462 on main) — the failure moves earlier but the message never names 141 and never says the fallback is unavailable; (b) the exported 8 GiB host window is silently moot on such a device because the native side chose the default window.
Fix: fold 141 into the exported decision — e.g. host_vmm = use_host_vmm(...) && host_numa_vmm != 0, with a separate diagnostic field for why — so one component decides once and the error names the missing attribute and the device (charter #397: don't move unexplained failures around).
F5 — Major: undeclared platform-wide contract changes
(a) Device granularity acceptance narrowed on every platform (allocator.rs:494-502, changed line 497):
let granule = granularity as u64;
let two_granules = granule
.checked_mul(2)
- .filter(|_| granule != 0)
+ .filter(|_| granule.is_power_of_two())
.ok_or_else(|| { invalid(format!("invalid CUDA allocation granularity {granule:#x}")) })?;
This is the same PR that relies on & !(align - 1) masking for the new host path (allocator.rs:392, 399-408), so tightening is defensible for the host granule (host.rs:91-95 already does it), but it silently changes the device-granularity contract for Windows and every Linux GPU and is absent from the PR description. Keep != 0 for the device granule; keep is_power_of_two only where masking is used.
(b) helios/src/runtime_core/mod.rs:23 (hunk @@ -19,8 +19,7 @@):
-#[cfg(any(windows, test))]
-mod host;
+pub mod host;
with pub unsafe fn host_numa_properties (host.rs:52-57) — a new public runtime API for a single internal caller, also undeclared. Narrow it to pub(crate) (or pub(super) scope) unless it is meant as API surface.
F6 — Major: deployment ABI coupling (snapshot key + class rename)
ignition/preparation/core_storage.py:103:
self._host_vmm = bool(layout["host_vmm"])
self.HOST_BASE = layout["host_base"]
self.HOST_RESERVATION_BYTES = layout.get("host_extent", self.HOST_RESERVATION_BYTES)
host_vmm is a brand-new key from this PR's flare_core_snapshot() (allocator.rs:861-869). A stale flare_heliopause extension (wheel not rebuilt with ignition, or a cached build) raises a bare KeyError: 'host_vmm' from the middle of CoreStorage.__init__ — after the native allocator is already initialised — and the neighbouring key on the very next line is read with .get(...), so the hard index is inconsistent with the file's own convention. There is no snapshot version field and no comparison against a Python constant anywhere in the file.
Same coupling for WindowsHostRegion → HostVmmRegion (core_storage.py:492) with no alias; the dispatch also changes meaning from os.name == "nt" to self._host_vmm (core_storage.py:356). The only in-repo reference is that dispatch site, so out-of-repo importers break at import time.
Fix: layout.get("host_vmm") with an explicit error naming the required flare_heliopause rebuild (or add/compare a snapshot version), and keep WindowsHostRegion = HostVmmRegion as a deprecated alias for one release.
F7 — Major: the core does not record the host backing mode, but the PR claims cross-board interchange
Helios re-derives the mode from the local device on every load (mod.rs:364-389, host_vmm), and the three MappedHost branches pick mmap+cuMemHostRegister vs host-NUMA VMM from it (mod.rs:645, :711, :1610). The exported core records only the addresses, never which mechanism produced them. Meanwhile the new allocator test asserts cross-board interchange explicitly (allocator.rs:1589-1638):
// Both 8 GiB Orin Nano and 64 GiB AGX Orin place host VMM at 40..48 GiB so cores
// exported on AGX remain loadable on Nano.
A host-VMM-exported core replayed on a device with 99==1 && 91==1 (Thor, a discrete Linux GPU) therefore takes the registration path at 40..48 GiB addresses chosen for VMM-reservability, and vice versa. The two modes have different preconditions (identity mmap at an exact address + cuMemHostGetDevicePointer_v2 equality vs. cuMemCreate/cuMemMap inside a reserved range), and no test covers a core produced in one mode being loaded in the other — the replay fixture used for the PR's evidence is #[ignore]d and requires FLARE_EVENT_TEST_CORE (helios/tests/fixed_core_fixture.py:111 → helios/src/runtime_core/event_tests.rs:14-53 (not opened)), so nothing in CI exercises it.
Fix: record the backing mode in the core's MappedHost table and reject (with a clear message) or honour it on load, or drop the cross-board interchange claim from the test comment and docs until it is measured.
2. Unintended system-level consequences
- Failure-propagation blast radius (F1) is the dominant one. One
cuMemAddressReserverefusal inside init now fails every export on that device — a per-model, per-run blast radius that did not exist before, and it is reached before any model-specific knowledge, so no core can be exported to diagnose it. - Ordering/lifetime hazard (F2) is a genuine concurrency surface: the probed window is contended with the CUDA context, cuBLAS handles, other processes and co-located ranks between init and first host allocation. The
ARENAmutex (allocator.rs:439) makes init itself serialized, so the probe is not a hot-path contention problem — but the unheld address is exactly a race, since nothing in the allocator or inseal_low_windowprotects 12..48 GiB. - No memory amplification: the 8 GiB is virtual address space; physical host backing is still committed per mailbox by
cuMemCreateinHostVmmRegion, so RSS/VRAM behaviour is unchanged. Worth stating explicitly since the PR does not. - Default-window shift for all SM87 exports:
DEVICE_BASE72 GiB → 48 GiB with the same 48 GiB extent (core_storage.py:66-71) andEXTERNAL_FLOORleft at 12 GiB. Every SM87 export moves, mailbox or not. The native counterpart encodes its own copy of that floor (allocator.rs:526-530):
let min_host_base = if integrated != 0 && base < 0x40_0000_0000 {
0x3_0000_0000
} else {
0x40_0000_0000
};
The floor now lives in two places with no shared channel (core_storage.py:42 EXTERNAL_FLOOR = 0x4000000000, core_storage.py:69 0x300000000), so any future change to the Python floor silently invalidates the native "at or above the low restore floor" guarantee — and that collision is not hypothetical: open PR #658 raises exactly this floor to 36 GiB (0x900000000) while keeping DEVICE_BASE = 0x1200000000. Under #658's floor, the 48−8 = 40 GiB pre-device placement this PR validates would land inside the sealed low window and be unreservable. Fix: pass the floor into the native initialiser (or return the chosen host base and let Python seal around it) instead of duplicating the constant.
- Merge conflict / invariant inversion: #669 and #658 rewrite the same five lines (
core_storage.py:66-71) in opposite directions; #658 carries a test assertingDEVICE_BASE == 0x1200000000, which #669 breaks. Neither mentions the other. This needs a maintainer decision on which GA10B aperture is authoritative before either lands. - Metric/rate span check: no rate, latency or admission metric is touched. The only observability change is one new snapshot field (
allocator.rs:861-869,"host_vmm"), consumed solely atcore_storage.py:103. Noted gap: helios never logs or exposes its ownhost_vmmdecision on the serve side, so an operator diagnosing a replay failure has no way to see which MappedHost mechanism was chosen. Add it to the existing load-time diagnostics.
3. Architecture, contracts & charter compliance
- Reverses merged #589's stated capability model without updating it. #589 (merged 2026-11-28) codified that host-NUMA VMM is unsupported "on Windows WDDM and integrated Tegra/GA10B GPUs" —
helios/src/cuda.rs:552-557(is_host_numa_unsupported, status 1|801),selene/src/offload.rs:693-695,docs/prefix-cache-offload.md:588-590. #669 measures141 == 1on Orin Nano and touches none of those three places, so the repo now asserts both things. Two capability idioms also coexist: attribute-at-init (this PR) vs probe-the-call-and-fall-back (#589). Pick one and update the stale sites. - Docs left stale:
docs/same-process-tp.md:38-45(not opened) still describes 1 TiB host ranges at0x0c00_0000_0000/0x2000_0000_0000;docs/windows.md:212-217still frames host-backed VMM as Windows-only.docs/runtime-core-design.md(+11/−6) is updated for the new path, so the inconsistency is internal todocs/. - Charter "No magic defaults":
8 GiBper-rank host window,1 GiBminimum alignment and the twomin_host_basethresholds are hardcoded inallocator.rs:386-400and:526-530with no config surface and no opt-in, and they change behaviour for every host-VMM device (reach: any Linux GPU lacking attribute 99 or 91). - Charter "Supported matrix & compatibility": the shared MappedHost path serves SM87/103/110/120/121 (
docs/cli-design.md:6(not opened)); the PR declares Windows WDDM, GB10/SM121, AGX Orin 64 GiB, discrete Linux GPUs and RoCE over host-VMM buffers unrun. The allocator test asserts single-rank placement for two boards but nothing covers the Windows branch being skipped (!cfg!(windows),allocator.rs:516) or the 141==0 branch being not skipped in Python.
4. Tests & claim accuracy
- Not covered by any test: the
!cfg!(windows) && host_vmmbranch condition (allocator.rs:516);min_host_baseselection (allocator.rs:526-530); the realhost_numa_propertiespath (attributes 141/134 +cuMemGetAllocationGranularity); the snapshot →CoreStoragepropagation ofhost_vmm(tests/preparation/test_core_storage.py:83-139buildsCoreStorage.__new__(CoreStorage)and assignsstorage._host_vmmby hand, so the hard-indexKeyErrorpath cannot be caught); and helios's threeif !self.host_vmmMappedHost branches (mod.rs:645,:711,:1610). Nothing tests the F1 scenario (init withhost_vmm == trueand no MappedHost core). - Verified present and correct:
use_host_vmmwith the 8-combination unit test (host.rs:12-18,host.rs:206-221);vmm_host_windowparameterised test covering the Nano 96.56 GiB cap, AGX 64 GiB cap, floor collision → post-device placement, world=2 span, default fit, granules 0 and 3 MiB, unreservable, and probe-cleanup errors (allocator.rs:1589-1638);HostVmmRegiondispatch, overflow non-mutation and 141 rejection (tests/preparation/test_core_storage.py:83-139). - Verified sound in helios: the
#[cfg(unix)] { … }→#[cfg(unix)] if !self.host_vmm { … }rewrite atmod.rs:645/:711/:1610leaves no gap — on Windows the block is compiled out by#[cfg(unix)]as before, on Unix the VMM branch handles the mapping, the CPU zero-fill still runs for both modes, and the teardown drain (mod.rs:~1618) is now unconditional so host mappings are released on Linux too. ThecuMemReleasereorder (host.rs:158-168) correctly checks the release status after recording the mapping, which is the right ordering for the failure path. - Claim accuracy: the PR's "Result" says Linux devices lacking identity addressing "automatically export and natively replay" MappedHost cores; on a device that also lacks
HOST_NUMA_VMM(141) the new behaviour is a hard early failure with no fallback (F4), and the 8 GiB host window is silently unused. All end-to-end evidence is self-reported hardware-local (Orin Nano 8 GiB, Thor SM110) with no attached device-attribute log, exported core or transcript, and no CI onea65cb2; the replay fixture is#[ignore]d. Suite counts (helios 1775/6, heliopause 228/1, flare 253, flare-cli 241, pytest 18/1 skip) are unattached to any run.
Open questions / not found
- Which of #669's 96.56 GiB and #658's "128 GiB GA10B VMM window" reflects the real GA10B aperture — probably board-dependent (8 GiB Nano vs 64 GiB AGX), but neither PR states it for the other's board and no in-repo fact reconciles them.
- Whether a Linux device with 99/91==0 and 141==0 exists in practice (F4). If impossible, F4 collapses to a documentation/error-message issue; if possible, it is the difference between "moved failure" and "new failure".
- No device-attribute log, exported core or run transcript backs the Orin/Thor numbers.
- Whether anything outside this repo imports
WindowsHostRegion— the rename has no alias and I could only verify the single in-repo reference (core_storage.py:356). - Whether helios's
host_vmmdecision can disagree with the exporting host's for a given core (F7) was not measured; there is no test and no recorded mode in the core format to check it against.