Repository navigation
Fall back to host-backed CUDA VMM when registered host memory lacks identity addressing - #669
kbenkhaled wants to merge 2 commits into
Conversation
…gistered host memory lacks identity addressing
Why:
Tegra Linux GPUs such as Jetson Orin (GA10B / SM87) report
CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM (91) == 0 alongside
CU_DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED (99) == 1 and
CU_DEVICE_ATTRIBUTE_HOST_NUMA_VMM (141) == 1. Because Flare's Linux MappedHost
path requires registered host pages to share the exact CPU and GPU virtual
address, fixed-address MappedHost buffers (such as offloaded embedding
mailboxes) fail on these devices even though the driver supports host-backed
CUDA VMM. In addition, the default SM87 device window (0x12_0000_0000 + 48 GiB =
120 GiB) exceeds the measured 96.56 GiB (0x18_23c0_0000) CUDA VMM ceiling on
8 GiB Jetson Orin Nano, and the default 12 TiB HOST_BASE also exceeds Orin's
VMM aperture.
What:
- Before: host-backed CUDA VMM (allocate_host / host_mappings in Helios,
WindowsHostRegion in CoreStorage) was gated strictly behind #[cfg(windows)] /
os.name == "nt"; Heliopause always used the 12 TiB / 32 TiB host range on
Linux; and SM87 placed its 48 GiB device window at 0x12_0000_0000 (72..120 GiB).
- After:
- helios/src/runtime_core/{driver.rs,host.rs,mod.rs}: define named CUDA
device attribute constants (18, 91, 99, 116, 134, 141); add shared
host::use_host_vmm(windows, host_register_supported, can_use_host_pointer)
and host::host_numa_properties(driver, device) (validating HOST_NUMA_VMM
and power-of-two host-NUMA granularity); ungate allocate_host and
host_mappings on Unix; query both attributes 99 and 91 in
NativeResources::initialize and check cuMemRelease status during VMM
mapping.
- heliopause/src/allocator.rs: query attributes 99 and 91 via
host::use_host_vmm, store host_vmm on Arena, and expose it in
flare_core_snapshot() so Ignition consumes one source of truth. When
!cfg!(windows) && host_vmm and host_numa_properties returns Some, align
fallback host windows to max(granule, 1 GiB) (matching exported GiB-rounded
device reservations), probe the full host span (propagating
cuMemAddressFree errors), and fall back to an 8 GiB per-rank host VMM
window immediately before (at or above the low restore floor) or after the
device windows.
- ignition/preparation/core_storage.py: lower the default SM87 DEVICE_BASE
from 0x12_0000_0000 to 0x0c_0000_0000 (48..96 GiB), read _host_vmm from
layout["host_vmm"], rename WindowsHostRegion to HostVmmRegion, and check
HOST_NUMA_VMM (141) before allocation to match Helios.
- docs/runtime-core-design.md: document host-backed CUDA VMM fallback,
narrow-aperture host ranges across Linux and WDDM, and SM87 defaults.
- Tests: add host_vmm_dispatch_requires_both_host_register_and_host_pointer
in host.rs, vmm_host_window_respects_aperture_floor_and_rank_count in
allocator.rs, and HostVmmRegion dispatch, overflow non-mutation, and
HOST_NUMA_VMM rejection in tests/preparation/test_core_storage.py.
Result:
Linux devices lacking identity-addressed host registration automatically export
and natively replay fixed-address MappedHost cores using host-backed CUDA VMM
and a reservable host address range (verified end-to-end on Jetson Orin Nano
8 GiB SM87), while Linux GPUs supporting both attributes 99 and 91 preserve
the existing mmap + cuMemHostRegister path (verified end-to-end on Jetson AGX
Thor SM110).
Evidence:
- Live end-to-end MappedHost export + native Helios replay + two-phase teardown
(helios/tests/fixed_core_fixture.py -> runtime_core::event_tests::named_external_wait_survives_export_and_native_replay):
- Jetson Orin Nano 8 GiB (SM87, JetPack 6 / CUDA 12.6; attributes 18=1, 91=0,
99=1, 134=0, 141=1; max 2 MiB VMM end = 0x18_23c0_0000 = 96.56 GiB):
CoreStorage selected host_vmm=True, DEVICE_BASE=0xc00000000 (48 GiB, extent
48 GiB), HOST_BASE=0xa00000000 (40 GiB, extent 8 GiB); exported 6-allocation
core including MappedHost table and passed native replay + byte-exact output
check + clean teardown in 1.04s.
- Jetson AGX Thor (SM110; attributes 18=1, 91=1, 99=1, 134=0, 141=1):
CoreStorage kept host_vmm=False, DEVICE_BASE=0x80000000000,
HOST_BASE=0xc0000000000 (HostRegion); exported and passed native replay +
teardown in 0.37s.
- Full release-mode Rust & Python CPU suites (ARM64 container on Thor, non-root
runner, ext4 TMPDIR):
- helios (--locked --release --features runtime-core,server): --lib 1775
passed, 6 failed (all 6 in tests/support/templates.rs:19 due to 401
Unauthorized on gated meta-models/Muse-Spark-Open-816B-A42B-NVFP4);
--test '*': 62 passed, 0 failed.
- heliopause (--locked --release): 228 passed, 1 failed (unrelated
export::blob::tests::verification_retries_hardlink_metadata_changes_and_bounds_churn
coarse ctime on ARM64 ext4; all 19 allocator and 34 export::core tests passed).
- flare (--locked --release): 253 passed, 0 failed (245 + 7 + 1).
- flare-cli (--locked --release): 241 passed, 0 failed (215 + 9 + 6 + 4 + 7).
- pytest -q tests/preparation/test_core_storage.py tests/preparation/test_core_boundary.py tests/preparation/test_low_window.py:
18 passed, 1 skipped, 0 failed.
- Limitations: Windows WDDM builds/serving, GB10 (SM121), AGX Orin 64 GiB,
discrete Linux GPUs, and RoCE over host-VMM buffers were not run locally.
Design-Signed-Off-By: Gemini 4 Neon (Cursor); design-review=2e5b
Signed-off-by: kbenkhaled <kbenkhaled@nvidia.com>
|
A case file has been opened for 669. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe capability-driven host-VMM fallback is clean and memory-safe, but four verified issues block merge: a head-on GA10B address-layout conflict with open PR #658 plus a duplicated
Walkthrough
Merge Risk: Medium · up to
|
Probing the non-WDDM host VMM address range with reserve-then-free left a
TOCTOU gap before HostVmmRegion mapped it, failing the host VMM probe
aborted allocator initialization even for models without MappedHost
storage while discarding CUDA status codes, allocator.rs hardcoded an
integrated-GPU floor heuristic instead of using CoreStorage.EXTERNAL_FLOOR,
and the cuDeviceGetAttribute(99/91) queries were duplicated between Helios
and Heliopause.
Changes:
- helios/src/runtime_core/host.rs and mod.rs: move CUDA driver attribute
99/91 queries into host::use_host_vmm(driver, device) and share it across
Helios and Heliopause; remove the tautological boolean/constant unit tests.
- heliopause/src/allocator.rs: add min_host_base to
flare_core_initialize_window (passed from CoreStorage.EXTERNAL_FLOOR);
group vmm_host_window inputs into HostWindowPlan (removing
clippy::too_many_arguments and unreachable granularity/usize checks); keep
the successfully probed host VMM VA span reserved for the allocator
lifetime (releasing it if device-window reservation fails); and record
host-NUMA query or probe failures (with attempted ranges and CUDA status)
in Arena.host_error instead of aborting initialization, exposing
host_reserved and host_error via flare_core_snapshot().
- ignition/preparation/core_storage.py: pass self.EXTERNAL_FLOOR to
flare_core_initialize_window, read host_reserved and host_error directly
from the snapshot, raise host_error only in host_allocate(), drop the
unused lock parameter from HostVmmRegion, and add reserved=bool so
pre-reserved non-WDDM spans skip cuMemAddressReserve/cuMemAddressFree
while Windows WDDM keeps its existing reserve/free lifecycle.
- docs/runtime-core-design.md and tests/preparation/test_core_storage.py:
document the held fallback reservation and cover deferred host_error,
pre-reserved vs unreserved HostVmmRegion lifecycles, and HostWindowPlan.
Result: closes the host VMM reservation race on non-WDDM host-VMM devices,
keeps non-MappedHost initialization working when no host VMM window is
available while surfacing full CUDA diagnostics on host_allocate(), and
eliminates duplicated driver queries and hardcoded floor constants.
Validation:
- Jetson Orin Nano 8 GiB (SM87, JetPack 6 / CUDA 12.6, hf-orin):
- Multi-region held-reservation check: CoreStorage initialized with
host_vmm=True, host_reserved=True, host_error=None,
DEVICE_BASE=0xc00000000, HOST_BASE=0xa00000000, extent=8 GiB; mapped
two back-to-back HostVmmRegion(reserved=True) allocations inside the
single held VA span (0xa00000000+0x200000, 0xa00200000+0x200000),
verified bidirectional CPU/GPU reads and writes at identical virtual
addresses, closed both (cuMemUnmap without freeing the held span), and
mapped/verified/closed a third allocation at 0xa00400000+0x200000.
- End-to-end MappedHost export + native Helios replay + teardown
(helios/tests/fixed_core_fixture.py ->
runtime_core::event_tests::named_external_wait_survives_export_and_native_replay):
exported 6-allocation core and passed native replay in 1.13s (1 passed).
- Unit tests (Thor hf-thor-v2b container):
- cargo test --manifest-path helios/Cargo.toml --features runtime-core --lib host:
30 passed, 0 failed (2 GPU-only ignored)
- cargo test --manifest-path heliopause/Cargo.toml --lib allocator:
19 passed, 0 failed (1 GPU-only ignored)
- pytest -q tests/preparation/test_core_storage.py: 13 passed, 1 skipped
(Windows-only layout test)
Material limitations: Windows WDDM execution and multi-rank TP export on
host-VMM hardware were not run locally; unreserved WDDM HostVmmRegion calls
are covered by driver-stubbed unit tests and multi-rank placement by unit
tests.
Design-Signed-Off-By: Gemini 4 Neon; design-review=2e5b
Signed-off-by: kbenkhaled <kbenkhaled@nvidia.com>
Problem
Mapped host buffers (like offloaded embedding mailboxes) need the CPU and GPU to
access the exact same virtual address. On Linux, Flare allocates these with
mmap+cuMemHostRegisterand checks that the GPU pointer matches the CPUaddress.
On Jetson Orin (GA10B / SM87), the Tegra driver cannot expose registered host
memory at the same CPU/GPU address (
CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM == 0),even though it already supports host-backed CUDA VMM (
HOST_NUMA_VMM == 1) —the exact mechanism Flare already uses on Windows. Because that VMM path is
gated behind Windows checks, both export and serving fail on Orin whenever a
model uses
MappedHoststorage.Two address-range limits also block export on 8 GiB Jetson Orin Nano, where
CUDA VMM reservations top out at
96.56 GiB(0x18_23c0_0000):72..120 GiB) exceeds96.56 GiBand fails
cuMemAddressReserve.12 TiBhost base also lies outside Orin's VMM range.Solution
Reuse the existing host-backed CUDA VMM (
HOST_NUMA) path on Linux whenever adevice lacks identity-addressed host registration (
99 == 0or91 == 0),keeping every Linux GPU supporting both attributes (discrete GPUs, GB10, Thor)
on the existing
mmap+cuMemHostRegisterpath:helios/src/runtime_core/{driver.rs,host.rs,mod.rs}):define named CUDA device attribute constants (
18, 91, 99, 116, 134, 141),add shared
host::use_host_vmmandhost::host_numa_properties(validatingHOST_NUMA_VMMand power-of-two host-NUMA granularity), ungateallocate_hostand
host_mappingson Unix, query attributes99and91inNativeResources::initialize, and checkcuMemReleasestatus during mapping.heliopause/src/allocator.rs):compute
host_vmmviahost::use_host_vmm, store it onArena, and expose"host_vmm"inflare_core_snapshot(). When!cfg!(windows) && host_vmm(never running speculative probes on Windows WDDM) and
host_numa_propertiesreturns
Some, align fallback host windows tomax(granule, 1 GiB)(soGiB-rounded device reservations cannot overlap adjacent mailboxes), probe the
full host span while propagating
cuMemAddressFreeerrors, and place an8 GiBper-rank host window before (at or above the low restore floor) orafter the device windows.
ignition/preparation/core_storage.py): lower the defaultintegrated SM87
DEVICE_BASEfrom0x12_0000_0000to0x0c_0000_0000(
48..96 GiB), read_host_vmmfromlayout["host_vmm"], renameWindowsHostRegiontoHostVmmRegion, and verifyHOST_NUMA_VMM(141)before allocation.
docs/runtime-core-design.md,host.rs,allocator.rs,tests/preparation/test_core_storage.py): document Linux host-VMM fallback,narrow-aperture host ranges, and SM87 defaults; test
use_host_vmm,vmm_host_window(narrow apertures, floor collisions, GiB alignment,multi-rank spans, invalid granularity, probe cleanup errors), and
HostVmmRegiondispatch, overflow non-mutation, andHOST_NUMA_VMMrejection.
Result
Linux devices lacking identity-addressed host registration automatically export
and natively replay fixed-address
MappedHostcores using host-backed CUDA VMMand a reservable host address range (verified end-to-end on Jetson Orin Nano
8 GiB SM87), while Linux GPUs supporting both attributes
99and91keep theexisting
mmap+cuMemHostRegisterpath unchanged (verified end-to-end onJetson AGX Thor SM110).
Validation
MappedHostexport + Helios native replay + two-phase teardown(
helios/tests/fixed_core_fixture.py→runtime_core::event_tests::named_external_wait_survives_export_and_native_replay):18=1, 91=0, 99=1, 134=0, 141=1; measured max 2 MiB VMM end0x18_23c0_0000(96.56 GiB).CoreStorageselectedhost_vmm=True,DEVICE_BASE=0xc00000000(48 GiB, extent48 GiB),HOST_BASE=0xa00000000(40 GiB, extent8 GiB); exported 6-allocationcore with
MappedHosttable and passed native replay, byte-exact outputcheck, and clean teardown in
1.04s.18=1, 91=1, 99=1, 134=0, 141=1.CoreStoragekepthost_vmm=False,DEVICE_BASE=0x80000000000,HOST_BASE=0xc0000000000(HostRegion); exported and passed native replayand teardown in
0.37s.TMPDIR):helios(--locked --release --features runtime-core,server):--lib1,775passed, 6 failed (all 6 in
tests/support/templates.rs:19due to 401Unauthorized on gated
meta-models/Muse-Spark-Open-816B-A42B-NVFP4);--test '*'62 passed, 0 failed.heliopause(--locked --release): 228 passed, 1 failed (unrelatedexport::blob::testscoarsectimeon ARM64 ext4; all 19allocatorand34
export::coretests passed).flare(--locked --release): 253 passed, 0 failed.flare-cli(--locked --release): 241 passed, 0 failed.pytest -q tests/preparation/test_core_storage.py tests/preparation/test_core_boundary.py tests/preparation/test_low_window.py:18 passed, 1 skipped, 0 failed.
discrete Linux GPUs, and RoCE over host-VMM buffers were not run locally.
Discord: no username provided