Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions docs/source/zh_archive/kunpeng_ub_transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Kunpeng UB Transport
Kunpeng UbTransport源代码路径为Mooncake/mooncake-transfer-engine/src/transport/kunpneg_transport,该路径下有UB协议的Transport对接代码和实现逻辑。

## 概述
UB(Unified Bus,统一总线) 是与RDMA、CXL、NVLink 和TCP处于同一抽象层的传输协议,属于可在应用层灵活选择的传输方案。目前 UB 协议有两个开源实现:URMA(远程内存访问语义)和 OBMM(Load/Store 语义)。

URMA(Unified Remote Memory Access,统一远程内存访问)是UB协议为上层应用提供的统一编程抽象与核心语义层。它基于 UB 协议低延迟、高带宽的底层特性,为远程共享内存的访问与操作提供统一的 API 和语义接口。

URMA 开源代码仓库:https://atomgit.com/openeuler/umdk

OBMM (Ownership Based Memory Management) 是面向超节点环境的内核内存管理系统,支持跨节点的物理内存共享。该系统通过内核模块 (obmm.ko) 和用户态库 (libobmm.so) 提供高效的远程内存访问能力。

OBMM 开源代码仓库:https://atomgit.com/openeuler/obmm

## 新增依赖
Kunpeng UbTransport在Mooncake本身依赖的基础上,新增了一部分URMA和OBMM的依赖:

