[GH-ISSUE #5170] [Engine] DeepSeek V4.1 on a DGX Spark: a decoded token waits 29 ms for the CPU lane; compute those experts on the GPU when it shares the memory? #3076

Open
opened 2026-11-07 14:37:51 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @R-Okauchi on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5170

Area

[Engine]

What do you want to do?

I'm trying DeepSeek-V4.1-Flash-1017 IQ2_XS on my DGX Spark as the main model of a coding agent, and I would like its decode
to get closer to what the box allows. The 2.25 bpw set does not fit in the Spark's 128 GB: the engine places about 10,200 of 15,360 experts on the GPU and
runs the other 5,100 (50 GB) on the CPU lane, read in place from the model files. On a GB10 the CPU and the GPU share that
memory, so the CPU lane's experts are in memory the GPU can read as well.

Measured on my DGX Spark (GB10, driver 580.178.04, CUDA 13.0, Ubuntu 24.04 container), the release package
strata-dsv41-0.1.56-linux-aarch64-cuda-cuda13, standalone: strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> --n 256 --max-context 262144 --eos 1 --vision on --experts 6 --dspark none, DS4_PROF=1 DS4_PROF_SYNC=1 DS4_UMA_HEADROOM_GIB=12
(12: the Spark also runs a few other containers), after a 1,308-token chat prompt:

Run GPU per token attention routing + shared expert experts gate/up waiting for the CPU lane down + post decode
as above 92.80 ms 35.10 13.95 8.47 28.92 6.34 10.42 tok/s
DS4_LANE_SKIP=1 (the timing oracle: wrong answers) 59.07 ms 32.61 12.70 7.85 0.34 5.56 16.12 tok/s
--experts 5 79.64 ms 34.43 13.44 7.11 19.25 5.40 11.97 tok/s
after a 65,095-token prompt, 128 tokens 88.15 ms 34.84 13.62 8.24 25.43 6.00 10.94 tok/s
  • In the first run the CPU lane took 1,851 of 61,200 picks (3.0%), and a CPU-lane call cost 4.9 ms (gate+up 2.70 ms, down
    2.13 ms, 1.17 experts a call). So 3% of the picks are 31% of the token.
  • --dspark auto --dspark-conf 0.65 without the profiler: 12.24 tok/s (the drafter's experts move about 1,000 more experts to
    the CPU lane).
  • Prompts: 1,308 tokens at 159 tok/s, 65,095 tokens at 658 tok/s. DS4_FAST_ATTN=1 changed nothing on this CUDA device
    (657 tok/s). The prompt table of the long prompt (with #5127, which makes DS4_PROF work on chunked prompts): experts incl.
    waits 43%, sparse attention 19%, q_b + rope 13%, ffn mHC + router + sort 10%.

What I would like to agree on before writing code:

  1. The CPU lane on an integrated NVIDIA GPU. The PCIe lane already streams CPU-lane experts to the GPU on a discrete card,
    but only for MXFP4 layers (lane_layer_ok) and only with DS4_STREAM=1; for the ISTA-DAS sets every non-resident pick is
    computed by the CPU. On a GB10 the GPU could compute those picks where the files' pages already are (zero-copy, or a copy
    inside the same memory), so a decoded token would not wait for the CPU at all. The oracle bounds the gain at about +55%
    for this set. Would a change like this be welcome, opt-in first (the default path unchanged) and measured with paired
    runs and output hashes? Is it already planned?
  2. Attention. 35 ms a token at 1.3K and at 65K context alike: the largest part once the CPU lane's wait is gone. I have not
    profiled it per kernel yet.

Related: #4637 (DS4_UMA_HEADROOM_GIB on a Spark), #5061 (Strix Halo: with every expert on the GPU, 45 tok/s).

What do you do today instead?

For now I run --experts 5 with the drafter, the fastest setting I found here: 13.5 tok/s in serve/server.py (a 924-token
answer), against 11.0 with 6 experts. I found nothing faster that keeps the quality.

Originally created by @R-Okauchi on GitHub (Nov 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5170 ### Area [Engine] ### What do you want to do? I'm trying DeepSeek-V4.1-Flash-1017 IQ2_XS on my DGX Spark as the main model of a coding agent, and I would like its decode to get closer to what the box allows. The 2.25 bpw set does not fit in the Spark's 128 GB: the engine places about 10,200 of 15,360 experts on the GPU and runs the other 5,100 (50 GB) on the CPU lane, read in place from the model files. On a GB10 the CPU and the GPU share that memory, so the CPU lane's experts are in memory the GPU can read as well. Measured on my DGX Spark (GB10, driver 580.178.04, CUDA 13.0, Ubuntu 24.04 container), the release package `strata-dsv41-0.1.56-linux-aarch64-cuda-cuda13`, standalone: `strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> --n 256 --max-context 262144 --eos 1 --vision on --experts 6 --dspark none`, `DS4_PROF=1 DS4_PROF_SYNC=1 DS4_UMA_HEADROOM_GIB=12` (12: the Spark also runs a few other containers), after a 1,308-token chat prompt: | Run | GPU per token | attention | routing + shared expert | experts gate/up | waiting for the CPU lane | down + post | decode | | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | | as above | 92.80 ms | 35.10 | 13.95 | 8.47 | 28.92 | 6.34 | 10.42 tok/s | | `DS4_LANE_SKIP=1` (the timing oracle: wrong answers) | 59.07 ms | 32.61 | 12.70 | 7.85 | 0.34 | 5.56 | 16.12 tok/s | | `--experts 5` | 79.64 ms | 34.43 | 13.44 | 7.11 | 19.25 | 5.40 | 11.97 tok/s | | after a 65,095-token prompt, 128 tokens | 88.15 ms | 34.84 | 13.62 | 8.24 | 25.43 | 6.00 | 10.94 tok/s | - In the first run the CPU lane took 1,851 of 61,200 picks (3.0%), and a CPU-lane call cost 4.9 ms (gate+up 2.70 ms, down 2.13 ms, 1.17 experts a call). So 3% of the picks are 31% of the token. - `--dspark auto --dspark-conf 0.65` without the profiler: 12.24 tok/s (the drafter's experts move about 1,000 more experts to the CPU lane). - Prompts: 1,308 tokens at 159 tok/s, 65,095 tokens at 658 tok/s. `DS4_FAST_ATTN=1` changed nothing on this CUDA device (657 tok/s). The prompt table of the long prompt (with #5127, which makes `DS4_PROF` work on chunked prompts): experts incl. waits 43%, sparse attention 19%, q_b + rope 13%, ffn mHC + router + sort 10%. What I would like to agree on before writing code: 1. **The CPU lane on an integrated NVIDIA GPU.** The PCIe lane already streams CPU-lane experts to the GPU on a discrete card, but only for MXFP4 layers (`lane_layer_ok`) and only with `DS4_STREAM=1`; for the ISTA-DAS sets every non-resident pick is computed by the CPU. On a GB10 the GPU could compute those picks where the files' pages already are (zero-copy, or a copy inside the same memory), so a decoded token would not wait for the CPU at all. The oracle bounds the gain at about +55% for this set. Would a change like this be welcome, opt-in first (the default path unchanged) and measured with paired runs and output hashes? Is it already planned? 2. **Attention.** 35 ms a token at 1.3K and at 65K context alike: the largest part once the CPU lane's wait is gone. I have not profiled it per kernel yet. Related: #4637 (`DS4_UMA_HEADROOM_GIB` on a Spark), #5061 (Strix Halo: with every expert on the GPU, 45 tok/s). ### What do you do today instead? For now I run `--experts 5` with the drafter, the fastest setting I found here: 13.5 tok/s in `serve/server.py` (a 924-token answer), against 11.0 with 6 experts. I found nothing faster that keeps the quality.
Author
Owner

@R-Okauchi commented on GitHub (Nov 5, 2026):

A correction to my report above, with measurements.

I wrote that the PCIe lane serves only MXFP4 layers. That was wrong: every GGUF expert layer has lay.fmt == kFmtMXFP4
(the low-bit ones keep their types in lay.K), so lane_layer_ok passes the ISTA-DAS sets' IQ layers too, and the lane
already has an in-place mode for an integrated GPU (DS4_STREAM_DIRECT).

So I measured it on the same Spark: 0.1.57 (v0.2.11's release package), the IQ2_XS pack, standalone with the same
1,308-token prompt, --n 256 --experts 6 --dspark none, DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none, one run each:

Run decode CPU lane / streamed to the GPU
CPU lane alone 10.00 tok/s 1,952 / 0
DS4_STREAM=2 (the lane's slots kept, nothing streamed) 10.52 tok/s 2,156 / 0
DS4_STREAM=1 9.62 tok/s 2,125 / 157
DS4_STREAM=1 DS4_STREAM_DIRECT=1 10.44 tok/s 1,964 / 140
DS4_STREAM=1 DS4_STREAM_DIRECT=0 9.87 tok/s 2,057 / 161
DS4_STREAM=1 DS4_STREAM_THREADS=4 9.74 tok/s 2,009 / 125
--dspark auto --dspark-conf 0.65 10.56 tok/s 4,888 / 0
the same with DS4_STREAM=1 10.97 tok/s 5,210 / 10

(of 61,200 picks, 70-73K with the drafter; from the engine's decode: line)

Within the spread between runs, the lane changes nothing here. The engine's own timings say why. At load the lane plans
with an expert at 0.15-0.20 ms on the CPU lane, 0.3-0.7 ms streamed and 2.1-2.6 ms from the disk, so it streams at most
one of a layer's six picks, and only when four or more of them are in RAM; in decode it times the CPU lane again at
2.1-3.0 ms an expert, the disk's time. The start-up lines show where that comes from:

ds4: the CPU lane's experts (49.1 GB) do not all fit the RAM this process can get now (1.1 GB beside 9 GB for the rest): read in place from the model's files (--mmap-experts off copies what fits)
ds4: CUDA0 layers [0, 39] + head: weights 5.86 GB, experts 100.78 GB (10347 of 15360 in VRAM), caches 0.24 GB, 792 MiB free

The GPU's experts take the unified memory the CPU lane's experts would be cached in (1-5 GB of RAM left for ~50 GB of
them in these runs), so most CPU-lane picks are read from the SSD, and that read is the wait (DS4_PROF with the lane
on: waiting for the CPU lane 39.6 of 103.9 ms a token). Computing those picks on the GPU would still have to read them,
so my first question does not stand as I asked it: streaming the CPU lane's picks to the GPU cannot shorten a wait that
is the SSD's.

DS4_STREAM=1 DS4_LANE_CHECK=1 put each of the pack's ten expert formats through both lanes at load: max |diff|
0.198-0.276, 2.8-3.3% of the largest output, none bit-identical (the lanes round the activations differently).

What does help here is one tier instead of two. With --vram-experts 0 the RAM store (ds4_store.hpp) gets the memory
the GPU's expert tier had (72.7 GB here, where the CPU lane had 1-5 GB), and 92% of the picks are then found in RAM. The
CPU lane computing all of them is already a little faster than the default. DS4_STORE_ZC=1 has the GPU compute the
store's experts, but it copies each one into a staging slot first, which on a Spark is a second pass over the same RAM.
Pointing the plan at the slot itself on an integrated GPU (a small change: a zc_point beside zc_stage, chosen by
cudaDevAttrIntegrated; I can open it as a draft) is faster, and more so with a bigger store. Same prompt and settings
as above, one run each, 256 tokens:

Run decode store misses a token
main, default placement 10.32 tok/s -
main, --vram-experts 0 (the CPU lane on the RAM store) 11.01 tok/s 18.6
main, + DS4_STORE_ZC=1 DS4_STORE_ZC_FRAC=100 (the staging copy) 10.66 tok/s 17.1
the branch, the slots read in place 12.31 tok/s 18.1
the branch, the same with --max-context 65536 (a 94.5 GB store) 13.39 tok/s 11.7

Each run's answer reads correctly (its first 64 tokens, decoded). With the drafter it does not help yet (9.27 tok/s):
the verify windows do not take the store's experts on the GPU. The startup warning that ZC on a GPU sharing the RAM will
likely fault did not come true here (94.5 GB registered, no fault).

Would an opt-in setting for an integrated GPU along these lines be welcome: no expert tier in the GPU's own allocations,
the store sized to the memory and read by the GPU in place for decoded tokens and verify windows, and the CPU lane for
the misses? I would measure it with paired runs before asking to change any default.

<!-- gh-comment-id:6672487023 --> @R-Okauchi commented on GitHub (Nov 5, 2026): A correction to my report above, with measurements. I wrote that the PCIe lane serves only MXFP4 layers. That was wrong: every GGUF expert layer has `lay.fmt == kFmtMXFP4` (the low-bit ones keep their types in `lay.K`), so `lane_layer_ok` passes the ISTA-DAS sets' IQ layers too, and the lane already has an in-place mode for an integrated GPU (`DS4_STREAM_DIRECT`). So I measured it on the same Spark: 0.1.57 (v0.2.11's release package), the IQ2_XS pack, standalone with the same 1,308-token prompt, `--n 256 --experts 6 --dspark none`, `DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none`, one run each: | Run | decode | CPU lane / streamed to the GPU | | --- | ---: | ---: | | CPU lane alone | 10.00 tok/s | 1,952 / 0 | | `DS4_STREAM=2` (the lane's slots kept, nothing streamed) | 10.52 tok/s | 2,156 / 0 | | `DS4_STREAM=1` | 9.62 tok/s | 2,125 / 157 | | `DS4_STREAM=1 DS4_STREAM_DIRECT=1` | 10.44 tok/s | 1,964 / 140 | | `DS4_STREAM=1 DS4_STREAM_DIRECT=0` | 9.87 tok/s | 2,057 / 161 | | `DS4_STREAM=1 DS4_STREAM_THREADS=4` | 9.74 tok/s | 2,009 / 125 | | `--dspark auto --dspark-conf 0.65` | 10.56 tok/s | 4,888 / 0 | | the same with `DS4_STREAM=1` | 10.97 tok/s | 5,210 / 10 | (of 61,200 picks, 70-73K with the drafter; from the engine's `decode:` line) Within the spread between runs, the lane changes nothing here. The engine's own timings say why. At load the lane plans with an expert at 0.15-0.20 ms on the CPU lane, 0.3-0.7 ms streamed and 2.1-2.6 ms from the disk, so it streams at most one of a layer's six picks, and only when four or more of them are in RAM; in decode it times the CPU lane again at 2.1-3.0 ms an expert, the disk's time. The start-up lines show where that comes from: ``` ds4: the CPU lane's experts (49.1 GB) do not all fit the RAM this process can get now (1.1 GB beside 9 GB for the rest): read in place from the model's files (--mmap-experts off copies what fits) ds4: CUDA0 layers [0, 39] + head: weights 5.86 GB, experts 100.78 GB (10347 of 15360 in VRAM), caches 0.24 GB, 792 MiB free ``` The GPU's experts take the unified memory the CPU lane's experts would be cached in (1-5 GB of RAM left for ~50 GB of them in these runs), so most CPU-lane picks are read from the SSD, and that read is the wait (`DS4_PROF` with the lane on: waiting for the CPU lane 39.6 of 103.9 ms a token). Computing those picks on the GPU would still have to read them, so my first question does not stand as I asked it: streaming the CPU lane's picks to the GPU cannot shorten a wait that is the SSD's. `DS4_STREAM=1 DS4_LANE_CHECK=1` put each of the pack's ten expert formats through both lanes at load: max |diff| 0.198-0.276, 2.8-3.3% of the largest output, none bit-identical (the lanes round the activations differently). What does help here is one tier instead of two. With `--vram-experts 0` the RAM store (`ds4_store.hpp`) gets the memory the GPU's expert tier had (72.7 GB here, where the CPU lane had 1-5 GB), and 92% of the picks are then found in RAM. The CPU lane computing all of them is already a little faster than the default. `DS4_STORE_ZC=1` has the GPU compute the store's experts, but it copies each one into a staging slot first, which on a Spark is a second pass over the same RAM. Pointing the plan at the slot itself on an integrated GPU (a small change: a `zc_point` beside `zc_stage`, chosen by `cudaDevAttrIntegrated`; I can open it as a draft) is faster, and more so with a bigger store. Same prompt and settings as above, one run each, 256 tokens: | Run | decode | store misses a token | | --- | ---: | ---: | | main, default placement | 10.32 tok/s | - | | main, `--vram-experts 0` (the CPU lane on the RAM store) | 11.01 tok/s | 18.6 | | main, + `DS4_STORE_ZC=1 DS4_STORE_ZC_FRAC=100` (the staging copy) | 10.66 tok/s | 17.1 | | the branch, the slots read in place | 12.31 tok/s | 18.1 | | the branch, the same with `--max-context 65536` (a 94.5 GB store) | 13.39 tok/s | 11.7 | Each run's answer reads correctly (its first 64 tokens, decoded). With the drafter it does not help yet (9.27 tok/s): the verify windows do not take the store's experts on the GPU. The startup warning that ZC on a GPU sharing the RAM will likely fault did not come true here (94.5 GB registered, no fault). Would an opt-in setting for an integrated GPU along these lines be welcome: no expert tier in the GPU's own allocations, the store sized to the memory and read by the GPU in place for decoded tokens and verify windows, and the CPU lane for the misses? I would measure it with paired runs before asking to change any default.
Author
Owner

@R-Okauchi commented on GitHub (Nov 7, 2026):

I've opened #5453 as a draft: the opt-in setting I asked about above (DS4_UMA_TIER=1), with what it needed to pay
off: the RAM store in slot classes, the prompt path reading the store in place, and the store's regrowth moved out of
the read path.

The same Spark, prompt and command as above, main (9f7d977d) and the PR built from source the same way, runs
interleaved, 256 tokens:

Run decode prompt (1,308 tokens)
main, --dspark none (3 runs) 11.72-12.03 tok/s 155-164 tok/s
the PR, DS4_UMA_TIER=1 (3 runs) 14.12-14.19 tok/s 187-191 tok/s
main, --dspark auto --dspark-conf 0.65 (2 runs) 13.50-15.27 tok/s
the PR, DS4_UMA_TIER=1, the same (2 runs) 22.22-23.33 tok/s

Without the variable nothing changes. The PR lists what I checked and what I could not. Would you take this as an
opt-in setting for an integrated GPU? I'll keep the PR a draft until we agree on the scope here.

<!-- gh-comment-id:6702213418 --> @R-Okauchi commented on GitHub (Nov 7, 2026): I've opened #5453 as a draft: the opt-in setting I asked about above (`DS4_UMA_TIER=1`), with what it needed to pay off: the RAM store in slot classes, the prompt path reading the store in place, and the store's regrowth moved out of the read path. The same Spark, prompt and command as above, main (9f7d977d) and the PR built from source the same way, runs interleaved, 256 tokens: | Run | decode | prompt (1,308 tokens) | | --- | ---: | ---: | | main, `--dspark none` (3 runs) | 11.72-12.03 tok/s | 155-164 tok/s | | the PR, `DS4_UMA_TIER=1` (3 runs) | 14.12-14.19 tok/s | 187-191 tok/s | | main, `--dspark auto --dspark-conf 0.65` (2 runs) | 13.50-15.27 tok/s | | | the PR, `DS4_UMA_TIER=1`, the same (2 runs) | 22.22-23.33 tok/s | | Without the variable nothing changes. The PR lists what I checked and what I could not. Would you take this as an opt-in setting for an integrated GPU? I'll keep the PR a draft until we agree on the scope here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3076
No description provided.