You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DeepSeek-V4.1-Flash split over two DGX Sparks (-sm tensor across two ggml-rpc-servers) decodes well below the
hardware's bandwidth ceiling: each token waits on 80 host all-reduces, both ranks run the same mirrored work, the
expert split leaves one rank idle at every FFN all-reduce, and the hyper-connection blocks launch hundreds of tiny
kernels. These commits add six switches, each off by default so the branch behaves as before until a deployment
turns them on:
b8545f38GGML_CUDA_MMVQ_IQ3_SMALL_K=1: IQ3_XXS and IQ3_S take the small-K mul_mat_vec_q path, which
upstream turns off for them on Turing and newer. An expert down projection split across two ranks has only 4 or
5 blocks of K.
3ddbb3aeLLAMA_DSV4_HC_WEIGHTS=1: the hyper-connection pre, post and comb weights in one op
(ggml_dsv4_hc_weights, a mode of GGML_OP_DSV4_HC_COMB), bit-identical to the separate kernels, 640 fewer
launches per DeepSeek-V4.1 token. CPU and CUDA implement it; Metal, Vulkan and SYCL decline it.
b5d5e142GGML_RPC_COMM_WIRE_F32=1 (client, from 786e3d96): the host all-reduce sends prompt-sized
partials as F32 instead of rounding them to BF16.
07e3676eGGML_RPC_COMM_NCCL=1 (client, from 786e3d96): the pairwise all-reduce through NCCL on the
backend stream, so a rank's GPU no longer drains at every all-reduce. The NCCL_* tuning variables stay on the
rpc-servers, where NCCL runs.
9ee5a14fGGML_RPC_SET_ASYNC=1 (client): buffer writes are queued without waiting for the send.
3aebfba3LLAMA_DSV4_SHEXP_SHIFT=<rows>: shared-expert rows move to the rank with the lighter expert
split, so the two ranks reach each FFN all-reduce together.
762743bcspiceai/README.md lists them.
786e3d96 review fixes: the client sends the NCCL and F32-wire choices to both servers in COMM_INIT, so two
servers cannot disagree; the NCCL path takes only a contiguous F32 tensor; a server frees its NCCL communicators
when its client disconnects without COMM_FREE.
043e5a1d review fix: LLAMA_DSV4_SHEXP_SHIFT reads the routed split the way the split loop computes it.
7a55dbcc second-review fixes: with neither GGML_RPC_COMM_NCCL nor GGML_RPC_COMM_WIRE_F32 set, the client
sends upstream's 80-byte COMM_INIT, which a server without the flags (upstream b11803, or this branch before 786e3d96) reads; the 84-byte form, and with it the need for both rpc-servers to come from this branch, only
with a switch set. A server whose client disconnects
without COMM_FREE aborts its NCCL communicators (ncclCommAbort) instead of waiting on a collective the peer
never joins. The NCCL path also refuses a tensor whose byte size is not 4 per element (a wrapped ggml_nbytes).
a656b459 second-review fix: LLAMA_DSV4_SHEXP_SHIFT applies only with an unset or equal tensor_split; an
uneven split is left as given.
c34c0f6c third-review fix: the CPU ggml_dsv4_hc_weights rounds each product to F32 before adding the base,
so a compiler's fused multiply-add can no longer make it differ from the separate nodes; test-dsv4-hc-weights
compares the two bit for bit.
012c48f1 third-review fix: Vulkan stops on the weights mode instead of writing past its result. Over RPC, LLAMA_DSV4_HC_WEIGHTS=1 needs rpc-servers from this branch on CPU or CUDA, since an RPC device reports every
op as supported.
4114ec70 fourth-review fix: after ncclCommInitRank, the two servers agree on whether both have a
communicator; unless both do, neither keeps one and both copy through the host, so one rank can no longer wait in
NCCL while the other reduces over the peer connection.
772078a9 fourth-review fix: under GGML_RPC_SET_ASYNC=1, writes into weight buffers wait for their send
again, so model loading cannot queue copies of the model faster than the connection sends them; other writes,
such as a decode's inputs, are still only queued. 3185bd41 prints each test difference under its case.
Evidence
All runs: this branch (762743bc) built with -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=121 -DGGML_RPC=ON -DGGML_RPC_RDMA=ON, DeepSeek-V4.1-Flash-1017 UD-Q2_K_XL (unsloth/DeepSeek-V4.1-Flash-1017-GGUF at 60ad3651)
split over two DGX Sparks (GB10) with -sm tensor across two ggml-rpc-servers on RoCE addresses, llama-server
on a third Spark, 2026-10-24. A rate is 8 prompts x 200 tokens at temperature 0, pooled, after the same warm-up
request before every arm; each configuration is one server load running two arms.
The switches that keep the arithmetic leave the output unchanged. Plain decoding (no drafter):
the same, NCCL instead of the F32 host path (GGML_RPC_COMM_NCCL=1, 4 channels, LL)
22.72, 22.37
8/8 equal to the F32 reference
These runs predate 786e3d96, when the NCCL and F32-wire variables were read on the servers; they were set on both
servers and the client.
NCCL's sum equals the host path's once the host path sends F32 too; the default host path's texts differ because it
rounds the prompt's partials to BF16.
DSpark (--spec-type draft-dspark -md dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf -ngld all --spec-draft-n-max 3):
Configuration
tok/s (two arms)
Accepted per pass
Gap P99
everything off
31.35, 31.66
2.750
123.5, 124.8 ms
all six on, LLAMA_DSV4_SHEXP_SHIFT=1024, NCCL with NCCL_MIN_NCHANNELS=4 NCCL_MAX_NCHANNELS=4 NCCL_PROTO=LL
34.72, 34.71
2.780
87.1, 85.8 ms
That is 68% of the two-rank bandwidth ceiling (50.8 tok/s for 10.76 GB per token at 273 GB/s per Spark), up from
62%. The shift changes the split and with it the order of the sums, so these texts are not those of the default
split, and the acceptance moved with them (2.750 to 2.780); the passes themselves got about 9% faster.
What each switch did, measured one at a time on an equivalent tree:
small-K: in a rank trace, the IQ3_XXS down projection's p50/p99 went from 97.1/166.6 to 88.7/132.0 us, and all expert
mat-vecs from 8.96 to 8.73 ms per token.
NCCL: with a DSpark draft of 3, 30.63 / 31.56 / 32.74 tok/s against 31.24 / 29.20 for the host path, arms
interleaved in one load; gap P99 86.5-96.6 against 116.8-121.1 ms. Four channels beat one (verify 58.6 against
60.4 ms); two did not, and eight matched four. GPUDirect RDMA is not available with this rdma-core
(mlx5dv_reg_dmabuf_mr missing), so NCCL stages through its proxy.
queued uploads: per upload, the rank waited 59-78 us instead of 86-122 us; 24.21 / 24.12 / 24.02 against
23.57 / 23.89 / 23.92 tok/s, interleaved, texts identical.
shared-expert shift: the 4-token verify went from ~64.3 to ~62.3 ms at 1024 (63.3 at 512).
After the first review's fixes (043e5a1d), the DSpark configuration above with all six on: 35.03 and 35.13
tok/s (gap P99 86.8 and 84.4 ms) against 34.72 and 34.71 at 762743bc, texts and per-prompt draft acceptance
identical to the 762743bc run in both arms; both rpc-servers logged [comm_init] device 0 NCCL all-reduce on with
the NCCL choice sent by the client; after a SIGKILL of llama-server with no COMM_FREE, both servers printed Client connection closed, which follows ~rpc_server.
On the Sparks at 012c48f1 (CUDA sm_121, RPC and RDMA, GCC on aarch64): test-backend-ops -b CUDA0 passes
DSV4_HC_WEIGHTS 3/3 and DSV4_HC_COMB 11/11, and MUL_MAT_ID 16/16 and MUL_MAT 98/98 for type_a=iq3* with GGML_CUDA_MMVQ_IQ3_SMALL_K 0 and 1; test-dsv4-hc-weights passes (0 values differ in all 12 cases), and with c34c0f6c's ops.cpp change reverted it fails (11 of 12 cases, up to 4289 of 98304 values), so GCC contracts the
multiply-add too. The two-rank runs of 7a55dbcc onward (kills, mixed builds, DeepSeek decode) are in progress; 4114ec70 and 772078a9 are not run on the Sparks yet. With the default split those runs use, a656b459 makes the same shift
decisions as 043e5a1d (below). test-dsv4-hc-weights, run with ctest on an arm64 macOS CPU build, fails
before c34c0f6c (11 of 12 cases differ, up to 4295 of 98304 values) and passes after it (0 values differ in
all 12). The same comparison against a -ffp-contract=off build of the old code finds no difference, so the cause
is the contracted multiply-add. Checks on a CPU build (macOS, -DGGML_RPC=ON, 012c48f1): it builds without
warnings, and test-backend-ops -b CPU passes DSV4_HC_WEIGHTS 3/3, DSV4_HC_COMB 11/11, DSV4_HC_PRE
18/18 and DSV4_HC_POST 9/9 (CPU against itself). The NCCL path's tensor check, evaluated on tensors built the way deserialize_tensor builds them, refuses ne0 = 2^62+1 (ggml_nbytes wraps to 4) and passes 8192 floats. The
shared-expert rank choice, swept over 640 cases per tensor_split with the split loop's expressions, matches 043e5a1d for unset and equal splits and never shifts for uneven ones, where 043e5a1d moved rows onto the
device with more routed rows in 234 to 265 of 640.
Backend tests on GB10, this branch: test-backend-ops -b CUDA0 DSV4_HC_WEIGHTS 3/3, DSV4_HC_COMB 11/11, and
MUL_MAT_ID 16/16 and MUL_MAT 98/98 for type_a=iq3*, each with GGML_CUDA_MMVQ_IQ3_SMALL_K 0 and 1.
Not covered: the switches are untested on other GPUs and on models other than DeepSeek-V4.1 (deepseek4 shares
the hyper-connection code; GLM-5.3 and Qwen3.8 do not use these paths unless the small-K switch is set).
Spice's llama-cpp crate pins this fork by commit; turning these on in a Spice deployment, and moving the pin,
are separate spiceai/spiceai changes.
…behind GGML_CUDA_MMVQ_IQ3_SMALL_K
mul_mat_vec_q gives each row one warp when the whole block covers K in a single loop iteration (small_k),
except for IQ3_XXS and IQ3_S on Turing and newer, which keep four warps per row. A DeepSeek-V4.1 expert down
projection split across two ranks has K = 1280 or 1024 (5 or 4 IQ blocks), so with four warps most threads
of each block have no work.
GGML_CUDA_MMVQ_IQ3_SMALL_K=1 lets the IQ3 types take the small-K path too. On a DGX Spark (GB10):
- test-backend-ops perf, MUL_MAT_ID with 384 experts, 6 used, n=1, m=5120: IQ3_XXS k=1280 75.7 and 67.0 us
became 54.3 and 47.0 us; IQ3_S k=1280 62.8 and 58.2 became 53.5 and 52.4 us; IQ3_S k=1024 44.5 became 40.3
and 40.5 us (interleaved runs; the large-K shapes, which do not take the path, did not change).
- in a two-rank DeepSeek-V4.1-Flash decode, the IQ3_XXS down projection's p50/p99 went from 97.1/166.6 us to
88.7/132.0 us.
It is off by default because it was measured only on GB10. test-backend-ops MUL_MAT_ID passes for the IQ3
types with it on.
…hts in one op behind LLAMA_DSV4_HC_WEIGHTS
build_hc_mixes computes the pre and post weights with a MUL, ADD, SIGMOID and SCALE chain each and the comb
with ggml_dsv4_hc_comb, so every hyper-connection block launches nine kernels for its 24 values per token.
ggml_dsv4_hc_weights is a mode of GGML_OP_DSV4_HC_COMB (op param 2 = 1) whose [24, n_tokens] result holds
pre, post and comb. With LLAMA_DSV4_HC_WEIGHTS=1, build_hc_mixes takes views of it instead, which removes
eight launches per block (640 per DeepSeek-V4.1 token). The CUDA kernel rounds the affine step the way the
separate MUL and ADD kernels do (no fused multiply-add), so the weights are bit-identical: a two-rank
DeepSeek-V4.1-Flash decode produced the same 8 of 8 texts. CPU and CUDA implement the mode; Metal, Vulkan
and SYCL report it unsupported, so the scheduler never hands it to them. test-backend-ops gains
DSV4_HC_WEIGHTS cases against the CPU reference.
…PC_COMM_WIRE_F32
The host all-reduce halves the bytes of partials of 32768 elements and more (a prompt's) by sending them as
BF16, which rounds each rank's partial before the sum. GGML_RPC_COMM_WIRE_F32=1 on the servers sends them as
F32. With it, a two-rank DeepSeek-V4.1-Flash decode produced the same 8 of 8 texts as an F32 NCCL reduction,
where the default host path differed from NCCL in all 8 (from the first token for one prompt, part-way
through the others, because only the prompt's all-reduces are rounded).
…s behind GGML_RPC_COMM_NCCL
The pairwise all-reduce waits for the producing graph, copies the partial to the host, exchanges it with the
peer and copies the sum back, so a rank's GPU drains at every all-reduce: 80 times per DeepSeek-V4.1 token
over two ranks, ~46 us each at the median.
With GGML_RPC_COMM_NCCL=1 on both servers, comm_init creates an NCCL communicator between them, through
functions the CUDA backend now exports from its proc address table, and comm_allreduce queues ncclAllReduce
on the backend stream, so a rank keeps running the graphs already queued behind it. A server that cannot
(a build without GGML_USE_NCCL, or a backend that does not export the calls) keeps the host path; the two
servers agree before initializing, because ncclCommInitRank waits for every rank. NCCL sums in F32 while the
default host path sends prompt-sized partials as BF16, so outputs differ from that path unless the servers
also set GGML_RPC_COMM_WIRE_F32=1.
On two DGX Sparks over a RoCE link (NCCL 2.32.3, NCCL_PROTO=LL), DeepSeek-V4.1-Flash UD-Q2_K_XL with a DSpark
draft of 3 decoded at 30.63 / 31.56 / 32.74 tok/s against 31.24 / 29.20 for the host path, interleaved in one
load, with the gap P99 at 86.5-96.6 ms against 116.8-121.1 ms. Four channels did better than one
(verify 58.6 against 60.4 ms).
…SET_ASYNC
ggml_backend_rpc_buffer_set_tensor and set_tensor_2d copied the data into the request and then waited until
the dispatcher had sent it. The server sends no reply to these commands and handles a connection's commands
in order, so a later graph compute or read on that server sees the write either way. With
GGML_RPC_SET_ASYNC=1 the client queues the request and returns. The hash-cache path, which needs the
server's answer, is unchanged.
In a two-rank DeepSeek-V4.1-Flash decode with NCCL all-reduces, the time a rank waited for each upload fell
from 86-122 us to 59-78 us and decode went from 23.57 / 23.89 / 23.92 to 24.21 / 24.12 / 24.02 tok/s
(interleaved arms of one load), with identical texts.
…pert rows behind LLAMA_DSV4_SHEXP_SHIFT
With -sm tensor over two devices, the routed experts' ff dimension of 2304 (9 blocks of 256 for the IQ and K
quants) splits 1280 / 1024, alternating by layer, so at each FFN all-reduce the rank with 1024 rows waits for
the other. In a 4-token DSpark verify of DeepSeek-V4.1-Flash, the FFN all-reduce of every other layer took
~170 us on the waiting rank against 59-71 us for the other all-reduces.
LLAMA_DSV4_SHEXP_SHIFT=<rows> moves that many rows of the shared expert (rounded down to its split
granularity, and the same for gate, up and down so their splits still match) to the expert-light rank, in
each layer whose expert split is uneven. How many rows balance depends on the batch, since the routed work
grows with each verified token and the shared expert's does not, so it is off by default. With 1024 and a
DSpark draft of 3, the 4-token verify went from ~64.3 to ~62.3 ms. A different split changes the order of the
sums, so outputs can differ from the default split.
Adds six opt-in performance switches to the Spice.ai fork for DeepSeek-V4 decoding across two RPC-backed GPUs, preserving existing behavior by default.
Changes:
Adds small-K IQ3 execution and fused hyper-connection weights with CPU/CUDA support and backend tests.
…s, and check NCCL tensors
Each rpc-server read GGML_RPC_COMM_NCCL and GGML_RPC_COMM_WIRE_F32 from its own environment, so two servers
started differently disagreed: with NCCL set on one only, that one waited on the peer link for a handshake the
other never sent, and with the F32 wire on one only, the two exchanged partials of different sizes. The client
now reads both variables and sends them to the two ranks as flags in COMM_INIT, so both always take the same
path; when NCCL is requested, the servers still agree that each can before creating the communicator. A server
built without these flags fails COMM_INIT on its exact-size check instead of desynchronizing.
The NCCL path reduces ggml_nelements floats in place, so a request for anything but a contiguous F32 tensor
is now refused rather than read past the tensor's bytes. A server whose client disconnects without COMM_FREE
destroys its NCCL communicators with the rest of its state.
… actual tensor split
The shift assumed an even split when deciding whether a layer's routed experts split unevenly. It now computes
the first device's share the way the split loop does, from tensor_split and the layer's rotation, and shifts
only when rounding that share down to the granularity removed rows; the first device is then the lighter one.
Choose smaller rounded tensor-split share before rotation
src/llama-model.cpp:919
[P2] With --tensor-split 3,1, 2304 routed rows, granularity 256, and rotation 0, the rounded shares are 1536/768, but this branch labels the first rank light. Enabling the shift therefore adds shared-expert work to the heavier rank and worsens the imbalance. Compare the rounded shares, skip equal shares, and apply tc.rotation after choosing the smaller one.
…L after a lost client, and bound the NCCL tensor
COMM_INIT grew from upstream's 80 bytes to 84 for the flags, so against a client or server from upstream b11803, or
from this branch before the flags, it failed even with every switch off. The client now sends upstream's 80-byte
request when neither GGML_RPC_COMM_NCCL nor GGML_RPC_COMM_WIRE_F32 is set, and the 84-byte one only when one is; the
server reads either. With a switch set, an older server still refuses the longer request, so both rpc-servers must
come from this branch, as spiceai/README.md now says.
A client that disconnects without COMM_FREE may have sent an all-reduce to one rank only, which the peer never joins,
and ncclCommDestroy would wait for it, leaving the server's one-client accept loop unable to serve the next client.
~rpc_server now aborts each communicator left open through a new ggml_backend_cuda_nccl_comm_abort (ncclCommAbort)
and logs it; COMM_FREE still destroys them.
The NCCL all-reduce also refuses a tensor whose ggml_nbytes / 4 is not its element count: for a huge ne, ggml_nbytes
wraps, so deserialize_tensor's bounds check passes a few bytes while NCCL would reduce ne floats.
…r_split
With an uneven split, the device whose share rounding shrank can still have more routed rows (3:1 over 2304 rows at
granularity 256 gives 1536 and 768), so the shift could move shared-expert rows onto the heavier rank, and which rank
is lighter there depends on whether the split stands for device speed or memory. An uneven split is now left as
given. With an unset or equal one, the device whose half was rounded down has fewer rows, and the shift behaves as
before.
Its three open threads have replies with the evidence: protocol size (#5 (comment)), the abort on an unclean disconnect (#5 (comment)), and the tensor extent (#5 (comment)). This comment answers the body-only item, "Choose smaller rounded tensor-split share before rotation" (src/llama-model.cpp:919), which is also the headline's "asymmetric rank selection".
a656b45 applies LLAMA_DSV4_SHEXP_SHIFT only when tensor_split is unset or equal (llama-model.cpp:900-911). There, the device whose half was rounded down really has fewer routed rows. An uneven split is left as given. I did not take the smaller-share rule: under an uneven split, it also shifts when the split is exactly the requested ratio (3:1 with no rounding), pulling toward 1:1. Which rank is lighter under an uneven split depends on whether the split stands for device speed or memory, so the shift stays out of that case. This is the "restrict this optimization to equal splits" option from the first review.
Checked with the split loop's expressions extracted into a standalone sweep: 640 cases per tensor_split (ne 128 to 16384, block sizes 1, 32 and 256, both rotations), comparing 043e5a1's rule with a656b45's:
tensor_split null / 1,1 / 2.5,2.5: shift decisions differ in 0 of 640 each; shexp rows given to the device with MORE routed rows: 0
tensor_split 3,1 and 1,3: 043e5a1d gave them to the device with more routed rows in 234 of 640; a656b459: 0 (no shift)
tensor_split 0.6,0.4 / 5,3 / 11,9: 043e5a1d: 240 / 265 / 263 of 640; a656b459: 0
your example (3,1; 2304 rows; granularity 256; rotation 0): routed rows dev0=1536 dev1=768 | 043e5a1d: shift to dev0 | a656b459: no shift
The two-Spark runs use the default split, where a656b45 makes the same shift decisions as 043e5a1. The uneven-split case is not run on hardware; it is verified by code inspection plus the sweep. The earlier thread on the same code (#5 (comment)) was resolved by your review of 043e5a1.
The earlier review, #5 (review), was answered on its five threads.
Prevent FMA contraction from changing F32 weight results
ggml/src/ggml-cpu/ops.cpp:11560
On builds that allow fused multiply-add contraction, these CPU expressions can round differently from the separate multiplication and addition nodes, so enabling the switch can change the pre/post weights. Force each product to round to F32 before adding its base, and add a regression comparison against the unfused graph.
…the base, as the separate nodes do
ggml_dsv4_hc_weights computed sigmoid(mixes*scale + base) in one expression, which a compiler may contract into a
fused multiply-add (Apple clang does by default on arm64), rounding once where the MUL and ADD nodes it replaces
round twice. So LLAMA_DSV4_HC_WEIGHTS=1 changed the CPU backend's pre and post weights: on an arm64 macOS build, the
new test-dsv4-hc-weights found differences from those nodes in 11 of its 12 cases, up to 4295 of 98304 values, and
none with -ffp-contract=off. Each product is now rounded to F32 through a volatile before the add, as the CUDA kernel
does with __fmul_rn and __fadd_rn, and the test compares the op with the separate nodes bit for bit on the CPU
backend.
… past its result
Vulkan's supports_op declines the weights mode, but an RPC device reports every op as supported, so a client with
LLAMA_DSV4_HC_WEIGHTS=1 can still send that mode to a Vulkan rpc-server. ggml_vk_dsv4_hc_comb would then run the
4x4-per-token comb kernel with the strides of the [24, n_tokens] result and write past it. It now asserts the mode,
as the CPU, CUDA, Metal and SYCL comb paths already stop on the result's shape. spiceai/README.md says that over RPC
the switch needs rpc-servers from this branch on the CPU or CUDA backend.
Its open thread, RPC weights-fusion support, has a reply: #5 (comment). This comment answers its body-only item, "Prevent FMA contraction from changing F32 weight results" (ggml/src/ggml-cpu/ops.cpp:11560), which is also the headline's "fusion correctness issues".
Reproduced. On an arm64 macOS CPU build (Apple clang, default flags), ggml_dsv4_hc_weights differed bit for bit from the separate MUL, ADD, SIGMOID and SCALE_BIAS/SCALE nodes that build_hc_mixes uses without the switch. c34c0f6 rounds each product to F32 through a volatile before adding the base (ops.cpp:11559-11565), as the CUDA kernel does with __fmul_rn and __fadd_rn (dsv4-hc.cu:73-78). It also adds tests/test-dsv4-hc-weights.cpp, which builds both graphs on the CPU backend for 1, 17, 257 and 4096 tokens and three seeds, and compares every pre, post and comb value bit for bit.
ctest -R test-dsv4-hc-weights --output-on-failure with a656b45's ops.cpp, the last lines of its output (each first difference line belongs to the case printed after it):
n_tokens = 4096, seed = 1: 2412 of 98304 values differ
first difference: post[0] of token 2: fused 0.0892300829, separate nodes 0.0892301053
n_tokens = 4096, seed = 2: 4295 of 98304 values differ
first difference: post[2] of token 1: fused 0.63910675, separate nodes 0.63910681
n_tokens = 4096, seed = 3: 2913 of 98304 values differ
FAIL: 11 of 12 cases differ from the separate nodes
...
55 - test-dsv4-hc-weights (Failed) main
55: n_tokens = 1, seed = 1: 0 of 24 values differ
...
55: n_tokens = 4096, seed = 3: 0 of 98304 values differ
55: OK
100% tests passed out of 1
and again at 012c48f: 1/1 Test #55: test-dsv4-hc-weights ............. Passed.
The same comparison against a build of the old code with -ffp-contract=off found no difference (0 of 16384 pre and 0 of 16384 post values for each of three seeds at 4096 tokens), so the cause is the contracted multiply-add. The CUDA kernel already rounds each step separately, which is consistent with the identical two-Spark texts in the description.
Not run yet: the two-rank run of the protocol and lifecycle fixes (7a55dbc), the other half of the headline, is in progress.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
NCCL failure handling and upload memory bounds need fixes, and the latest distributed cleanup and compatibility changes still need two-rank validation.
[P2] Tensor-parallel model loading sends split weights through SET_TENSOR_2D, which copies the complete payload into an unbounded dispatcher queue without a hash-cache round-trip. With asynchronous writes enabled, loading can exhaust client RAM when weight reads outpace the RPC connection. Keep weight uploads synchronous, or impose a byte limit on queued uploads, to preserve loading backpressure while allowing asynchronous decode uploads.
…g it
ncclCommInitRank can succeed on one rank and fail on the other. The failed rank then reduced over the peer
connection while its peer waited in ncclAllReduce, and neither all-reduce could finish. After initializing, the two
servers now exchange whether they have a communicator; unless both do, the one that has one aborts it, and both copy
through the host. A handshake that fails on the peer connection now fails COMM_INIT instead of continuing on one
rank.
Model loading writes every weight through set_tensor or, for a tensor split across ranks, set_tensor_2d, which has
no hash-cache round trip to wait on. With GGML_RPC_SET_ASYNC=1, each write returned once a copy of its data was
queued, so loading from storage faster than the RPC connection could queue copies until the client ran out of
memory. A write into a weight buffer (GGML_BACKEND_BUFFER_USAGE_WEIGHTS, which llama sets before it loads the data and
the split backend passes to each rank's buffer) waits for its send again; other writes, such as a decode's inputs,
are still only queued.
Its open thread has a reply: #5 (comment). This comment answers its body-only item, "Prevent unbounded async tensor weight upload queue" (ggml/src/ggml-rpc/ggml-rpc.cpp:932), the headline's "upload memory bounds".
Fixed in 772078a by keeping weight uploads synchronous. Under GGML_RPC_SET_ASYNC=1, a write now waits for its send when its buffer's usage is GGML_BACKEND_BUFFER_USAGE_WEIGHTS (ggml-rpc.cpp:872-881, used at 907 and 933). Llama sets that usage on every model buffer before it loads the data (llama-model.cpp:2021, then load_all_data at 2069). For a tensor-split model, ggml_backend_buffer_set_usage passes it on to each rank's RPC buffer (ggml-backend-meta.cpp:1717-1723). So set_tensor_2d during loading waits again, while writes into other buffers, such as a decode's inputs, where the queued writes were measured to help, are still only queued.
The unbounded growth is unverified, code inspection only: the two-Spark loads finished without it, over a link fast enough to keep up. Model loading with GGML_RPC_SET_ASYNC=1 at 3185bd4 is part of the two-rank run in progress. That run also covers the headline's "two-rank validation" of 7a55dbc onward, the protocol, abort and initialization paths.
3185bd4 is test output only: each test-dsv4-hc-weights difference now prints under the case it belongs to.
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
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.
Summary
DeepSeek-V4.1-Flash split over two DGX Sparks (
-sm tensoracross twoggml-rpc-servers) decodes well below thehardware's bandwidth ceiling: each token waits on 80 host all-reduces, both ranks run the same mirrored work, the
expert split leaves one rank idle at every FFN all-reduce, and the hyper-connection blocks launch hundreds of tiny
kernels. These commits add six switches, each off by default so the branch behaves as before until a deployment
turns them on:
b8545f38GGML_CUDA_MMVQ_IQ3_SMALL_K=1: IQ3_XXS and IQ3_S take the small-Kmul_mat_vec_qpath, whichupstream turns off for them on Turing and newer. An expert down projection split across two ranks has only 4 or
5 blocks of K.
3ddbb3aeLLAMA_DSV4_HC_WEIGHTS=1: the hyper-connection pre, post and comb weights in one op(
ggml_dsv4_hc_weights, a mode ofGGML_OP_DSV4_HC_COMB), bit-identical to the separate kernels, 640 fewerlaunches per DeepSeek-V4.1 token. CPU and CUDA implement it; Metal, Vulkan and SYCL decline it.
b5d5e142GGML_RPC_COMM_WIRE_F32=1(client, from786e3d96): the host all-reduce sends prompt-sizedpartials as F32 instead of rounding them to BF16.
07e3676eGGML_RPC_COMM_NCCL=1(client, from786e3d96): the pairwise all-reduce through NCCL on thebackend stream, so a rank's GPU no longer drains at every all-reduce. The
NCCL_*tuning variables stay on therpc-servers, where NCCL runs.
9ee5a14fGGML_RPC_SET_ASYNC=1(client): buffer writes are queued without waiting for the send.3aebfba3LLAMA_DSV4_SHEXP_SHIFT=<rows>: shared-expert rows move to the rank with the lighter expertsplit, so the two ranks reach each FFN all-reduce together.
762743bcspiceai/README.mdlists them.786e3d96review fixes: the client sends the NCCL and F32-wire choices to both servers inCOMM_INIT, so twoservers cannot disagree; the NCCL path takes only a contiguous F32 tensor; a server frees its NCCL communicators
when its client disconnects without
COMM_FREE.043e5a1dreview fix:LLAMA_DSV4_SHEXP_SHIFTreads the routed split the way the split loop computes it.7a55dbccsecond-review fixes: with neitherGGML_RPC_COMM_NCCLnorGGML_RPC_COMM_WIRE_F32set, the clientsends upstream's 80-byte
COMM_INIT, which a server without the flags (upstream b11803, or this branch before786e3d96) reads; the 84-byte form, and with it the need for both rpc-servers to come from this branch, onlywith a switch set. A server whose client disconnects
without
COMM_FREEaborts its NCCL communicators (ncclCommAbort) instead of waiting on a collective the peernever joins. The NCCL path also refuses a tensor whose byte size is not 4 per element (a wrapped
ggml_nbytes).a656b459second-review fix:LLAMA_DSV4_SHEXP_SHIFTapplies only with an unset or equaltensor_split; anuneven split is left as given.
c34c0f6cthird-review fix: the CPUggml_dsv4_hc_weightsrounds each product to F32 before adding the base,so a compiler's fused multiply-add can no longer make it differ from the separate nodes;
test-dsv4-hc-weightscompares the two bit for bit.
012c48f1third-review fix: Vulkan stops on the weights mode instead of writing past its result. Over RPC,LLAMA_DSV4_HC_WEIGHTS=1needs rpc-servers from this branch on CPU or CUDA, since an RPC device reports everyop as supported.
4114ec70fourth-review fix: afterncclCommInitRank, the two servers agree on whether both have acommunicator; unless both do, neither keeps one and both copy through the host, so one rank can no longer wait in
NCCL while the other reduces over the peer connection.
772078a9fourth-review fix: underGGML_RPC_SET_ASYNC=1, writes into weight buffers wait for their sendagain, so model loading cannot queue copies of the model faster than the connection sends them; other writes,
such as a decode's inputs, are still only queued.
3185bd41prints each test difference under its case.Evidence
All runs: this branch (
762743bc) built with-DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=121 -DGGML_RPC=ON -DGGML_RPC_RDMA=ON, DeepSeek-V4.1-Flash-1017 UD-Q2_K_XL (unsloth/DeepSeek-V4.1-Flash-1017-GGUFat60ad3651)split over two DGX Sparks (GB10) with
-sm tensoracross twoggml-rpc-servers on RoCE addresses,llama-serveron a third Spark, 2026-10-24. A rate is 8 prompts x 200 tokens at temperature 0, pooled, after the same warm-up
request before every arm; each configuration is one server load running two arms.
The switches that keep the arithmetic leave the output unchanged. Plain decoding (no drafter):
GGML_CUDA_MMVQ_IQ3_SMALL_K=1 LLAMA_DSV4_HC_WEIGHTS=1 GGML_RPC_SET_ASYNC=1GGML_RPC_COMM_WIRE_F32=1GGML_RPC_COMM_NCCL=1, 4 channels, LL)These runs predate
786e3d96, when the NCCL and F32-wire variables were read on the servers; they were set on bothservers and the client.
NCCL's sum equals the host path's once the host path sends F32 too; the default host path's texts differ because it
rounds the prompt's partials to BF16.
DSpark (
--spec-type draft-dspark -md dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf -ngld all --spec-draft-n-max 3):LLAMA_DSV4_SHEXP_SHIFT=1024, NCCL withNCCL_MIN_NCHANNELS=4 NCCL_MAX_NCHANNELS=4 NCCL_PROTO=LLThat is 68% of the two-rank bandwidth ceiling (50.8 tok/s for 10.76 GB per token at 273 GB/s per Spark), up from
62%. The shift changes the split and with it the order of the sums, so these texts are not those of the default
split, and the acceptance moved with them (2.750 to 2.780); the passes themselves got about 9% faster.
What each switch did, measured one at a time on an equivalent tree:
mat-vecs from 8.96 to 8.73 ms per token.
interleaved in one load; gap P99 86.5-96.6 against 116.8-121.1 ms. Four channels beat one (verify 58.6 against
60.4 ms); two did not, and eight matched four. GPUDirect RDMA is not available with this rdma-core
(
mlx5dv_reg_dmabuf_mrmissing), so NCCL stages through its proxy.23.57 / 23.89 / 23.92 tok/s, interleaved, texts identical.
After the first review's fixes (
043e5a1d), the DSpark configuration above with all six on: 35.03 and 35.13tok/s (gap P99 86.8 and 84.4 ms) against 34.72 and 34.71 at
762743bc, texts and per-prompt draft acceptanceidentical to the
762743bcrun in both arms; both rpc-servers logged[comm_init] device 0 NCCL all-reduce onwiththe NCCL choice sent by the client; after a SIGKILL of
llama-serverwith noCOMM_FREE, both servers printedClient connection closed, which follows~rpc_server.On the Sparks at
012c48f1(CUDA sm_121, RPC and RDMA, GCC on aarch64):test-backend-ops -b CUDA0passesDSV4_HC_WEIGHTS 3/3 and DSV4_HC_COMB 11/11, and MUL_MAT_ID 16/16 and MUL_MAT 98/98 for
type_a=iq3*withGGML_CUDA_MMVQ_IQ3_SMALL_K0 and 1;test-dsv4-hc-weightspasses (0 values differ in all 12 cases), and withc34c0f6c'sops.cppchange reverted it fails (11 of 12 cases, up to 4289 of 98304 values), so GCC contracts themultiply-add too. The two-rank runs of
7a55dbcconward (kills, mixed builds, DeepSeek decode) are in progress;4114ec70and772078a9are not run on the Sparks yet. With the default split those runs use,a656b459makes the same shiftdecisions as
043e5a1d(below).test-dsv4-hc-weights, run withcteston an arm64 macOS CPU build, failsbefore
c34c0f6c(11 of 12 cases differ, up to 4295 of 98304 values) and passes after it (0 values differ inall 12). The same comparison against a
-ffp-contract=offbuild of the old code finds no difference, so the causeis the contracted multiply-add. Checks on a CPU build (macOS,
-DGGML_RPC=ON,012c48f1): it builds withoutwarnings, and
test-backend-ops -b CPUpasses DSV4_HC_WEIGHTS 3/3, DSV4_HC_COMB 11/11, DSV4_HC_PRE18/18 and DSV4_HC_POST 9/9 (CPU against itself). The NCCL path's tensor check, evaluated on tensors built the way
deserialize_tensorbuilds them, refusesne0 = 2^62+1(ggml_nbyteswraps to 4) and passes 8192 floats. Theshared-expert rank choice, swept over 640 cases per
tensor_splitwith the split loop's expressions, matches043e5a1dfor unset and equal splits and never shifts for uneven ones, where043e5a1dmoved rows onto thedevice with more routed rows in 234 to 265 of 640.
Backend tests on GB10, this branch:
test-backend-ops -b CUDA0DSV4_HC_WEIGHTS 3/3, DSV4_HC_COMB 11/11, andMUL_MAT_ID 16/16 and MUL_MAT 98/98 for
type_a=iq3*, each withGGML_CUDA_MMVQ_IQ3_SMALL_K0 and 1.Not covered: the switches are untested on other GPUs and on models other than DeepSeek-V4.1 (
deepseek4sharesthe hyper-connection code; GLM-5.3 and Qwen3.8 do not use these paths unless the small-K switch is set).
Spice's
llama-cppcrate pins this fork by commit; turning these on in a Spice deployment, and moving the pin,are separate spiceai/spiceai changes.