- **硬件平台**: 支持原生UB互联架构的鲲鹏950 CPU
- **OS版本**: openEuler 24.03 (LTS-SP3) [下载链接](https://www.openeuler.openatom.cn/zh/download/#openEuler%2024.03%20LTS%20SP3)
- **URMA依赖**: UMDK: `yum install umdk-urma-devel` 或从[源码](https://atomgit.com/openeuler/umdk)构建。
- **协议优势**: URMA 提供类似 RDMA 的内存语义,针对鲲鹏芯片片上互联进行了优化

---

## 构建与编译

**前置条件**

- openEuler 24.03 (LTS-SP3) [下载链接](https://www.openeuler.openatom.cn/zh/download/#openEuler%2024.03%20LTS%20SP3)
- 已安装 UMDK: `yum install umdk-urma-devel` 或从[源码](https://atomgit.com/openeuler/umdk)构建

**CMake 配置**

```bash
# 克隆 Mooncake 仓库
git clone https://github.com/kvcache-ai/Mooncake.git
cd Mooncake

# 启用 UB 传输层进行配置
mkdir build && cd build
cmake .. -DUSE_UB=ON \
-DURMA_INCLUDE_DIR=/usr/include \
-DURMA_LIBRARY=/usr/lib64/liburma.so

# 编译
make -j$(nproc)
```

**验证**

```bash
# 检查 UB 传输层是否已注册
./mooncake_server --list-transports
# 预期输出: rdma, tcp, nvlink, ub
```

---

## 运行与测试

**单节点基准测试**

```bash
# 终端 1: 目标端(Target)
./transfer_engine_bench \
--mode=target \
--protocol=ub \
--device_name=urma0 \
--local_server_name=127.0.0.1 \
--metadata_server=P2PHANDSHAKE

# 终端 2: 发起端(Initiator)
./transfer_engine_bench \
--mode=initiator \
--protocol=ub \
--device_name=urma0 \
--metadata_server=P2PHANDSHAKE \
--segment_size=8388608 \
--batch_size=1\
--segment_id=127.0.0.1:$PORT
```

**多设备基准测试**

```bash
# 自动发现多个 URMA 设备
./transfer_engine_bench \
--protocol=ub \
--device_name=urma0,urma1,urma2,urma3
```
5 changes: 5 additions & 0 deletions mooncake-common/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ option(USE_ASCEND_HETEROGENEOUS "option for transferring between ascend npu and
option(USE_MNNVL "option for using Multi-Node NVLink transport" OFF)
option(USE_CXL "option for using CXL protocol" OFF)
option(USE_EFA "option for using AWS EFA transport" OFF)
option(USE_UB "option for using UB protocol transport" OFF)

if (USE_UB)
add_compile_definitions(USE_UB)
message(STATUS "ub transport is enabled")
endif()
if (USE_EFA)
# Find libfabric headers and library; default to AWS EFA installer path
find_path(LIBFABRIC_INCLUDE_DIR rdma/fabric.h
Expand Down
6 changes: 6 additions & 0 deletions mooncake-transfer-engine/example/transfer_engine_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ static void freeMemoryPool(void *addr, size_t size) {
#endif
}
#else
if (FLAGS_protocol == "ub") {
munmap(addr, size); // for urma
}
numa_free(addr, size);
#endif
}
Expand Down Expand Up @@ -459,6 +462,9 @@ static Transport *installTransportFromFlags(TransferEngine *engine) {
args.get()[0] = const_cast<char *>(nic_priority_matrix.c_str());
args.get()[1] = nullptr;
xport = engine->installTransport(FLAGS_protocol.c_str(), args.get());
} else if (FLAGS_protocol == "ub") {
engine->getLocalTopology()->discover({FLAGS_device_name});
xport = engine->installTransport(FLAGS_protocol, nullptr);
} else if (FLAGS_protocol == "efa") {
// EFA needs topology discovery to find devices, but auto_discovery
// would auto-install RDMA transport. Manually discover instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ int initiator() {
args[0] = (void *)nic_priority_matrix.c_str();
args[1] = nullptr;
xport = engine->installTransport("rdma", args);
} else if (FLAGS_protocol == "ub") {
engine->getLocalTopology()->discover({FLAGS_device_name});
xport = engine->installTransport(FLAGS_protocol, nullptr);
} else if (FLAGS_protocol == "tcp") {
xport = engine->installTransport("tcp", nullptr);
} else if (FLAGS_protocol == "nvlink") {
Expand Down Expand Up @@ -412,6 +415,9 @@ int target() {
args[0] = (void *)nic_priority_matrix.c_str();
args[1] = nullptr;
engine->installTransport("rdma", args);
} else if (FLAGS_protocol == "ub") {
engine->getLocalTopology()->discover({FLAGS_device_name});
engine->installTransport(FLAGS_protocol, nullptr);
} else if (FLAGS_protocol == "tcp") {
engine->installTransport("tcp", nullptr);
} else if (FLAGS_protocol == "nvlink") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ int target() {
args[0] = (void *)nic_priority_matrix.c_str();
args[1] = nullptr;
engine->installTransport("rdma", args);
} else if (FLAGS_protocol == "ub") {
engine->getLocalTopology()->discover({FLAGS_device_name});
xport = engine->installTransport(FLAGS_protocol, nullptr);
} else if (FLAGS_protocol == "tcp") {
engine->installTransport("tcp", nullptr);
} else {
Expand Down
7 changes: 7 additions & 0 deletions mooncake-transfer-engine/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ struct GlobalConfig {
int ib_pci_relaxed_ordering_mode = 0;
bool ascend_use_fabric_mem = false;
bool ascend_agent_mode = false;
// ub config parameters
size_t num_jfc_per_ctx = 2;
size_t num_jfce_per_ctx = 2;
int eid_index = 0;
uint64_t max_seg_size = 0x10000000000;
size_t max_jfc_e = 4096; // urma is temporarily using this default value.
size_t num_jetty_per_ep = 1;
};

struct RpcCommunicatorConfig {
Expand Down
16 changes: 11 additions & 5 deletions mooncake-transfer-engine/include/transfer_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ class TransferMetadata {
std::string name;
uint16_t lid;
std::string gid;
std::string eid; // for ub
};

struct BufferDesc {
std::string name;
uint64_t addr;
uint64_t length;
std::vector<uint32_t> lkey; // for rdma
std::vector<uint32_t> rkey; // for rdma
std::string shm_name; // for nvlink and hip
uint64_t offset; // for cxl
std::vector<uint32_t> lkey; // for rdma
std::vector<uint32_t> rkey; // for rdma
std::string shm_name; // for nvlink and hip
uint64_t offset; // for cxl
std::vector<std::string> tseg; // for ub/urma
std::vector<uint32_t> l_seg_index; // for ub/urma
};

struct NVMeoFBufferDesc {
Expand All @@ -82,7 +85,7 @@ class TransferMetadata {
struct SegmentDesc {
std::string name;
std::string protocol;
// this is for rdma/shm
// this is for rdma/shm/urma
std::vector<DeviceDesc> devices;
Topology topology;
std::vector<BufferDesc> buffers;
Expand Down Expand Up @@ -113,6 +116,9 @@ class TransferMetadata {
struct HandShakeDesc {
std::string local_nic_path;
std::string peer_nic_path;
#ifdef USE_UB
std::vector<uint32_t> jetty_num; // for ub/urma
#endif
#ifdef USE_BAREX
uint16_t barex_port;
#endif
Expand Down
Loading
Loading