You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over RDMA, a message longer than one 256 KiB chunk went out one chunk at a time. Each chunk was copied into the connection's single send buffer and waited for before the next one was copied. A deferred send longer than one chunk fell back to that blocking send. So the mesh all-reduce's 1 MiB pieces (rpc_comm_mesh_exchange, chunked) went to one peer, then the other, with the link idle while each chunk was copied. The chunked exchange is meant to send each piece to every peer at once.
How it showed: a cold read of a 3754-token prompt across three ranks, profiled with Nsight Systems on each rank's ggml-rpc-server. Each rank's GPU spent 1.9–2.0 s of the 5.4–5.5 s read waiting on all-reduces: 882 of them, 2.5–2.6 ms each (P50) for a 512-token partial of 5 MiB. The kernels took 2.3–2.5 s.
The change (ggml/src/ggml-rpc/transport.cpp, the Linux RDMA transport):
Send buffers: a connection keeps four 256 KiB send buffers instead of one, registered as one region. Four hold a whole 1 MiB mesh piece. A connection now registers 28 chunks (7 MiB) instead of 25.
Posting: a chunk is copied into the next free buffer and posted. A send waits only when the send queue (now 8 entries, from 4) or every buffer is in use. Buffers are taken in posting order and freed in completion order, so the oldest buffer in use is always the one the oldest pending copied send reads.
Deferred sends: a deferred send of any length is posted chunk by chunk, and its completions are taken when the queue or the buffers are needed again, or by wait_sends. So a rank posts a piece to every peer before either peer acknowledges it.
Blocking sends: a blocking send posts the same way, then waits for every pending send on the connection, so the call still reports a failure.
Also (tests/test-rpc-comm-mesh.cpp): the test's two-rank runs now drop the GGML_RPC_COMM_HOSTS entries for ranks 2 and up. They read each entry as rpc_comm_mesh_hosts does, and keep any entry that doesn't parse, so the comm still reports it. A lab whose ranks share one link per pair needs a three-rank map, and the two-rank mesh refused that map's rank-2 entries, so those checks never ran there.
Tests
test-rpc-comm-mesh checks that every rank ends with the same bits, the F32 sum of the partials in rank order, for 1, 7168, 300007 and 4000037 floats. It runs over the three-rank mesh, a two-rank mesh, and the pairwise comm. Here it ran on three DGX Spark (GB10) nodes, every link RDMA, with the servers and the client each on the build named:
The test is this PR's. Against b20c7a2 it ran with b20c7a2's servers and libraries. Before this PR's test change, the two-rank mesh rows did not run on this lab: GGML_RPC_COMM_HOSTS entry '2:0=…' is not i:j=host with j < i < 2, then world 2: the comm did not initialize.
Mutation: the mutation lets a chunk take the next send buffer without waiting for the send still reading it. The test fails on it at 4000037 floats, in every comm and on every rank:
world 3, 4000037 floats, rank 0: 3656053 floats differ from the rank-order sum, first at 77620 (-174.474365, want -382.56897)
world 3, 4000037 floats, rank 1: 3656053 floats differ from the rank-order sum, first at 77620 (-174.474365, want -382.56897)
world 3, 4000037 floats, rank 2: 3656053 floats differ from the rank-order sum, first at 77620 (-174.474365, want -382.56897)
At that size the test uploads each partial as one message of 62 chunks. Up to 300007 floats, a message is at most five chunks, and those checks pass.
Build: CUDA build on GB10, as in the lab rows below. The macOS CPU build compiles ggml-rpc and test-rpc-comm-mesh. It doesn't compile this RDMA transport, which is Linux only.
All-reduce cost, from test-rpc-comm-mesh's bench mode (TEST_RPC_COMM_MESH_BENCH, three ranks). It reports a mean per all-reduce over the count, so it measures the transport alone and the tables above carry the tails. Arms interleaved b20c7a2, PR, PR, b20c7a2:
Prompt reads: 10% faster from 966 tokens up (1.22–1.24 against 1.36–1.38 ms per prompt token), with the kernels unchanged.
Decode: inside the noise, with every text identical, as expected: a decode partial fits one chunk and never waited on a buffer.
Multi-turn at concurrency 1: first-token P99 882–896 against 937–952 ms. At concurrency 2 the turns wait on each other's decode, and the arms are within the noise.
What's left: each 512-token all-reduce still costs about 1.7 ms. A follow-up reduces large partials by a reduce-scatter and an all-gather.
A message longer than one 256 KiB chunk was sent chunk by chunk, each chunk copied into the connection's one send
buffer and waited for before the next, and a deferred send longer than one chunk fell back to that blocking send. So a
mesh all-reduce's 1 MiB pieces went to one peer, then the next, with the link idle while each chunk was copied.
A connection now keeps four send buffers. A chunk is copied into the next free one and posted without waiting, and a
send waits only when the send queue or every buffer is taken; a blocking send then waits for all of its chunks. A
deferred send of any length is posted chunk by chunk, so a rank posts a piece to every peer before either acknowledges it.
…TS's entries for rank 1
With a map of where each of three ranks reaches the others, as a lab whose ranks share a link per pair needs, the
two-rank mesh refused the map's rank-2 entries and its checks did not run.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The test’s literal prefix check drops valid rank-1 entries accepted by the production parser, causing the two-rank mesh to lose its link override and fall back to an unreachable endpoint host.
…comm_mesh_hosts does
The two-rank runs kept an entry only when it began with "1:", so one the comm accepts for rank 1, such as "01:0=host",
was dropped and the two-rank mesh fell back to rank 0's serving host. They now drop only the entries that parse as rank
2 or up, and keep any other, so an entry that does not parse is reported by the comm as before.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Two new comments in ggml/src/ggml-rpc/transport.cpp use a multiplication sign instead of ASCII x, contrary to the source convention documented in AGENTS.md.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Replace multiplication signs in comments with ASCII x
ggml/src/ggml-rpc/transport.cpp:72
Use ASCII x instead of the multiplication sign in this new comment to follow the documented source convention in AGENTS.md. Apply the same replacement to the buffer-size comment at ggml/src/ggml-rpc/transport.cpp:88.
Re: Copilot's review 5820902474, the previously missed issue: fixed in 7216f35. transport.cpp:72 and :88, the two comments this PR added, now use ASCII x. The same character at :70 and :91 predates this PR, so it stays as it is.
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
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
Over RDMA, a message longer than one 256 KiB chunk went out one chunk at a time. Each chunk was copied into the connection's single send buffer and waited for before the next one was copied. A deferred send longer than one chunk fell back to that blocking send. So the mesh all-reduce's 1 MiB pieces (
rpc_comm_mesh_exchange, chunked) went to one peer, then the other, with the link idle while each chunk was copied. The chunked exchange is meant to send each piece to every peer at once.How it showed: a cold read of a 3754-token prompt across three ranks, profiled with Nsight Systems on each rank's
ggml-rpc-server. Each rank's GPU spent 1.9–2.0 s of the 5.4–5.5 s read waiting on all-reduces: 882 of them, 2.5–2.6 ms each (P50) for a 512-token partial of 5 MiB. The kernels took 2.3–2.5 s.The change (
ggml/src/ggml-rpc/transport.cpp, the Linux RDMA transport):wait_sends. So a rank posts a piece to every peer before either peer acknowledges it.Also (
tests/test-rpc-comm-mesh.cpp): the test's two-rank runs now drop theGGML_RPC_COMM_HOSTSentries for ranks 2 and up. They read each entry asrpc_comm_mesh_hostsdoes, and keep any entry that doesn't parse, so the comm still reports it. A lab whose ranks share one link per pair needs a three-rank map, and the two-rank mesh refused that map's rank-2 entries, so those checks never ran there.Tests
test-rpc-comm-meshchecks that every rank ends with the same bits, the F32 sum of the partials in rank order, for 1, 7168, 300007 and 4000037 floats. It runs over the three-rank mesh, a two-rank mesh, and the pairwise comm. Here it ran on three DGX Spark (GB10) nodes, every link RDMA, with the servers and the client each on the build named:The test is this PR's. Against b20c7a2 it ran with b20c7a2's servers and libraries. Before this PR's test change, the two-rank mesh rows did not run on this lab:
GGML_RPC_COMM_HOSTS entry '2:0=…' is not i:j=host with j < i < 2, thenworld 2: the comm did not initialize.Mutation: the mutation lets a chunk take the next send buffer without waiting for the send still reading it. The test fails on it at 4000037 floats, in every comm and on every rank:
At that size the test uploads each partial as one message of 62 chunks. Up to 300007 floats, a message is at most five chunks, and those checks pass.
Build: CUDA build on GB10, as in the lab rows below. The macOS CPU build compiles
ggml-rpcandtest-rpc-comm-mesh. It doesn't compile this RDMA transport, which is Linux only.Lab A/B:
llama-server, b20c7a2 against this PRSetup:
-sm tensor, the mesh comm (GGML_RPC_COMM_MESH=1).--spec-type draft-mtp --spec-draft-n-max 3),-fa on -c 8192 -b 512 -ub 512 -np 1.Prompt read, one-token requests after an unrelated flush, median of 3 per length:
Decode, 8 prompts × 200 tokens, temperature 0, two counted runs per session:
Multi-turn, 4 conversations × 5 turns × 200 tokens, the whole history re-sent each turn (n=20 turns):
All-reduce cost, from
test-rpc-comm-mesh's bench mode (TEST_RPC_COMM_MESH_BENCH, three ranks). It reports a mean per all-reduce over the count, so it measures the transport alone and the tables above carry the tails. Arms interleaved b20c7a2, PR, PR, b20c7a2:The profile again, cold 3754-token read, Nsight Systems on two of the three ranks, three windows each:
What the numbers say: