Repository navigation
Add nccl support for multi-node tensor parallelism - #28967
Conversation
|
Do you have any |
| // Same as above, but each rank is a separate process, so a process owns one backend of the | ||
| // communicator rather than all of them. | ||
| // One rank produces the unique id. Every other rank needs it, out of band, before calling | ||
| // comm_init_rank, which blocks until all ranks have joined. Free with ggml_backend_comm_free_t. | ||
| #define GGML_BACKEND_COMM_UNIQUE_ID_SIZE 128 | ||
| typedef bool (*ggml_backend_comm_get_unique_id_t)(void * id_out); | ||
| typedef void * (*ggml_backend_comm_init_rank_t)(ggml_backend_t backend, const void * id, int rank, int world_size); | ||
| typedef bool (*ggml_backend_comm_allreduce_rank_t)(void * comm_ctx, struct ggml_tensor * tensor); | ||
|
|
There was a problem hiding this comment.
Without having looked at any of the other code, changes to the ggml backend API like this should be avoided if at all possible.
There was a problem hiding this comment.
Added llama-bench results.
Removed ggml_backend_comm_allreduce_rank_t and now reuse ggml_backend_comm_allreduce_tensor for per-rank communicators.
@am17an , @JohannesGaessler, do you have any suggestions for handling ggml_backend_comm_get_unique_id_t and ggml_backend_comm_init_rank_t?
There was a problem hiding this comment.
@JohannesGaessler we are taking the same approach for single-process multi-GPU where all comm typedefs are defined in ggml-backend.h.
An alternative could be to move all these typedefs to ggml-backend-impl.h to not expose them in the public API.
|
what's the reason why using NCCL is so much faster for PP vs TG? Maybe there is something to optimize in the generic path too |
@am17an, I tested three optimizations on the pairwise path:
Further improvement likely requires restructuring the collective into an overlapping pipeline of GPU transfers, network communication, and reduction. |
|
Ah okay nice these can be even added to the original PR I think. @ggerganov perhaps it may help in the metal speedup. Do you have a branch with these changes? |
|
errr I'm very confused, I've recently acquired a third 5060 Ti and started using tensor parallelism with NCCL enabled. Enabling NCCL doubled decode - I think prefill also increased significantly. I admit that I don't fully understand (or barely understand) the mechanics underneath - that's why the following question came to my mind when reading this PR: why does the PR say "Add nccl support for tensor parrallel" if that's something that apparently is already working? thanks |
|
This PR is for NCCL support over RDMA, not related to your setup. @zyang-dev perhaps change the title to reflect it better |
The changes are on the |
Added multi-node to the title. |
cf00d3b to
d09d1c7
Compare
267d466 to
2ab5211
Compare
3a10a77 to
f6ae027
Compare
|
@zyang-dev can you rebase your PR on TOT master and make master the target branch as #26610 is now merged? |
|
The PR looks in good shape to me. @am17an @ggerganov @JohannesGaessler can you please take a look? This provides a much faster path on Nvidia GPUs. |
|
what about doing the improvements here too? #28967 (comment). These would help non-NV GPUs too or NV GPUs running vulkan |
Can that be done in separate PR? |
|
I think the current implementation is coupled too tightly to NCCL-specific structures. My understanding is that the unique NCCL ID is generated once by one process and then broadcast to the other processes. So I would suggest that we instead change @ggml-org/ggml-rpc lease tell me if my understanding is wrong or my idea of how to do this is flawed. |
|
@JohannesGaessler, |
|
@JohannesGaessler , Another option is to keep two different sets of APIs for the one-process and multi-process scenarios. I'll replace the two new interfaces ( The first one is implemented by the caller and moves the bytes between ranks. The library decides what to exchange and how many rounds to run, so different libraries can do their own initial information exchange. The second one is similar to the current |
|
@rgerganov @am17an could you please review RPC changes? |
|
@am17an Let me know if you can reproduce the reported numbers on your DGX Sparks. On my pair I can't reproduce (i.e. perf is same as |
|
I can reproduce these numbers when both sparks run at 2400mhz |
|
|
||
| static void * ggml_backend_rpc_comm_init(ggml_backend_t * backends, size_t n_backends) { | ||
| if (n_backends != 2 || std::getenv("GGML_RPC_NO_COMM") != nullptr) { | ||
| if (n_backends < 2 || std::getenv("GGML_RPC_NO_COMM") != nullptr) { |
There was a problem hiding this comment.
this will probably not work for all RDMA devices right?
There was a problem hiding this comment.
I think this check should be fine for now. ggml_backend_rpc_comm_init is only used for pairwise and nccl currently. On a config that doesn't have nccl and has more than 2 nodes, the code will fall back to pairwise. rpc_server::comm_init rejects pairwise with the check (request.world != 2). So the client gets nullptr, and the meta backend uses its generic path, the same as before the change.
|
I did not notice that each NCCL instance takes 2GB more per RPC node. Do we know why that is? |
|
@am17an , |
…ate processes, implement it in the CUDA backend using NCCL, and use it in the RPC server when available.
…llreduce_tensor for per-rank communicators
…s. Remove the helper function backend_comm_proc_address
…ank_t to more generic multi-process backend communicator interfaces
* Add a backend interface for collectives across ranks running in separate processes, implement it in the CUDA backend using NCCL, and use it in the RPC server when available. * Drop ggml_backend_comm_allreduce_rank_t and reuse ggml_backend_comm_allreduce_tensor for per-rank communicators * reuse ggml_backend_cuda_comm_allreduce_nccl for per-rank communicators. Remove the helper function backend_comm_proc_address * Change ggml_backend_comm_get_unique_id_t and ggml_backend_comm_init_rank_t to more generic multi-process backend communicator interfaces * set maxCTAs in ncclConfig_t to 8 for dgx spark in ggml_backend_cuda_comm_init_rank (cherry picked from commit 71efc55)
Overview
Add a backend interface for collectives across ranks running in separate processes, implement it in the CUDA backend using NCCL, and use it in the RPC server when available.
The implementation is on top of PR #26610.
Results on DGX spark:
single node:
Two nodes with NCCL:
Two nodes with pairwise:
Ratio to a single node:
Requirements