[PR #5472] [Engine] DeepSeek on a DGX Spark: STRATA_DS4_DISK_SKIP_RANK / PROMPT_SKIP_RANK, a store miss left out by its pick rank (opt-in, changes the answers) #5442

Open
opened 2026-11-07 17:34:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: dsv41-skip-rank


📝 Commits (10+)

  • 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
  • a8759ad DeepSeek engine: STRATA_DS4_DISK_SKIP_RANK, the SSD skip by rank (opt-in)
  • d6eb1a7 DeepSeek engine: STRATA_DS4_DISK_SKIP_RANK reads the experts it leaves out in behind

📊 Changes

9 files changed (+650 additions, -142 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 (+34 -0)
📝 src/dsv41/ds4_kernels.cuh (+11 -0)
📝 src/dsv41/ds4_model.cu (+317 -45)
📝 src/dsv41/ds4_store.hpp (+272 -89)
📝 src/dsv41/ds4_tq.cu (+1 -1)

📄 Description

Problem and result

With #5453's tier on a DGX Spark, a decoded token still waits for the experts that are in neither the RAM store nor
the page cache. The CPU lane reads them from the SSD and computes them: in the runs below that was 8.1-8.5 misses a
token, and 9.9-10.5 ms a token spent waiting. main's STRATA_DS4_DISK_SKIP_W can leave such experts out by route
weight.

This PR adds a narrower rule, by the router's pick order. It is opt-in, experimental, and changes the answers:

  • STRATA_DS4_DISK_SKIP_RANK=R (decode): an expert in neither the page cache nor the store is left out when no token of
    the window picked it among its first R picks. Its route weight is lost, as with DISK_SKIP_W. Its read is queued
    behind the demand reads, so the store learns what the answer uses. STRATA_DS4_SKIP_PREFETCH_RANK=N queues only those
    that some token picked among its first N.
  • STRATA_DS4_PROMPT_SKIP_RANK=R (prompt): the same rule on the chunked prompt path.

With R = 2 for both on top of #5453's tier, #5170's command was faster:

  • decode: 15.87 and 16.00 tok/s instead of 14.24 and 14.25, and 26.03 instead of 22.96 with the drafter;
  • the 1,308-token prompt: 287-288 tok/s instead of 185-234;
  • experts left out: 3.0-3.1% of the routed ones (4.3% with the drafter).

On a server, 480 MMLU questions gave 386 right with the rule against 390 without, which is not a measurable difference
(paired p = 0.45).

#5170. There is no scope agreement yet, so this is a draft.

This PR is stacked on #5453 (also a draft). Its first eight commits are #5453's, and this PR's own are the last four.
The prompt rule needs #5453's in-place prompt flow.

Approach

  • The decode rule (STRATA_DS4_DISK_SKIP_RANK=R): for each expert the window's routing picked that is in neither the
    page cache nor the store, its best rank over the window's tokens decides. If that rank is worse than R, the expert is
    left out. Otherwise it is read as before.
  • Read-behind: a skipped expert's read is queued as a guess behind the demand reads. Left unread, a skipped expert
    never reached the store and stayed a miss. Over an agent benchmark on a GB10 server, the CPU lane's share of the
    experts then grew from 5% to 20%.
  • STRATA_DS4_SKIP_PREFETCH_RANK=N (default: all, as before; 0: none). With R = 2 on a GB10 over 256 decoded tokens,
    3,107 experts were read behind. 795 of them were used before their slots were taken again, and 1,972 were given up.
    Together they were about 100 of the 117 MB a token the SSD read.
  • The prompt rule (STRATA_DS4_PROMPT_SKIP_RANK=R) works on a chunk:
    • It covers the experts that the chunk's routing picked and that the layer's likely experts did not already queue.
      One that is in neither the RAM store nor the page cache, and that no token of the chunk picked among its first R,
      is not read.
    • Its rows run on a ring slot's bytes of zeros. Zero blocks decode to zeros in every expert type, so its outputs
      are 0. Its route weights go to 0 before the layer's batches combine.
    • The batches, the bounds and the order of the sums do not change.
    • best_rank finds each expert's best pick on the device, with the bounds, and zero_picks clears the weights on
      the stream the batches run on. The prompt's stream line counts the experts left out.

Compatibility: all three variables are unset by default, and then nothing changes.

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. #5453's head (4b63d7e5) and this branch were built from source the same way, with
spark/build_engine.sh's flags (sm_121 plus PTX). The command is #5170's, after the same 1,308-token chat prompt,
greedy:

DS4_UMA_TIER=1 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

Passed:

  • The runs, in the order they ran. "The rule" is STRATA_DS4_DISK_SKIP_RANK=2 STRATA_DS4_PROMPT_SKIP_RANK=2, and the
    drafter's runs add --dspark auto --dspark-conf 0.65:

    # Engine Settings Prompt Decode CPU lane Left out Waited for the SSD
    1 #5453 185.47 tok/s 14.24 tok/s 2,198 of 61,200 9.9 ms a token
    2 this branch the rule 287.23 15.87 1,104 7.3 a token (3.0%) 3.2
    3 #5453 234.09 14.25 2,318 10.5
    4 this branch the rule 288.11 16.00 1,099 7.4 (3.1%) 2.8
    5 #5453 drafter 214.87 22.96 (2.46 a round) 3,354 of 70,830 10.2
    6 this branch the rule, drafter 288.09 26.03 (2.42) 1,520 of 69,585 10.8 (4.3%) 3.8

    "Left out" counts the decode rule's experts a token. The last column is the CPU lane's wait for the store's misses.

  • The answers, on the same Spark, from Strata's server with a branch that carries #5453's tier, this PR's rules and
    other changes:

    • Setup: another IQ2_XS set (GSQ), with DS4_UMA_TIER=1 STRATA_DS4_DSPARK_CUM=0.3 DS4_UMA_CTX_GB=3 STRATA_DS4_SKIP_PREFETCH_RANK=2 and --dspark-depth 3. The two sides differed only in
      STRATA_DS4_DISK_SKIP_RANK=2 STRATA_DS4_PROMPT_SKIP_RANK=2.
    • Questions: 480 MMLU questions (200 of them moral_scenarios), thinking off, greedy. The answers were right on 390
      without the rule and 386 with it. 10 were right only without it and 6 only with it (exact McNemar p = 0.45). On
      moral_scenarios the split was 154 against 150 (8 : 4, p = 0.39), and on the other subjects 236 against 236
      (2 : 2).
    • An agent-like conversation: an ~8K-token system prompt, then turns that each add ~250 tokens and allow up to 1,024
      in answer, greedy. Over the seven turns after the first, the first token came at a median of 2.71 s without the
      rule and 2.21 s with it. The decode ran at 27.8 and 31.8 tok/s.
  • Builds of the head:

    • CUDA 13.0.2 for sm_121 with spark/build_engine.sh's flags, on the Spark: strata-dsv41 builds. It is the binary
      above.
    • 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 rule without #5453's tier: the default placement, a discrete GPU, or --mmap-experts off.
  • Quality on more than the 480 questions above, and on long contexts.
  • Other values of R.
  • HIP and Metal at runtime. The prompt rule acts only in CUDA's in-place flow.

Limits

  • The rule changes the answers. On these 480 questions the difference was within chance, but four fewer were right.
  • What it saves depends on how much of a token misses both RAM and the store. That depends on the box's RAM and on
    the set: measured on one GB10 with two IQ2_XS sets.

🔄 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/5472 **Author:** [@R-Okauchi](https://github.com/R-Okauchi) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `dsv41-skip-rank` --- ### 📝 Commits (10+) - [`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 - [`a8759ad`](https://github.com/Niko1221/Strata/commit/a8759ada482ac51bd8ab9f5055b7bd4e756ea0a9) DeepSeek engine: STRATA_DS4_DISK_SKIP_RANK, the SSD skip by rank (opt-in) - [`d6eb1a7`](https://github.com/Niko1221/Strata/commit/d6eb1a77e2579640c0a79a910469b586995499d0) DeepSeek engine: STRATA_DS4_DISK_SKIP_RANK reads the experts it leaves out in behind ### 📊 Changes **9 files changed** (+650 additions, -142 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` (+34 -0) 📝 `src/dsv41/ds4_kernels.cuh` (+11 -0) 📝 `src/dsv41/ds4_model.cu` (+317 -45) 📝 `src/dsv41/ds4_store.hpp` (+272 -89) 📝 `src/dsv41/ds4_tq.cu` (+1 -1) </details> ### 📄 Description ## Problem and result With #5453's tier on a DGX Spark, a decoded token still waits for the experts that are in neither the RAM store nor the page cache. The CPU lane reads them from the SSD and computes them: in the runs below that was 8.1-8.5 misses a token, and 9.9-10.5 ms a token spent waiting. main's `STRATA_DS4_DISK_SKIP_W` can leave such experts out by route weight. This PR adds a narrower rule, by the router's pick order. It is opt-in, experimental, and changes the answers: - `STRATA_DS4_DISK_SKIP_RANK=R` (decode): an expert in neither the page cache nor the store is left out when no token of the window picked it among its first R picks. Its route weight is lost, as with `DISK_SKIP_W`. Its read is queued behind the demand reads, so the store learns what the answer uses. `STRATA_DS4_SKIP_PREFETCH_RANK=N` queues only those that some token picked among its first N. - `STRATA_DS4_PROMPT_SKIP_RANK=R` (prompt): the same rule on the chunked prompt path. With R = 2 for both on top of #5453's tier, #5170's command was faster: - decode: 15.87 and 16.00 tok/s instead of 14.24 and 14.25, and 26.03 instead of 22.96 with the drafter; - the 1,308-token prompt: 287-288 tok/s instead of 185-234; - experts left out: 3.0-3.1% of the routed ones (4.3% with the drafter). On a server, 480 MMLU questions gave 386 right with the rule against 390 without, which is not a measurable difference (paired p = 0.45). ## Related discussion #5170. There is no scope agreement yet, so this is a draft. This PR is stacked on #5453 (also a draft). Its first eight commits are #5453's, and this PR's own are the last four. The prompt rule needs #5453's in-place prompt flow. ## Approach - The decode rule (`STRATA_DS4_DISK_SKIP_RANK=R`): for each expert the window's routing picked that is in neither the page cache nor the store, its best rank over the window's tokens decides. If that rank is worse than R, the expert is left out. Otherwise it is read as before. - Read-behind: a skipped expert's read is queued as a guess behind the demand reads. Left unread, a skipped expert never reached the store and stayed a miss. Over an agent benchmark on a GB10 server, the CPU lane's share of the experts then grew from 5% to 20%. - `STRATA_DS4_SKIP_PREFETCH_RANK=N` (default: all, as before; 0: none). With R = 2 on a GB10 over 256 decoded tokens, 3,107 experts were read behind. 795 of them were used before their slots were taken again, and 1,972 were given up. Together they were about 100 of the 117 MB a token the SSD read. - The prompt rule (`STRATA_DS4_PROMPT_SKIP_RANK=R`) works on a chunk: - It covers the experts that the chunk's routing picked and that the layer's likely experts did not already queue. One that is in neither the RAM store nor the page cache, and that no token of the chunk picked among its first R, is not read. - Its rows run on a ring slot's bytes of zeros. Zero blocks decode to zeros in every expert type, so its outputs are 0. Its route weights go to 0 before the layer's batches combine. - The batches, the bounds and the order of the sums do not change. - `best_rank` finds each expert's best pick on the device, with the bounds, and `zero_picks` clears the weights on the stream the batches run on. The prompt's stream line counts the experts left out. Compatibility: all three variables are unset by default, and then nothing changes. ## 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. #5453's head (4b63d7e5) and this branch were built from source the same way, with `spark/build_engine.sh`'s flags (sm_121 plus PTX). The command is #5170's, after the same 1,308-token chat prompt, greedy: ``` DS4_UMA_TIER=1 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 ``` **Passed:** - The runs, in the order they ran. "The rule" is `STRATA_DS4_DISK_SKIP_RANK=2 STRATA_DS4_PROMPT_SKIP_RANK=2`, and the drafter's runs add `--dspark auto --dspark-conf 0.65`: | # | Engine | Settings | Prompt | Decode | CPU lane | Left out | Waited for the SSD | | --- | --- | --- | ---: | ---: | ---: | ---: | ---: | | 1 | #5453 | | 185.47 tok/s | 14.24 tok/s | 2,198 of 61,200 | | 9.9 ms a token | | 2 | this branch | the rule | 287.23 | 15.87 | 1,104 | 7.3 a token (3.0%) | 3.2 | | 3 | #5453 | | 234.09 | 14.25 | 2,318 | | 10.5 | | 4 | this branch | the rule | 288.11 | 16.00 | 1,099 | 7.4 (3.1%) | 2.8 | | 5 | #5453 | drafter | 214.87 | 22.96 (2.46 a round) | 3,354 of 70,830 | | 10.2 | | 6 | this branch | the rule, drafter | 288.09 | 26.03 (2.42) | 1,520 of 69,585 | 10.8 (4.3%) | 3.8 | "Left out" counts the decode rule's experts a token. The last column is the CPU lane's wait for the store's misses. - The answers, on the same Spark, from Strata's server with a branch that carries #5453's tier, this PR's rules and other changes: - Setup: another IQ2_XS set (GSQ), with `DS4_UMA_TIER=1 STRATA_DS4_DSPARK_CUM=0.3 DS4_UMA_CTX_GB=3 STRATA_DS4_SKIP_PREFETCH_RANK=2` and `--dspark-depth 3`. The two sides differed only in `STRATA_DS4_DISK_SKIP_RANK=2 STRATA_DS4_PROMPT_SKIP_RANK=2`. - Questions: 480 MMLU questions (200 of them moral_scenarios), thinking off, greedy. The answers were right on 390 without the rule and 386 with it. 10 were right only without it and 6 only with it (exact McNemar p = 0.45). On moral_scenarios the split was 154 against 150 (8 : 4, p = 0.39), and on the other subjects 236 against 236 (2 : 2). - An agent-like conversation: an ~8K-token system prompt, then turns that each add ~250 tokens and allow up to 1,024 in answer, greedy. Over the seven turns after the first, the first token came at a median of 2.71 s without the rule and 2.21 s with it. The decode ran at 27.8 and 31.8 tok/s. - Builds of the head: - CUDA 13.0.2 for sm_121 with `spark/build_engine.sh`'s flags, on the Spark: `strata-dsv41` builds. It is the binary above. - 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 rule without #5453's tier: the default placement, a discrete GPU, or `--mmap-experts off`. - Quality on more than the 480 questions above, and on long contexts. - Other values of R. - HIP and Metal at runtime. The prompt rule acts only in CUDA's in-place flow. ## Limits - The rule changes the answers. On these 480 questions the difference was within chance, but four fewer were right. - What it saves depends on how much of a token misses both RAM and the store. That depends on the box's RAM and on the set: measured on one GB10 with two IQ2_XS sets. --- <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#5442
No description provided.