Skip to content

Merge spiceai-b11803 (#18, #19) into spiceai-b11999 - #22

Merged
lukekim merged 4 commits into
spiceai-b11999from
lukim/b11999-forward-b11803
Nov 3, 2026
Merged

lukekim merged 4 commits into
spiceai-b11999from
lukim/b11999-forward-b11803

Conversation

@lukekim

@lukekim lukekim commented Oct 30, 2026 •

Copy link
Copy Markdown

Carries #18 and #19 forward into spiceai-b11999. Both merged into spiceai-b11803, the previous Spice branch, after spiceai-b11999 was cut. spiceai/README.md says every PR merged into the previous branch must be in the new one before it is tagged. #15 and #16 came forward the same way in a42907e.

What changes

Two merge commits of spiceai-b11803 into spiceai-b11999 (f3bce26), neither with conflicts:

The details and lab evidence are in #18's and #19's descriptions.

Evidence (macOS, Metal, 2026-11-01, on a799a6f, from a clean build directory)

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

Maintainer judgment is needed on whether deployments can accept unversioned same-host RDMA negotiation requiring coordinated peer upgrades or matching RDMA settings.

No open issues 🎉

What changed in this PR

Carries #18's RPC transport change from spiceai-b11803 into spiceai-b11999, keeping the new Spice branch aligned with its predecessor.

Changes:

  • Enables NIC RoCE v2 loopback for same-host RPC connections when no eligible port carries the connection's address.
  • Adds same-host GID compatibility checks so peers selecting different GIDs fall back to TCP.
File Description
ggml/​src/​ggml-rpc/​transport.cpp Adds same-host detection, loopback GID selection, compatibility checks, and diagnostic logging.

Review effort: Balanced

@lukekim

lukekim commented Oct 30, 2026

Copy link
Copy Markdown
Author

Addressed #22 (review). Same-host RDMA negotiation is #18's design. #18 was reviewed and merged on spiceai-b11803; this PR only carries it into spiceai-b11999, with no conflicts and no other change.

The constraint the review names is real, and #18 documents it in ggml/src/ggml-rpc/transport.cpp beside the check:

  • The two ends of a connection to the same host share RDMA only when they chose the same GID.
  • A peer built without this check activates RDMA whenever both ends advertise it.
  • So mixing builds on one host needs either both ends from this build, or the same GGML_RDMA_DEV and GGML_RDMA_GID on both.
  • When the two ends choose different ports, the connection logs a warning and continues on TCP.

Old and new builds on one host. The Spice runtime does not mix them. Each runtime process serves its own GPUs from one in-process RPC server (serve_gpus in crates/llms-llamacpp/src/distributed.rs, "one per process"). So a same-host connection, the head reaching its own GPU, always has the same build on both ends. Connections between hosts never take this path. That part is code inspection only.

A different maintainer could decide otherwise. If they would rather version the negotiation (for example a capability bit in the RDMA handshake), that belongs in a PR against #18's code, not in this forward merge.

…it 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.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 03:04
@lukekim lukekim changed the title Merge spiceai-b11803 (#18) into spiceai-b11999 Merge spiceai-b11803 (#18, #19) into spiceai-b11999 Nov 1, 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

The merged branch has only macOS validation, leaving Linux RoCE loopback negotiation and the default CUDA/RPC asynchronous all-reduce path unverified on target RDMA/GPU hardware.

No open issues 🎉

Review effort: Balanced

@lukekim

lukekim commented Nov 1, 2026

Copy link
Copy Markdown
Author

On the latest Copilot review (a799a6f): this PR adds no code of its own. Its net diff against spiceai-b11999 is exactly #18's and #19's changes: the same 4 files and the same changed lines (+131/−21), checked by comparing git diff spiceai-b11999 a799a6fcb with #18's and #19's own diffs. Both merges went in without conflicts, and b11999 already has every switch #19 changes the default of, under the same names.

The Linux paths were validated in those PRs, on the three-Spark CUDA lab, where #18's RoCE loopback and #19's defaults were measured. That evidence is in #18's and #19's descriptions. Here, on macOS: test-llama-archs passes all 548 tests and test-rpc-transport exits 0. Re-measuring on the lab after this merge: not run, because the lab is offline. A person needs to decide whether to merge on that basis.

@lukekim lukekim self-assigned this Nov 2, 2026
@lukekim
lukekim merged commit a4e0cd4 into spiceai-b11999 Nov 3, 2026
21 of 42 checks passed
@lukekim

lukekim commented Nov 3, 2026

Copy link
Copy Markdown
Author

Addressed review 5726197264 after the merge: the Linux RoCE loopback negotiation (#18) and the default-on tensor-split levers (#19) on target hardware, on this PR's head a799a6fcb.

Rig and build. Three DGX Spark (GB10) nodes, each pair cabled over 200 GbE ConnectX-7 (RoCE v2), Qwen3.8-Flash-Next UD-Q3_K_XL split three ways (-sm tensor), 2026-11-03 00:32–00:51Z. A clean worktree at a799a6fcb (tree 9bb39da7c912), Release, -DGGML_CUDA=ON -DGGML_RPC=ON -DGGML_RPC_RDMA=ON -DCMAKE_CUDA_ARCHITECTURES=121. The build adds no warnings in ggml-rpc, ggml-backend.cpp or llama-context.cpp; test-rpc-transport exits 0 on Linux.

#18: a connection to the same host takes the NIC's loopback

Three CUDA ggml-rpc-servers on one node, all listening at that node's /32 address on the loopback interface, which no port carries. test-rpc-comm-mesh runs on the same node against the three: ./test-rpc-comm-mesh <lo-addr>:50052 <lo-addr>:50053 <lo-addr>:50054.

run server logs test-rpc-comm-mesh that node's RDMA port counters
as built every connection: RDMA probed: dev=rocep1s0f0 gid=3 RoCEv2 … (a connection to this host, looped back by the NIC) (7, 7 and 3 per server), RDMA activated, client connected, transport: RDMA; mesh links over RDMA 12/12 sizes exact, exit 0 0.391 GiB received on rocep1s0f0
GGML_RPC_NO_RDMA=1 on every process every connection transport: TCP, mesh links over TCP 12/12 sizes exact, exit 0 no RDMA traffic on any device

#19: the levers run by default on a tensor split, and change no output

  • D: no lever variable set.
  • O: LLAMA_GRAPH_SLOTS=1 GGML_SCHED_SYNC_INPUTS_ONCE=0 GGML_RPC_COMM_ASYNC=0 GGML_RPC_COMM_SEND_DEFER=0 on every process.

Which levers run. None of them logs a line of its own, so I counted calls under gdb. The breakpoints only count (ignore N), on an untimed llama-bench … -sm tensor -p 0 -n 16 -r 1:

what it shows counted D O
two graph slots ggml_backend_sched_new (client) 2 1
one input wait per split ggml_backend_synchronize (client) 246 1669
deferred sends socket_t::send_data_deferred (rank 0) 6528 0
stream-queued all-reduce servers logging ggml_backend_cuda_comm_wait_flags: device 0 can flush writes after waiting on host memory, printed only on that path 3/3 0/3

A/B. llama-bench -m <qwen> --rpc <r0>,<r1>,<r2> -dev RPC0/RPC1/RPC2 -sm tensor -ngl 999 -fa 1 -lm dio -p 512 -n 64 -r 3, rpc-servers restarted per run, run order D O O D D O O D, n=12 samples per arm:

arm pp512, ms per batch (min–max) tg64, tok/s (min–max)
D 698.20–729.42 39.15–41.86
O 733.20–784.28 36.19–39.08

D is faster on both: every D sample beats every O sample. These are 12 samples per arm, so no P99 is stated.

Outputs. llama-perplexity … -sm tensor -fa on -c 2048 -b 2048 -ub 512 --chunks 4 -f wiki.test.raw, D and O identical: [1]1.4155 [2]1.4048 [3]1.4938 [4]1.9963, final 1.9963 ± 0.05226.

test-rpc-comm-mesh, 3 ranks on CUDA across the nodes

Each server listens at its node's loopback-interface address, which routes over the direct cables. So the test needs no GGML_RPC_COMM_HOSTS, its two-rank phases form too, and the ranks move to the cable they share.

env world 3 two-rank phases exit servers on the stream-queued path links
D 4/4 sizes exact 8/8 0 3/3 8 over RDMA
O 4/4 sizes exact 8/8 0 0/3 8 over RDMA

Not run: a two-rank NCCL split, and backends other than CUDA.

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.

4 participants