Repository navigation
[Dev]: Add rank-shared host weight offload - #99
Merged
Merged
Conversation
wtr0504
force-pushed
the
dev/offload_shm
branch
from
November 6, 2026 07:01
ade4ed6 to
0c02ad8
Compare
Park every sharing group's chunk k in WORLD round k instead of advancing groups one at a time, with two exchanges per round (writer publish, reader handoff). Plan inputs and their collection errors share one gather. Remove capacity checks that no longer apply to memfd regions: the MAGI_SHARED_BIN_PATH budget, MemAvailable/cgroup headroom and the per-chunk capacity gather. An allocation-time ENOSPC still keeps that chunk private. Plan chunks directly instead of laying out a full region and re-splitting it, give the writer memfd a single close point, park private weights after the last round, and drop the comparison timing log. Co-authored-by: Cursor <cursoragent@cursor.com>
cennn
pushed a commit
that referenced
this pull request
Nov 12, 2026
The graph weight offload that came in from main (Offload V2, #80 / #99) called torch.cuda and compared device types with "cuda" directly: its H2D stream, events and synchronizes, the bandwidth probe, the stand-in device, the move probe that decides parking, and the NUMA lookup. They now go through PLATFORM, so MUSA parks and streams weights the same way. cuda_device_numa_node becomes device_numa_node and returns None for a runtime that reports no PCI address.
This was referenced Nov 12, 2026
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.
🗂️ PR Category
Description
Replicated models using host weight offload keep a pinned CPU copy of every weight on every rank. This change adds opt-in rank-shared host regions so ranks on the same machine can share one physical copy of identical weights while keeping pinned mappings for asynchronous H2D transfers.
Set
offload_config.offload_host_weight_sharingto:off(default): keep a private host copy per rank.per_numa_node: share one copy among the ranks whose GPUs attach to the same NUMA node, with pages preferred on that node.per_host_interleaved: share one copy per host, with pages interleaved across its NUMA nodes.NUMA placement is best effort: if the mempolicy syscalls are unavailable or denied, a warning is logged and the current policy is kept. Unknown GPU NUMA affinity falls back to host grouping with the default policy.
Scope
Sharing applies to eligible unsharded CPU weights parked on a host-built model's first CUDA move. FSDP shards, DTensors, and weights materialized through
to_emptykeep their existing per-rank behavior. Ranks match weights by name, shape, dtype, and a sampled fingerprint; readers then compare the actual bytes before adopting a shared copy, so a fingerprint collision only costs a private copy.How parking works
When sharing is enabled, parking is a WORLD collective over the Gloo group: every rank must move the same compiled models to CUDA in the same order, including ranks with no eligible CPU weights (they take part with empty offers).
posix_fallocateunder the NUMA policy, maps and pins it, and fills it./proc/<pid>/fd/<fd>path.A failure on any rank in planning, writer allocation, mapping or fill, or reader mapping or handoff is exchanged so that every rank raises the same error instead of hanging in a later collective.
Memory and capacity
per_numa_nodeon a two-socket host).MAGI_SHARED_BIN_PATH, and memfd regions are not limited by/dev/shmsize.posix_fallocatereturnsENOSPC, that chunk's weights stay private on every rank of the group, and the other chunks and groups continue.ENOSPCinstead of aSIGBUSwhile filling the region.Requirements
/proc/<pid>/fd/<fd>.cudaHostRegister) and libcudart must be loadable; otherwise parking fails with an error that suggestsoffload_host_weight_sharing='off'.H2D microbenchmark
A standalone H2D benchmark on 8× NVIDIA H200 GPUs and two Xeon Platinum 8558 CPUs compared the three placement modes. It was measured before the parking-protocol refactor; page placement is unchanged by it. Each active GPU repeatedly copied its 256 MiB source into its own device buffer; each per-GPU result is the median of five windows of 20 copies after warmup. The 1-GPU case uses GPU 0, the 4-GPU case uses GPUs 0–3 on NUMA node 0, and the 8-GPU case spans both NUMA nodes. This is a single run on one host, not an application throughput measurement.
offper_numa_nodeper_host_interleavedPage placement was checked through
/proc/self/numa_maps: private and per-NUMA pages were local to each GPU's node, while host-interleaved pages were split evenly across the two nodes. Results can vary with topology, concurrent activity, transfer size, and copy scheduling.Validation
At
9c58b96, on 8× RTX 5090 across two NUMA nodes: 204 passed.test_rank_shared_host_weights.py(21 tests) covers:ENOSPCfallback;test_ep_shared_memory.py,test_weight_offload.py,test_h2d_reorder.py,test_offload_cache.py.Run from the repository root on a CUDA host: