mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #750] [MERGED] [HybridEP] Add DMA-BUF fallback for GPU RDMA memory registration #754
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepEP#754
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepEP/pull/750
Author: @janbernloehr
Created: 9/12/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @jershi425
Base:
hybrid-ep← Head:jbernloehr/hybridep-dmabuf-registration📝 Commits (3)
6e2c53afix(hybrid_ep): add DMA-BUF registration fallback6e6017cfix(hybrid_ep): harden DMA-BUF registration fallback4242f70refactor(hybrid_ep): keep GPU registration state in coordinator📊 Changes
2 files changed (+297 additions, -62 deletions)
View changed files
📝
csrc/hybrid_ep/buffer/internode_doca.cu(+294 -60)📝
csrc/hybrid_ep/buffer/internode_doca.cuh(+3 -2)📄 Description
Summary
Add DMA-BUF support to HybridEP's direct verbs-based GPU memory registration
path.
HybridEP currently detects
CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED, but theDOCA/RDMA coordinator still registers every
cudaMallocbuffer exclusivelywith
ibv_reg_mr. On systems wherenvidia_peermemis unavailable,ibv_reg_mrreturnsnullptr. The returned memory-region pointer is thendereferenced without validation, causing a segmentation fault while
constructing the HybridEP buffer.
This change:
ibv_reg_mras the preferred path;cuMemGetHandleForAddressRangeandibv_reg_dmabuf_mrwhenlegacy registration fails;
cudaMallocpointers by exporting their containingpage-aligned range;
remote-address metadata;
ibv_mr;buffers.
Closes #367.
Problem
The failure reproduces when all of the following are true:
nvidia_peermemis not loaded;cudaMalloc-backeddispatch and combine buffers.
A representative configuration was:
nvidia_peermemThe failure occurs immediately when HybridEP initializes its RDMA buffers,
before the first training iteration completes:
A similar public failure signature is reported in
NVIDIA-NeMo/Megatron-Bridge#5051.
Root cause
HybridEP's DOCA backend allocates the communication buffers with
cudaMallocand registers them directly with libibverbs:
This path relies on legacy peer-memory support for GPU allocations. Without
nvidia_peermem, the call fails and returnsnullptr.Although HybridEP already queries
CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED, theresult was not used by the buffer registration code. NVSHMEM's own DMA-BUF
support does not cover these allocations because the HybridEP RDMA coordinator
registers these buffers directly rather than through NVSHMEM's
memory-registration path.
The subsequent HybridEP code accesses fields such as
mr->lkey,mr->rkey,and
mr->addrwithout checking the result, producing the segmentation fault.DMA-BUF alignment requirement
The first checked implementation attempted to export the exact CUDA pointer
and size. That replaced the segmentation fault with a useful error and exposed
a second issue:
Ordinary
cudaMallocaddresses are not guaranteed to be aligned to the hostpage size.
cuMemGetHandleForAddressRangerequires the exported address rangeto satisfy the DMA-BUF alignment requirements.
The final implementation therefore exports the containing page-aligned range:
The implementation also checks for arithmetic overflow before calculating the
aligned range.
Implementation
A shared
register_gpu_memoryhelper now performs the following sequence forevery dispatch and combine buffer:
Call
ibv_reg_mrfirst.This preserves existing behavior and avoids changing systems where legacy
peer-memory registration already works.
If
ibv_reg_mrfails, save itserrno.The error is preserved before any CUDA or diagnostic calls can overwrite
it.
Verify that CUDA reports DMA-BUF support.
If DMA-BUF is unavailable, raise an error containing the buffer name, the
legacy verbs error, and the fact that CUDA does not support DMA-BUF on the
device.
Determine the host page size with
sysconf(_SC_PAGESIZE).Align the start address down and the end address up to cover the entire CUDA
allocation range.
Export the aligned range using:
Register the exported descriptor using:
Close the exported file descriptor after registration.
Use the resulting memory region's
lkeyandrkey, while retaining theoriginal CUDA buffer addresses for work requests and remote-address
exchange.
The last point is important for subranges of the exported allocation.
ibv_mr::addrmust not be assumed to represent the original, potentiallyunaligned CUDA buffer pointer. Dispatch and combine metadata now explicitly
uses the corresponding CUDA allocation pointers.
The fallback covers:
Dispatch buffers
Combine buffers
When the fallback is selected, rank 0 of each node reports:
CUDA export failures and DMA-BUF verbs registration failures include the
buffer name, CUDA error name and description or verbs
errno, and the originalibv_reg_mrerror where applicable.Validation
The implementation was tested with three multinode MoE training
configurations:
Each configuration used 64 B200 GPUs across eight nodes, eight ranks per node,
and EP64. Each test ran 30 training iterations with synthetic data.
DMA-BUF environment
The environment had CUDA DMA-BUF support and did not load
nvidia_peermem.Before this change:
RDMACoordinator::allocate_combine_buffers;After this change:
The DMA-BUF fallback banner appeared on all eight nodes. Every rank exited
successfully.
Legacy peer-memory environment
The same three configurations were also run on a second 8-node B200
environment where
ibv_reg_mrcan register GPU memory through the legacypeer-memory path.
The DMA-BUF fallback banner did not appear, confirming that the existing
ibv_reg_mrpath remained active.Performance sanity check
Across the matched configurations, throughput in the DMA-BUF environment was
within +/-2.4% of the legacy peer-memory environment:
The geometric mean of the matched ratios was +1.16%. These were single runs on
two independent systems rather than a controlled performance benchmark, but
they show no obvious throughput regression from the DMA-BUF registration path.
Tested revisions
The full multinode runtime matrix was executed with HybridEP revision:
The same patch applies cleanly to the current
hybrid-eptip used as the baseof this change:
The current-tip branch passes
git diff --check. The full 64-GPU runtimevalidation described above was performed on the earlier tested revision.
Compatibility
ibv_reg_mrsucceeds continue using the existing path.exception instead of a null-pointer segmentation fault.
Related issues
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.