Repository navigation
helios: trim trailing VMM reservation slack on CUDA_ERROR_INVALID_VALUE - #73
Draft
FujitsuPolycom wants to merge 1 commit into
Draft
FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
Conversation
Prepared model cores align fixed virtual-memory reservations to coarse
boundaries that can include unallocated trailing padding beyond the
highest declared device allocation. On integrated GPUs whose kernel or
firmware exposes a slightly tighter CUDA VMM ceiling than the exporting
host (for example, stock QSPI boot firmware on JetPack 7.2.2 on Jetson
Orin Nano 8 GB at ~95.83 GiB vs. a 96.0 GiB reservation end),
cuMemAddressReserve fails with CUDA_ERROR_INVALID_VALUE even though
every fixed and runtime-sized allocation fits.
- helios/src/runtime_core/driver.rs:
- Before: CUDA_ERROR_INVALID_VALUE was not defined as a named constant.
- After: adds pub const CUDA_ERROR_INVALID_VALUE: c_int = 1.
- helios/src/runtime_core/mod.rs & model.rs:
- Before: NativeResources::reserve requested reservation.nbytes once
and only received cores[0] in NativeModel::load.
- After: adds private unsafe fn NativeResources::reserve_for(&mut self,
cores: &[Core]) and trimmed_reservation_bytes (using
usize::checked_next_multiple_of). On CUDA_ERROR_INVALID_VALUE, it
queries cuMemGetAllocationGranularity (CU_MEM_ALLOC_GRANULARITY_MINIMUM),
computes the granule-aligned span covering every rank's Memory::Device
fixed and maximum runtime-sized extents inside the reservation, and
retries cuMemAddressReserve only when 0 < trimmed < reservation.nbytes.
self.reservations records the actual reserved length so teardown frees
the exact span. Adds CPU unit tests for trimmed_reservation_bytes.
- Compatibility: zero behavior change when the full reservation succeeds;
existing signed cores load without re-export or re-signing.
Result:
- Expected to unblock loading unmodified signed cores whose coarse
trailing reservation slack overhangs a tighter integrated-GPU VMM
ceiling, with zero steady-state runtime overhead.
Evidence:
- Verified on clean git archive via cargo test --locked --release
--manifest-path helios/Cargo.toml --features runtime-core,server and
CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_core_boundary.py.
- Limitations: live GPU verification of the retry and cuMemAddressFree
teardown path on this candidate commit (single-rank SM87, multi-rank
TP > 1, SM103/SM120/SM121, 64 KiB pages, and Windows WDDM) remains
unrun.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: Dooner <dooner@users.noreply.github.com>
FujitsuPolycom
force-pushed
the
jetson/pr-a-vmm-reservation-slack-trim
branch
from
December 4, 2026 21:57
5597325 to
ccd6460
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Prepared model cores align fixed virtual-memory reservations to coarse boundaries (typically GiB-rounded spans) that include unallocated trailing padding beyond the highest declared device allocation. On integrated GPUs whose kernel or firmware configuration exposes a slightly tighter CUDA VMM virtual-address ceiling than the host that exported the core (for example, stock QSPI boot firmware on JetPack 7.2.2 on Jetson Orin Nano 8 GB at ~95.83 GiB vs. a 96.0 GiB reservation end),
cuMemAddressReservefails withCUDA_ERROR_INVALID_VALUEeven though every fixed and runtime-sized device allocation in the core fits inside the device's address space.Trimming only the unallocated trailing slack—after the full reservation fails with
CUDA_ERROR_INVALID_VALUE, rounded up to the device's livecuMemGetAllocationGranularity—lets existing signed cores load without re-exporting or relaxing any address-overlap, mapping, or teardown invariants.What changed
Before this change,
NativeResources::reserveissued a singlecuMemAddressReserveforreservation.nbytesand failed immediately onCUDA_ERROR_INVALID_VALUE.helios/src/runtime_core/driver.rs:CUDA_ERROR_INVALID_VALUEwas not declared alongsideCUDA_ERROR_NOT_READYandCUDA_ERROR_PRIMARY_CONTEXT_ACTIVE.pub const CUDA_ERROR_INVALID_VALUE: c_int = 1.helios/src/runtime_core/mod.rs&helios/src/runtime_core/model.rs:NativeResources::reserve(&mut self, core: &Core)always requestedreservation.nbytesand only sawcores[0]during multi-rank loading inNativeModel::load.unsafe fn reserve_for(&mut self, cores: &[Core])(called byNativeModel::loadwith all ranks&cores, whileNativeResources::reserve(&mut self, core: &Core)delegates to it for single-rank callers). WhencuMemAddressReservereturnsCUDA_ERROR_INVALID_VALUE,reserve_forqueriescuMemGetAllocationGranularity(CU_MEM_ALLOC_GRANULARITY_MINIMUM) for the target device, computestrimmed_reservation_bytesacross every rank'sMemory::Deviceallocations inside[reservation.address, reservation.address + reservation.nbytes)usingAllocation::extent()(covering both fixed and maximum runtime-sized extents) rounded up viausize::checked_next_multiple_of(granularity), and retriescuMemAddressReserveonly when0 < trimmed < reservation.nbytes.self.reservations.push((address, reserved_bytes))records the actual reserved length before checkingaddress != reservation.address, sorelease_reservations_and_contextalways passes the exact reserved size tocuMemAddressFree. Nounsafeinvariants change and no physical memory is allocated.cuMemGetAllocationGranularityavoids assuming a hardcoded2 MiBgranule on 4 KiB or 64 KiB page hosts. On Windows (#[cfg(windows)]) andhost_vmmLinux devices,address_space::check_fitscontinues to guard virtual-address width first andMemory::MappedHostremains managed separately byallocate_host.helios/src/runtime_core/mod.rs): Adds CPU tests fortrimmed_reservation_bytescovering trailing slack trimming, runtime-sizedSizingextents, multi-rank merged reservations where a secondary rank holds the highest device address, ignoredMappedHost/Peer/unaddressed/before-window/at-window-end/external allocations,granularity == 0, no-slack boundary, reservation with no device allocations, and address overflow.Claimed benefit and result
ccd6460b): Unblocks loading unmodified signed cores whose GiB-rounded trailing reservation slack overhangs a tighter integrated-GPU VMM ceiling (such as stock QSPI boot firmware on JetPack 7.2.2 on Jetson Orin Nano 8 GB) without re-exporting.cuMemAddressReservefails. No serving throughput benchmark is claimed.Supporting evidence and limitations
Tested on clean
git archive ccd6460bf8088715c2026996d2498291dcbfb87batopNVIDIA/hyperflare-inferencemain(7bbc6707792aa1cb8633794ee189b7592091cc45):ccd6460bf8088715c2026996d2498291dcbfb87b):cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server(withFLARE_TEST_TEMPLATE_DIRprepared viatests/frontend/prepare_templates.py):1,920 passed; 0 failed; 49 ignored(lib, including all 3 newruntime_core::tests::trimmed_reservation_bytes_*tests) and62 passed; 0 failed; 36 ignoredacross integration tests (85ignored tests require external model checkpoint snapshots or GPU hardware).CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_core_boundary.py -v:4 passed.CUDA_ERROR_INVALID_VALUEretry andcuMemAddressFreeteardown path onccd6460bf8088715c2026996d2498291dcbfb87bhas not yet been run (single-rank SM87 Jetson Orin Nano with stock QSPI boot firmware, multi-rankTP > 1,SM103/SM120/SM121, 64 KiB page systems, and Windows WDDM are covered by CPU unit tests and code audit rather than live GPU fault injection).Discord: Dooner