[PR #558] [CLOSED] DeepSeek --parallel N: several conversations at once on a two-GPU layer split #594

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/558
Author: @somnergy
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: pr/ds4-parallel


📝 Commits (1)

  • 2f00f7d DeepSeek --parallel N: several conversations at once on a two-GPU layer split

📊 Changes

9 files changed (+2522 additions, -91 deletions)

View changed files

📝 docs/SETTINGS.md (+43 -3)
📝 maya.py (+38 -8)
📝 serve/server.py (+23 -2)
📝 src/ds4/ds4_kernels.cu (+407 -10)
📝 src/ds4/ds4_kernels.cuh (+23 -0)
📝 src/ds4/ds4_main.cpp (+615 -3)
📝 src/ds4/ds4_model.cu (+1287 -33)
📝 src/ds4/ds4_model.hpp (+51 -0)
📝 tools/test_maya_parallel.py (+35 -32)

📄 Description

DeepSeek-V4.1-Flash gets --parallel N: several conversations at once on a two-GPU layer split. maya-ds4 has served one conversation at a time ( #332, #409). The default stays one conversation, and nothing changes unless --parallel is given.

What it does

  • One state per conversation. Each has its own window rings, compressors, the KV sources' compressed KV and index keys, Engram rows and sampler history. The decode loop pipelines conversations across the split's two stages: GPU 0 runs layers 0-19 for some while GPU 1 runs 20-39 and the head for others. A request that arrives while every conversation is busy waits its turn instead of failing.

  • Prefix reuse across requests. Each conversation keeps checkpoints:

    • every MAYA_DS4_SEQ_CK_EVERY prompt tokens;
    • where requests read together share a prefix;
    • where the system message ends (the server marks it);
    • at each prompt's end.

    A new request goes back to the latest checkpoint its tokens agree with and reads only the rest. A continued conversation reuses its whole state. cached_tokens and the DONE line report the reuse.

  • Prompts and decode together. A prompt read gives each GPU up between its chunks, so the conversations that are writing get steps during a long read.

  • Row groups (MAYA_DS4_ROWS_BATCH=1, opt-in). The writing conversations go through the stages as two groups.

    • Shared within a group: the dense projections, the experts' weight reads and the head.
    • One launch over the group's rows: the attention's per-row parts (RoPE, the window rings, sparse attention), using per-row positions and window segments.
  • Split decode attention (DS4_ATTN_SPLITK=1, opt-in). A decoded token's sparse attention is split over its selected rows across more blocks, and the parts are combined with the sink once. Same math, different summation order.

  • Start-up checks. --parallel needs --tp 1, two GPUs, --dspark none and no vision tower; a start that breaks one of these fails and says which. The start also fails, and names what to lower, if a GPU would have less than MAYA_DS4_SEQ_RESERVE_MIB (256) free next to the states. Buffers allocated at first use need that room.

  • Launcher. maya.py accepts --parallel for a DeepSeek config, but not with a calibration, which measures one request at a time and tunes tensor parallel groups. MiniMax is still rejected; #525's tests are adjusted to match. --bench now works with an engine that announces multi=.

  • Docs. docs/SETTINGS.md has a new section, "DeepSeek: several conversations at once".

Results

Verdict by hardware class:

  • Two GPUs, every expert in VRAM: 4 conversations at once give 2.95× the pooled tokens of one (227.8 vs 77.1 tok/s), and 2.2× upstream's best single-conversation setting (TP2 + DSpark) serving the same 4 (see below). For one user at a time, TP2 + DSpark stays faster. The single-conversation path is unchanged (maya-bench below).
  • Two GPUs, experts streamed from RAM: not measured. Each conversation's state comes out of the experts' VRAM, so expect a smaller gain.
  • One GPU, or a tensor-parallel group: not supported (--parallel needs a two-GPU layer split).

Setup: 2× RTX PRO 5000 72 GB (Blackwell), Core Ultra 9 285K, 188 GB RAM. DeepSeek-V4.1-Flash-1017, IQ2_XXS experts with IQ4_NL Engram, every expert in VRAM (--vram-experts 1.0), --tp 1, --dspark none, --vision off, --prefill-chunk 2048.

Maya's --bench (3 answers × 256 tokens, greedy, thinking off; prefill at 2K / 8K):

build --parallel context decode prefill 2K prefill 8K
v1.1.32 (main) 1 1M 86.1 tok/s 1548 2474
this PR 1 1M 86.2 tok/s 1555 2503
this PR 4 (one request through it) 800K a conversation 85.4 tok/s 1558 2507

(Measured on v1.1.32. The branch is rebased on v1.1.33, which changes only tools/mm3/pack_gguf.py besides the version.)

Several conversations through the server. These are 700-token essays at temperature 0.7, started together; pooled tokens/s is all completion tokens over the wall time. Settings: --parallel 4, MAYA_DS4_SEQ_CTX=819200, MAYA_DS4_ROWS_BATCH=1, DS4_ATTN_SPLITK=1.

conversations at once 1 2 3 4
pooled tok/s 77.1 148.7 151.1 227.8
per conversation 77.1 74.4 50.4 57.0

Three conversations run one by one through the pipeline: a group of 2 + 1, or one group of 3, left a GPU waiting and measured slower.

How much each part adds at 4 conversations, measured on a v1.1.28 base before rebasing (pooled tok/s; not re-measured part by part on main):

pooled tok/s
pipelined single steps 143.8
+ row groups (MAYA_DS4_ROWS_BATCH=1) 196.4
+ row-batched attention parts 209.2
+ split decode attention (DS4_ATTN_SPLITK=1) 213.5

Shared-prefix matrix (token_bench essay-matrix-reuse): every stream of a cell shares one long prefix and differs only in its final request. Contexts 32K-512K × 1/2/4 streams, 512 tokens each. Config and full results: github.com/somnergy/token_bench@fec0ebd629/results/2026-10-27_essay-matrix-reuse_ds4-parallel4_2x-rtx-pro-5000-72gb_core-ultra-9-285k_188gb (config: configs/matrix/essay-matrix-reuse.json; 15 cells, 0 failed requests)

context TTFT, 1 / 4 streams decode once all write, 1 / 2 / 4 streams (tok/s in all)
32K 8.4 / 8.9 s 75.7 / 150.2 / 226.9
64K 16.7 / 17.1 s 75.0 / 148.8 / 225.0
128K 34.9 / 35.1 s 73.6 / 148.0 / 221.7
256K 78.3 / 78.3 s 72.8 / 146.4 / 219.0
512K 183.2 / 188.1 s 71.2 / 143.6 / 212.9

At 4 streams, the first token comes about as soon as one stream's would: the shared prefix is read once, and the other three take it from the checkpoints.

Content checks (the same build):

  • 4 concurrent exact answers; 4 concurrent one-sentence answers; a 25K-token prompt; a 25K shared-prefix batch of 4; dashboard streaming;
  • a needle test: 4 concurrent ~20K-token prompts, each with its own code at 15-85% depth; every answer is its own code;
  • prefix reuse: a 30K continuation reuses 30,023 tokens (0.4 s instead of 8.4 s); a simultaneous batch of 4 and a staggered 4 reuse 30,018-30,019 tokens in 3 of 4; a shared system message reuses 30,013 of 30,027;
  • deterministic number-list prompts, 3 rounds: concurrent outputs identical to sequential.

All checks pass. Exact greedy token parity between a conversation run alone and one run beside others is not claimed: chunk boundaries and the group kernels change the summation order.

Against upstream's best single-conversation setup (TP2 + DSpark)

Upstream's fastest setting for one conversation on two GPUs is tensor parallel 2 with the DSpark drafter. That setting can't run with --parallel, so the honest comparison is between the two setups. Measured on the same two cards in a second host (Threadripper 7980X, 251 GB RAM, GPU peer copies at 54 GB/s each way). --parallel measured the same there as on the Core Ultra host (229.0 vs 227.8 tok/s at 4). TP2's all-reduce, though, depends on GPU peer copies, which ran at ~5 GB/s on the Core Ultra board. On a typical consumer board, expect TP2 + DSpark to be slower than the figures below.

maya --bench (greedy, 3 × 256 tokens; DSpark keeps 83-98% of its drafts on these answers):

setup decode
main, --tp 2 --dspark on 198.2 tok/s (one answer)
this PR, --parallel 4 85.7 tok/s one answer; 209.0 tok/s in all, 4 answers at once

Through the server (700-token essays at temperature 0.7, started together; main queues the requests it can't serve at once):

conversations at once main, --tp 2 --dspark on this PR, --parallel 4
1 97.1 78.7
2 99.1 149.0
4 103.8 229.0

For one user at a time, DSpark on TP2 stays the better setting: 1.2× at temperature 0.7 and about 2.3× on greedy code. From two concurrent users up, --parallel gives 1.5× at two and 2.2× at four. A drafter for a conversation writing alone, inside --parallel, would combine the two; that is follow-up work, not in this PR.

Suggested settings

requests at once two GPUs, every expert in VRAM two GPUs, experts streamed from RAM one GPU / tensor parallel
2 --parallel 2 (pipelined; row groups add nothing at 2) not measured not supported
4 --parallel 4 MAYA_DS4_ROWS_BATCH=1 DS4_ATTN_SPLITK=1 not measured not supported
8 not measured (row groups of 4; the attention scratch holds up to 7 rows, more falls back per row) not measured not supported

Context per conversation: at 4 × 1M, the second GPU (layers 20-39 + head) was left with 148 MiB, below the reserve, and the start refuses. 4 × 800K leaves 530 MiB.

Not in this PR

  • DSpark, prompt lookup and pictures with --parallel (rejected at start).
  • Decode during a long prompt read is limited to a step per chunk gap: the decode step queues behind the chunk's work on the same stream. A high-priority decode stream is the follow-up.

Checks

tools/check_hip_compat.py passes; server tests (456) pass; tools tests show the same 4 failures as main in this environment. Built for sm_120.


🔄 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/558 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/ds4-parallel` --- ### 📝 Commits (1) - [`2f00f7d`](https://github.com/mw00/project-maya/commit/2f00f7d8dfcedc8292211ce06c0b905d522d3d3d) DeepSeek --parallel N: several conversations at once on a two-GPU layer split ### 📊 Changes **9 files changed** (+2522 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+43 -3) 📝 `maya.py` (+38 -8) 📝 `serve/server.py` (+23 -2) 📝 `src/ds4/ds4_kernels.cu` (+407 -10) 📝 `src/ds4/ds4_kernels.cuh` (+23 -0) 📝 `src/ds4/ds4_main.cpp` (+615 -3) 📝 `src/ds4/ds4_model.cu` (+1287 -33) 📝 `src/ds4/ds4_model.hpp` (+51 -0) 📝 `tools/test_maya_parallel.py` (+35 -32) </details> ### 📄 Description DeepSeek-V4.1-Flash gets `--parallel N`: several conversations at once on a two-GPU layer split. maya-ds4 has served one conversation at a time ( #332, #409). The default stays one conversation, and nothing changes unless `--parallel` is given. ## What it does - **One state per conversation.** Each has its own window rings, compressors, the KV sources' compressed KV and index keys, Engram rows and sampler history. The decode loop pipelines conversations across the split's two stages: GPU 0 runs layers 0-19 for some while GPU 1 runs 20-39 and the head for others. A request that arrives while every conversation is busy waits its turn instead of failing. - **Prefix reuse across requests.** Each conversation keeps checkpoints: - every `MAYA_DS4_SEQ_CK_EVERY` prompt tokens; - where requests read together share a prefix; - where the system message ends (the server marks it); - at each prompt's end. A new request goes back to the latest checkpoint its tokens agree with and reads only the rest. A continued conversation reuses its whole state. `cached_tokens` and the `DONE` line report the reuse. - **Prompts and decode together.** A prompt read gives each GPU up between its chunks, so the conversations that are writing get steps during a long read. - **Row groups** (`MAYA_DS4_ROWS_BATCH=1`, opt-in). The writing conversations go through the stages as two groups. - Shared within a group: the dense projections, the experts' weight reads and the head. - One launch over the group's rows: the attention's per-row parts (RoPE, the window rings, sparse attention), using per-row positions and window segments. - **Split decode attention** (`DS4_ATTN_SPLITK=1`, opt-in). A decoded token's sparse attention is split over its selected rows across more blocks, and the parts are combined with the sink once. Same math, different summation order. - **Start-up checks.** `--parallel` needs `--tp 1`, two GPUs, `--dspark none` and no vision tower; a start that breaks one of these fails and says which. The start also fails, and names what to lower, if a GPU would have less than `MAYA_DS4_SEQ_RESERVE_MIB` (256) free next to the states. Buffers allocated at first use need that room. - **Launcher.** `maya.py` accepts `--parallel` for a DeepSeek config, but not with a calibration, which measures one request at a time and tunes tensor parallel groups. MiniMax is still rejected; #525's tests are adjusted to match. `--bench` now works with an engine that announces `multi=`. - **Docs.** `docs/SETTINGS.md` has a new section, "DeepSeek: several conversations at once". ## Results Verdict by hardware class: - **Two GPUs, every expert in VRAM:** 4 conversations at once give **2.95×** the pooled tokens of one (227.8 vs 77.1 tok/s), and 2.2× upstream's best single-conversation setting (TP2 + DSpark) serving the same 4 (see below). For one user at a time, TP2 + DSpark stays faster. The single-conversation path is unchanged (maya-bench below). - **Two GPUs, experts streamed from RAM:** not measured. Each conversation's state comes out of the experts' VRAM, so expect a smaller gain. - **One GPU, or a tensor-parallel group:** not supported (`--parallel` needs a two-GPU layer split). Setup: 2× RTX PRO 5000 72 GB (Blackwell), Core Ultra 9 285K, 188 GB RAM. DeepSeek-V4.1-Flash-1017, IQ2_XXS experts with IQ4_NL Engram, every expert in VRAM (`--vram-experts 1.0`), `--tp 1`, `--dspark none`, `--vision off`, `--prefill-chunk 2048`. **Maya's `--bench`** (3 answers × 256 tokens, greedy, thinking off; prefill at 2K / 8K): | build | `--parallel` | context | decode | prefill 2K | prefill 8K | |---|---|---|---|---|---| | v1.1.32 (main) | 1 | 1M | 86.1 tok/s | 1548 | 2474 | | this PR | 1 | 1M | 86.2 tok/s | 1555 | 2503 | | this PR | 4 (one request through it) | 800K a conversation | 85.4 tok/s | 1558 | 2507 | (Measured on v1.1.32. The branch is rebased on v1.1.33, which changes only `tools/mm3/pack_gguf.py` besides the version.) **Several conversations through the server.** These are 700-token essays at temperature 0.7, started together; pooled tokens/s is all completion tokens over the wall time. Settings: `--parallel 4`, `MAYA_DS4_SEQ_CTX=819200`, `MAYA_DS4_ROWS_BATCH=1`, `DS4_ATTN_SPLITK=1`. | conversations at once | 1 | 2 | 3 | 4 | |---|---|---|---|---| | pooled tok/s | 77.1 | 148.7 | 151.1 | **227.8** | | per conversation | 77.1 | 74.4 | 50.4 | 57.0 | Three conversations run one by one through the pipeline: a group of 2 + 1, or one group of 3, left a GPU waiting and measured slower. How much each part adds at 4 conversations, measured on a v1.1.28 base before rebasing (pooled tok/s; not re-measured part by part on main): | | pooled tok/s | |---|---| | pipelined single steps | 143.8 | | + row groups (`MAYA_DS4_ROWS_BATCH=1`) | 196.4 | | + row-batched attention parts | 209.2 | | + split decode attention (`DS4_ATTN_SPLITK=1`) | 213.5 | **Shared-prefix matrix** (token_bench `essay-matrix-reuse`): every stream of a cell shares one long prefix and differs only in its final request. Contexts 32K-512K × 1/2/4 streams, 512 tokens each. Config and full results: https://github.com/somnergy/token_bench/tree/fec0ebd62957122b240652f4a93359de9205418b/results/2026-10-27_essay-matrix-reuse_ds4-parallel4_2x-rtx-pro-5000-72gb_core-ultra-9-285k_188gb (config: [`configs/matrix/essay-matrix-reuse.json`](https://github.com/somnergy/token_bench/blob/fec0ebd62957122b240652f4a93359de9205418b/configs/matrix/essay-matrix-reuse.json); 15 cells, 0 failed requests) | context | TTFT, 1 / 4 streams | decode once all write, 1 / 2 / 4 streams (tok/s in all) | |---|---|---| | 32K | 8.4 / 8.9 s | 75.7 / 150.2 / 226.9 | | 64K | 16.7 / 17.1 s | 75.0 / 148.8 / 225.0 | | 128K | 34.9 / 35.1 s | 73.6 / 148.0 / 221.7 | | 256K | 78.3 / 78.3 s | 72.8 / 146.4 / 219.0 | | 512K | 183.2 / 188.1 s | 71.2 / 143.6 / 212.9 | At 4 streams, the first token comes about as soon as one stream's would: the shared prefix is read once, and the other three take it from the checkpoints. **Content checks** (the same build): - 4 concurrent exact answers; 4 concurrent one-sentence answers; a 25K-token prompt; a 25K shared-prefix batch of 4; dashboard streaming; - a needle test: 4 concurrent ~20K-token prompts, each with its own code at 15-85% depth; every answer is its own code; - prefix reuse: a 30K continuation reuses 30,023 tokens (0.4 s instead of 8.4 s); a simultaneous batch of 4 and a staggered 4 reuse 30,018-30,019 tokens in 3 of 4; a shared system message reuses 30,013 of 30,027; - deterministic number-list prompts, 3 rounds: concurrent outputs identical to sequential. All checks pass. Exact greedy token parity between a conversation run alone and one run beside others is not claimed: chunk boundaries and the group kernels change the summation order. ## Against upstream's best single-conversation setup (TP2 + DSpark) Upstream's fastest setting for one conversation on two GPUs is tensor parallel 2 with the DSpark drafter. That setting can't run with `--parallel`, so the honest comparison is between the two setups. Measured on the same two cards in a second host (Threadripper 7980X, 251 GB RAM, GPU peer copies at 54 GB/s each way). `--parallel` measured the same there as on the Core Ultra host (229.0 vs 227.8 tok/s at 4). TP2's all-reduce, though, depends on GPU peer copies, which ran at ~5 GB/s on the Core Ultra board. On a typical consumer board, expect TP2 + DSpark to be slower than the figures below. maya `--bench` (greedy, 3 × 256 tokens; DSpark keeps 83-98% of its drafts on these answers): | setup | decode | |---|---| | main, `--tp 2 --dspark on` | 198.2 tok/s (one answer) | | this PR, `--parallel 4` | 85.7 tok/s one answer; **209.0 tok/s in all, 4 answers at once** | Through the server (700-token essays at temperature 0.7, started together; main queues the requests it can't serve at once): | conversations at once | main, `--tp 2 --dspark on` | this PR, `--parallel 4` | |---|---|---| | 1 | **97.1** | 78.7 | | 2 | 99.1 | **149.0** | | 4 | 103.8 | **229.0** | For one user at a time, DSpark on TP2 stays the better setting: 1.2× at temperature 0.7 and about 2.3× on greedy code. From two concurrent users up, `--parallel` gives 1.5× at two and 2.2× at four. A drafter for a conversation writing alone, inside `--parallel`, would combine the two; that is follow-up work, not in this PR. ## Suggested settings | requests at once | two GPUs, every expert in VRAM | two GPUs, experts streamed from RAM | one GPU / tensor parallel | |---|---|---|---| | 2 | `--parallel 2` (pipelined; row groups add nothing at 2) | not measured | not supported | | 4 | `--parallel 4 MAYA_DS4_ROWS_BATCH=1 DS4_ATTN_SPLITK=1` | not measured | not supported | | 8 | not measured (row groups of 4; the attention scratch holds up to 7 rows, more falls back per row) | not measured | not supported | Context per conversation: at 4 × 1M, the second GPU (layers 20-39 + head) was left with 148 MiB, below the reserve, and the start refuses. 4 × 800K leaves 530 MiB. ## Not in this PR - DSpark, prompt lookup and pictures with `--parallel` (rejected at start). - Decode during a long prompt read is limited to a step per chunk gap: the decode step queues behind the chunk's work on the same stream. A high-priority decode stream is the follow-up. ## Checks `tools/check_hip_compat.py` passes; server tests (456) pass; tools tests show the same 4 failures as main in this environment. Built for sm_120. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:27:18 +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#594
No description provided.