[PR #5453] [Engine] DeepSeek on a DGX Spark: DS4_UMA_TIER=1, one expert tier the GPU reads in place (opt-in) #5434

Open
opened 2026-11-07 16:35:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5453
Author: @R-Okauchi
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: dsv41-uma-tier


📝 Commits (8)

  • 5ed6371 DeepSeek engine: on a GPU that shares the PC's memory, read the store's slots in place
  • cab3efb DeepSeek engine: DS4_UMA_TIER, one expert tier on a GPU that shares the PC's memory
  • 61d016f DeepSeek engine: under DS4_UMA_TIER, the store's context room from measurements, and chunks it can give back
  • 87c6762 DeepSeek engine: the RAM store's slots in classes, one a blob size
  • 4800c84 DeepSeek engine: the prompt path reads the RAM store's experts where they lie
  • d68d5e9 DeepSeek engine: a long prompt's layer-major buffers take RAM back from the store first
  • 12b6129 DeepSeek engine: a store the GPU maps grows back only at store_watch, never on the read path
  • 4b63d7e DeepSeek engine: DS4_UMA_TIER in CUDA builds only

📊 Changes

9 files changed (+514 additions, -136 deletions)

View changed files

📝 include/strata/dsv41/exl3.hpp (+3 -0)
📝 src/dsv41/ds4_gguf.cu (+7 -3)
📝 src/dsv41/ds4_iq.cu (+4 -4)
📝 src/dsv41/ds4_iq.cuh (+1 -0)
📝 src/dsv41/ds4_kernels.cu (+11 -0)
📝 src/dsv41/ds4_kernels.cuh (+4 -0)
📝 src/dsv41/ds4_model.cu (+211 -39)
📝 src/dsv41/ds4_store.hpp (+272 -89)
📝 src/dsv41/ds4_tq.cu (+1 -1)

📄 Description

Problem and result

On a DGX Spark (GB10), DeepSeek V4.1's IQ2_XS set does not fit in the GPU's memory budget. The engine keeps about
10,100 of the 15,360 experts on the GPU and computes the other ~5,300 on the CPU lane, read in place from the model
files. In #5170 a decoded token waited 29 ms of its 93 ms for that lane. On a GB10 the CPU and the GPU share the same
RAM, so the GPU can compute the experts that a RAM store holds where they lie.

With DS4_UMA_TIER=1 (opt-in), #5170's command decodes at 14.12-14.19 tok/s instead of main's 11.72-12.03, and at
22.22-23.33 tok/s instead of 13.50-15.27 with the drafter. It reads the 1,308-token prompt at 187-191 tok/s instead of
155-164. Without the variable nothing changes.

#5170. There is no scope agreement yet. I'm opening this as a draft so the change can be read next to the proposal.

Approach

  • One expert tier. Under the tier the trunk's experts get no VRAM slots. The RAM store takes that memory, registered
    for the GPU, and the GPU reads its slots in place (zc_point, no staging copy) for decode tokens and verify windows.
    The CPU lane computes the misses. The drafter's experts keep their VRAM.
  • Slots in size classes. The GSQ sets' layers need slots of 9.2 to 11.4 MB, and with every slot at the largest size
    a 64.3 GB arena held 51.7 GB of experts. Each class holds one slot size and is sized from the profile's hottest
    experts. This is on under the tier or with DS4_STORE_CLASSES=1; otherwise the store is one class as before.
  • The prompt path reads store-held experts in place too, through a table of blob addresses that the GGUF set kernels
    take (SetArgs::wptr; null keeps today's addressing). Before, each one was copied into pinned staging and DMA'd
    into the ring: 47.7 GB of copies for a 97-token prompt. The batches are the same, and so are the bytes each kernel
    reads. DS4_FLOW_IN_PLACE=0 copies as before.
  • Room for the context. The store leaves DS4_UMA_CTX_GB (13) for a long prompt's layer-major host buffers. Under
    the tier such a prompt first takes chunks back from the store (store_give_back: the slots come off the GPU's
    tables, the device's work finishes, then the chunks go), so a smaller setting costs a long prompt nothing.
  • The store grows back at store_watch, never on the read path. Registering a chunk on the CPU lane's thread while a
    decode kernel waits on that lane hangs. This is the hazard the pregrow comment describes, and I hit it on the GB10
    after a 112K-token prompt. The same change covers DS4_STORE_ZC=1, the other mode in which the GPU maps the store.

Compatibility: everything is behind DS4_UMA_TIER=1, DS4_STORE_ZC=1 or DS4_STORE_CLASSES=1, all opt-in, and the
default path does not change. The tier is on in CUDA builds only. A Metal build counts its GPU as integrated, and so
does a HIP build on an APU such as a Strix Halo, but I have not run the tier on either, so uma_tier() stays false
in those builds. Both still build.

Validation

On one DGX Spark (GB10, 128 GB, driver 580.178.04, CUDA 13.0.2 in an Ubuntu 24.04 container, nothing else on the GPU),
with #5170's IQ2_XS pack (made by v0.2.11's tools/dsv41/pack_gguf.py). main (9f7d977d) and this branch were built from
source the same way, with spark/build_engine.sh's flags (sm_121 plus PTX). The release engine (0.1.57, v0.2.11's DGX
Spark package) is there for reference. The command is #5170's, after the same 1,308-token chat prompt, greedy:

DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> --n 256 \
  --max-context 262144 --eos 1 --vision on --experts 6 --dspark none

The Spark's runs are of an earlier state of this branch. Since then it changed in two places, and both make
something depend on the opt-in settings: the layer-major give-back runs only under the tier, and the prompt batches'
pointer tables are allocated only with DS4_UMA_TIER=1 or DS4_STORE_ZC=1. Under the tier both run as before.
Without it, the measured tree allocated the small tables and never used them, and the give-back never ran, because
the Spark's default placement has no RAM store.

Passed:

  • The runs, in the order they ran:

    # Engine Settings Prompt Decode CPU lane
    1 release 0.1.57 144.69 tok/s 11.17 tok/s 1,670 of 61,200
    2 main 154.95 12.03 1,616
    3 this branch DS4_UMA_TIER=1 186.53 14.17 2,241
    4 main 157.49 11.94 1,574
    5 this branch DS4_UMA_TIER=1 190.70 14.12 2,351
    6 main 163.91 11.72 1,712
    7 this branch DS4_UMA_TIER=1 187.66 14.19 2,242
    8 this branch none 160.06 12.23 1,662
    9 this branch DS4_UMA_TIER=1 DS4_FLOW_IN_PLACE=0 163.27 14.24 2,161
    10 main --dspark auto --dspark-conf 0.65 159.18 15.27 (2.42 a round) 3,164 of 70,260
    11 this branch the same, DS4_UMA_TIER=1 177.29 23.33 (2.49) 3,135 of 70,740
    12 main --dspark auto --dspark-conf 0.65 156.37 13.50 (2.46) 3,411 of 72,855
    13 this branch the same, DS4_UMA_TIER=1 181.07 22.22 (2.39) 3,382 of 75,000
    14 main a 65,000-token prompt 541.60 9.96 2,272 of 61,200
    15 this branch the same, DS4_UMA_TIER=1 DS4_UMA_CTX_GB=3 528.61 13.52 2,169 of 61,200

    Prompt is the prompt's tok/s, Decode the 256 tokens', CPU lane its picks of all. Under the tier the store was sized at
    86.8-87.1 GB (78.3-78.5 GB with the drafter, whose 384 experts took 7.2 GB of VRAM). main kept 10,081-10,084 experts
    in VRAM (9,648-9,650 with the drafter).

  • The 65,000-token prompt (a text corpus repeated, in the chat format) with DS4_UMA_CTX_GB=3: for the prompt's
    layer-major buffers the store (up to 9,998 slots, 96.9 GB) gave back 8 chunks, down to 9,522 slots, and store_watch
    took all 8 back while the 256 tokens decoded (one a check, 18.9 GB free at the first, 14.7 GB at the last), with no
    stall. The prompt read at 528.61 tok/s against main's 541.60, give-back included, and the tokens after it decoded at
    13.52 tok/s against 9.96.

  • Each run's first 64 tokens, decoded, describe the prompt's text (a repository's README) sensibly. No two runs gave
    the same tokens, main's three included. main's expert cache moves experts between the GPU and the CPU lane as it
    decodes (860-918 moves in its runs), the tier's store fills as it decodes, and the two lanes round differently
    (#5170), so where two runs part varies.

  • The kernels the change touches, on an RTX 4070 Ti (sm_89, driver 595.71.05, x86-64), with main's and this branch's
    tests built the same way (CUDA 13.0.2, -DSTRATA_BUILD_TESTS=ON, 89-real;120-real): main's ds4_iq_test --dump,
    then this branch's ds4_iq_test --cmp against it: bit-compare vs golden: 84 buffers, 0 differ -> IDENTICAL, ALL
    OK. ds4_tq_test and ds4_gguf_test: ALL OK for both. This is how I checked the default path: with no address
    table (SetArgs::wptr null) the set kernels give main's bits, and run 8 (no variable) falls within main's spread.
    The head's kernel files are the ones tested.

  • Builds of the head, on every backend the change touches:

    • CUDA 13.0.2 for sm_121 (121-real;121-virtual) with spark/build_engine.sh's flags, on the Spark:
      strata-dsv41 builds.
    • HIP, ROCm 7.2.4 for gfx1151 and gfx1201: tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_test builds both.
    • Metal, macOS 26.4 on an M3 Max: metal/ with metal-cpp, target strata_ds4, builds.

Failed: none observed.

Not run:

  • The default path with a RAM store in use (a discrete GPU with RAM to spare, or --vram-experts 0). With no class
    settings the store keeps one class as before, but I have not run it.
  • A discrete GPU with DS4_STORE_ZC=1, where this branch moves the store's regrowth to store_watch.
  • The tier under HIP or Metal. It is off in those builds, which I only built.
  • A bit-for-bit comparison of the prompt's logits with and without DS4_FLOW_IN_PLACE=0.
  • tests/dsv41/store_test.cpp. CMake does not build it, and main's does not compile either (ram_avail).
  • The server (serve/server.py) with the tier.

Limits

  • Measured on one GB10 (128 GB), with one set (IQ2_XS), with the CLI only.
  • The CPU lane still computes the store's misses: 2,161-2,351 of the 61,200 picks in the runs above. The drafter keeps
    its own VRAM experts.
  • DS4_UMA_CTX_GB's default (13) comes from this box: a 112K-token prompt's layer-major buffers took 11.4 GB at its
    start.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5453 **Author:** [@R-Okauchi](https://github.com/R-Okauchi) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `dsv41-uma-tier` --- ### 📝 Commits (8) - [`5ed6371`](https://github.com/Niko1221/Strata/commit/5ed6371fa97728999c82de138b565cfc97d2b4f8) DeepSeek engine: on a GPU that shares the PC's memory, read the store's slots in place - [`cab3efb`](https://github.com/Niko1221/Strata/commit/cab3efb6786c7668d896a82071cf92c0a04de98c) DeepSeek engine: DS4_UMA_TIER, one expert tier on a GPU that shares the PC's memory - [`61d016f`](https://github.com/Niko1221/Strata/commit/61d016f437a0273767c06c07000b707982058d11) DeepSeek engine: under DS4_UMA_TIER, the store's context room from measurements, and chunks it can give back - [`87c6762`](https://github.com/Niko1221/Strata/commit/87c67620f386a71e861be2b632c12793a327d4dc) DeepSeek engine: the RAM store's slots in classes, one a blob size - [`4800c84`](https://github.com/Niko1221/Strata/commit/4800c84c109a98ddbba08f219584603ecec9b764) DeepSeek engine: the prompt path reads the RAM store's experts where they lie - [`d68d5e9`](https://github.com/Niko1221/Strata/commit/d68d5e9f8cb3245c3a87a2707f51566b8da20987) DeepSeek engine: a long prompt's layer-major buffers take RAM back from the store first - [`12b6129`](https://github.com/Niko1221/Strata/commit/12b6129e654bea1524a95bb304d6b3d97b146b3c) DeepSeek engine: a store the GPU maps grows back only at store_watch, never on the read path - [`4b63d7e`](https://github.com/Niko1221/Strata/commit/4b63d7e5375bca604c2fbce42f5d346ac685f3cb) DeepSeek engine: DS4_UMA_TIER in CUDA builds only ### 📊 Changes **9 files changed** (+514 additions, -136 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/dsv41/exl3.hpp` (+3 -0) 📝 `src/dsv41/ds4_gguf.cu` (+7 -3) 📝 `src/dsv41/ds4_iq.cu` (+4 -4) 📝 `src/dsv41/ds4_iq.cuh` (+1 -0) 📝 `src/dsv41/ds4_kernels.cu` (+11 -0) 📝 `src/dsv41/ds4_kernels.cuh` (+4 -0) 📝 `src/dsv41/ds4_model.cu` (+211 -39) 📝 `src/dsv41/ds4_store.hpp` (+272 -89) 📝 `src/dsv41/ds4_tq.cu` (+1 -1) </details> ### 📄 Description ## Problem and result On a DGX Spark (GB10), DeepSeek V4.1's IQ2_XS set does not fit in the GPU's memory budget. The engine keeps about 10,100 of the 15,360 experts on the GPU and computes the other ~5,300 on the CPU lane, read in place from the model files. In #5170 a decoded token waited 29 ms of its 93 ms for that lane. On a GB10 the CPU and the GPU share the same RAM, so the GPU can compute the experts that a RAM store holds where they lie. With `DS4_UMA_TIER=1` (opt-in), #5170's command decodes at 14.12-14.19 tok/s instead of main's 11.72-12.03, and at 22.22-23.33 tok/s instead of 13.50-15.27 with the drafter. It reads the 1,308-token prompt at 187-191 tok/s instead of 155-164. Without the variable nothing changes. ## Related discussion #5170. There is no scope agreement yet. I'm opening this as a draft so the change can be read next to the proposal. ## Approach - One expert tier. Under the tier the trunk's experts get no VRAM slots. The RAM store takes that memory, registered for the GPU, and the GPU reads its slots in place (`zc_point`, no staging copy) for decode tokens and verify windows. The CPU lane computes the misses. The drafter's experts keep their VRAM. - Slots in size classes. The GSQ sets' layers need slots of 9.2 to 11.4 MB, and with every slot at the largest size a 64.3 GB arena held 51.7 GB of experts. Each class holds one slot size and is sized from the profile's hottest experts. This is on under the tier or with `DS4_STORE_CLASSES=1`; otherwise the store is one class as before. - The prompt path reads store-held experts in place too, through a table of blob addresses that the GGUF set kernels take (`SetArgs::wptr`; null keeps today's addressing). Before, each one was copied into pinned staging and DMA'd into the ring: 47.7 GB of copies for a 97-token prompt. The batches are the same, and so are the bytes each kernel reads. `DS4_FLOW_IN_PLACE=0` copies as before. - Room for the context. The store leaves `DS4_UMA_CTX_GB` (13) for a long prompt's layer-major host buffers. Under the tier such a prompt first takes chunks back from the store (`store_give_back`: the slots come off the GPU's tables, the device's work finishes, then the chunks go), so a smaller setting costs a long prompt nothing. - The store grows back at `store_watch`, never on the read path. Registering a chunk on the CPU lane's thread while a decode kernel waits on that lane hangs. This is the hazard the pregrow comment describes, and I hit it on the GB10 after a 112K-token prompt. The same change covers `DS4_STORE_ZC=1`, the other mode in which the GPU maps the store. Compatibility: everything is behind `DS4_UMA_TIER=1`, `DS4_STORE_ZC=1` or `DS4_STORE_CLASSES=1`, all opt-in, and the default path does not change. The tier is on in CUDA builds only. A Metal build counts its GPU as integrated, and so does a HIP build on an APU such as a Strix Halo, but I have not run the tier on either, so `uma_tier()` stays false in those builds. Both still build. ## Validation On one DGX Spark (GB10, 128 GB, driver 580.178.04, CUDA 13.0.2 in an Ubuntu 24.04 container, nothing else on the GPU), with #5170's IQ2_XS pack (made by v0.2.11's `tools/dsv41/pack_gguf.py`). main (9f7d977d) and this branch were built from source the same way, with `spark/build_engine.sh`'s flags (sm_121 plus PTX). The release engine (0.1.57, v0.2.11's DGX Spark package) is there for reference. The command is #5170's, after the same 1,308-token chat prompt, greedy: ``` DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> --n 256 \ --max-context 262144 --eos 1 --vision on --experts 6 --dspark none ``` The Spark's runs are of an earlier state of this branch. Since then it changed in two places, and both make something depend on the opt-in settings: the layer-major give-back runs only under the tier, and the prompt batches' pointer tables are allocated only with `DS4_UMA_TIER=1` or `DS4_STORE_ZC=1`. Under the tier both run as before. Without it, the measured tree allocated the small tables and never used them, and the give-back never ran, because the Spark's default placement has no RAM store. **Passed:** - The runs, in the order they ran: | # | Engine | Settings | Prompt | Decode | CPU lane | | --- | --- | --- | ---: | ---: | ---: | | 1 | release 0.1.57 | | 144.69 tok/s | 11.17 tok/s | 1,670 of 61,200 | | 2 | main | | 154.95 | 12.03 | 1,616 | | 3 | this branch | `DS4_UMA_TIER=1` | 186.53 | 14.17 | 2,241 | | 4 | main | | 157.49 | 11.94 | 1,574 | | 5 | this branch | `DS4_UMA_TIER=1` | 190.70 | 14.12 | 2,351 | | 6 | main | | 163.91 | 11.72 | 1,712 | | 7 | this branch | `DS4_UMA_TIER=1` | 187.66 | 14.19 | 2,242 | | 8 | this branch | none | 160.06 | 12.23 | 1,662 | | 9 | this branch | `DS4_UMA_TIER=1 DS4_FLOW_IN_PLACE=0` | 163.27 | 14.24 | 2,161 | | 10 | main | `--dspark auto --dspark-conf 0.65` | 159.18 | 15.27 (2.42 a round) | 3,164 of 70,260 | | 11 | this branch | the same, `DS4_UMA_TIER=1` | 177.29 | 23.33 (2.49) | 3,135 of 70,740 | | 12 | main | `--dspark auto --dspark-conf 0.65` | 156.37 | 13.50 (2.46) | 3,411 of 72,855 | | 13 | this branch | the same, `DS4_UMA_TIER=1` | 181.07 | 22.22 (2.39) | 3,382 of 75,000 | | 14 | main | a 65,000-token prompt | 541.60 | 9.96 | 2,272 of 61,200 | | 15 | this branch | the same, `DS4_UMA_TIER=1 DS4_UMA_CTX_GB=3` | 528.61 | 13.52 | 2,169 of 61,200 | Prompt is the prompt's tok/s, Decode the 256 tokens', CPU lane its picks of all. Under the tier the store was sized at 86.8-87.1 GB (78.3-78.5 GB with the drafter, whose 384 experts took 7.2 GB of VRAM). main kept 10,081-10,084 experts in VRAM (9,648-9,650 with the drafter). - The 65,000-token prompt (a text corpus repeated, in the chat format) with `DS4_UMA_CTX_GB=3`: for the prompt's layer-major buffers the store (up to 9,998 slots, 96.9 GB) gave back 8 chunks, down to 9,522 slots, and `store_watch` took all 8 back while the 256 tokens decoded (one a check, 18.9 GB free at the first, 14.7 GB at the last), with no stall. The prompt read at 528.61 tok/s against main's 541.60, give-back included, and the tokens after it decoded at 13.52 tok/s against 9.96. - Each run's first 64 tokens, decoded, describe the prompt's text (a repository's README) sensibly. No two runs gave the same tokens, main's three included. main's expert cache moves experts between the GPU and the CPU lane as it decodes (860-918 moves in its runs), the tier's store fills as it decodes, and the two lanes round differently (#5170), so where two runs part varies. - The kernels the change touches, on an RTX 4070 Ti (sm_89, driver 595.71.05, x86-64), with main's and this branch's tests built the same way (CUDA 13.0.2, `-DSTRATA_BUILD_TESTS=ON`, `89-real;120-real`): main's `ds4_iq_test --dump`, then this branch's `ds4_iq_test --cmp` against it: `bit-compare vs golden: 84 buffers, 0 differ -> IDENTICAL`, ALL OK. `ds4_tq_test` and `ds4_gguf_test`: ALL OK for both. This is how I checked the default path: with no address table (`SetArgs::wptr` null) the set kernels give main's bits, and run 8 (no variable) falls within main's spread. The head's kernel files are the ones tested. - Builds of the head, on every backend the change touches: - CUDA 13.0.2 for sm_121 (`121-real;121-virtual`) with `spark/build_engine.sh`'s flags, on the Spark: `strata-dsv41` builds. - HIP, ROCm 7.2.4 for gfx1151 and gfx1201: `tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_test` builds both. - Metal, macOS 26.4 on an M3 Max: `metal/` with metal-cpp, target `strata_ds4`, builds. **Failed:** none observed. **Not run:** - The default path with a RAM store in use (a discrete GPU with RAM to spare, or `--vram-experts 0`). With no class settings the store keeps one class as before, but I have not run it. - A discrete GPU with `DS4_STORE_ZC=1`, where this branch moves the store's regrowth to `store_watch`. - The tier under HIP or Metal. It is off in those builds, which I only built. - A bit-for-bit comparison of the prompt's logits with and without `DS4_FLOW_IN_PLACE=0`. - `tests/dsv41/store_test.cpp`. CMake does not build it, and main's does not compile either (`ram_avail`). - The server (`serve/server.py`) with the tier. ## Limits - Measured on one GB10 (128 GB), with one set (IQ2_XS), with the CLI only. - The CPU lane still computes the store's misses: 2,161-2,351 of the 61,200 picks in the runs above. The drafter keeps its own VRAM experts. - `DS4_UMA_CTX_GB`'s default (13) comes from this box: a 112K-token prompt's layer-major buffers took 11.4 GB at its start. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5434
No description provided.