Repository navigation
ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address - #18
Merged
Merged
Conversation
…n no port has its address The RDMA probe finds the port whose GID is the TCP connection's local address, so a client that reaches a server on its own host at an address no port carries (a /32 on the loopback interface, 127.0.0.1) stays on TCP over the loopback interface. When the connection's two ends are this host and no port has its address, both ends now take the IPv4 RoCE v2 GID of the first active port (of GGML_RDMA_DEV, when set), and the NIC loops the connection back. GGML_RDMA_GID and GGML_RPC_NO_RDMA keep their meaning.
There was a problem hiding this comment.
🟡 Changes recommended
Loopback RDMA selection can choose an inactive or RoCE v1 port or incompatible NICs across peers, breaking localhost connections.
2 open issues
What changed in this PR
This PR enables same-host RPC connections to use NIC RDMA loopback when their TCP address is not assigned to an RDMA port, reducing transport overhead for the head node's own GPU.
Changes:
- Detects connections whose local and peer addresses match.
- Adds fallback selection of an active port's IPv4 RoCE v2 GID when no port carries the TCP address.
- Logs when the NIC loopback fallback is selected.
| File | Description |
|---|---|
ggml/src/ggml-rpc/transport.cpp |
Adds same-host detection, loopback GID selection, and diagnostic logging to the non-Apple RDMA transport. |
Review effort: Balanced
…th this host only on one GID The loopback fallback handed the probe only GID bytes, so a device scanned earlier with the same GID on a down or RoCE v1 port could carry the connection; it now names the device and the GID's index it chose. Each end of a connection to this host also chooses its port from its own GGML_RDMA_DEV and GGML_RDMA_GID, and two ports need not reach each other, so such a connection now takes RDMA only when both ends chose the same GID, which both see the same way, and otherwise stays on TCP at both ends.
Author
|
Round on c72ae2d, answering Copilot review #18 (review):
|
The two ends of a connection to this host compare only the GID bytes they advertised, and a RoCE v1 entry has the same bytes as the v2 one, so one end pinned to the v1 index (GGML_RDMA_GID) and one choosing v2 passed the comparison with incompatible modes. On such a connection an end whose GID is not RoCE v2 now advertises nothing, and both stay on TCP.
Author
|
Round on 84f12a9, answering Copilot review #18 (review):
|
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer confirmation is needed that the unversioned same-host GID exchange’s requirement for matching endpoint builds or RDMA settings is acceptable for supported deployments.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
bjchambers
approved these changes
Oct 30, 2026
lukekim
added a commit
that referenced
this pull request
Nov 3, 2026
* ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address (#18) * ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address The RDMA probe finds the port whose GID is the TCP connection's local address, so a client that reaches a server on its own host at an address no port carries (a /32 on the loopback interface, 127.0.0.1) stays on TCP over the loopback interface. When the connection's two ends are this host and no port has its address, both ends now take the IPv4 RoCE v2 GID of the first active port (of GGML_RDMA_DEV, when set), and the NIC loops the connection back. GGML_RDMA_GID and GGML_RPC_NO_RDMA keep their meaning. * ggml-rpc: take the loopback port by name and index, and share RDMA with this host only on one GID The loopback fallback handed the probe only GID bytes, so a device scanned earlier with the same GID on a down or RoCE v1 port could carry the connection; it now names the device and the GID's index it chose. Each end of a connection to this host also chooses its port from its own GGML_RDMA_DEV and GGML_RDMA_GID, and two ports need not reach each other, so such a connection now takes RDMA only when both ends chose the same GID, which both see the same way, and otherwise stays on TCP at both ends. * ggml-rpc: advertise RDMA on a connection to this host only over RoCE v2 The two ends of a connection to this host compare only the GID bytes they advertised, and a RoCE v1 entry has the same bytes as the v2 one, so one end pinned to the v1 index (GGML_RDMA_GID) and one choosing v2 passed the comparison with incompatible modes. On such a connection an end whose GID is not RoCE v2 now advertises nothing, and both stay on TCP. * Turn the tensor-split levers on by default: graph slots, one input wait per split, stream-queued all-reduce, deferred sends (#19) * llama, ggml-backend: two graph slots and one input wait per split by default for a tensor split LLAMA_GRAPH_SLOTS and GGML_SCHED_SYNC_INPUTS_ONCE were off unless set. Unset, a tensor split (LLAMA_SPLIT_MODE_TENSOR) now gets the second graph slot, and a split on the meta backend waits for its backend once before copying its inputs; any other model keeps one slot and a wait per input, and a value in the environment still decides either way. On a GLM-5.3 split across three nodes over RPC, each was worth 3-5% of decode with the other levers on. * ggml-rpc: queue a tensor split's all-reduce on a stream and defer its sends by default GGML_RPC_COMM_ASYNC and GGML_RPC_COMM_SEND_DEFER were off unless set; they are now on unless set to 0. Only a tensor split's all-reduce reaches either. On a GLM-5.3 split across three nodes over RPC, with the other levers on, the stream-queued all-reduce was worth 1.4-2.6% of decode and the deferred sends 0.9-1.7%, with replies unchanged.
This was referenced Nov 4, 2026
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 this changes
The RDMA transport picks the port whose GID is the TCP connection's local address. A client that reaches a server on its own host at an address no port carries (a
/32on the loopback interface,127.0.0.1) therefore stayed on TCP over the loopback interface. When a connection's two ends are this host (the peer's address is the socket's own) and no port has that address, both ends now take the IPv4 RoCE v2 GID of the first active port (ofGGML_RDMA_DEV, when set), and the NIC loops the connection back. Both ends run the same choice on the same device list, so they pick the same port (by device name and GID index). Each end of any connection to this host also chooses its port from its ownGGML_RDMA_DEVandGGML_RDMA_GID, so such a connection takes RDMA only when both ends chose the same GID, which both see; otherwise both stay on TCP. On such a connection an end advertises RDMA only over a RoCE v2 GID, since the two ends compare GID bytes alone and a RoCE v1 entry has the same bytes as the v2 one. A peer from a build without this change cannot take part in that agreement, because the exchanged capabilities carry no version: a connection to this host needs both ends from this build, or the sameGGML_RDMA_DEVandGGML_RDMA_GIDon both.Nothing else changes: a connection whose address a port has uses that port as before, and a connection between two hosts is untouched.
GGML_RDMA_GID(an explicit GID index) andGGML_RPC_NO_RDMAkeep their meaning. A peer without this change advertises no RDMA for such a connection, so the two negotiate TCP as before.Why
A tensor split over RPC (#8) drives every rank's GPU as a device, the head's own included, through an RPC server on the head. Spice serves that GPU at the head's own address from its
nodeslist, so that no GPU server listens on an interface the list does not name. When that address is not on the RDMA NIC (in this lab, a/32onlothat routes to every node), the head drove its own GPU over TCP. Naming the head's ConnectX address instead decoded GLM-5.3 6.6% faster (symmetric) in an earlier A/B. With this change the head takes the NIC's loopback whatever address it serves at, so nothing has to be configured for it.Testing
How it was measured
Three DGX Spark (GB10) nodes, each pair cabled over 200 GbE ConnectX-7 (RoCE v2), serving GLM-5.3 (Q2_K_XL) split three ways (
-sm tensor, the full-mesh all-reduce from #8). The head's own GPU is served at an address on the loopback interface, which no port carries. Each bench is 8 prompts, so no P99 is stated.Transport, llama.cpp's own tools (base 3fcbdd2 vs this branch, each with a local test-only hook that lets
test-backend-opsreach an RPC server):test-backend-ops -b RPC0 -o MUL_MATthrough a CUDA RPC server at the loopback address: on both builds, the same 185 cases, all OK, with identical per-case results. Both runs then stop at the same next case, in an abort inside the CUDA backend (mmvq.cu:1460, thedefaultofmul_mat_vec_q's type switch). That case is TQ2_0: intest-backend-ops' type list it follows Q6_K, the last type that passed. Neither upstream nor this fork's CUDA backend has a TQ2_0 kernel. The case ran because the RPC device reports every op as supported (ggml_backend_rpc_device_supports_op, upstream's TODO to ask the server). So the abort is the same on both builds and independent of this change.llama-serverdecode (no draft model), interleaved sessions:Replies were identical in all six sessions (8/8 each).
The Spice runtime's llama.cpp engine, the target. spiced was built against the merged levers (a337bb5 + the commits of #14, #15 and #16), with and without this commit cherry-picked, and the opt-in decode levers on.
Ends that choose different ports (c72ae2d), CPU
ggml-rpc-serverat the loopback address, withtest-backend-ops -b RPC0 -o ADDagainst it (167 cases):rocep1s0f1, client unpinnedrocep1s0f1rocep1s0f0, 167/167rocep1s0f1, 167/167rocep1s0f0, 167/167rocep1s0f1, 167/167On this lab the two ports loop back through one NIC, so the mismatched case passed even on 16789f2; ports that cannot reach each other were not available to test.
RoCE v1 and v2 (84f12a9), same setup;
rocep1s0f0's GID 2 is RoCE v1 and GID 3 RoCE v2, with the same bytes:GGML_RPC_RDMA_APPLE, untouched by this change).