[PR #4198] [CLOSED] [Docs] design for batched decoding in the DeepSeek-V4.1 engine #4943

Closed
opened 2026-11-07 16:31:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4198
Author: @suifei
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: docs/dsv41-batching-design


📝 Commits (1)

  • 77b083e docs(dsv41): design for batched decoding (continuous batching)

📊 Changes

1 file changed (+115 additions, -0 deletions)

View changed files

➕ docs/DSV41_BATCHING.md (+115 -0)

📄 Description

Problem and result

Three concurrent requests to a deepseek41 server take the sum of the three: strata-dsv41 --serve reads one request at a time (GEN/GENI/STOP/QUIT), the model holds one conversation, and the server queues behind one FIFO. The engine's slots are conversations saved to disk and restored (a context switch), not parallel decoding, and --parallel is ignored with a warning.

Measured on 4 x L20 (2.25 bpw, 1M context): one 300-token answer ~5 s (65 tok/s); three 150-token answers sent together ~6.5-21 s; a 6.6K-token cold prompt ~9.6 s (654-690 tok/s prefill). Aggregate throughput stays at one request's worth however many clients wait.

This PR adds the design for continuous batching in that engine: per-sequence state and paged KV, a scheduler, varlen attention, a batched MoE, the protocol and server changes, milestones, memory numbers, and what helps today without engine work. No behaviour changes - documentation only.

None yet. Per CONTRIBUTING this is a substantial feature, so this draft is a proposal for scope; the code would follow M1-M4 in the document, and I am happy to turn it into an issue first or to start with the smallest useful slice (decode-only batching, prefill still one sequence at a time).

Approach

The document scopes the work in four milestones, cheapest first:

  • M1 SeqState + scheduler loop (one kernel call per sequence per step): plumbing, no speedup yet.
  • M2 varlen attention with per-sequence positions and block tables (ds4_attn_split.cuh, ds4_kernels.cu).
  • M3 batched MoE: routing rows of several sequences concatenated, then the grouped GEMM the prefill path already uses (ds4_iq.cu, ds4_tq.cu).
  • M4 protocol (GEN <seq> ..., STOP <seq>) and server streaming for N in-flight requests.

Expected shape from the measurements: three answers finish in roughly the time of one (+20-40 %) instead of 3x, per-sequence decode ~45-55 tok/s, aggregate 135-165 tok/s. Single-request latency does not improve.

Validation

Documentation-only change, so no GPU builds were run for it. The numbers quoted come from the deployment that motivated it (4 x NVIDIA L20, driver 595.71, CUDA 13.2, strata-dsv41 0.1.51, IST-DAS 2.25 bpw pack, 1M context):

Passed:

  • python -m unittest serve.test_dsv41 - 60 tests, OK (skipped=1), the tree this document describes.
  • Measurements above from POST /v1/chat/completions with 1 and 3 concurrent clients (Python threads), temperature: 0, reasoning_effort: none.

Failed:

none observed.

Not run:

  • No engine code changes, so no build, no bench of a batched path.
  • HIP/SYCL/Metal: no such hardware.

Limits

The design does not touch the kernels yet, and the effort estimate for M2-M3 (4-8 weeks for an experienced CUDA engineer) is the author's estimate, not a measurement. The first useful version is likely decode-only batching with prefill still one sequence at a time; the document says so and lists the open questions (DSpark in a batch, --parallel ownership, preemption).


🔄 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/4198 **Author:** [@suifei](https://github.com/suifei) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `docs/dsv41-batching-design` --- ### 📝 Commits (1) - [`77b083e`](https://github.com/Niko1221/Strata/commit/77b083e3637e3a8ba7a86b6046eb806ef5250f9d) docs(dsv41): design for batched decoding (continuous batching) ### 📊 Changes **1 file changed** (+115 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `docs/DSV41_BATCHING.md` (+115 -0) </details> ### 📄 Description ## Problem and result Three concurrent requests to a `deepseek41` server take the **sum** of the three: `strata-dsv41 --serve` reads one request at a time (GEN/GENI/STOP/QUIT), the model holds one conversation, and the server queues behind one FIFO. The engine's `slots` are conversations saved to disk and restored (a context switch), not parallel decoding, and `--parallel` is ignored with a warning. Measured on 4 x L20 (2.25 bpw, 1M context): one 300-token answer ~5 s (65 tok/s); three 150-token answers sent together ~6.5-21 s; a 6.6K-token cold prompt ~9.6 s (654-690 tok/s prefill). Aggregate throughput stays at one request's worth however many clients wait. This PR adds the **design** for continuous batching in that engine: per-sequence state and paged KV, a scheduler, varlen attention, a batched MoE, the protocol and server changes, milestones, memory numbers, and what helps today without engine work. No behaviour changes - documentation only. ## Related discussion None yet. Per CONTRIBUTING this is a substantial feature, so this draft is a proposal for scope; the code would follow M1-M4 in the document, and I am happy to turn it into an issue first or to start with the smallest useful slice (decode-only batching, prefill still one sequence at a time). ## Approach The document scopes the work in four milestones, cheapest first: * **M1** `SeqState` + scheduler loop (one kernel call per sequence per step): plumbing, no speedup yet. * **M2** varlen attention with per-sequence positions and block tables (`ds4_attn_split.cuh`, `ds4_kernels.cu`). * **M3** batched MoE: routing rows of several sequences concatenated, then the grouped GEMM the prefill path already uses (`ds4_iq.cu`, `ds4_tq.cu`). * **M4** protocol (`GEN <seq> ...`, `STOP <seq>`) and server streaming for N in-flight requests. Expected shape from the measurements: three answers finish in roughly the time of one (+20-40 %) instead of 3x, per-sequence decode ~45-55 tok/s, aggregate 135-165 tok/s. Single-request latency does not improve. ## Validation Documentation-only change, so no GPU builds were run for it. The numbers quoted come from the deployment that motivated it (4 x NVIDIA L20, driver 595.71, CUDA 13.2, `strata-dsv41` 0.1.51, IST-DAS 2.25 bpw pack, 1M context): **Passed:** * `python -m unittest serve.test_dsv41` - 60 tests, OK (skipped=1), the tree this document describes. * Measurements above from `POST /v1/chat/completions` with 1 and 3 concurrent clients (Python threads), `temperature: 0`, `reasoning_effort: none`. **Failed:** none observed. **Not run:** * No engine code changes, so no build, no bench of a batched path. * HIP/SYCL/Metal: no such hardware. ## Limits The design does not touch the kernels yet, and the effort estimate for M2-M3 (4-8 weeks for an experienced CUDA engineer) is the author's estimate, not a measurement. The first useful version is likely decode-only batching with prefill still one sequence at a time; the document says so and lists the open questions (DSpark in a batch, `--parallel` ownership, preemption). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:31:31 +07:00
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#4943
No description provided.