Skip to content

Turn the tensor-split levers on by default: graph slots, one input wait per split, stream-queued all-reduce, deferred sends - #19

Merged
lukekim merged 2 commits into
spiceai-b11803from
lukim/b11803-split-defaults
Nov 1, 2026
Merged

lukekim merged 2 commits into
spiceai-b11803from
lukim/b11803-split-defaults

Conversation

@lukekim

@lukekim lukekim commented Oct 29, 2026

Copy link
Copy Markdown

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:

lever unset, a tensor split unset, any other model
LLAMA_GRAPH_SLOTS two graph slots (a second scheduler) one, as before
GGML_SCHED_SYNC_INPUTS_ONCE one wait per split on the meta backend a wait per input, as before
GGML_RPC_COMM_ASYNC on ("0" turns it off) not reached: only a tensor split's all-reduce uses it
GGML_RPC_COMM_SEND_DEFER on ("0" turns it off) not reached

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:

levers symmetric mean (range), tok/s standard mean (range), tok/s
all of #8's and #12's switches on 50.05 (48.80–52.02) 48.06 (47.95–48.18)
none 42.17 (41.32–43.05) 40.90 (40.74–41.05)

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):

lever pass 1 pass 2
GGML_SCHED_SYNC_INPUTS_ONCE +3.1% +5.2%
LLAMA_GRAPH_SLOTS +3.9% +3.8%
GGML_RPC_COMM_ASYNC +1.4% +2.6%
GGML_RPC_COMM_SEND_DEFER +1.7% +0.9%
GGML_RPC_GET_ASYNC −2.3% +1.7%
GGML_RPC_SET_BATCH −1.4% −1.2%

So the four that help consistently are made the default here. GGML_RPC_GET_ASYNC and GGML_RPC_SET_ASYNC change 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_BATCH stays off; with GGML_RPC_SET_ASYNC off 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 of send_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

…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.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 14:42
@github-actions github-actions Bot added the ggml label Oct 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@lukekim
lukekim merged commit aad0211 into spiceai-b11803 Nov 1, 2026
20 of 41 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants