[PR #639] [CLOSED] DeepSeek: restore points, one-launch --parallel attention, logprobs, faster i-quant kernels and CPU rows, a prompt read in parts, a RAM expert store, pack tools #641

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/639
Author: @needmorevram
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: ds4-engine-features


📝 Commits (10+)

  • 2f69607 DeepSeek: restore points a request asks for (GEN marks= / shared=)
  • 0c39be8 serve: MAYA_DS4_RESTORE_POINTS - DeepSeek restore points at the last user turn, the tail and the system prompt's end
  • ad38d6b DeepSeek: a prompt's run of chunks read in parts with the plan of one call
  • d9f1752 DeepSeek --parallel: running requests decode between a long prompt's chunks; a long read gives way to a short one
  • 7bed54a DeepSeek: a GEMV call's int8 inputs rounded in one launch by default, an input several jobs read rounded once
  • 6ee87bc DeepSeek: the HC mix and split in one launch where they run on the layer's own stream
  • 94028f6 DeepSeek: a GGUF head reads 8 rows a pass
  • 9482b5b DeepSeek: the drafter's markov head as Q8_0 blocks (opt-in, MAYA_DS4_MARKOV_Q8)
  • 34faf4f DeepSeek: the HC mix + split launch opt-in until measured
  • 979a23b DeepSeek: a prompt's path by its length (DS4_PROMPT_PICK=length), the prompt GEMMs warmed up at load

📊 Changes

55 files changed (+12379 additions, -731 deletions)

View changed files

📝 CMakeLists.txt (+99 -1)
➕ cmake/build_id.cmake (+45 -0)
📝 docs/RESPONSES.md (+5 -0)
📝 docs/SETTINGS.md (+365 -11)
📝 include/strata/spec/draft_policy.hpp (+54 -2)
📝 maya.py (+2 -1)
📝 serve/fake_multi_engine.py (+8 -2)
📝 serve/frontend.py (+1 -0)
📝 serve/responses.py (+20 -3)
📝 serve/server.py (+297 -19)
➕ serve/test_ds4_restore_points.py (+198 -0)
➕ serve/test_logprobs.py (+330 -0)
📝 src/ds4/ds4_cpu_exl3.hpp (+4 -1)
📝 src/ds4/ds4_engram_io.hpp (+17 -7)
📝 src/ds4/ds4_gguf.cu (+148 -66)
📝 src/ds4/ds4_gguf.cuh (+9 -3)
📝 src/ds4/ds4_gguf_cpu.hpp (+3 -2)
➕ src/ds4/ds4_interleave.hpp (+85 -0)
📝 src/ds4/ds4_iq.cu (+401 -197)
📝 src/ds4/ds4_iq.cuh (+17 -7)

...and 35 more files

📄 Description

What

A set of DeepSeek engine and server improvements on top of v1.1.36 (it builds on #611's --parallel drafter). Everything here is exact: the model's math is unchanged, and the defaults that changed were measured first. One request without --parallel decodes the same tokens as v1.1.36's engine.

On by default

  • Restore points (MAYA_DS4_RESTORE_POINTS, 4).
    • The server asks the engine to keep the state at three more places of a long prompt: the start of the last user turn, 512 tokens before the end, and the end of the system prompt and tools.
    • An edited last message, a new question after the same document, or another agent behind the same system prompt then reads only its new part.
    • Kept conversations (MAYA_DS4_SLOT_KEEP) save and load the points.
    • 0 turns them off.
  • A --parallel step's attention in one launch (MAYA_DS4_MULTI_ATTN).
    • The ring reads and writes, the KV rows' finish, the sparse attention and the rotations run once for all the step's rows, instead of once per request.
    • Each row runs the same kernels with the same arithmetic.
  • GGUF experts:
    • i-quant token and light kernels for codebooks of 8 KiB and more (IQ1_S / IQ1_M / IQ2_S) on persistent grids (MAYA_DS4_IQ_PERSIST=0: the full grids);
    • IQ1_M decoded through a 4096-entry code table;
    • a GEMV call's int8 inputs rounded in one launch, and an input that several jobs read rounded once;
    • a GGUF head reads 8 rows per pass.
      All of these give the same bits.
  • IQ4_NL experts load and run on the GPU and the CPU lane. Before, such a pack failed to load.
  • Light sets' scratch and the tensor-core check are kept per device. Before, they were kept per stream, which could reuse the first GPU's scratch or answer on another GPU.
  • CPU lane: exact AVX-512 rows for IQ2_XS and IQ1_M, chosen by the CPU's features. They give ggml-cpu's bits. DS4_IQ512=0: as before.
  • The prompt path's GEMMs warmed up at load, on a thread of their own. The first prompt no longer pays the BLAS start.
  • Chunk buffers that do not fit: the load halves the chunk, then falls back to windows of 16, instead of failing.
  • Integrated GPUs: --mmap-experts auto no longer copies every expert into RAM when the GPU shares it.
  • Logprobs on request:
    • logprobs / top_logprobs (up to 20) on chat completions and the Responses API, streamed or not;
    • each accepted DSpark draft gets its own row's numbers;
    • no cost when not asked.

Opt-in, documented in docs/SETTINGS.md

  • A long prompt read in parts beside running requests (MAYA_DS4_PROMPT_SHARE, MAYA_DS4_PROMPT_GAP_MS, MAYA_DS4_PROMPT_YIELD).
    • The prompt is read in parts with the plan of one call, so the chunks and the prompt skip are the same.
    • The running requests decode between the parts.
    • The next part's first Engram rows are read ahead during the pause.
    • Where GPUs lend a GGUF's expert slots to the prompt, the lend is kept across the parts.
  • A RAM expert store for experts read from the SSD (--ssd-cache, --ssd-policy). It reads whole experts past the page cache, serves demand reads before guesses, and gives RAM back when memory is low.
  • DSpark's window by the measured cost of a verified row (DS4_DRAFT_COST).
  • Smaller pieces:
    • the prompt path by length (DS4_PROMPT_PICK=length);
    • the staging ring from each GPU's VRAM (DS4_RING_MB=auto);
    • the cache learning from a chunked prompt (DS4_SETTLE_MS);
    • huge-page RAM copies (DS4_COPY_HUGETLB, auto only when a reserved pool holds them all; DS4_COPY_PIN_RO);
    • integrated NVIDIA GPU placement from MemAvailable (DS4_UMA_FREE);
    • the HC mix and split in one launch (MAYA_DS4_HC_MIX_SPLIT);
    • the drafter's markov head in Q8_0 (MAYA_DS4_MARKOV_Q8; it changes the drafts only, never the verified tokens).

Tools

  • maya-ds4 --pack-info: a pack described without a GPU or its weights. It shows the types, bytes per expert and per token, the tiers by profile, tensors without a kernel, missing files ("DEAD PACK") and suspicious metadata.
  • maya-ds4 --version, and a build line with --verbose.
  • --profile-run / --profile-out: an expert profile from a corpus. --profile-readonly: placement from a profile that is never written back.
  • --spec-eval with DS4_ROUND_LOG: the drafter's acceptance by position and confidence.
  • --sampler-test: a chi-square check that speculative sampling draws as the model does.
  • --parts-check: a prompt read in parts against one call, bit for bit.
  • tools/ds4/concurrent_check.py: conversations at once must not see each other's state.

Measured

One RTX 3090 + eight RTX 5060 Ti (--tp 8 over a layer split), EXL3 3.5 bpw, two thirds of the experts in RAM, unless noted.

  • Restore points: an 18K-token chat with its last message edited reads 14 tokens instead of 18,055. The first token comes after 0.2 s instead of 15.0 s. The chat's first read costs about 1 s more.
  • One-launch attention: --parallel 2 --multi-check, expert cache off, gives the same logits bit for bit, 398 of 398 rows. 2 × 200 tokens go 43.9 → 49.3 tok/s in all without drafts and 52.0 → 56.3 with them (measured on v1.1.35). On this branch on top of v1.1.36: 52.7 tok/s together without drafts and 60.4 with them in one pass, every mode the same tokens as alone.
  • GGUF kernels (IST-DAS 1.75 bpw, IQ1_S / IQ1_M experts, 9 GPUs): decode 88.2 → 92.0 tok/s, the same 200 greedy tokens; the drafter's round 7.25 → 6.51 ms.
  • AVX-512 rows (the same pack on 3 GPUs, 70% of the experts on the CPU lane, Xeon Gold 6152): 35.4 → 36.9 tok/s, the same tokens. Single-thread, IQ2_XS 2.32 → 3.62 GB/s and IQ1_M 1.12 → 2.05 GB/s at one token.
  • A prompt read in parts: a 24K-token prompt joining a streaming answer, MAYA_DS4_PROMPT_SHARE=0.5.
    • The stream's longest stop is 18.5 s in one run, 5.9 s with parts of one chunk, and 11.9 s with parts of up to 8 s.
    • The prompt's first token comes after 18.7 s, 49.0 s and 38.5 s respectively.
    • The Engram read-ahead took the parts' Engram waits from 15.4 s to 3.1 s.
    • It trades the long prompt's time for the other conversation's longest stop, so it stays off by default.
  • DS4_DRAFT_COST and MAYA_DS4_PROMPT_SHARE: no gain in the two-request server test, so both stay opt-in.

Tested

  • Build: maya-ds4, maya and maya-mm3 build for sm_86 and sm_120 with no new warnings.
  • CPU tests (13 programs, all pass):
    • restore points; the parts scheduler; the Engram reader's priority;
    • Q8_0 rounding; the prompt / memory rules; --pack-info;
    • the AVX-512 rows against ggml (399 cases); the IQ1_M code table and IQ4_NL rows against ggml;
    • the draft policy (old and new); logprobs; the multi-attention layout; the RAM store (real O_DIRECT on ext4).
  • Server tests: serve/test_logprobs.py (19) and serve/test_ds4_restore_points.py (8). The 13 test_responses_schema failures happen on v1.1.36 too.
  • GPU (on the setup above):
    • ds4_gguf_test, including --trims, --persist and --devices on all 9 GPUs: all OK;
    • ds4_multi_attn_test: OK;
    • --multi-check: bit for bit;
    • --parts-check (a 24K-token prompt in 7 parts with another conversation stepped between): bit for bit;
    • the single-request path: the same tokens as before;
    • IST-DAS 1.75 and 2.00 bpw packs: --pack-info says they can load.
  • Not built here: HIP and Windows.

🔄 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/639 **Author:** [@needmorevram](https://github.com/needmorevram) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `ds4-engine-features` --- ### 📝 Commits (10+) - [`2f69607`](https://github.com/mw00/project-maya/commit/2f69607f168d29d034b757667defc18f8e75e5e5) DeepSeek: restore points a request asks for (GEN marks= / shared=) - [`0c39be8`](https://github.com/mw00/project-maya/commit/0c39be868a9e7d83a51edcd4df3796833a785310) serve: MAYA_DS4_RESTORE_POINTS - DeepSeek restore points at the last user turn, the tail and the system prompt's end - [`ad38d6b`](https://github.com/mw00/project-maya/commit/ad38d6bc1c9555eca2d03e3fd3e743b29b337b3e) DeepSeek: a prompt's run of chunks read in parts with the plan of one call - [`d9f1752`](https://github.com/mw00/project-maya/commit/d9f175261ac3ad9d6ab275990765bb1555c29979) DeepSeek --parallel: running requests decode between a long prompt's chunks; a long read gives way to a short one - [`7bed54a`](https://github.com/mw00/project-maya/commit/7bed54a0f314f2389dbbea09cb158a2f6fa7adcb) DeepSeek: a GEMV call's int8 inputs rounded in one launch by default, an input several jobs read rounded once - [`6ee87bc`](https://github.com/mw00/project-maya/commit/6ee87bcc4110b39beb8f2eec09dd5bfed96b139b) DeepSeek: the HC mix and split in one launch where they run on the layer's own stream - [`94028f6`](https://github.com/mw00/project-maya/commit/94028f69cccc4908cda66fe1a97d988c9ebe936f) DeepSeek: a GGUF head reads 8 rows a pass - [`9482b5b`](https://github.com/mw00/project-maya/commit/9482b5b148b1ce2c0d1367d89f206d7b352937e1) DeepSeek: the drafter's markov head as Q8_0 blocks (opt-in, MAYA_DS4_MARKOV_Q8) - [`34faf4f`](https://github.com/mw00/project-maya/commit/34faf4fbeaadd876d0ecd26fe4d98a650dd6d0e3) DeepSeek: the HC mix + split launch opt-in until measured - [`979a23b`](https://github.com/mw00/project-maya/commit/979a23b5d731326b0a9c5a6903a01894fd8e1c2f) DeepSeek: a prompt's path by its length (DS4_PROMPT_PICK=length), the prompt GEMMs warmed up at load ### 📊 Changes **55 files changed** (+12379 additions, -731 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+99 -1) ➕ `cmake/build_id.cmake` (+45 -0) 📝 `docs/RESPONSES.md` (+5 -0) 📝 `docs/SETTINGS.md` (+365 -11) 📝 `include/strata/spec/draft_policy.hpp` (+54 -2) 📝 `maya.py` (+2 -1) 📝 `serve/fake_multi_engine.py` (+8 -2) 📝 `serve/frontend.py` (+1 -0) 📝 `serve/responses.py` (+20 -3) 📝 `serve/server.py` (+297 -19) ➕ `serve/test_ds4_restore_points.py` (+198 -0) ➕ `serve/test_logprobs.py` (+330 -0) 📝 `src/ds4/ds4_cpu_exl3.hpp` (+4 -1) 📝 `src/ds4/ds4_engram_io.hpp` (+17 -7) 📝 `src/ds4/ds4_gguf.cu` (+148 -66) 📝 `src/ds4/ds4_gguf.cuh` (+9 -3) 📝 `src/ds4/ds4_gguf_cpu.hpp` (+3 -2) ➕ `src/ds4/ds4_interleave.hpp` (+85 -0) 📝 `src/ds4/ds4_iq.cu` (+401 -197) 📝 `src/ds4/ds4_iq.cuh` (+17 -7) _...and 35 more files_ </details> ### 📄 Description ## What A set of DeepSeek engine and server improvements on top of v1.1.36 (it builds on #611's `--parallel` drafter). Everything here is exact: the model's math is unchanged, and the defaults that changed were measured first. One request without `--parallel` decodes the same tokens as v1.1.36's engine. ### On by default - **Restore points** (`MAYA_DS4_RESTORE_POINTS`, 4). - The server asks the engine to keep the state at three more places of a long prompt: the start of the last user turn, 512 tokens before the end, and the end of the system prompt and tools. - An edited last message, a new question after the same document, or another agent behind the same system prompt then reads only its new part. - Kept conversations (`MAYA_DS4_SLOT_KEEP`) save and load the points. - `0` turns them off. - **A `--parallel` step's attention in one launch** (`MAYA_DS4_MULTI_ATTN`). - The ring reads and writes, the KV rows' finish, the sparse attention and the rotations run once for all the step's rows, instead of once per request. - Each row runs the same kernels with the same arithmetic. - **GGUF experts:** - i-quant token and light kernels for codebooks of 8 KiB and more (IQ1_S / IQ1_M / IQ2_S) on persistent grids (`MAYA_DS4_IQ_PERSIST=0`: the full grids); - IQ1_M decoded through a 4096-entry code table; - a GEMV call's int8 inputs rounded in one launch, and an input that several jobs read rounded once; - a GGUF head reads 8 rows per pass. All of these give the same bits. - **IQ4_NL experts** load and run on the GPU and the CPU lane. Before, such a pack failed to load. - **Light sets' scratch and the tensor-core check are kept per device.** Before, they were kept per stream, which could reuse the first GPU's scratch or answer on another GPU. - **CPU lane: exact AVX-512 rows** for IQ2_XS and IQ1_M, chosen by the CPU's features. They give ggml-cpu's bits. `DS4_IQ512=0`: as before. - **The prompt path's GEMMs warmed up at load**, on a thread of their own. The first prompt no longer pays the BLAS start. - **Chunk buffers that do not fit:** the load halves the chunk, then falls back to windows of 16, instead of failing. - **Integrated GPUs:** `--mmap-experts auto` no longer copies every expert into RAM when the GPU shares it. - **Logprobs on request:** - `logprobs` / `top_logprobs` (up to 20) on chat completions and the Responses API, streamed or not; - each accepted DSpark draft gets its own row's numbers; - no cost when not asked. ### Opt-in, documented in docs/SETTINGS.md - **A long prompt read in parts beside running requests** (`MAYA_DS4_PROMPT_SHARE`, `MAYA_DS4_PROMPT_GAP_MS`, `MAYA_DS4_PROMPT_YIELD`). - The prompt is read in parts with the plan of one call, so the chunks and the prompt skip are the same. - The running requests decode between the parts. - The next part's first Engram rows are read ahead during the pause. - Where GPUs lend a GGUF's expert slots to the prompt, the lend is kept across the parts. - **A RAM expert store for experts read from the SSD** (`--ssd-cache`, `--ssd-policy`). It reads whole experts past the page cache, serves demand reads before guesses, and gives RAM back when memory is low. - **DSpark's window by the measured cost of a verified row** (`DS4_DRAFT_COST`). - **Smaller pieces:** - the prompt path by length (`DS4_PROMPT_PICK=length`); - the staging ring from each GPU's VRAM (`DS4_RING_MB=auto`); - the cache learning from a chunked prompt (`DS4_SETTLE_MS`); - huge-page RAM copies (`DS4_COPY_HUGETLB`, auto only when a reserved pool holds them all; `DS4_COPY_PIN_RO`); - integrated NVIDIA GPU placement from MemAvailable (`DS4_UMA_FREE`); - the HC mix and split in one launch (`MAYA_DS4_HC_MIX_SPLIT`); - the drafter's markov head in Q8_0 (`MAYA_DS4_MARKOV_Q8`; it changes the drafts only, never the verified tokens). ### Tools - **`maya-ds4 --pack-info`:** a pack described without a GPU or its weights. It shows the types, bytes per expert and per token, the tiers by profile, tensors without a kernel, missing files ("DEAD PACK") and suspicious metadata. - **`maya-ds4 --version`**, and a build line with `--verbose`. - **`--profile-run` / `--profile-out`:** an expert profile from a corpus. **`--profile-readonly`:** placement from a profile that is never written back. - **`--spec-eval` with `DS4_ROUND_LOG`:** the drafter's acceptance by position and confidence. - **`--sampler-test`:** a chi-square check that speculative sampling draws as the model does. - **`--parts-check`:** a prompt read in parts against one call, bit for bit. - **`tools/ds4/concurrent_check.py`:** conversations at once must not see each other's state. ## Measured One RTX 3090 + eight RTX 5060 Ti (`--tp 8` over a layer split), EXL3 3.5 bpw, two thirds of the experts in RAM, unless noted. - **Restore points:** an 18K-token chat with its last message edited reads 14 tokens instead of 18,055. The first token comes after 0.2 s instead of 15.0 s. The chat's first read costs about 1 s more. - **One-launch attention:** `--parallel 2 --multi-check`, expert cache off, gives the same logits bit for bit, 398 of 398 rows. 2 × 200 tokens go 43.9 → 49.3 tok/s in all without drafts and 52.0 → 56.3 with them (measured on v1.1.35). On this branch on top of v1.1.36: 52.7 tok/s together without drafts and 60.4 with them in one pass, every mode the same tokens as alone. - **GGUF kernels** (IST-DAS 1.75 bpw, IQ1_S / IQ1_M experts, 9 GPUs): decode 88.2 → 92.0 tok/s, the same 200 greedy tokens; the drafter's round 7.25 → 6.51 ms. - **AVX-512 rows** (the same pack on 3 GPUs, 70% of the experts on the CPU lane, Xeon Gold 6152): 35.4 → 36.9 tok/s, the same tokens. Single-thread, IQ2_XS 2.32 → 3.62 GB/s and IQ1_M 1.12 → 2.05 GB/s at one token. - **A prompt read in parts:** a 24K-token prompt joining a streaming answer, `MAYA_DS4_PROMPT_SHARE=0.5`. - The stream's longest stop is 18.5 s in one run, 5.9 s with parts of one chunk, and 11.9 s with parts of up to 8 s. - The prompt's first token comes after 18.7 s, 49.0 s and 38.5 s respectively. - The Engram read-ahead took the parts' Engram waits from 15.4 s to 3.1 s. - It trades the long prompt's time for the other conversation's longest stop, so it stays off by default. - **`DS4_DRAFT_COST` and `MAYA_DS4_PROMPT_SHARE`:** no gain in the two-request server test, so both stay opt-in. ## Tested - **Build:** `maya-ds4`, `maya` and `maya-mm3` build for sm_86 and sm_120 with no new warnings. - **CPU tests** (13 programs, all pass): - restore points; the parts scheduler; the Engram reader's priority; - Q8_0 rounding; the prompt / memory rules; `--pack-info`; - the AVX-512 rows against ggml (399 cases); the IQ1_M code table and IQ4_NL rows against ggml; - the draft policy (old and new); logprobs; the multi-attention layout; the RAM store (real O_DIRECT on ext4). - **Server tests:** `serve/test_logprobs.py` (19) and `serve/test_ds4_restore_points.py` (8). The 13 `test_responses_schema` failures happen on v1.1.36 too. - **GPU** (on the setup above): - `ds4_gguf_test`, including `--trims`, `--persist` and `--devices` on all 9 GPUs: all OK; - `ds4_multi_attn_test`: OK; - `--multi-check`: bit for bit; - `--parts-check` (a 24K-token prompt in 7 parts with another conversation stepped between): bit for bit; - the single-request path: the same tokens as before; - IST-DAS 1.75 and 2.00 bpw packs: `--pack-info` says they can load. - **Not built here:** HIP and Windows. --- <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:46 +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#641
No description provided.