Repository navigation
Turn the tensor-split levers on by default: graph slots, one input wait per split, stream-queued all-reduce, deferred sends - #19
Merged
Conversation
…default for a tensor split LLAMA_GRAPH_SLOTS and GGML_SCHED_SYNC_INPUTS_ONCE were off unless set. Unset, a tensor split (LLAMA_SPLIT_MODE_TENSOR) now gets the second graph slot, and a split on the meta backend waits for its backend once before copying its inputs; any other model keeps one slot and a wait per input, and a value in the environment still decides either way. On a GLM-5.3 split across three nodes over RPC, each was worth 3-5% of decode with the other levers on.
… sends by default GGML_RPC_COMM_ASYNC and GGML_RPC_COMM_SEND_DEFER were off unless set; they are now on unless set to 0. Only a tensor split's all-reduce reaches either. On a GLM-5.3 split across three nodes over RPC, with the other levers on, the stream-queued all-reduce was worth 1.4-2.6% of decode and the deferred sends 0.9-1.7%, with replies unchanged.
There was a problem hiding this comment.
🔵 Needs a closer look
Backend-owner hardware validation is still needed for default-on graph-slot scheduling and stream-queued collectives across untested tensor-split configurations, including synchronization safety, failure propagation, and teardown.
No open issues 🎉
What changed in this PR
Enables four existing performance options by default for tensor-split models, reducing graph rebuild and communication overhead without requiring environment configuration. Other model modes retain their existing defaults, and explicit environment overrides remain supported.
Changes:
- Allocate two graph slots by default for tensor-split contexts.
- Wait once per scheduler split when copying inputs to the meta backend.
- Enable stream-queued RPC all-reduce and deferred sends by default.
| File | Description |
|---|---|
src/llama-context.cpp |
Defaults tensor-split contexts to two graph slots while preserving overrides. |
ggml/src/ggml-rpc/ggml-rpc.cpp |
Enables asynchronous all-reduce and deferred sends unless explicitly disabled. |
ggml/src/ggml-backend.cpp |
Defaults meta-backend input synchronization to one wait per split. |
Review effort: Balanced
bjchambers
approved these changes
Oct 30, 2026
lukekim
added a commit
that referenced
this pull request
Nov 1, 2026
lukekim
added a commit
that referenced
this pull request
Nov 3, 2026
* ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address (#18) * ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address The RDMA probe finds the port whose GID is the TCP connection's local address, so a client that reaches a server on its own host at an address no port carries (a /32 on the loopback interface, 127.0.0.1) stays on TCP over the loopback interface. When the connection's two ends are this host and no port has its address, both ends now take the IPv4 RoCE v2 GID of the first active port (of GGML_RDMA_DEV, when set), and the NIC loops the connection back. GGML_RDMA_GID and GGML_RPC_NO_RDMA keep their meaning. * ggml-rpc: take the loopback port by name and index, and share RDMA with this host only on one GID The loopback fallback handed the probe only GID bytes, so a device scanned earlier with the same GID on a down or RoCE v1 port could carry the connection; it now names the device and the GID's index it chose. Each end of a connection to this host also chooses its port from its own GGML_RDMA_DEV and GGML_RDMA_GID, and two ports need not reach each other, so such a connection now takes RDMA only when both ends chose the same GID, which both see the same way, and otherwise stays on TCP at both ends. * ggml-rpc: advertise RDMA on a connection to this host only over RoCE v2 The two ends of a connection to this host compare only the GID bytes they advertised, and a RoCE v1 entry has the same bytes as the v2 one, so one end pinned to the v1 index (GGML_RDMA_GID) and one choosing v2 passed the comparison with incompatible modes. On such a connection an end whose GID is not RoCE v2 now advertises nothing, and both stay on TCP. * Turn the tensor-split levers on by default: graph slots, one input wait per split, stream-queued all-reduce, deferred sends (#19) * llama, ggml-backend: two graph slots and one input wait per split by default for a tensor split LLAMA_GRAPH_SLOTS and GGML_SCHED_SYNC_INPUTS_ONCE were off unless set. Unset, a tensor split (LLAMA_SPLIT_MODE_TENSOR) now gets the second graph slot, and a split on the meta backend waits for its backend once before copying its inputs; any other model keeps one slot and a wait per input, and a value in the environment still decides either way. On a GLM-5.3 split across three nodes over RPC, each was worth 3-5% of decode with the other levers on. * ggml-rpc: queue a tensor split's all-reduce on a stream and defer its sends by default GGML_RPC_COMM_ASYNC and GGML_RPC_COMM_SEND_DEFER were off unless set; they are now on unless set to 0. Only a tensor split's all-reduce reaches either. On a GLM-5.3 split across three nodes over RPC, with the other levers on, the stream-queued all-reduce was worth 1.4-2.6% of decode and the deferred sends 0.9-1.7%, with replies unchanged.
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
Four opt-in levers from #8 and #12 now default on for a tensor split (
LLAMA_SPLIT_MODE_TENSOR), and stay off for any other model. A value in the environment still decides either way:LLAMA_GRAPH_SLOTSGGML_SCHED_SYNC_INPUTS_ONCEGGML_RPC_COMM_ASYNC"0"turns it off)GGML_RPC_COMM_SEND_DEFER"0"turns it off)Why
A program that serves a split model has no reason to know these switches exist, and before this change one that set none of them decoded about 16% slower. Interleaved sessions on three DGX Spark (GB10) nodes over 200 GbE RoCE, GLM-5.3 (Q2_K_XL) split three ways through the Spice runtime's llama.cpp engine:
What each lever was worth with all the others on (each switched off and back within one session, two passes in opposite orders, 8 prompts per bench):
GGML_SCHED_SYNC_INPUTS_ONCELLAMA_GRAPH_SLOTSGGML_RPC_COMM_ASYNCGGML_RPC_COMM_SEND_DEFERGGML_RPC_GET_ASYNCGGML_RPC_SET_BATCHSo the four that help consistently are made the default here.
GGML_RPC_GET_ASYNCandGGML_RPC_SET_ASYNCchange any RPC client's reads and writes, not only a split's, so they stay opt-in: Spice will set them for its split models.GGML_RPC_SET_BATCHstays off; withGGML_RPC_SET_ASYNCoff it costs far more, about 37% of decode in one run, because a batch waits up to 100 µs for a next write that a synchronous writer cannot send yet (by reading ofsend_set_tensor_batch).Scoping matters because the switches are read once per process. A Spice node that serves a split model also serves other models from the same process: a second scheduler for each of those would cost memory for nothing.
Testing
Through the Spice runtime's llama.cpp engine: GLM-5.3 split three ways, with the head's GPU served at an address no port carries (ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address #18 loops it back). The fork build is the merged levers (ggml-rpc: serialize and deserialize a graph without allocating per tensor #14, llama: LLAMA_KV_PAD pads n_kv beyond 256 cells, so a growing context rebuilds its graphs less often #15, llama: read a state's tensors asynchronously and synchronize once #16) plus ggml-rpc: carry a connection to this host over the NIC's loopback when no port has its address #18, without and with this change cherry-picked. Sessions A D Z Z D A, each two symmetric and one standard bench of 8 prompts:
GGML_RPC_GET_ASYNC,GGML_RPC_SET_ASYNC,GGML_CUDA_MMVQ_IQ3_SMALL_K,LLAMA_KV_PAD=1024So the four defaults stand in for the four switches they replace: D measures the same as A, and its replies are identical to A's (8/8 in both sessions). Z's replies differ from A's on 7 of 8 because Z also drops
LLAMA_KV_PAD, which moves near ties (checked against an oracle in llama: LLAMA_KV_PAD pads n_kv beyond 256 cells, so a growing context rebuilds its graphs less often #15).A local model is unchanged:
test-llama-context --test baselineon Qwen3-0.6B (Metal), schedulers created per context counted under lldb (ggml_backend_sched_new): base 1, this branch 1, this branch withLLAMA_GRAPH_SLOTS=2set 2. ForGGML_SCHED_SYNC_INPUTS_ONCE, the default keys on the meta device type, so a model on one device keeps a wait per input. That part is by reading: the single-device run made no synchronize call on any build, so it could not show the difference.Replies: none of these levers changed a token in any session (every comparison 8/8 identical).
Not run: a two-rank NCCL split; a split on another backend than CUDA.