[PR #253] [MERGED] GLM: keep the snapshot as a checkpoint when the next turn starts right after it - an edit of the last message after a short reply 21.5 -> 1.0 s #427

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/253
Author: @merbanan
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00

Base: main ← Head: pr/ckpt-turn


📝 Commits (1)

  • 1019221 glm: keep the previous prompt's snapshot as a checkpoint when the new turn starts right after it

📊 Changes

5 files changed (+102 additions, -2 deletions)

View changed files

📝 include/strata/core/glm_model.hpp (+7 -0)
📝 src/core/glm_fast_path.cu (+74 -0)
📝 src/core/glm_model.cu (+1 -0)
📝 src/core/glm_multi.cu (+1 -0)
📝 src/program/generate.cpp (+19 -2)

📄 Description

The gap: a prompt that continues from the snapshot and opens its last turn (<|user|> / <|observation|>) within 512 tokens of it gets no conversation checkpoint at that turn, because ckpt_marks wants 512 fresh tokens before a mark. A short reply puts the turn mark that close to the snapshot. Editing that last message (or regenerating with a changed message) then reads the whole conversation from token 0.

The fix: in that case the snapshot itself (the previous prompt but its last token, a few tokens before the turn) is kept as a checkpoint. It is copied from VRAM to host RAM on a side thread while the new prompt runs. The snapshot stays intact until that prompt's snapshot_save, which waits for the copy, as do ckpt_save / ckpt_restore / slot_load / seq_bind / teardown. The copy costs the prompt nothing. STRATA_GLM_CKPT_TURN=0 turns it off.

Measured on this branch (v1.1.15 + this), one V100, GLM-5.3-Flash Maya-S24, two rounds

Setup: a 13.5K-token chat, a 16-token reply, then a 6.4K-token turn (A2). Then:

  • (B) the next turn as a client sends it, with the reply's thinking dropped;
  • (C) the last user message edited.
CKPT_TURN=1 (this) CKPT_TURN=0 (before) STRATA_GLM_CKPTS=0
C: edit of the last message 0.99 / 0.98 s 21.5 / 21.6 s 21.1 s
A2: the 6.4K turn 10.77 / 10.87 s 10.84 / 10.85 s 10.86 s
B: the next turn 488 / 480 ms 480 / 487 ms 487 ms
  • C reads 29 of its 13,548 tokens; the other 13,519 come from the checkpoint.
  • C's 8 greedy tokens and B's 5 are the same as the full reread's in every run.
  • The side-thread copy is 152.7 MB in 27-38 ms.

🔄 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/253 **Author:** [@merbanan](https://github.com/merbanan) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr/ckpt-turn` --- ### 📝 Commits (1) - [`1019221`](https://github.com/mw00/project-maya/commit/10192212ead937bbc2cc94b3895a5e8eb604cde4) glm: keep the previous prompt's snapshot as a checkpoint when the new turn starts right after it ### 📊 Changes **5 files changed** (+102 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/glm_model.hpp` (+7 -0) 📝 `src/core/glm_fast_path.cu` (+74 -0) 📝 `src/core/glm_model.cu` (+1 -0) 📝 `src/core/glm_multi.cu` (+1 -0) 📝 `src/program/generate.cpp` (+19 -2) </details> ### 📄 Description **The gap:** a prompt that continues from the snapshot and opens its last turn (`<|user|>` / `<|observation|>`) within 512 tokens of it gets no conversation checkpoint at that turn, because `ckpt_marks` wants 512 fresh tokens before a mark. A short reply puts the turn mark that close to the snapshot. Editing that last message (or regenerating with a changed message) then reads the whole conversation from token 0. **The fix:** in that case the snapshot itself (the previous prompt but its last token, a few tokens before the turn) is kept as a checkpoint. It is copied from VRAM to host RAM on a side thread while the new prompt runs. The snapshot stays intact until that prompt's `snapshot_save`, which waits for the copy, as do `ckpt_save` / `ckpt_restore` / `slot_load` / `seq_bind` / teardown. The copy costs the prompt nothing. `STRATA_GLM_CKPT_TURN=0` turns it off. ### Measured on this branch (v1.1.15 + this), one V100, GLM-5.3-Flash Maya-S24, two rounds Setup: a 13.5K-token chat, a 16-token reply, then a 6.4K-token turn (A2). Then: - (B) the next turn as a client sends it, with the reply's thinking dropped; - (C) the last user message edited. | | CKPT_TURN=1 (this) | CKPT_TURN=0 (before) | STRATA_GLM_CKPTS=0 | |---|---:|---:|---:| | C: edit of the last message | **0.99 / 0.98 s** | 21.5 / 21.6 s | 21.1 s | | A2: the 6.4K turn | 10.77 / 10.87 s | 10.84 / 10.85 s | 10.86 s | | B: the next turn | 488 / 480 ms | 480 / 487 ms | 487 ms | - C reads 29 of its 13,548 tokens; the other 13,519 come from the checkpoint. - C's 8 greedy tokens and B's 5 are the same as the full reread's in every run. - The side-thread copy is 152.7 MB in 27-38 ms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:25:16 +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#427
No description provided.