[PR #657] DS4: a checkpoint at every turn (MAYA_DS4_CKPTS), so an edit or a branch back reads on from there #653

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/657
Author: @mgabor3141
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: ds4-turn-checkpoints


📝 Commits (1)

  • e8fdaf8 DS4: a checkpoint at every turn (MAYA_DS4_CKPTS, 16): the state where each turn starts, taken at the start of a prompt that continues an earlier one and before each user or tool-result message inside a prompt read in a run of chunks, kept in the model (per conversation under --parallel) and in the slot, at least 512 tokens apart, the newest 4 kept past the cap; an edited message or a branch back some turns reads on from there instead of the anchor. 4x RTX 3090, 26K conversation: edit 24.2 -> 12.3 s, back to turn 3/5 11.5/18.0 -> 0.6 s, from a slot or the folder 15.9/23.4 -> 0.6 s; decode and prompt speed unchanged (#606)

📊 Changes

4 files changed (+214 additions, -74 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -0)
📝 src/ds4/ds4_main.cpp (+7 -2)
📝 src/ds4/ds4_model.cu (+196 -72)
📝 src/ds4/ds4_model.hpp (+10 -0)

📄 Description

Closes #606.

A DeepSeek conversation can be resumed only at its last prompt's end, the position before it, or the anchor. An edited message or a client going back some turns therefore re-reads everything from the anchor or token 0.

This keeps the state where each turn starts as well, up to MAYA_DS4_CKPTS (default 16, max 64, 0 off), in the model and in the slot. slot_take already picks the latest usable checkpoint, so nothing changes there.

  • When: at the start of a prompt that continues an earlier one, and, during a chunked read, before each <|User|> token (user messages and tool results). The mid-read marks are off when YOCO cuts rows.
  • How many: at least 512 tokens apart. Past the cap the newest 4 stay and the older ones are thinned evenly.
  • --parallel: kept per conversation (moved by seq_park/seq_unpark).
  • Cost: about 3 MB each with Maya-S, one device-to-host copy per checkpoint.

Results: 4x RTX 3090, Maya-S, main (v1.1.36), --parallel 2, MAYA_DS4_SLOT_KEEP=1. The test conversation has 6 turns of about 4K tokens, each giving a code. Each branch asks for all codes so far.

main this PR
edit the last message 24.2 s (21,847 tokens read) 12.3 s (4,576)
back to turn 3 / turn 5 11.5 / 18.0 s 0.6 / 0.6 s
back to turn 4 from a slot 15.9 s 0.6 s
back to turn 6 after a restart (slot folder) 23.4 s 0.6 s
decode prose / code, 101K prompt 30.9 / 33.4, 1,219 tok/s 30.0 / 33.4, 1,216 tok/s

Every answer listed the right codes on both builds. Without the patch, each case resumed at the anchor.

Compatibility:

  • An engine without this deletes slots with more than 3 checkpoints, so after a downgrade those conversations are read once more.
  • With 0, no turn checkpoints are taken, but the last-row snapshot now goes through the same capture path, so it isn't bit-for-bit the old code.
  • HIP is untested.

🔄 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/657 **Author:** [@mgabor3141](https://github.com/mgabor3141) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ds4-turn-checkpoints` --- ### 📝 Commits (1) - [`e8fdaf8`](https://github.com/mw00/project-maya/commit/e8fdaf8c5842272259fb46fc23da362414c7ccad) DS4: a checkpoint at every turn (MAYA_DS4_CKPTS, 16): the state where each turn starts, taken at the start of a prompt that continues an earlier one and before each user or tool-result message inside a prompt read in a run of chunks, kept in the model (per conversation under --parallel) and in the slot, at least 512 tokens apart, the newest 4 kept past the cap; an edited message or a branch back some turns reads on from there instead of the anchor. 4x RTX 3090, 26K conversation: edit 24.2 -> 12.3 s, back to turn 3/5 11.5/18.0 -> 0.6 s, from a slot or the folder 15.9/23.4 -> 0.6 s; decode and prompt speed unchanged (#606) ### 📊 Changes **4 files changed** (+214 additions, -74 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/ds4/ds4_main.cpp` (+7 -2) 📝 `src/ds4/ds4_model.cu` (+196 -72) 📝 `src/ds4/ds4_model.hpp` (+10 -0) </details> ### 📄 Description Closes #606. A DeepSeek conversation can be resumed only at its last prompt's end, the position before it, or the anchor. An edited message or a client going back some turns therefore re-reads everything from the anchor or token 0. This keeps the state where each turn starts as well, up to `MAYA_DS4_CKPTS` (default 16, max 64, `0` off), in the model and in the slot. `slot_take` already picks the latest usable checkpoint, so nothing changes there. - **When:** at the start of a prompt that continues an earlier one, and, during a chunked read, before each `<|User|>` token (user messages and tool results). The mid-read marks are off when YOCO cuts rows. - **How many:** at least 512 tokens apart. Past the cap the newest 4 stay and the older ones are thinned evenly. - **`--parallel`:** kept per conversation (moved by `seq_park`/`seq_unpark`). - **Cost:** about 3 MB each with Maya-S, one device-to-host copy per checkpoint. **Results:** 4x RTX 3090, Maya-S, main (v1.1.36), `--parallel 2`, `MAYA_DS4_SLOT_KEEP=1`. The test conversation has 6 turns of about 4K tokens, each giving a code. Each branch asks for all codes so far. | | main | this PR | |---|---:|---:| | edit the last message | 24.2 s (21,847 tokens read) | 12.3 s (4,576) | | back to turn 3 / turn 5 | 11.5 / 18.0 s | 0.6 / 0.6 s | | back to turn 4 from a slot | 15.9 s | 0.6 s | | back to turn 6 after a restart (slot folder) | 23.4 s | 0.6 s | | decode prose / code, 101K prompt | 30.9 / 33.4, 1,219 tok/s | 30.0 / 33.4, 1,216 tok/s | Every answer listed the right codes on both builds. Without the patch, each case resumed at the anchor. **Compatibility:** - An engine without this deletes slots with more than 3 checkpoints, so after a downgrade those conversations are read once more. - With `0`, no turn checkpoints are taken, but the last-row snapshot now goes through the same capture path, so it isn't bit-for-bit the old code. - HIP is untested. --- <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 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#653
No description provided.