mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #572] glm: keep the snapshot before the generation prompt, not before the last token #604
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#604
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/572
Author: @rushisan
Created: 10/27/2026
Status: 🔄 Open
Base:
main← Head:glm-snapshot-before-generation-prompt📝 Commits (1)
42b3e69glm: keep the snapshot before the generation prompt, not before the last token📊 Changes
2 files changed (+29 additions, -12 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
src/program/generate.cpp(+28 -12)📄 Description
Problem
The snapshot (the state the next turn continues from) is saved before the prompt's last token. A GLM prompt ends with its generation prompt,
<|assistant|><think>(or<think></think>with thinking off), so the snapshot holds... <|assistant|>. That is fine when the next prompt carries the answer (<|assistant|>is there again), but not when it doesn't:<|user|>where the snapshot has<|assistant|>. While the conversation is still in the model the turn-start checkpoint covers this, but once another conversation has taken the model the conversation's slot is not a prefix of the new prompt any more and the whole prompt is read again.On our server (2x RTX 3080, two agents on one engine, prompts of 115-180K tokens) that was 2-3 minutes of prefill per occurrence, often enough to time out the client again.
Change
prep_promptsaves the snapshot before the trailing<|assistant|>(looked for in the last 4 tokens, at or pastreuse) instead of before the last token; the prompt path reads up to there and the token path reads the 2-3 tokens of the generation prompt. Everything that continued the old snapshot continues the new one: the next turn, a tool result, the same prompt again (it now reads 3 tokens instead of 1).MAYA_GLM_SNAP_GEN=0restores the old position; a row indocs/SETTINGS.md.The several-conversation path (
--parallel) is unchanged. No CUDA calls, no change to the model arithmetic or the slot / checkpoint formats.Measured
v1.1.33, 4x RTX 2080 Ti 22 GB (sm_75, CUDA 12.2), 2x Xeon E5-2673 v4, 247 GB RAM, GLM-5.3 · Maya-S24, 131072 context, one conversation, greedy, thinking off,
MAYA_GLM_CKPTS=16. Same binary, the setting on and off;cache_nfrom the response timings:MAYA_GLM_SNAP_GEN=1=0(before)The same scenarios on 2x RTX 3080 (huihui's abliterated GLM-5.3-Flash UD-Q4_K_XL, 1M context,
--kv int8, layer split) give the same numbers. Answers are unchanged: the tokens the model reads are the same, only the position the state is saved at moves.Not measured: Windows / AMD (no code specific to them is touched).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.