Repository navigation
ggml-rpc: abort a lost client's NCCL communicators so a stuck rank recovers - #6
Conversation
…o a rank blocked behind a collective the peer never joins recovers
There was a problem hiding this comment.
🟡 Changes recommended
The communicator status log reads shared state without synchronization while the watchdog can modify it, causing a C++ data race.
1 open issue
What changed in this PR
This PR extends the opt-in RPC NCCL path with disconnect recovery so a lost client does not leave a server stuck behind an unfinished collective.
Changes:
- Adds non-consuming peer-close detection and a Linux client watchdog.
- Synchronizes communicator access and rejects all-reduces after an abort.
- Defaults
NCCL_RUNTIME_CONNECTto0unless explicitly configured.
| File | Description |
|---|---|
ggml/src/ggml-rpc/transport.h |
Declares peer-close detection methods. |
ggml/src/ggml-rpc/transport.cpp |
Implements polling for connection closure without reading data. |
ggml/src/ggml-rpc/ggml-rpc.cpp |
Adds watchdog recovery, communicator locking, and the NCCL connection default. |
Review effort: Balanced
The client watchdog can abort the communicator and set state.nccl to null under comm_mutex while the serving thread is still finishing COMM_INIT, so the status log's unlocked read of state.nccl was a data race. Read it under the same lock; no other lock is held at that point.
|
Addressed #6 (review): Kill test on a build of
I added the row to the description's kill-test table. The decode runs there were not repeated, since the new lock is taken once per connection, not per token. The human review of the cross-thread teardown that the summary asks for is still open. |

Summary
With
GGML_RPC_COMM_NCCL=1(#5), killing the client mid-decode sometimes leaves oneggml-rpc-serverrank stuck: it never logsClient connection closedand never accepts another client. Its main thread is inrpc_server::get_tensor→rpc_server::sync_all_backends→cudaStreamSynchronize, behind an NCCL all-reduce that the client sent to this rank but not to the peer. The peer has already aborted its communicator, so the collective never completes, the thread never reads the closed socket again, and the abort in~rpc_servernever runs.POLLRDHUP; the RDMA transport keeps that socket open and idle after the upgrade) and then aborts the client's NCCL communicators (rpc_server::abort_comms), which ends the stuck collective. The serving thread then fails its next send or receive as before. The watchdog keeps aborting after the close, so a communicator whose initialization finishes later is aborted too, and it runs only where a close can be seen without reading the socket (Linux).comm_mutexorders the abort against the serving thread's own NCCL calls (initialization, all-reduce enqueue, free), so neither uses a communicator the other freed. An aborted communicator makes later all-reduces fail instead of falling back to the host path.NCCL_RUNTIME_CONNECT=0at start unless it is already set. NCCL 2.22 and later otherwise connect a channel inside the firstncclAllReducethat uses it, waiting for the peer without a timeout whilecomm_mutexis held, where the watchdog could not abort it.COMM_FREEwhosencclCommDestroywaits behind such a collective, aCOMM_INITthat only one rank received, a peer server that dies while the client lives, and a client host that vanishes without closing the connection. TheCOMM_INITcase extends to rank 1 failing to reach rank 0's address: rank 0'saccept()for the pairwise connection has no timeout while rank 1 gives up after about 5 s (from readingrpc_server::comm_init; not reproduced here).Evidence
Kill test, 2026-10-25: Qwen3.8-Flash-Next UD-Q3_K_XL split over two DGX Sparks with
-sm tensoracross twoggml-rpc-servers on RoCE addresses,llama-serveron a third Spark withGGML_RPC_COMM_NCCL=1. Each kill sends SIGKILL tollama-serveronce it has streamed at least 40 tokens (66 to 100 in these runs) and polls both ranks' logs for 30 s; a rank that does not logClient connection closedcounts as hung, is dumped with gdb, and both ranks restart for the next kill.3185bd41(head of #5, merged asd6d4a25f)rpc_server::get_tensor→sync_all_backends→ggml_backend_cuda_synchronize→cudaStreamSynchronizeand the GPU at 96%012c48f1,043e5a1d(earlier heads of #5)012c48f1with the same backtrace,043e5a1dwith its main thread inside libcuda (gdb could not unwind further)3df556e1aborted the NCCL communicator the client left openandClient connection closedwithin 1.7 s, and after the 20th a new client loads and replies71fdd870(head)Decode speed, 2026-10-25: DeepSeek-V4.1-Flash UD-Q2_K_XL split over the same two Sparks with every switch from #5 on and DSpark drafting (3 tokens). Each row is one
llama-serverload running the same 8 prompts twice at temperature 0, with the loads in the order shown. In every arm, all 8 replies equal the reference run's. The rows for this branch ran a build of its tree (bea6035b).3185bd41(head of #5)3185bd41(head of #5)NCCL_RUNTIME_CONNECT=1Two loads of the same build differ by up to 8% (32.10 vs 34.80 tok/s). On the second runs this branch averages 33.45 tok/s and #5 averages 33.53, so the change costs no decode speed measurable on this rig.
NCCL_RUNTIME_CONNECT=1, NCCL's default, lands within the same spread as the 0 this branch sets.71fdd870adds only one change to3df556e1:comm_inittakescomm_mutexto read the status it logs. Its kill-test row ran on a build of71fdd870itself (2026-10-25, 08:21 to 08:31 UTC), where both ranks print that status line (NCCL all-reduce on) for every client, and the build passes the backend tests for #5's switches (DSV4_HC_WEIGHTS,DSV4_HC_COMB,MUL_MAT/MUL_MAT_IDwith IQ3 types). The decode runs above ran on3df556e1's tree and were not repeated: the new lock is taken once per connection, not per token.