Skip to content

[P2P] Add Cambricon MLU (CNRT) support for cross-node P2P RDMA#1011

Open
Iwandy777 wants to merge 4 commits into
uccl-project:mainfrom
Iwandy777:feat/cambricon-mlu-p2p
Open

[P2P] Add Cambricon MLU (CNRT) support for cross-node P2P RDMA#1011
Iwandy777 wants to merge 4 commits into
uccl-project:mainfrom
Iwandy777:feat/cambricon-mlu-p2p

Conversation

@Iwandy777

Copy link
Copy Markdown
Contributor

Description

Adds Cambricon MLU (CNRT) cross-node P2P RDMA (write + read), extending the
existing intra-node IPC support. Plain cnrtMalloc / torch_mlu tensors are not
peer-able, so the NIC cannot DMA them directly; uccl relays user buffers through
a bounded peer-able staging buffer in chunks (as CNCL does). Also caches the IPC
handle per allocation (cnrtAcquireMemHandle succeeds only once per allocation),
and adds header dependencies to Makefile.cnrt. All changes are guarded by
__CAMBRICON_PLATFORM_MLU__; non-Cambricon builds (CUDA/HIP/MUSA) are
byte-identical to main.

Type of Change

  • Bug fix
  • New feature
  • Documentation update

How Has This Been Tested?

  • Integration tests — one-sided IPC suite (24/24 PASS)
  • Manual testing — single-node self-test (write+read) and real 2-node cross-node write/read

Checklist

  • I have run format.sh to follow the style guidelines.
  • I have verified compilation (make -f Makefile.cnrt).
  • I have removed redundant variables and comments.
  • I have updated the documentation.
  • I have added tests.

Iwandy777 and others added 3 commits June 26, 2026 15:24
Map the gpu* runtime abstraction onto CNRT/CNDRV under the
__CAMBRICON_PLATFORM_MLU__ guard, leaving CUDA/HIP builds unchanged:
- gpu_rt.h: CNRT macro mappings + inline wrappers where signatures differ
- util.h: MLU vendor id (0xcabc), CNRT-based BDF enumeration, get_dev_idx
- engine.cc: open IPC handles in the owner GPU context and copy across
  cards via cnrtMemcpyPeerAsync; use the exact allocation base for
  cnrtAcquireMemHandle
- nccl_types.h: alias cudaStream_t to cnrtQueue_t
- add Makefile.cnrt and a torch-free one-sided IPC test

Verified on MLU370-X8: MLU0<->MLU1 one-sided IPC (write/read/writev/readv
and async variants) all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…bench

- probe_peermem_regmr.py: verify ibv_reg_mr on MLU device memory via
  cambricon_peer_mem (the cross-node MLU P2P gating capability)
- xnode_cnrt.py: inter-node RDMA-WRITE between two MLU nodes with built-in
  TCP rendezvous; correctness + bandwidth sweep
- bench_ipc_cnrt.py: intra-node IPC P2P bandwidth/latency

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- engine: transparent bounded peer-able staging for write/read so plain
  cnrtMalloc buffers (non peer-able, e.g. torch_mlu tensors) work over RDMA;
  plain device memory can't be NIC-DMA'd directly on Cambricon.
- engine: cache the IPC mem handle per allocation (cnrtAcquireMemHandle only
  succeeds once per allocation) so repeated advertise_ipc is idempotent; fixes
  a hang in bench_ipc_cnrt.py at the second advertised size.
- Makefile.cnrt: auto-generate header deps (-MMD -MP) to avoid ABI mismatch
  when engine.h changes.
- tests/xnode_cnrt.py: single-node self-test (spawn two local MLUs, RDMA over
  NIC loopback, write+read) plus manual real inter-node mode.
- benchmarks/benchmark_nixl.py: use the resolved device string in the padding
  block allocation.

All changes are guarded by __CAMBRICON_PLATFORM_MLU__ and do not affect
CUDA/HIP/MUSA.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Iwandy777

Copy link
Copy Markdown
Contributor Author

Config: 2x Cambricon MLU370-X8, Neuware, ConnectX-5 (mlx5, RoCEv2), built with
make -f Makefile.cnrt, torch-free. Verified: cross-process/cross-GPU IPC,
single-node self-test, and cross-node RDMA write/read.

Intra-node IPC (bench_ipc_cnrt.py):

Size BW (GB/s) Lat (us)
4 KB 0.04 116
64 KB 0.54 120
1 MB 6.30 167
16 MB 17.63 952
256 MB 24.71 10865

Cross-node GDR (128 MB, 4 chunks): WRITE 6.89 GB/s, READ 6.31 GB/s.

Reformat probe_peermem_regmr.py and bench_ipc_cnrt.py with black to satisfy
the python-format-check CI. Formatting only, no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant