mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5453] [Engine] DeepSeek on a DGX Spark: DS4_UMA_TIER=1, one expert tier the GPU reads in place (opt-in) #5434
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5434
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
5ed6371DeepSeek engine: on a GPU that shares the PC's memory, read the store's slots in placecab3efbDeepSeek engine: DS4_UMA_TIER, one expert tier on a GPU that shares the PC's memory61d016fDeepSeek engine: under DS4_UMA_TIER, the store's context room from measurements, and chunks it can give back87c6762DeepSeek engine: the RAM store's slots in classes, one a blob size4800c84DeepSeek engine: the prompt path reads the RAM store's experts where they lied68d5e9DeepSeek engine: a long prompt's layer-major buffers take RAM back from the store first12b6129DeepSeek engine: a store the GPU maps grows back only at store_watch, never on the read path4b63d7eDeepSeek 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 at22.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
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.
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.take (
SetArgs::wptr; null keeps today's addressing). Before, each one was copied into pinned staging and DMA'dinto 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=0copies as before.DS4_UMA_CTX_GB(13) for a long prompt's layer-major host buffers. Underthe tier such a prompt first takes chunks back from the store (
store_give_back: the slots come off the GPU'stables, the device's work finishes, then the chunks go), so a smaller setting costs a long prompt nothing.
store_watch, never on the read path. Registering a chunk on the CPU lane's thread while adecode 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=1orDS4_STORE_CLASSES=1, all opt-in, and thedefault 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 falsein 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 fromsource the same way, with
spark/build_engine.sh's flags (sm_121 plus PTX). The release engine (0.1.57, v0.2.11's DGXSpark package) is there for reference. The command is #5170's, after the same 1,308-token chat prompt, greedy:
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=1orDS4_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:
DS4_UMA_TIER=1DS4_UMA_TIER=1DS4_UMA_TIER=1DS4_UMA_TIER=1 DS4_FLOW_IN_PLACE=0--dspark auto --dspark-conf 0.65DS4_UMA_TIER=1--dspark auto --dspark-conf 0.65DS4_UMA_TIER=1DS4_UMA_TIER=1 DS4_UMA_CTX_GB=3Prompt 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'slayer-major buffers the store (up to 9,998 slots, 96.9 GB) gave back 8 chunks, down to 9,522 slots, and
store_watchtook 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'sds4_iq_test --dump,then this branch's
ds4_iq_test --cmpagainst it:bit-compare vs golden: 84 buffers, 0 differ -> IDENTICAL, ALLOK.
ds4_tq_testandds4_gguf_test: ALL OK for both. This is how I checked the default path: with no addresstable (
SetArgs::wptrnull) 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:
121-real;121-virtual) withspark/build_engine.sh's flags, on the Spark:strata-dsv41builds.tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_testbuilds both.metal/with metal-cpp, targetstrata_ds4, builds.Failed: none observed.
Not run:
--vram-experts 0). With no classsettings the store keeps one class as before, but I have not run it.
DS4_STORE_ZC=1, where this branch moves the store's regrowth tostore_watch.DS4_FLOW_IN_PLACE=0.tests/dsv41/store_test.cpp. CMake does not build it, and main's does not compile either (ram_avail).serve/server.py) with the tier.Limits
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 itsstart.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.