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
iSWA: llama_memory_seq_rm returns true after a cut into overwritten SWA rows (swa_full=false), next decode silently wrong #31457
Observed at tag b6000 (4762ad7), CPU, via the library API (llama.h). llama_kv_cache_iswa::seq_rm on master (31 Oct 2026) still only ANDs the two caches' results, with no check against the window.
Problem
With swa_full = false (the common default, so llama-cli and llama-server run this way), an iSWA model's SWA cache holds about n_swa + n_ubatch cells and reuses the cells of masked positions. A later llama_memory_seq_rm(mem, seq, p0, -1) that cuts back into positions whose SWA rows were already overwritten returns true, and the next decode runs without those rows. llama.h documents seq_rm as "Returns false if a partial sequence cannot be removed", so a library caller gets no signal. llama-server avoids this with its own seq_pos_min check and re-processes the prompt; other callers do not.
Reproduction
Gemma 3-architecture GGUF with sliding window 4 on its local layers, f32 weights and KV cache, flash attention off, swa_full = false, n_ubatch = 4:
The 4 logits rows are 2.82 (absolute) away from a fresh prefill of the same 14 ids in llama.cpp itself, and the greedy token differs at all 4 positions. A cut to 40 (rows still held) is bit-identical to a fresh prefill; with swa_full = true, both cuts are; with the llama-server-style guard (llama_memory_seq_pos_min compared with n_past - n_swa, then re-prefill) the cut to 10 is bit-identical too.
Related but distinct: #16768 (seq_rm result unchecked in server), #26695 (recurrent rollback returns true without restoring state), #21831.
Expected behavior
seq_rm on an iSWA cache should return false when the rows that the next position's window would read are no longer held (so callers can re-prefill, as the server does), or the iSWA cache should refuse/clear the sequence rather than report success.
Hit this too on gemma3 with swa_full=false. I have a fix: iswa seq_rm now checks if the SWA cache still has the positions it needs and returns false without touching the sequence if not. Added a small test (fails before, passes after), test-llama-context still all green. Want me to open a PR?
Thanks for confirming it on Gemma 3, and for the test. Yes please, open the PR. Returning false so the caller can re-prefill is exactly the behaviour we hoped for.
Activity
kukirin-ui commentedon Oct 31, 2026
Hit this too on gemma3 with swa_full=false. I have a fix: iswa seq_rm now checks if the SWA cache still has the positions it needs and returns false without touching the sequence if not. Added a small test (fails before, passes after), test-llama-context still all green. Want me to open a PR?
JohnnyTeutonic commentedon Oct 31, 2026
Thanks for confirming it on Gemma 3, and for the test. Yes please, open the PR. Returning false so the caller can re-prefill is exactly the behaviour we hoped for.