Repository navigation
ggml-rpc: exchange a mesh partial over 1 MiB as pieces sent to every peer at once - #24
Conversation
…peer at once On a mesh whose links are all RDMA, a partial larger than RPC_COMM_MESH_EAGER_BYTES went pair by pair: one transfer at a time, though each pair of ranks has its own link. A tensor split's prompt chunk all-reduces such partials (a 512-token chunk of a 2560-wide model is 5 MiB). It now goes as pieces of at most 1 MiB, each sent to every peer before any is received, so the pieces travel on every link at once. A rank sends piece k+1 only after it has read piece k from every peer, so a link never holds more than two unread pieces, the bound the eager exchange already relies on. The partials are summed in rank order as before. On by default; GGML_RPC_COMM_CHUNKED=0 restores the pair-by-pair exchange.
There was a problem hiding this comment.
🟡 Changes recommended
Per-rank chunking decisions can produce incompatible wire framing and fail large all-reduces, requiring all ranks to agree on the exchange mode and use a mesh-wide fallback when any link is TCP.
1 open issue
What changed in this PR
This PR adds chunked exchange for large RPC mesh all-reduce partials, aiming to improve prompt-processing throughput on RDMA meshes with more than two ranks.
Changes:
- Exchanges partials larger than 1 MiB in bounded pieces, sending each piece to all peers before receiving.
- Adds the default-on
GGML_RPC_COMM_CHUNKEDswitch, includingflag:support and one-time logging. - Validates each piece's sequence and size while preserving rank-ordered summation.
| File | Description |
|---|---|
ggml/src/ggml-rpc/ggml-rpc.cpp |
Adds chunked mesh exchange, runtime mode selection, header checks, and logging. |
Review effort: Balanced
Exchanging a large partial in pieces changes what it looks like on the wire, but each rank decided on its own: from its own links (all RDMA or not) and from its own GGML_RPC_COMM_CHUNKED, read again at every all-reduce. A rank with a TCP link, or one with the switch set differently, expected the whole partial where its peers sent pieces, and the all-reduce failed. The ranks now agree when the mesh forms: each tells every peer whether it wants pieces, and the mesh exchanges in pieces only when all of them do. The switch is read then. A peer whose build sends no answer fails the mesh's setup within its deadline rather than reading the agreement as a partial.
…ves at their deadline A piece's header gave only the piece's own size, so ranks whose partials differed in size could read pieces of the sizes they expected: the rank with the smaller partial finished while its peers waited for pieces it never sent. Every piece's header now carries the whole partial's sequence number and size, as the other exchanges' headers do, so such a peer fails at the first piece; a piece's own size follows from its offset. The agreement's receives run after the links have moved to RDMA, where a receive ignored its deadline, so a peer of a build that sends no agreement held COMM_INIT forever. A receive deadline now bounds RDMA receives too, on Linux and Apple: past it the receive fails, as over TCP, and the mesh's setup fails when its deadline passes.
…ed data The Apple transport checked a receive's deadline only while it waited on an empty queue, so a frame already queued was read after the deadline had passed. It now checks at every pass of the receive loop, as the Linux transport and TCP do, and a receive past its deadline breaks the connection.
|
More than three ranks, on 4d74009. macOS arm64, the clean What this run cannot cover: the pieces themselves. A rank exchanges in pieces only when every one of its links is RDMA ( What it does cover:
Each server's log: The unequal-count refusal, from a one-off client that is not part of the PR. Against N fresh servers, it all-reduces 300007 floats on every rank but the last and 300008 there, then 300007 everywhere: |
|
Four and five ranks over RDMA, on 4d74009 (the lab build's tree, 15bc18be9f27, equals this head's), 2026-11-02. Three DGX Sparks, each pair joined by its own 200 GbE RoCE link, CPU
On every rank of both meshes, every link came up over RDMA, the same-host ones included, and the rank logged |
|
On 4d74009, the first attempt of The cause is not established, and the same commit passed on rerun. What is known about it:
|
|
Declined for now: Copilot's review 5731851038 (🔵, no open issues) asks for the Apple RDMA receive deadline to be validated on Apple hardware, and that can't run here. Not done: no Apple RDMA hardware here. Running it needs two Macs joined over Thunderbolt RDMA, which we don't have. So the Apple path's deadline check (4d74009,
This needs a maintainer's call on the Apple path: approve with that path labelled unverified, or wait for someone with two Thunderbolt-RDMA Macs. |


What this changes
On a mesh whose links are all RDMA (more than two ranks), an all-reduce partial larger than
RPC_COMM_MESH_EAGER_BYTES(1 MiB) went pair by pair: one transfer at a time, in rank order, though each pair of ranks has its own link. It now goes as pieces of at most 1 MiB, each sent to every peer before any is received, so the pieces travel on every link at once.On by default. The ranks agree on it when the mesh forms: the mesh exchanges in pieces only if every rank's links are all RDMA and no rank sets
GGML_RPC_COMM_CHUNKED=0; otherwise every rank exchanges pair by pair. The switch is read then (flag:<path>works as for the other comm switches, and takes effect when the next mesh forms). A mesh with a TCP link, a two-rank comm, and every partial up to 1 MiB (every decode-sized one) take the same path as before. Each rank logs at setup which way its mesh exchanges.Why it is safe
Why
A tensor split all-reduces two partials per layer, and prompt processing makes them large: a 512-token chunk of a 2560-wide model is 5 MiB per partial. Exchanging them one link at a time left two of the three links idle.
Measured on three DGX Spark (GB10) nodes, each pair joined by its own 200 GbE RoCE link, every model split three ways (
-sm tensor, one rank per node). Base =spiceai-b11999(f3bce26), branch = this PR's first commit on it (built from the same tree; the agreement commit is measured separately below);llama-bench -fa 1 --load-mode dio -ub 512 -n 0 -r 5, arms interleaved base, branch, branch, base (the RPC servers restarted per arm), nothing in the environment but the mesh's own variables. Each cell is the arm's slowest and fastest of its 5 repetitions, tok/s:On every row the slowest branch repetition beats the fastest base repetition (n=10 each side).
Every repetition, tok/s
Decode cannot reach the change: a decode step's partials are a few tokens wide, tens of KB, far under the 1 MiB threshold. Measured anyway, Qwen3.8
-p 0 -n 128 -r 10, the same interleaved order, each arm's range over its 10 repetitions: base 36.36–39.39, branch 38.26–39.58, branch 38.46–40.07, base 38.55–39.75 tok/s. The two base arms alone differ by 2.8 tok/s (medians 36.73 and 39.49), so decode shows no change inside that same-build noise.Through the Spice runtime's llama.cpp engine (the same exchange on the fork's earlier b11803 line, before the agreement, switched live with
flag:inside each loaded server, Qwen3.8 as above, two sessions): a cold 3,754-token prompt took 6.07 / 5.98 s off and 5.15 / 5.21 s on (−14 %), and the first bench after loading, off in one session and on in the other, gave greedy replies to 8 fixed prompts identical on all 8.Testing
test-rpc-comm-meshover the RDMA mesh (threeggml-rpc-servers, one per node, CPU device unless stated), all-reduces of 1, 7168, 300007 and 4000037 floats; the last two are over 1 MiB:GGML_RPC_COMM_CHUNKED=0on every rank, and on the branch with CUDA servers (the stream-staged path). All three ranks log the pieces on the branch, none on the base or with the switch at 0.rank 1 expected all-reduce 3 of 1200028 bytes from rank 0, got 3 of 1048576 bytesand the otherslost rank 1 during all-reduce 3. With the agreement: world 3 passes all four sizes, the two ranks with the switch on log that a rank of the mesh has a TCP link orGGML_RPC_COMM_CHUNKED=0, so partials over 1 MiB go pair by pair, and no rank logs pieces.world 3: the comm did not initialize, ranks 0 and 2 loggingRDMA recv failed: past its deadline.GGML_RPC_COMM_CHUNKED=0on one rank (pair by pair).GGML_RPC_COMM_HOSTSlist, whose entries for the third rank are invalid at world 2. The world-2 pairwise comm passes all four sizes in every run.llama-bench -p 2048 -n 0 -r 5, first commit vs both commits, interleaved first, both, both, first, tok/s: 763.48, 764.34, 781.31, 778.81, 766.03 / 761.01, 764.52, 782.96, 778.04, 763.78 / 784.78, 789.77, 806.09, 804.33, 793.81 / 768.56, 770.18, 789.75, 784.58, 775.47. The first agreement arm's range (761.01–782.96) contains that of the first-commit arm before it (763.48–781.31), and the second overlaps the first-commit arm after it (both builds ran faster in the later runs), so no change.llama-perplexityon Qwen3.8 (wiki.test.raw,-c 2048 -b 2048 -ub 512, 4 chunks): base and branch print the same per-chunk values ([1]1.4155 [2]1.4048 [3]1.4938 [4]1.9963) and the same estimate, PPL = 1.9963 ± 0.05226, at 4.67 and 4.14 s per pass.test-rpc-transportpasses on Linux, base and branch.llama-bench -p 2048 -n 0 -r 5, arms interleaved, tok/s: with the fix 765.41–784.64, 778.06–799.47, 786.55–808.63; without 773.53–795.37, 762.06–783.58, 759.59–775.73. The ranges overlap, so no change.-DGGML_CCACHE=OFF), on the first commit and again with the agreement:test-rpc-comm-mesh(world 3 and world 2, all four sizes, and the pairwise comm),test-rpc-transportandtest-rpc-multi-serverpass underctest. Their servers are on loopback TCP, where the mesh exchanges pair by pair, so these show that path unchanged; the pieces are exercised by the RDMA runs above.ggml-rpc-servers shared a host where the three Sparks ran out. Every link came up over RDMA, the same-host ones included, and every rank logged the pieces. Every size held the exact sum on every rank (run in a comment below). Four and five ranks also pass on loopback TCP, which goes pair by pair.