[PR #415] [CLOSED] maya-ds4: a helper GPU for the experts VRAM leaves over, opt-in (MAYA_DS4_HELPER) - DeepSeek's counterpart of #201 #520

Closed
opened 2026-10-29 21:26:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/415
Author: @pepuscz
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: pr/ds4-helper


📝 Commits (1)

  • 8ff6e3f maya-ds4: a helper GPU for the experts VRAM leaves over, opt-in (MAYA_DS4_HELPER) - DeepSeek's counterpart of #201

📊 Changes

6 files changed (+748 additions, -21 deletions)

View changed files

📝 docs/SETTINGS.md (+17 -0)
📝 src/ds4/ds4_kernels.cu (+46 -0)
📝 src/ds4/ds4_kernels.cuh (+8 -0)
📝 src/ds4/ds4_main.cpp (+16 -2)
📝 src/ds4/ds4_model.cu (+657 -19)
📝 src/ds4/ds4_model.hpp (+4 -0)

📄 Description

What. On a box whose GPUs' VRAM cannot hold a GGUF pack's routed experts, the rest run on the CPU lane. On a
Strix Halo box with two discrete cards, about 41 of 59 ms a decoded token went there (DS4_PROF). This is DeepSeek's
counterpart of #201's GLM expert helper: MAYA_DS4_HELPER=<visible GPU> with MAYA_DS4_HELPER_GB=<GB> takes a GPU off
the layer devices and gives it a pool of the most-routed experts the layer GPUs do not hold, chosen by the expert
profile. An integrated GPU's large shared memory fits it well; a small extra card works too.

  • Its own stream. The helper's picks run on its own stream from the window's plan. The CPU lane's service thread
    makes no CUDA call; it adds the helper's sums. A failure, or 10 s without an answer, hands the picks back to the CPU
    lane, and STAT counts them.
  • DSpark verify windows. Their picks take the helper's grouped window path, which reads each expert once for the
    window's tokens. It matches its per-token path bit for bit: MAYA_DS4_HELPER_CHECK=1 compares the two, and the
    helper against the CPU lane, at load.
  • Exactly once. A pick in a VRAM slot (#344's recent slots included) is the GPU's, a pick in the pool is the
    helper's, and the rest are the CPU lane's. The expert-cache swaps and the read-ahead leave the helper's experts out,
    and the recent slots' fills never see them.
  • Host RAM. MAYA_DS4_WARM_CAP_GB is required with the helper: it sets the load's experts in host RAM beside the
    pool, since an integrated GPU's pool is host RAM too. It is ignored under #368's DS4_REQUIRE_ALL_RAM.
  • Tests. DS4_HELPER_FAIL=flags|pool makes that allocation fail as a real one would.

Unset, every path is as before. It is not yet on tensor-parallel groups: a group's layers stay off the helper. On
naming, #410 asks whether this should follow #201's STRATA_GLM_EXPERT_HELPER, e.g. as STRATA_DS4_EXPERT_HELPER.
I'll rename it if you prefer that.

Changes. src/ds4/ds4_model.cu, src/ds4/ds4_model.hpp, src/ds4/ds4_kernels.cu/.cuh, src/ds4/ds4_main.cpp,
docs/SETTINGS.md. The engine reads STRATA_DS4_HELPER* and STRATA_DS4_WARM_CAP_GB (and DS4_*).

Verified. The load with MAYA_DS4_HELPER=2 MAYA_DS4_HELPER_GB=95 MAYA_DS4_WARM_CAP_GB=14.9 MAYA_DS4_HELPER_CHECK=1
(the Radeon 8060S as the helper):

ds4: helper CUDA2 holds 8600 experts (95.0 of 95.0 GB): 98.6% of the routing the layer devices' VRAM leaves over, by the profile (each layer's share)
ds4: helper check: IQ2_S/IQ2_S/IQ3_S (layer 0): CUDA2 vs the CPU lane, 4 tokens, 6 picks of its own and one not: 3639 of 20480 outputs bit-identical, max |diff| 1.43e-06 (1.76e-07 of the largest)
ds4: helper check: IQ2_S/IQ2_S/IQ3_S (layer 0): CUDA2's window of 4 grouped against per token: 20480 of 20480 outputs bit-identical
ds4: helper check: IQ2_XXS/IQ2_XXS/IQ3_XXS (layer 4): CUDA2 vs the CPU lane, 4 tokens, 6 picks of its own and one not: 3654 of 20480 outputs bit-identical, max |diff| 1.91e-06 (2.34e-07 of the largest)
ds4: helper check passed (2 expert formats)
--tp 1 (the two XTX in a layer split), 128K, --dspark none without the helper with the helper
experts a decode pass (of 122,640): CPU lane 25,491-32,447 1,202-2,091
experts a decode pass: helper (fallbacks) - 65,760-67,001 (0)
perplexity, 23 sequences x 2048 tokens (47,081 scored) 7.2526 7.2526
prefill, 2,048 tokens: cold / warm, tok/s 43.3 / 68.5 89.4 / 105.1
decode, 512 greedy tokens: cold / warm, tok/s 21.8 / 25.7 27.4 / 29.4
  • The --ppl forward does not go through the helper, so the perplexity pair shows only that the rest is unchanged.
    The helper's numbers rest on the load check above and on decode passes with no fallback.
  • The speeds are the means of two loads a side, each with a cold and a warm pass. The greedy streams part early, and
    a side's own two loads also part, so the decode rows compare different continuations.

Test setup. Measured on v1.1.23 + main's commits after it (main at c9683e3) + this branch. Rebased onto v1.1.24
(25deec5) without conflicts; the change's lines are the same. Main's engine change since then (df7e8b9) is
Windows-only, and this was tested on Linux only. HIP build (ROCm 7.2.4, gfx1100;gfx1151): 2x RX 7900 XTX (gfx1100)
as the layer devices, and the Ryzen AI Max+ 395's Radeon 8060S (gfx1151) as the helper. The engine CLI, with the same
binary, flags and expert profile both ways and an empty MAYA_DS4_LT_STORE each run. Model: DeepSeek-V4.1-Flash-1017
Maya-S (not the newer Maya-XS, which this did not test). This is a correctness check and one same-binary speed
comparison, not a quality or DSpark qualification.

🤖 Generated with Claude Code


🔄 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/mw00/project-maya/pull/415 **Author:** [@pepuscz](https://github.com/pepuscz) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/ds4-helper` --- ### 📝 Commits (1) - [`8ff6e3f`](https://github.com/mw00/project-maya/commit/8ff6e3f5ec4a1a61f40f463b94fe07b23de5cec9) maya-ds4: a helper GPU for the experts VRAM leaves over, opt-in (MAYA_DS4_HELPER) - DeepSeek's counterpart of #201 ### 📊 Changes **6 files changed** (+748 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+17 -0) 📝 `src/ds4/ds4_kernels.cu` (+46 -0) 📝 `src/ds4/ds4_kernels.cuh` (+8 -0) 📝 `src/ds4/ds4_main.cpp` (+16 -2) 📝 `src/ds4/ds4_model.cu` (+657 -19) 📝 `src/ds4/ds4_model.hpp` (+4 -0) </details> ### 📄 Description **What.** On a box whose GPUs' VRAM cannot hold a GGUF pack's routed experts, the rest run on the CPU lane. On a Strix Halo box with two discrete cards, about 41 of 59 ms a decoded token went there (DS4_PROF). This is DeepSeek's counterpart of #201's GLM expert helper: `MAYA_DS4_HELPER=<visible GPU>` with `MAYA_DS4_HELPER_GB=<GB>` takes a GPU off the layer devices and gives it a pool of the most-routed experts the layer GPUs do not hold, chosen by the expert profile. An integrated GPU's large shared memory fits it well; a small extra card works too. - **Its own stream.** The helper's picks run on its own stream from the window's plan. The CPU lane's service thread makes no CUDA call; it adds the helper's sums. A failure, or 10 s without an answer, hands the picks back to the CPU lane, and STAT counts them. - **DSpark verify windows.** Their picks take the helper's grouped window path, which reads each expert once for the window's tokens. It matches its per-token path bit for bit: `MAYA_DS4_HELPER_CHECK=1` compares the two, and the helper against the CPU lane, at load. - **Exactly once.** A pick in a VRAM slot (#344's recent slots included) is the GPU's, a pick in the pool is the helper's, and the rest are the CPU lane's. The expert-cache swaps and the read-ahead leave the helper's experts out, and the recent slots' fills never see them. - **Host RAM.** `MAYA_DS4_WARM_CAP_GB` is required with the helper: it sets the load's experts in host RAM beside the pool, since an integrated GPU's pool is host RAM too. It is ignored under #368's `DS4_REQUIRE_ALL_RAM`. - **Tests.** `DS4_HELPER_FAIL=flags|pool` makes that allocation fail as a real one would. Unset, every path is as before. It is not yet on tensor-parallel groups: a group's layers stay off the helper. On naming, #410 asks whether this should follow #201's `STRATA_GLM_EXPERT_HELPER`, e.g. as `STRATA_DS4_EXPERT_HELPER`. I'll rename it if you prefer that. **Changes.** `src/ds4/ds4_model.cu`, `src/ds4/ds4_model.hpp`, `src/ds4/ds4_kernels.cu/.cuh`, `src/ds4/ds4_main.cpp`, `docs/SETTINGS.md`. The engine reads `STRATA_DS4_HELPER*` and `STRATA_DS4_WARM_CAP_GB` (and `DS4_*`). **Verified.** The load with `MAYA_DS4_HELPER=2 MAYA_DS4_HELPER_GB=95 MAYA_DS4_WARM_CAP_GB=14.9 MAYA_DS4_HELPER_CHECK=1` (the Radeon 8060S as the helper): ``` ds4: helper CUDA2 holds 8600 experts (95.0 of 95.0 GB): 98.6% of the routing the layer devices' VRAM leaves over, by the profile (each layer's share) ds4: helper check: IQ2_S/IQ2_S/IQ3_S (layer 0): CUDA2 vs the CPU lane, 4 tokens, 6 picks of its own and one not: 3639 of 20480 outputs bit-identical, max |diff| 1.43e-06 (1.76e-07 of the largest) ds4: helper check: IQ2_S/IQ2_S/IQ3_S (layer 0): CUDA2's window of 4 grouped against per token: 20480 of 20480 outputs bit-identical ds4: helper check: IQ2_XXS/IQ2_XXS/IQ3_XXS (layer 4): CUDA2 vs the CPU lane, 4 tokens, 6 picks of its own and one not: 3654 of 20480 outputs bit-identical, max |diff| 1.91e-06 (2.34e-07 of the largest) ds4: helper check passed (2 expert formats) ``` | `--tp 1` (the two XTX in a layer split), 128K, `--dspark none` | without the helper | with the helper | |--|--:|--:| | experts a decode pass (of 122,640): CPU lane | 25,491-32,447 | 1,202-2,091 | | experts a decode pass: helper (fallbacks) | - | 65,760-67,001 (0) | | perplexity, 23 sequences x 2048 tokens (47,081 scored) | 7.2526 | 7.2526 | | prefill, 2,048 tokens: cold / warm, tok/s | 43.3 / 68.5 | 89.4 / 105.1 | | decode, 512 greedy tokens: cold / warm, tok/s | 21.8 / 25.7 | 27.4 / 29.4 | - The `--ppl` forward does not go through the helper, so the perplexity pair shows only that the rest is unchanged. The helper's numbers rest on the load check above and on decode passes with no fallback. - The speeds are the means of two loads a side, each with a cold and a warm pass. The greedy streams part early, and a side's own two loads also part, so the decode rows compare different continuations. **Test setup.** Measured on v1.1.23 + main's commits after it (main at c9683e3) + this branch. Rebased onto v1.1.24 (25deec5) without conflicts; the change's lines are the same. Main's engine change since then (df7e8b9) is Windows-only, and this was tested on Linux only. HIP build (ROCm 7.2.4, `gfx1100;gfx1151`): 2x RX 7900 XTX (gfx1100) as the layer devices, and the Ryzen AI Max+ 395's Radeon 8060S (gfx1151) as the helper. The engine CLI, with the same binary, flags and expert profile both ways and an empty `MAYA_DS4_LT_STORE` each run. Model: DeepSeek-V4.1-Flash-1017 **Maya-S** (not the newer Maya-XS, which this did not test). This is a correctness check and one same-binary speed comparison, not a quality or DSpark qualification. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:20 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#520
No description provided.