[Enhancement] Group.split() support for JACCL and Ring backends (parity with NCCL #3172)
Summary
Group.split() was recently added to the NCCL backend in #3172 for multi-parallelism support. The JACCL and Ring backends currently throw std::runtime_error when split() is called. Adding split() to these backends would bring parity across all MLX distributed backends and unlock the full range of multi-group distributed patterns on Apple Silicon Thunderbolt 5 clusters.
Motivation
Group.split() is a foundational primitive for creating communication subgroups allowing for other distributed patterns:
- Hybrid tensor + pipeline parallelism: TP within small node groups, PP between them.
- Expert parallelism: Distributing MoE experts across node subgroups instead of replicating all experts on every node. Reduces per-node memory for models like Kimi K2.5 where the vast majority of weights are unused per inference step.
- Data parallel replicas: Running independent model replicas on node subsets for concurrent serving. Each replica has its own TP subgroup for example.
- Context parallelism: Splitting long sequences across node subgroups, each handling a chunk of the context window. Relevant for architectures with large KV caches and large context.
- Speculative decoding: Draft model on one subgroup, verifier on another, coordinating candidate token generation and batch verification.
- Multi-model pipelines: Different models (vision encoder → LLM → reward model) on different subgroups with activation forwarding between them.
With TB5 RDMA and JACCL, fully connected topologies are limited by physical port count, and practical TP group sizes are further constrained by model dimension divisibility (attention heads, hidden sizes must divide evenly), making 2 and 4 the most common TP configurations.
| Machine | Chip | TB5 Ports | Full-Mesh TP Max (N-1 ≤ ports) |
|---|---|---|---|
| MacBook Pro | M4 Max | 3 | 4 nodes |
| Mac Studio | M4 Max | 4 | 5 nodes |
| Mac Studio | M3 Ultra | 6 | 7 nodes |
Note: Full-Mesh TP Max is a hardware ceiling.
Subgroup support would allow clusters of Apple Silicon machines to apply a broader spectrum of parallelism strategies such as running large models at full precision across nodes that individually can't hold them, serving concurrent usage with replica groups, or distributing MoE experts efficiently.
MLX already has the higher-level building blocks:
shard_linear/AllToShardedLinearfor TP.PipelineMixinwithsend/recvfor PPsharded_load()accepting bothpipeline_groupandtensor_group.
The subgroup primitive allows users to compose them.
Current behavior
world = mx.distributed.init(backend="jaccl")
tp_group = world.split(color=world.rank() // 2)
# RuntimeError: [jaccl] Group split not supported.
world = mx.distributed.init(backend="ring")
tp_group = world.split(color=world.rank() // 2)
# RuntimeError: [ring] Group split not supported.
Desired behavior
world = mx.distributed.init(backend="jaccl")
# Example: hybrid TP + PP
tp_group = world.split(color=world.rank() // 2) # TP sub-groups
pp_group = world.split(color=world.rank() % 2) # PP chain across groups
# Example: data parallel replicas
replica_group = world.split(color=world.rank() // 4) # independent replicas
# Example: expert parallel subgroups
ep_group = world.split(color=world.rank() % num_ep_groups)
Why this seems feasible
JACCL already supports point-to-point send/recv to arbitrary peers in the mesh. A sub-group would operate on a subset of existing RDMA connections rather than requiring new transport infrastructure. The NCCL implementation in #3172 can serve as a reference for the GroupImpl::split() interface contract.
For Ring, the sub-group would create a smaller ring over a subset of ranks — the neighbor-only send/recv constraint naturally maps to sequential forwarding patterns like pipeline parallelism.
Potential workarounds
Without split(), users could launch each subgroup as a separate backend instance with independent environment configuration and manage inter-group communication at the application layer. Although in general this functionality seems much better suited inside mlx
Environment
- MLX 0.31.0
- macOS 26.2+
- Apple Silicon with Thunderbolt 5/RDMA support
one can reopen an ibv device there is no problem with that and the ring does it already when there are only 2 nodes
#3245 was built around the opposite assumption. You are right on both counts.
The ring does do it at 2 nodes. get_ring_connectivity() computes
left = (rank + size - 1) % size and right = (rank + 1) % size, which are both 1 when
size == 2, so RingGroup calls create_connections() twice on the same device name and holds
two contexts on one device. A 2-rank all_sum over that path returns correct results on
596dc79f4.
Directly, outside MLX: opening the same device N times, each context with its own PD, CQ, MR and QP, works on an active port. 2, 4 and 8 all succeed, with distinct QP numbers and no deadlock.
But the eleventh fails:
[9] open... pd... cq... mr... qp... ok (ctx=0x95e400740 qp_num=4608)
[10] open... pd... cq... mr... qp... ibv_create_qp FAILED
The limit is on queue pairs rather than contexts: 10 per device, with errno 16 (EBUSY) after
that. Ten succeed whether they are spread across ten contexts or all created on a single one. The
failure is graceful: a NULL return, not a crash.
Since a sub-group needs its own queue pairs on a device the parent already holds, that is what bounds how many sub-groups a device can back, and it binds well before the ~100 MR limit discussed in #3162.
Tested on two machines and two ports, an M5 Max (rdma_en1) and an M4 Pro (rdma_en2), both
macOS 26.5.1 on direct Thunderbolt 5 with RDMA enabled.
Ring side is up in #4218. Writing up what I found scoping the JACCL half, since two of the constraints are physical and they decide what the API can promise.
A subgroup can only contain directly connected members. Config::devices_[src][dst] holds
the device names for each cabled pair and is empty where there is no link. A child is built from
the submatrix over its members, so every pair of members needs a link. A submatrix of a valid
mesh is still valid, so a mesh splits freely. A ring only splits into contiguous runs:
{0, 2} out of a four node ring has nothing between its two members. is_valid_ring() rejects
that submatrix, which is correct, but it means split on a ring cannot accept an
arbitrary coloring.
Children have to agree on a topology. Connection setup costs a fixed number of side channel
rounds per topology: mesh is barrier() plus one info gather, ring is barrier() plus left and
right. The count does not depend on group size, but it does depend on topology. If the child
side channel is backed by the parent through set_all_gather_factory, and one child builds a
ring while another builds a mesh, they issue different numbers of rounds against the same parent
and the shorter one stops participating while the longer one is still waiting. Requiring every
child to use the same topology removes it.
Those two together suggest the useful version is: split is supported when the group is fully connected, children are meshes, and anything else raises rather than hangs. That covers the case people are asking for here and refuses the ones the cabling cannot serve.
On the queue pair ceiling from my earlier comment. Ten per device is a real bound. Every child opens new queue pairs, so the number of live subgroups a device can carry is limited, and a mesh child of size n needs n-1 of them per member. Worth deciding whether split should fail early with a clear message when the requested subgroups would exceed it.
I am implementing the JACCL side next and will validate it on four nodes. Before I build against a guess, is the mesh-only shape the one you want, or would you rather split kept ring children for contiguous colorings?
@erwinzhang7 Thanks for the contribution and for the work on #4218. I understand that PR is meant to address Group.split() for the TCP ring backend; the comments below are about the JACCL half.
The broader target I have in mind is heterogeneous clusters of macOS Apple Silicon machines that expose usable JACCL RDMA endpoints over Thunderbolt 5 (e.g. MacBook Pros, Mac Studios, Mac minis, and future compatible apple systems) with different unified-memory capacities, compute performance, port counts, and physical connectivity.
A ladder built from three-port MacBook Pros is one possible topology, but it should not constrain JACCL’s implementation of the existing split(color, key) contract.
My understanding of the current implementation is that mesh children cover the common low-latency TP subgroup case and are probably the safest first implementation. So mesh-child support is a good first JACCL increment. I think mesh-only can be a setp toward the end goal without permanent JACCL restriction. Sparse heterogeneous clusters also need ordered PP communication and, with JACCL’s current mesh/ring data planes, PP groups can naturally map onto sparse rings.
A practical TP×PP runtime could call world.split() twice:
- once to form TP subgroups whose induced physical graphs are meshes; and
- once to form PP subgroups whose keyed member order forms valid physical rings.
Since the current Group.split() API carries only color and key, the child topology would have to be inferred or selected by a JACCL topology-planning layer rather than directly requested through the API.
As an initial implementation restriction, requiring all non-singleton children created by one split() invocation to use the same topology seems reasonable. That avoids the different side-channel round counts you mentioned. Longer term, child-scoped or tagged bootstrap channels seem ideal. Once bootstrap messages are namespaced by communicator ID and initialization round, children can execute different connection-setup sequences without sharing one untagged parent-wide sequence.
For ring children, I would define validity from the complete physical connectivity graph rather than contiguity in the parent’s rank order. After applying key ordering and the normal deterministic tie-break, a ring is valid when every adjacent pair and the final closure pair has a direct physical RDMA link. A non-contiguous set of global ranks can therefore form a valid ring if those machines are actually cabled.
This implies that the parent group, or retained topology state associated with it, should preserve:
- the global-rank mapping;
- the complete pairwise RDMA device matrix;
- all physical edges not used by the parent data plane; and
- multiple device entries where a pair has more than one cable.
The current configure_jaccl_ring() representation appears to emit only the selected ring-neighbor edges and discards the additional physical links. Those extra links are exactly what mixed-port clusters (e.g. MacBook Pros, Mac minis, and higher-port count Mac Studio systems) would want to reuse for TP children or alternative PP rings.
A reasonable implementation sequence would be:
- implement mesh-child split first;
- retain global-rank mappings and the complete physical connectivity matrix;
- preserve a topology-planning seam rather than making mesh-only a permanent semantic restriction;
- add keyed physical-cycle ring children in a follow-up; and
- eventually move to child-scoped or tagged bootstrap communication.
It makes sense that the complete child plan should be validated collectively before opening child transports. At minimum, the implementation should calculate requested QP/MR use by local RDMA device and protection domain, check any known or queryable limits, allocate transactionally, and propagate device-specific failures collectively so that partial child communicators are torn down. I would not encode the empirically observed ten-QP ceiling as a permanent API constant because it may vary across hardware and releases.
One additional scope distinction: Group.split() is the missing primitive for first-class heterogeneous TP×PP composition, but it will not by itself make placement heterogeneous end to end. MLX-LM currently divides pipeline layers approximately evenly and tensor shards equally. In the near term, I would expect a heterogeneous planner to place reasonably compatible machines inside each TP subgroup and express most heterogeneity through weighted PP placement (e.g. assigning more or heavier layers to faster, higher-memory TP groups). Unequal TP shards or variable TP widths would be separate future work. MLX-LM also needs to retain the supplied pipeline subgroup and pass it explicitly to pipeline send, recv, and all_gather operations. I view that and heterogeneous placement as companion MLX-LM/planner changes, not requirements for this first JACCL split PR.
So, tl;dr of your question: mesh-only is the shape I would support for the first landing step, provided the implementation preserves the topology and global-rank information needed for JACCL ring children later.
Mesh-first works, and the topology-preservation you are asking for has a specific place to happen. It isn't in the split implementation, it is upstream of it: the hostfile generator throws the information away before any C++ sees it.
python/mlx/_distributed_utils/config.py, configure_jaccl_ring():
for other in ring:
if other not in (peer_left, peer_right):
rdmas.append(None)
else:
rdma = []
for c in range(count):
rdma.append(f"rdma_{ips.ips[node, other][c][0]}")
rdmas.append(rdma[0] if count == 1 else rdma)
Every pair that is not a ring neighbour is written as None, including pairs that are
physically cabled. configure_jaccl() a few lines above emits the full N x N matrix, so the
connectivity survives in a mesh hostfile and is destroyed in a ring one.
That also settles the correction you made; I said ring children can only be
contiguous runs of the parent's rank order. That holds against the parent's selected ring
edges, which is all Config::devices_ contains after the generator has run, and it isn't a
property of the hardware. Ranks 0 and 2 can carry a ring edge if those two machines are cabled;
the reason the current code cannot tell is that the cable was discarded at configuration time.
So the ordering I would suggest is:
- Have
configure_jaccl_ringrecord the real connectivity for every pair that has it, while the runtime keeps using only the ring edges for the parent data plane. This is separable from split, testable from a synthetic connectivity matrix with no cluster, and correct on its own terms: discarding known hardware topology is a bug whether or not anything consumes it yet. - Mesh children, against the matrix that now survives.
- Keyed physical-cycle ring children, which become possible once 1 has landed.
On the queue pair ceiling, valid since 10 is just what two Thunderbolt 5 devices reported, and it can change with a firmware release. Counting the requested pairs per device and protection domain, checking against what the device reports, and tearing down collectively on failure is the right shape. The measurement remains useful as a reason to check before allocating.
Same-topology-per-split as the initial restriction, for the side channel round counts. Child scoped bootstrap channels are the better long term answer and would remove the restriction rather than working around it.
Ring Group.split() is up in #4218. I will validate the JACCL side on a four node full mesh shortly.
Two data points from the other side of the hardware table, since #4282 and #4218 were closed and this is the only thread left.
The QP ceiling is not 10 everywhere. @erwinzhang7 measured 10 QPs/device on M5 Max and M4 Pro (macOS 26.5.1). Our fleet, via ibv_query_device on every active rdma_enX:
| Machine | macOS | max_qp |
max_pd |
max_mr |
|---|---|---|---|---|
| M3 Ultra (m3u2) | 27.0 | 11 | 11 | 100 |
| M3 Ultra ×2 (m3u3/m3u4) | 26.6 | 11 | 11 | 100 |
| M5 Max (MBP) | 26.6 | 11 | 11 | 100 |
| M3 Ultra (hub, mesh coordinator, 6 ports) | 27.0 | 3 | 6 | 100 |
Same chip, same driver, and m3u2 is on the same OS build as hub — yet the coordinator reports a third of the QP budget. We haven't root-caused whether that's a per-port-count split or state left over from long-running meshes (hub has had serves up for ~12 days), but it settles one thing N0xMare raised: the limit must be queried per device at split time, not encoded as a constant. Our gate does that for QP/PD/MR before any child connection opens, and takes a collective verdict across ranks so one starved device fails the split for everyone instead of hanging it.
Where split lives now. Since upstream considers this out of scope for the moment, we ported @erwinzhang7's #4282 design — parent all-gather as the child SideChannel, mesh-only, raise on any uncabled pair — into the vendored JACCL inside asmi (the cluster daemon for r1o), and ran it on a 4-node fully-cabled M3 Ultra TB5 mesh today. Two things came out of that which #4282 as posted does not handle, offered here in case it ever reopens:
- A size-1 child segfaults. A
MeshGroupof size 1 builds its ring overconnections_[(rank±1)%1], i.e. its own nullptr slot, andallocate_buffersthen callsibv_reg_mron a null PD. mlx never sees it becauseops.cppshort-circuits singleton groups before the backend; the standalone lib has no such caller. We return a no-op local group instead. - Any non-symmetric colouring deadlocks. The child's side channel is a parent-wide collective, so a rank that builds no child (colour < 0, or a colour only it holds) issues zero rounds while the members' constructor issues four (info all_gather + barrier). Members block forever in the TCP all-gather. Fix is for non-members to pump exactly that many empty rounds; the count is asserted in our test. The consequence is a real contract: all groups derived from one parent must
splitin lockstep for life, which is the case N0xMare's child-scoped bootstrap channels would remove.
With those two plus the budget check, parity / identity / keyed-reorder / non-member / nested splits all pass on the 4-node mesh (and the 3-node subset before the last cable went in), with parent collectives verified intact after every split. That's the shape N0xMare's Aug 14 comment describes for a first landing. It also feeds ds4 expert-parallel (antirez/ds4 #351), the first non-MLX consumer of the standalone lib. If upstream reopens this, it's a tested diff to compare against; if not, it exists.
For the record, #3245 was the wrong design (TCP side-channel bulk) and Angelos was right to close it. #4282 was the right one.
Related, worth its own issue if nobody has filed it: with the child holding a shared_ptr to the parent, a parent rank that dies mid-child-bootstrap produces exactly the busy-wait in #4278 — every survivor spins in the parent-wide all_gather. A timeout on AllGatherFn would cover both.