Repository navigation
Conversation
added 2 commits
October 3, 2026 13:15
…rts over NCCL, byte gathers, peer exchanges Two-rank engines reach for faster or different transports (one-shot RoCE all-gathers on DGX Sparks, point-to-point exchanges for split work, ashhart#159's all-to-all), and each one is wired into one engine by hand today. This gives them one place to plug in: - Comm states what every engine assumes of a communicator (rank, world, all_gather, barrier). Module functions cover the optional capabilities, each with a fallback: fast_gather (a model exchange takes the communicator's all_gather_fast where there is one, else all_gather), exchange (NCCL.exchange: each send lands in the peer's matching receive, one ncclSend / ncclRecv group on the current stream; a communicator without exchange trades through its all-gather, two ranks only) and check (raise a failure the transport recorded). - Transport is a base that wraps NCCL and forwards whatever a subclass does not define (all_gather, store, ready, and later NCCL methods such as all_reduce or all_to_all), so a transport overrides only what it speeds up. - register_backend / open_comm: TF_COMM_BACKEND names a registered transport; unset (or nccl), open_comm builds the same NCCL as NCCL(...) does. The ranks compare the name through the rendezvous store and refuse to start with different ones (a transport on one rank only would hang the first exchange). NCCL stays the control channel. - NCCL gathers uint8, int8 and float16 too, and takes the rendezvous timeout and store key (defaults: 600 s and "tf_nccl_uid", as before). Same bits: nothing in the tree calls the new functions yet; NCCL's existing methods, and its constructor with the defaults, are unchanged. The next commit opens the two-rank engines through open_comm. Tests: tests/test_cuda_comm.py (CPU, a two-rank fake): fast_gather and check with and without the optional methods; exchange through the all-gather for float32, bfloat16 and int32 with unequal sizes, through a communicator's own exchange with the default peer and a named one, refused past two ranks without one; backends wrap NCCL, unknown names are refused, ranks naming different backends are refused; a Transport forwards store, ready and the all-gather. docs/recipes/cuda.md: the communicator paragraph.
…communicator with open_comm The three engines that built NCCL(rank, 2, master, port) themselves call open_comm(rank, 2, master, port), so a transport registered for TF_COMM_BACKEND reaches them without a change to any family. Unset, open_comm builds that same NCCL, plus one store round trip at start in which the ranks compare the backend name: same exchanges, same bits. A name no transport registered stops the start with a ValueError that lists the registered ones, before NCCL is set up. Tests: the GPU tests that replace tensorfold.cuda.comm.NCCL with a fake (tests/cuda/test_flashnext_tp.py, test_flashnext_nvfp4_loader.py) go through open_comm unchanged (the TP fake's real TCP store carries the backend check); tests/test_cuda_comm.py covers open_comm itself. tests/test_cuda_capacity.py's stand-in for tensorfold.cuda.comm answers open_comm only, so its two-rank GLM-5.3 and Flash Next constructors fail if they build NCCL themselves.
jayleaton
force-pushed
the
pr1-interfaces
branch
from
October 3, 2026 06:22
7e24835 to
3a13de6
Compare
Owner
|
Thank you, @jayleaton. The communicator interface ( We left out the CUDA_SERVE hook, as your update did. GLM-5.3, Flash Next and Nemotron now open their two-rank link through it, and it passed the two-Spark exactness run with #141 and #180. We look forward to the first transport built on it. |
Closed
This was referenced Oct 4, 2026
Closed
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
Two-rank CUDA engines get one place to plug in a faster or different transport.
tensorfold.cuda.commgains a smallcommunicator interface, and the three engines that built
NCCL(rank, 2, master, port)themselves (GLM-5.3, FlashNext, Nemotron) open it with
open_comm(rank, 2, master, port). WithTF_COMM_BACKENDunset, nothing changes.Comm: what every engine may assume (rank,world,all_gather,barrier).fast_gather(comm, send, recv): the transport'sall_gather_fastif it has one, elseall_gather.exchange(comm, sends, recvs, peer=None):NCCL.exchange(onencclSend/ncclRecvgroup on the currentstream). Without it, two ranks trade bytes through the all-gather.
check(comm): raises a failure the transport recorded.Transport: a base that wraps NCCL and forwards whatever a subclass does not define (store,ready,all_gather, and later NCCL methods), so a transport overrides only what it speeds up.register_backend(name, wrap)/open_comm(...):TF_COMM_BACKENDpicks a registered transport; unset, itbuilds the same NCCL as
NCCL(...). The ranks compare the name through the rendezvous store and refuse to startif they differ, since a transport on one rank only would hang the first exchange. An unknown name is refused
before NCCL is set up.
NCCLgathersuint8,int8andfloat16too, and takes the rendezvous timeout and store key (defaultsunchanged: 600 s and
tf_nccl_uid).Why: one-shot RoCE all-gathers on DGX Sparks now exist in three places (ours for two-Spark GLM-5.3-Flash, MiaAI-Lab's
RoceComm, and the one inside #159), each switched into one engine by its own variable. On our pair a 16 KiBgraph-captured gather takes 11.7 us against NCCL's 45.3 us, and decode gains 4-11% with the same bits. Point-to-point
trades (MiaAI-Lab's
NCCL.exchange, #159's all-to-all) have the same problem. A transport written once under thisinterface can serve any two-rank family. A
rocetransport would be a separate pull request on top of this one.Rebased onto 0.6.3.
comm.pyand the three call sites had not changed upstream, and no new directNCCL(...)construction was added (#159 is still open). Qwen3.8-27B's
torch.distributedprocess group is not anNCCLobject and is left as is. The optional
CUDA_SERVEcommit from the first version was dropped to keep one change inthis pull request; it was the only part that conflicted.
Receipt
9356df5) plus these two commits. Linux x86_64, Python 3.14.7, PyTorch 2.14.1+cpu,no GPU, no MLX, no Triton. No checkpoint was loaded.
TF_COMM_BACKENDunset,open_commbuilds the sameNCCLobject with the samearguments and the engines make the same exchanges in the same order; the only new step is one store round trip at
start in which the ranks compare the backend name. The new functions have no caller in the tree yet.
tests/test_cuda_comm.py(new, 10 tests) andtests/test_cuda_capacity.py, withtests/test_cuda_comm_ready.py:61 passed on this branch. On 0.6.3 with these test files: 27 failed, 34 passed. The 10 comm tests fail because
the interface does not exist; the 17 two-rank GLM-5.3 and Flash Next capacity tests fail because the stand-in for
tensorfold.cuda.commnow offers onlyopen_comm, which 0.6.3's engines do not call.python -m pytest -q -n 4 --timeout 300 --continue-on-collection-errors tests, same session:this branch 3,442 passed, 208 skipped, 148 failed, 14 errors; clean 0.6.3 3,432 passed, 208 skipped, 148 failed,
14 errors. The 162 failing and erroring ids are identical. They are 0.6.3's own on a Linux box without MLX,
Triton or a GPU (MLX server, prompt fill and reasoning tests).
tests/cuda, and the two-rank NCCL start were not run. The GPUtests that replace
tensorfold.cuda.comm.NCCLwith a fake (tests/cuda/test_flashnext_tp.py,tests/cuda/test_flashnext_nvfp4_loader.py) reach it throughopen_communchanged. Nothing was run on Metal; thischange touches no Metal path. If you want a GPU receipt, I can run
tools/bench_concurrent.py --alone --serial,tools/bench_openai.pyandtools/prefill_cold.pyon two DGX Sparks, before and after.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.(Not measured here; the exchanges are the same NCCL calls as before.)