Support 16-node distributed Soft-RoCE routing - #39
Merged
Conversation
Signed-off-by: victoryang00 <yangyiwei2000@gmail.com>
Signed-off-by: victoryang00 <yangyiwei2000@gmail.com>
Signed-off-by: victoryang00 <yangyiwei2000@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR extends CXLMemSim’s distributed server to reliably route memory traffic across a 16-node Soft-RoCE mesh, adding bulk transfer support and strengthening RDMA connection lifecycle handling so distributed workloads (e.g., vLLM TP16) consistently exercise remote memory paths.
Changes:
- Added bulk read/write operations with bounded sizes and 64 KiB RDMA chunking, plus stricter LSA bounds handling.
- Reworked RDMA connection setup/accept, buffer sizing, and completion handling to reduce Soft-RoCE QP wedging and improve shutdown behavior.
- Improved cluster bring-up robustness (RDMA peer connect retries) and added bookkeeping needed for distributed routing/counters.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared_memory_manager.cc | Adds direct range read/write helpers used by distributed/RDMA bulk paths. |
| include/shared_memory_manager.h | Exposes new read_range / write_range APIs. |
| src/rdma_communication.cpp | Adjusts RDMA buffer registration and completion handling (timeouts, polling, accept flow). |
| include/rdma_communication.h | Updates RDMA message sizing (64 KiB) and server accept API to support many peers. |
| src/main_server.cc | Adds retry loop when connecting RDMA peers during distributed startup. |
| src/distributed_server.cpp | Adds bulk TCP ops, RDMA reconnect retries, LSA hardening, and RDMA server message handling for persistence. |
| include/distributed_server.h | Extends distributed/RDMA connection state and adds bulk API declarations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+613
to
+631
| const uint64_t capacity = header->num_cachelines * SHM_CACHELINE_SIZE; | ||
| const uint64_t base = header->base_addr; | ||
| if (capacity == 0 || (base != 0 && addr < base)) | ||
| return false; | ||
| const uint64_t offset = base == 0 ? addr % capacity : addr - base; | ||
| if (offset > capacity || size > capacity - offset) | ||
| return false; | ||
|
|
||
| if (backing_mode == BackingMode::SsdStream) { | ||
| #ifdef CXLMEMSIM_HAS_SSD_STREAMING_BACKEND | ||
| return ssd_backend && call_backend_bool([&]() { return ssd_backend->read(offset, buffer, size); }); | ||
| #else | ||
| return false; | ||
| #endif | ||
| } | ||
| if (!data_area) | ||
| return false; | ||
| memcpy(buffer, data_area + offset, size); | ||
| return true; |
Comment on lines
+637
to
+656
| const uint64_t capacity = header->num_cachelines * SHM_CACHELINE_SIZE; | ||
| const uint64_t base = header->base_addr; | ||
| if (capacity == 0 || (base != 0 && addr < base)) | ||
| return false; | ||
| const uint64_t offset = base == 0 ? addr % capacity : addr - base; | ||
| if (offset > capacity || size > capacity - offset) | ||
| return false; | ||
|
|
||
| if (backing_mode == BackingMode::SsdStream) { | ||
| #ifdef CXLMEMSIM_HAS_SSD_STREAMING_BACKEND | ||
| return ssd_backend && call_backend_bool([&]() { return ssd_backend->write(offset, data, size); }); | ||
| #else | ||
| return false; | ||
| #endif | ||
| } | ||
| if (!data_area) | ||
| return false; | ||
| memcpy(data_area + offset, data, size); | ||
| __atomic_thread_fence(__ATOMIC_RELEASE); | ||
| return true; |
Comment on lines
+2196
to
+2214
| bool delivered = false; | ||
| for (int attempt = 0; attempt < 16; ++attempt) { | ||
| if (it->second.client && it->second.client->send_request(rdma_req, rdma_resp) == 0) { | ||
| delivered = true; | ||
| break; | ||
| } | ||
|
|
||
| // A Soft-RoCE QP can remain nominally RTS while no completion ever | ||
| // arrives. Recreate that one directed connection and replay the | ||
| // idempotent cacheline READ/WRITE instead of wedging the whole MPI job. | ||
| SPDLOG_WARN("Reconnecting RDMA peer node {} after request failure (attempt {}/16)", dst_node, attempt + 1); | ||
| auto replacement = std::make_unique<RDMAClient>(it->second.endpoint_addr, it->second.endpoint_port); | ||
| if (replacement->connect() == 0) { | ||
| it->second.client = std::move(replacement); | ||
| it->second.connected = true; | ||
| } else { | ||
| it->second.connected = false; | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
| } |
Comment on lines
622
to
627
| return -1; | ||
| } | ||
|
|
||
| if (receive_message(msg) < 0) { | ||
| if (receive_message(msg, 5000) < 0) { | ||
| return -1; | ||
| } |
Comment on lines
+2098
to
2102
| bool DistributedRDMATransport::connect_to_node(uint32_t node_id, const std::string &addr, uint16_t port, | ||
| uint64_t remote_addr, size_t remote_buffer_size) { | ||
| std::lock_guard<std::mutex> lock(connections_mutex_); | ||
|
|
||
| auto it = connections_.find(node_id); |
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.
What changed
Why
The previous path was not robust enough for one 16-node memory pool. The vLLM experiment needs every tensor-parallel rank to reach a different remote memory node instead of forming independent pairs or silently using local memory.
Validation