You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Eval bug: qwen35moe always forces a full prompt reprocess after each message, 'failed to truncate' #19690
version: 8070 (cc45f2a)
built with GNU 13.3.0 for Linux x86_64
Operating systems
Linux
GGML backends
CUDA
Hardware
Ryzen 9950x3d + 5090
Models
The issue presents with several quants of
Qwen3.5 397B
Problem description & steps to reproduce
When a generation is initiated, regardless if from the llama.cpp webui, sillytavern or other frontends, every generation regardless if it's a new reply or a swipe forces a full prompt reprocessing.
It is present since the commit adding support for qwen3.5moe
Relevant log output
slot get_availabl: id 3 | task -1 | selected slot by LCP similarity, sim_best = 1.000 (> 0.100 thold), f_keep = 0.838
slot launch_slot_: id 3 | task -1 | sampler chain: logits -> logit-bias -> top-k -> min-p -> ?temp-ext -> adaptive-p
slot launch_slot_: id 3 | task 427 | processing task, is_child = 0
slot update_slots: id 3 | task 427 | new prompt, n_ctx_slot = 96000, n_keep = 0, task.n_tokens = 2189
slot update_slots: id 3 | task 427 | need to evaluate at least 1 token for each active slot (n_past = 2189, task.n_tokens() = 2189)
slot update_slots: id 3 | task 427 | n_past was set to 2188
slot update_slots: id 3 | task 427 | n_tokens = 2188, memory_seq_rm [2188, end)
slot update_slots: id 3 | task 427 | failed to truncate tokens with position >= 2188 - clearing the memory
slot prompt_clear: id 3 | task 427 | clearing prompt with 2188 tokens
Reacted by Eduardo Fonseca, AlphaUrsaeMinoris, Alex, danielgue2, dzbydotpl, imnachar, Hanusz Leszek, Victor Nogueira, blumlaut, Enrique Cardona and 1 more
I think the issue is that for some reason even during times when it shouldn't, the model wants to fall back on context-checkpoints, which are disabled when an mmproj is loaded.
So there is probably something model specific going weird here as well.
I think the issue is that for some reason even during times when it shouldn't, the model wants to fall back on context-checkpoints, which are disabled when an mmproj is loaded.
So there is probably something model specific going weird here as well.
I'm sure there is. I have another machine running Kimi K2.5 with the mmproj file and this doesn't happen.
@LifesLight This is normal - we don't do checkpoints for such short prompts (208 tokens). The prompt has to be at least 512 tokens to create the checkpoint.
I'm sure there is. I have another machine running Kimi K2.5 with the mmproj file and this doesn't happen.
Qwen 3.5 is the first hybrid multi-modal model. Kimi K2.5 is not hybrid - i.e. it does not have a recurrent state.
@timkhronos The checkpointing logic can be improved. There is an issue for that: #19298. But all the reports here so far are solved by simply disabling mmproj.
Reacted by Eduardo Fonseca, Piotr Wilkin (ilintar) and timkhronos
@timkhronos To clarify your specific case, since it is a bit different from the rest. Basically, you observe that it recomputes the prompt even when continuing the last message, which on first glance does not need checkpoints.
The issue is that the server logic currently needs to always process at least one token prior to entering the "generation phase". Hence the message:
need to evaluate at least 1 token for each active slot (n_past = 2189, task.n_tokens() = 2189)
Technically, you are correct. It's just the server logic currently does not support this. There might be a way to fix this - I'll give it some thought.
@ggerganov You're right, using a larger ctx chat fixed re-building the cache when adding a new message, but saving and restoring the kv-cache is definitely not working (not sure if this is a different issue or related, but might be relevant):
Using --no-mmap, chat saved -> server restarted -> cache restored -> message appended
slot get_availabl: id 0 | task -1 | selected slot by LCP similarity, sim_best = 0.986 (> 0.100 thold), f_keep = 0.987
slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 0 | task 1 | processing task, is_child = 0
slot update_slots: id 0 | task 1 | new prompt, n_ctx_slot = 48128, n_keep = 0, task.n_tokens = 18605
slot update_slots: id 0 | task 1 | n_past = 18342, slot.prompt.tokens.size() = 18591, seq_id = 0, pos_min = 18590, n_swa = 1
slot update_slots: id 0 | task 1 | forcing full prompt re-processing due to lack of cache data (likely due to SWA or hybrid/recurrent memory, see https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055)
slot update_slots: id 0 | task 1 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id 0 | task 1 | prompt processing progress, n_tokens = 4096, batch.n_tokens = 4096, progress = 0.220156
I was thinking of adding a configurable option of allowing the creation of a recurrent snapshot every n batches during prompt processing (currently it's hardcoded at a specific point before the end), I'll try to give it a go when I'm done with the autoparser.
I think some of these issues with context checkpointing might be solved if we only create checkpoints right before starting text generation, not just whenever a llama_decode call is done (since that includes image chunks).
If I may.... Just to help to debug the problem, I ran the pwilkin's autoparser version with Unsloth Qwen3.5 397B A17B, and 262144 ctx. I wasn´t using mmproj.
When the prompt was around 65k (I was working with Roo Code), the truncate bug happened:
P.S. I just see the timkhronos' PR now. I'm gonna try it. ;-)
slot update_slots: id 0 | task 17430 | prompt processing progress, n_tokens = 65683, batch.n_tokens = 1024, progress = 0.983058
slot update_slots: id 0 | task 17430 | n_tokens = 65683, memory_seq_rm [65683, end)
slot update_slots: id 0 | task 17430 | prompt processing progress, n_tokens = 66303, batch.n_tokens = 620, progress = 0.992337
slot update_slots: id 0 | task 17430 | n_tokens = 66303, memory_seq_rm [66303, end)
slot update_slots: id 0 | task 17430 | prompt processing progress, n_tokens = 66815, batch.n_tokens = 512, progress = 1.000000
slot update_slots: id 0 | task 17430 | prompt done, n_tokens = 66815, batch.n_tokens = 512
slot init_sampler: id 0 | task 17430 | init sampler, took 12.21 ms, tokens: text = 66815, total = 66815
slot update_slots: id 0 | task 17430 | erasing old context checkpoint (pos_min = 31569, pos_max = 31569, size = 186.329 MiB)
slot update_slots: id 0 | task 17430 | created context checkpoint 8 of 8 (pos_min = 66302, pos_max = 66302, size = 186.329 MiB)
srv stop: cancel task, id_task = 17430
srv log_server_r: done request: POST /v1/chat/completions 192.168.0.4 200
srv params_from_: Chat format: peg-native
slot release: id 0 | task 17430 | stop processing: n_tokens = 66815, truncated = 0
slot get_availabl: id 0 | task -1 | selected slot by LCP similarity, sim_best = 1.000 (> 0.100 thold), f_keep = 1.000
slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> ?min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 0 | task 17439 | processing task, is_child = 0
slot update_slots: id 0 | task 17439 | new prompt, n_ctx_slot = 262144, n_keep = 0, task.n_tokens = 66815
slot update_slots: id 0 | task 17439 | need to evaluate at least 1 token for each active slot (n_past = 66815, task.n_tokens() = 66815)
slot update_slots: id 0 | task 17439 | n_past was set to 66814
slot update_slots: id 0 | task 17439 | n_tokens = 66814, memory_seq_rm [66814, end)
slot update_slots: id 0 | task 17439 | failed to truncate tokens with position >= 66814 - clearing the memory
slot prompt_clear: id 0 | task 17439 | clearing prompt with 66814 tokens
slot update_slots: id 0 | task 17439 | prompt processing progress, n_tokens = 1024, batch.n_tokens = 1024, progress = 0.015326
slot update_slots: id 0 | task 17439 | n_tokens = 1024, memory_seq_rm [1024, end)
slot update_slots: id 0 | task 17439 | prompt processing progress, n_tokens = 2048, batch.n_tokens = 1024, progress = 0.030652
slot update_slots: id 0 | task 17439 | n_tokens = 2048, memory_seq_rm [2048, end)
slot update_slots: id 0 | task 17439 | prompt processing progress, n_tokens = 3072, batch.n_tokens = 1024, progress = 0.045978
slot update_slots: id 0 | task 17439 | n_tokens = 3072, memory_seq_rm [3072, end)
slot update_slots: id 0 | task 17439 | prompt processing progress, n_tokens = 4096, batch.n_tokens = 1024, progress = 0.061304
There is a bug in Roo, very old one that they've masked pretty cleverly. The underlying Undici layer has a body timeout of 5 minutes. This is separate from the timeout in Roo, which is set on 10 minutes, and cannot be set by any means in Roo. They masked the problem by basically auto-resuming instantly if a BODY_TIMEOUT exception gets thrown.
See this?
srv stop: cancel task, id_task = 17430
This is the core problem. After this, the server wants to resume processing, but there's a problem with truncating just one token for some reason, so it clears the entire cache.
I think @ggerganov might chime in, but the two things I think can be done here is:
investigate why memory_seq_rm [66814, end) fails
if a truncation fails and we're in a model with hybrid checkpoints, try truncating from the previous checkpoint first instead of erasing the entire KV cache
@pwilkin Yes, this is the same as #19690 (comment). Recurrent models cannot erase tokens, so it is normal to fail. I think the fix is to improve the server logic to avoid needing at least one token to be processed.
Ah.... That explain it! Thanks @pwilkin ! And, I tested the @timkhronos PR and it worked! I ran until 129.054 tokens with mmproj without any problem. Thanks, Timkhronos!
Oh, you're using Roo! I know what the problem is.
There is a bug in Roo, very old one that they've masked pretty cleverly. The underlying Undici layer has a body timeout of 5 minutes. This is separate from the timeout in Roo, which is set on 10 minutes, and cannot be set by any means in Roo. They masked the problem by basically auto-resuming instantly if a BODY_TIMEOUT exception gets thrown......
I'm using llama.cpp via python binding (https://github.com/JamePeng/llama-cpp-python), and memory_seq_rm always fails in some relatively newer models.
The models causes the failure are Qwen3-Coder-Next and Nemotron 3 Nano.
Though I'm not 100% sure since i'm using llama.cpp via the binding while it seems simply porting memory_seq_rm, I wonder my situation is somewhat relating to this topic.
Anyone experiencing this problem with above models in addition to the newest Qwen3.5?
I haven't experienced that at all yet with Qwen3-Coder-Next, but with Qwen3.5 I'm getting a ton of cache invalidations with those same error messages:
slot get_availabl: id 0 | task -1 | selected slot by LCP similarity, sim_best = 0.986 (> 0.100 thold), f_keep = 1.000
slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> ?min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 0 | task 127 | processing task, is_child = 0
slot update_slots: id 0 | task 127 | new prompt, n_ctx_slot = 100096, n_keep = 0, task.n_tokens = 12186
slot update_slots: id 0 | task 127 | n_tokens = 12019, memory_seq_rm [12019, end)
slot update_slots: id 0 | task 127 | prompt processing progress, n_tokens = 12186, batch.n_tokens = 167, progress = 1.000000
slot update_slots: id 0 | task 127 | prompt done, n_tokens = 12186, batch.n_tokens = 167
slot init_sampler: id 0 | task 127 | init sampler, took 1.20 ms, tokens: text = 12186, total = 12186
slot update_slots: id 0 | task 127 | created context checkpoint 3 of 8 (pos_min = 12018, pos_max = 12018, size = 186.329 MiB)
slot print_timing: id 0 | task 127 |
prompt eval time = 6108.35 ms / 167 tokens ( 36.58 ms per token, 27.34 tokens per second)
eval time = 13476.44 ms / 210 tokens ( 64.17 ms per token, 15.58 tokens per second)
total time = 19584.79 ms / 377 tokens
slot release: id 0 | task 127 | stop processing: n_tokens = 12395, truncated = 0
srv update_slots: all slots are idle
srv log_server_r: done request: POST /v1/chat/completions 127.0.0.1 200
srv params_from_: Chat format: peg-constructed
slot get_availabl: id 0 | task -1 | selected slot by LRU, t_last = 341215298141
slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> ?min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 0 | task 338 | processing task, is_child = 0
slot update_slots: id 0 | task 338 | new prompt, n_ctx_slot = 100096, n_keep = 0, task.n_tokens = 12408
slot update_slots: id 0 | task 338 | erased invalidated context checkpoint (pos_min = 11435, pos_max = 11435, n_swa = 1, size = 186.329 MiB)
slot update_slots: id 0 | task 338 | erased invalidated context checkpoint (pos_min = 12018, pos_max = 12018, n_swa = 1, size = 186.329 MiB)
slot update_slots: id 0 | task 338 | n_tokens = 780, memory_seq_rm [780, end)
slot update_slots: id 0 | task 338 | failed to truncate tokens with position >= 780 - clearing the memory
slot prompt_clear: id 0 | task 338 | clearing prompt with 780 tokens
slot update_slots: id 0 | task 338 | prompt processing progress, n_tokens = 2048, batch.n_tokens = 2048, progress = 0.165055
This is a coding agent tool calling session, you can see that the first response log shows it reused the cached prompt but then when an append-only addition was made to the prompt and resent it clears everything and re-starts the processing (and for a model this size that is.. pretty painful).
On the flip side the identical test with Qwen3-Coder-Next continues into 30,000 tokens with cache hits on all responses.
I was thinking of adding a configurable option of allowing the creation of a recurrent snapshot every n batches during prompt processing (currently it's hardcoded at a specific point before the end), I'll try to give it a go when I'm done with the autoparser.
This is probably needed as there is a <think>\n\n</think>\n\n assistant prefill when thinking mode is off that isn't reproduced with further turns, breaking the assumption that next turns are prefixes of previous turns. The same issue happens with thinking on where the reasoning content before the last user prompt is discarded.
Activity
ebfio commentedon Feb 17, 2026
Can confirm, same thing happens to me.
LifesLight commentedon Feb 17, 2026
Same thing happening to me, I also tested saving and restoring the KV cache which resulted in this output:
ggerganov commentedon Feb 17, 2026
I can't run this model - do you see messages in the logs such as these:
ebfio commentedon Feb 17, 2026
@ggerganov no, I don't. I only see:
and
timkhronos commentedon Feb 17, 2026
Same here. I only see:
First gen:
regenerate:
next message:
ebfio commentedon Feb 17, 2026
A bit more context in sequence:
ggerganov commentedon Feb 17, 2026
Oh I see now. It's because this model is multi-modal:
llama.cpp/tools/server/server-context.cpp
Lines 2284 to 2287 in afa6bfe
I've left a TODO to fix that:
llama.cpp/tools/server/server-context.cpp
Lines 2336 to 2338 in afa6bfe
For now, you can disable the multi-modal part and it should be OK.
LifesLight commentedon Feb 17, 2026
I am running the model without the mmproj and it still exhibits the same issue.
Server Command:
Logs:
timkhronos commentedon Feb 17, 2026
@ggerganov
I think the issue is that for some reason even during times when it shouldn't, the model wants to fall back on context-checkpoints, which are disabled when an mmproj is loaded.
So there is probably something model specific going weird here as well.
ebfio commentedon Feb 17, 2026
I'm sure there is. I have another machine running Kimi K2.5 with the mmproj file and this doesn't happen.
ggerganov commentedon Feb 17, 2026
@LifesLight This is normal - we don't do checkpoints for such short prompts (208 tokens). The prompt has to be at least 512 tokens to create the checkpoint.
Qwen 3.5 is the first hybrid multi-modal model. Kimi K2.5 is not hybrid - i.e. it does not have a recurrent state.
@timkhronos The checkpointing logic can be improved. There is an issue for that: #19298. But all the reports here so far are solved by simply disabling mmproj.
ggerganov commentedon Feb 17, 2026
@timkhronos To clarify your specific case, since it is a bit different from the rest. Basically, you observe that it recomputes the prompt even when continuing the last message, which on first glance does not need checkpoints.
The issue is that the server logic currently needs to always process at least one token prior to entering the "generation phase". Hence the message:
Technically, you are correct. It's just the server logic currently does not support this. There might be a way to fix this - I'll give it some thought.
LifesLight commentedon Feb 17, 2026
@ggerganov You're right, using a larger ctx chat fixed re-building the cache when adding a new message, but saving and restoring the kv-cache is definitely not working (not sure if this is a different issue or related, but might be relevant):
Using
--no-mmap,chat saved -> server restarted -> cache restored -> message appendedpwilkin commentedon Feb 18, 2026
I was thinking of adding a configurable option of allowing the creation of a recurrent snapshot every
nbatches during prompt processing (currently it's hardcoded at a specific point before the end), I'll try to give it a go when I'm done with the autoparser.ddh0 commentedon Feb 18, 2026
I think some of these issues with context checkpointing might be solved if we only create checkpoints right before starting text generation, not just whenever a
llama_decodecall is done (since that includes image chunks).ChicoPinto70 commentedon Feb 20, 2026
If I may.... Just to help to debug the problem, I ran the pwilkin's autoparser version with Unsloth Qwen3.5 397B A17B, and 262144 ctx. I wasn´t using mmproj.
When the prompt was around 65k (I was working with Roo Code), the truncate bug happened:
P.S. I just see the timkhronos' PR now. I'm gonna try it. ;-)
pwilkin commentedon Feb 20, 2026
Oh, you're using Roo! I know what the problem is.
There is a bug in Roo, very old one that they've masked pretty cleverly. The underlying Undici layer has a body timeout of 5 minutes. This is separate from the timeout in Roo, which is set on 10 minutes, and cannot be set by any means in Roo. They masked the problem by basically auto-resuming instantly if a BODY_TIMEOUT exception gets thrown.
See this?
This is the core problem. After this, the server wants to resume processing, but there's a problem with truncating just one token for some reason, so it clears the entire cache.
I think @ggerganov might chime in, but the two things I think can be done here is:
memory_seq_rm [66814, end)failsggerganov commentedon Feb 20, 2026
@pwilkin Yes, this is the same as #19690 (comment). Recurrent models cannot erase tokens, so it is normal to fail. I think the fix is to improve the server logic to avoid needing at least one token to be processed.
NovNovikov commentedon Feb 20, 2026
I have the same issue on every swipe. Multimodality is not used.
slot update_slots: id 0 | task 26232 | new prompt, n_ctx_slot = 163840, n_keep = 0, task.n_tokens = 33981 slot update_slots: id 0 | task 26232 | n_past = 15157, slot.prompt.tokens.size() = 34874, seq_id = 0, pos_min = 34873, n_swa = 1 slot update_slots: id 0 | task 26232 | forcing full prompt re-processing due to lack of cache data (likely due to SWA or hybrid/recurrent memory, see https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055)ChicoPinto70 commentedon Feb 20, 2026
Ah.... That explain it! Thanks @pwilkin ! And, I tested the @timkhronos PR and it worked! I ran until 129.054 tokens with mmproj without any problem. Thanks, Timkhronos!
yamikumo-DSD commentedon Feb 21, 2026
I'm using llama.cpp via python binding (https://github.com/JamePeng/llama-cpp-python), and
memory_seq_rmalways fails in some relatively newer models.The models causes the failure are Qwen3-Coder-Next and Nemotron 3 Nano.
Though I'm not 100% sure since i'm using llama.cpp via the binding while it seems simply porting
memory_seq_rm, I wonder my situation is somewhat relating to this topic.Anyone experiencing this problem with above models in addition to the newest Qwen3.5?
lreeves commentedon Feb 23, 2026
I haven't experienced that at all yet with Qwen3-Coder-Next, but with Qwen3.5 I'm getting a ton of cache invalidations with those same error messages:
This is a coding agent tool calling session, you can see that the first response log shows it reused the cached prompt but then when an append-only addition was made to the prompt and resent it clears everything and re-starts the processing (and for a model this size that is.. pretty painful).
On the flip side the identical test with Qwen3-Coder-Next continues into 30,000 tokens with cache hits on all responses.
theo77186 commentedon Feb 25, 2026
This is probably needed as there is a
<think>\n\n</think>\n\nassistant prefill when thinking mode is off that isn't reproduced with further turns, breaking the assumption that next turns are prefixes of previous turns. The same issue happens with thinking on where the reasoning content before the last user prompt is discarded.server: fix context checkpoint restore for hybrid/recurrent models
fix: prevent full prompt re-processing for hybrid SSM models