Skip to content

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

Open
kbenkhaled wants to merge 2 commits into
NVIDIA:mainfrom
kbenkhaled:host-vmm-fallback
Open

kbenkhaled wants to merge 2 commits into
NVIDIA:mainfrom
kbenkhaled:host-vmm-fallback

Conversation

@kbenkhaled

@kbenkhaled kbenkhaled commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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 + cuMemHostRegister and checks that the GPU pointer matches the CPU
address.

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 MappedHost storage.

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):

  • The current SM87 default device window (72..120 GiB) exceeds 96.56 GiB
    and fails cuMemAddressReserve.
  • The default 12 TiB host base also lies outside Orin's VMM range.

Solution

Reuse the existing host-backed CUDA VMM (HOST_NUMA) path on Linux whenever a
device lacks identity-addressed host registration (99 == 0 or 91 == 0),
keeping every Linux GPU supporting both attributes (discrete GPUs, GB10, Thor)
on the existing mmap + cuMemHostRegister path:

  • Shared capability & host-NUMA helpers (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 and host::host_numa_properties (validating
    HOST_NUMA_VMM and power-of-two host-NUMA granularity), ungate allocate_host
    and host_mappings on Unix, query attributes 99 and 91 in
    NativeResources::initialize, and check cuMemRelease status during mapping.
  • Single source of truth & narrow-aperture host placement (heliopause/src/allocator.rs):
    compute host_vmm via host::use_host_vmm, store it on Arena, and expose
    "host_vmm" in flare_core_snapshot(). When !cfg!(windows) && host_vmm
    (never running speculative probes on Windows WDDM) and host_numa_properties
    returns Some, align fallback host windows to max(granule, 1 GiB) (so
    GiB-rounded device reservations cannot overlap adjacent mailboxes), probe the
    full host span while propagating cuMemAddressFree errors, and place an
    8 GiB per-rank host window before (at or above the low restore floor) or
    after the device windows.
  • Ignition (ignition/preparation/core_storage.py): lower the default
    integrated 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 verify HOST_NUMA_VMM (141)
    before allocation.
  • Docs & tests (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
    HostVmmRegion dispatch, overflow non-mutation, and HOST_NUMA_VMM
    rejection.

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 keep the
existing mmap + cuMemHostRegister path unchanged (verified end-to-end on
Jetson AGX Thor SM110).

Validation

  • Live end-to-end MappedHost export + Helios native 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 7 / CUDA 13.2): attributes
      18=1, 91=0, 99=1, 134=0, 141=1; measured 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 with MappedHost table and passed native replay, byte-exact output
      check, and 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
      and teardown in 0.37s.
  • Full release-mode Rust & Python CPU suites (ARM64 container, non-root runner, ext4 TMPDIR):
    • helios (--locked --release --features runtime-core,server): --lib 1,775
      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 coarse ctime on ARM64 ext4; all 19 allocator and
      34 export::core tests 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.
  • Limitations: Windows WDDM builds/serving, GB10 (SM121), AGX Orin 64 GiB,
    discrete Linux GPUs, and RoCE over host-VMM buffers were not run locally.

Discord: no username provided

…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>
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 669.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 1, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The 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 EXTERNAL_FLOOR heuristic, a TOCTOU gap where the probed host VMM range is freed inside the unsealed external band, init-time probe failures that swallow CUDA statuses and break non-MappedHost exports, and stale contradictory docs/comments. No CI has run on ea65cb2 yet.

  • Blockers: 0 · Should fix: 4 · Subtract/Simplify: 2 · Nits: 4
Walkthrough
  • helios/src/runtime_core/driver.rs:14-19: Defines named CU_DEVICE_ATTRIBUTE_* constants (18, 91, 99, 116, 134, 141).
  • helios/src/runtime_core/host.rs:12-18,57-174: Adds shared use_host_vmm and host_numa_properties (validating HOST_NUMA_VMM and power-of-two host granularity), ungates allocate_host on Unix, and checks cuMemRelease status after recording each host mapping.
  • helios/src/runtime_core/mod.rs:22,123-128,364-386,564-566,645,711,1610,1618-1620: Exports pub mod host (consumed by sibling crate heliopause), queries attributes 99/91 in NativeResources::initialize, routes MappedHost setup/teardown by self.host_vmm, and unconditionally drains host_mappings in Phase 1 teardown.
  • heliopause/src/allocator.rs:195,367-418,448-589,863,1589-1637: Computes host_vmm, exposes "host_vmm" in flare_core_snapshot(), tightens device granularity validation to is_power_of_two(), adds vmm_host_window() to probe a GiB-aligned 8 GiB/rank host range on non-Windows host_vmm devices, and adds unit coverage for vmm_host_window.
  • ignition/preparation/core_storage.py:66-71,103,356,492-505 & tests/preparation/test_core_storage.py:83-139: Lowers SM87 DEVICE_BASE to 0x0c00000000 (48..96 GiB), reads self._host_vmm from layout["host_vmm"], renames WindowsHostRegion to HostVmmRegion with an explicit HOST_NUMA_VMM (141) guard, and adds unit tests for region dispatch, overflow cleanup, and 141 rejection.
  • docs/runtime-core-design.md:92-121: Documents the Linux host-VMM fallback, narrow-aperture 8 GiB host range, and SM87 48..96 GiB / 12 GiB defaults.
Merge Risk: Medium · up to ea65cb2
  • Shared MappedHost load/init seams across all targets: Modifies heliopause/src/allocator.rs, helios/src/runtime_core/{driver,host,mod}.rs, and ignition/preparation/core_storage.py, which run on every export and native core load across SM87/103/110/120/121 and Windows WDDM. Linux GPUs with 99==1 && 91==1 and Windows WDDM (!cfg!(windows)) preserve their existing paths, keeping steady-state regression risk bounded, but no CI has verified Windows or non-Orin/Thor targets on ea65cb2.
  • Every SM87 export moves address windows and collides with fix(ignition): raise GA10B external floor, reseal unified-memory capture window, warm addmm, and mark vocab_ids numeric #658: Lowering integrated SM87 DEVICE_BASE from 0x12_0000_0000 (72 GiB) to 0x0c_0000_0000 (48 GiB) shifts all SM87 exports (even models without MappedHost) and directly conflicts with open PR fix(ignition): raise GA10B external floor, reseal unified-memory capture window, warm addmm, and mark vocab_ids numeric #658's GA10B cuRAND floor fix (EXTERNAL_FLOOR = 0x9_0000_0000, DEVICE_BASE = 0x12_0000_0000).
  • Narrow-aperture VA race during preparation: Freeing the probed [40 GiB, 48 GiB) host VMM range between CoreStorage.__init__ and host_allocate() leaves it exposed to intervening CUDA/cuBLAS external allocations in [EXTERNAL_FLOOR, DEVICE_BASE).
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: No untrusted external inputs, secret exposure, suspicious native/FFI behavior, or prompt-injection attempts in PR diff or metadata.
  • ⚠️ Charter & value fit: Capability-based reuse of host-backed CUDA VMM on SM87 (a documented target in docs/cli-design.md:6) fits the charter well, with zero per-model branches; however, allocator.rs:526-530 duplicates Python's EXTERNAL_FLOOR via a magic address heuristic, probe errors are swallowed without root-cause status (allocator.rs:544-553), and non-Orin/Thor targets in the supported matrix remain unverified.
  • ⚠️ Related / duplicate / conflict check: Head-on conflict with open PR fix(ignition): raise GA10B external floor, reseal unified-memory capture window, warm addmm, and mark vocab_ids numeric #658 on ignition/preparation/core_storage.py:66-71 and tests/preparation/test_core_storage.py:83+, plus stale statements left in helios/src/cuda.rs, selene/src/offload.rs, and docs/ from merged Fix CUDA 12 batched copies, Linux ARM64 release portability, and Selene unified-memory budgeting #589 and earlier Windows docs.
  • ⚠️ Tests & verification evidence: Unit tests in host.rs, allocator.rs, and test_core_storage.py are isolated (no global state leaks), but no CI ran on ea65cb2; end-to-end Orin Nano/Thor evidence is self-reported via the #[ignore]d fixed_core_fixture.py (not opened) -> event_tests.rs fixture, test_host_allocate_selects_region_by_host_vmm bypasses CoreStorage.__init__ via __new__, and Windows WDDM, AGX Orin 64 GiB, SM120/SM121, and RoCE over host-VMM were not exercised.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants