Skip to content

feat: support NVLink switch multicast - #606

Merged
nihalpasham merged 3 commits into
NVIDIA:mainfrom
drbh:nvls-multicast
Aug 1, 2026
Merged

nihalpasham merged 3 commits into
NVIDIA:mainfrom
drbh:nvls-multicast

Conversation

@drbh

@drbh drbh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

hi thank you for this very exciting project!!

this pr adds nvlink switch multicast support to cuda-core to enable multi-gpu work on nvls systems

  • adds wrappers for creating multicast objects, adding devices, binding physical allocations, mapping multicast virtual addresses, and cleaning them up on drop
  • adds helpers for checking multicast support and querying multicast granularity
  • adds a two gpu integration test covering the create, bind, map, access, and teardown flow
  • adds an nvls all-reduce example using multimem.ld_reduce and multimem.st
  • skips the test and example on unsupported systems

the example requires at least two multicast-capable gpus on an nvlink switch system and can be run like:

cargo oxide run nvls_all_reduce

and outputs the following on a machine with 8x B200s

=========================================
RUSTC-CODEGEN-CUDA: nvls_all_reduce
=========================================

Detected GPU arch: sm_100a (via nvidia-smi)

This is the proper cargo workflow:
  CARGO_ENCODED_RUSTFLAGS=<cuda-oxide flags> cargo run

Building and running nvls_all_reduce...

   Compiling nvls_all_reduce v0.1.0 (/home/david_holtz/Projects/cuda-oxide-fork/crates/rustc-codegen-cuda/examples/nvls_all_reduce)
    Finished `release` profile [optimized] target(s) in 0.86s
     Running `target/release/nvls_all_reduce`
nvls_all_reduce example
Team: 8 multicast-capable GPUs, 1048576 f32 elements
GPU 0: all 1048576 elements correct
GPU 1: all 1048576 elements correct
GPU 2: all 1048576 elements correct
GPU 3: all 1048576 elements correct
GPU 4: all 1048576 elements correct
GPU 5: all 1048576 elements correct
GPU 6: all 1048576 elements correct
GPU 7: all 1048576 elements correct
SUCCESS: NVLS all-reduce across 8 GPUs verified

please let me know if any changes should be made, I'm happy to split anything out if this is too much for one pr or adjust the feature in any other way!

@nihalpasham nihalpasham added enhancement New feature or request host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves labels Aug 1, 2026
cuMulticast* only exists in CUDA 12.1+ headers, and cuda-bindings binds
whatever the host cuda.h declares, so building against a CUDA 12.0
toolkit failed to compile all of cuda-core. A small build-script probe
(mirroring cuda-bindings' cuda_has_cuEventElapsedTime_v2 pattern and its
toolkit discovery) emits cuda_has_multicast, and the multicast surface
of vmm compiles out without it; multicast_supported keeps a uniform
probe-and-skip contract by answering false on pre-12.1 toolkits.
Verified both directions: a real 13.3 toolkit (cfg on, two-GPU test
skips gracefully on non-NVLS hardware) and a stripped cuda.h simulating
12.0 (cfg off, cuda-core compiles cleanly).

Also: drivers older than 12.1 answer CUDA_ERROR_INVALID_VALUE for the
multicast-support attribute; that now reads as "not supported" instead
of panicking the probe-and-skip callers, and the multicast VA
reservations pass the team granularity as their alignment instead of
relying on the driver default.
@nihalpasham
nihalpasham merged commit d3d1445 into NVIDIA:main Aug 1, 2026
33 checks passed
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…A#202)

* feat(cuda-core): port the CUDA VMM wrappers from cuda-oxide

RAII wrappers for the virtual memory management driver API: PhysicalAllocation (cuMemCreate/cuMemRelease), VirtualReservation (cuMemAddressReserve/cuMemAddressFree), Mapping (cuMemMap/cuMemUnmap), plus set_access and granularity helpers. VMM separates physical allocation, VA reservation, and mapping so physical memory from one device can be mapped into another device address space, the foundation for P2P symmetric heaps.

Ported from cuda-oxide cuda-core, which is migrating onto this crate. The integration test exercises the full single-GPU lifecycle, alignment edge cases, a data roundtrip through the mapping, and leak-free teardown. The GPU runner executes the target, and the implementation uses the bindings layout helper for CUmemLocation.

Signed-off-by: nihalp <[email protected]>

* feat(cuda-core): NVLink switch multicast wrappers

Safe RAII wrappers for the cuMulticast driver API within this crate CUDA 13.2+ toolkit floor: MulticastObject builds an NVLink SHARP team, add_device registers each GPU, bind_mem attaches per-GPU physical memory, and Mapping::new_multicast maps the team into a device address space so multimem instructions operate on all bound copies. Support and granularity queries allow probe-and-skip on systems without an NVLink switch.

Ported from cuda-oxide PR NVIDIA#606, validated end to end on an 8x B200 HGX system there. The two-GPU integration test establishes and tears down the full team plumbing and skips gracefully off NVLS hardware. The shared GPU runner now executes the test.

Signed-off-by: David Holtz <[email protected]>

Co-authored-by: nihalp <[email protected]>
Signed-off-by: nihalp <[email protected]>

---------

Signed-off-by: nihalp <[email protected]>
Co-authored-by: David Holtz <[email protected]>
Co-authored-by: Melih Elibol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) enhancement New feature or request host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants