Skip to content

Server forces full prompt re-processing on subsequent requests (SWA/recurrent memory error) #21831

Description

@asg-3d

Name and Version

$ ./llama-server --version
version: 8769 (21a4933)
built with Clang 19.1.5 for Windows x86_64
(Also reproduced on version 8025 (bb96bfd))

Operating systems

Windows

GGML backends

CUDA

Hardware

Intel Core i5-12400F + NVIDIA GeForce RTX 5060 Ti (16GB VRAM)

Models

Problem description & steps to reproduce

The llama-server fails to reuse the KV cache for subsequent requests in the same chat session. On the second request to the same slot, it forces a full prompt re-processing, logging: forcing full prompt re-processing due to lack of cache data (likely due to SWA or hybrid/recurrent memory). As a result, the model "forgets" the conversation history.

This occurs on different models (Qwen 3.5 MoE, Gemma 4 MoE), different llama.cpp versions (b8025, b8769), and even with minimal context (e.g., 45 tokens). The issue is reproducible with direct curl requests, ruling out client-side problems.

Steps to reproduce:

  1. Start llama-server with Qwen3.5-35B-A3B or Gemma-4-26B-A4B.
  2. Send first request:
    curl -X POST http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\": \"qwen3.5-35b-a3b-128k\", \"messages\": [{\"role\": \"user\", \"content\": \"My name is Tester. Remember it.\"}], \"temperature\": 0.6, \"max_tokens\": 50}"
  3. Send second request:
    curl -X POST http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\": \"qwen3.5-35b-a3b-128k\", \"messages\": [{\"role\": \"user\", \"content\": \"What is my name?\"}], \"temperature\": 0.6, \"max_tokens\": 50}"
  4. Observe server logs and model response.

Expected behavior:
Server restores context from KV cache; model answers "Tester".

Actual behavior:
Server logs forcing full prompt re-processing...; model responds that it does not know the name.

First Bad Commit

Unknown. The issue is present in both b8025 (month-old) and b8769 (latest). It likely predates both versions.

Relevant log output

# Command used to start the server (example for Qwen 3.5):
.\llama-server.exe --models-preset models.ini --host 127.0.0.1 --port 8080 --temp 1.0 --top-p 1.0 --min-p 0.01 --top-k 0 --reasoning-budget 0 --no-mmap --metrics

# First request (establish context):
curl -X POST http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\": \"qwen3.5-35b-a3b-128k\", \"messages\": [{\"role\": \"user\", \"content\": \"My name is Tester. Remember it.\"}], \"temperature\": 0.6, \"max_tokens\": 50}"

# Second request (check context):
curl -X POST http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\": \"qwen3.5-35b-a3b-128k\", \"messages\": [{\"role\": \"user\", \"content\": \"What is my name?\"}], \"temperature\": 0.6, \"max_tokens\": 50}"
Server log output (second request, v8769)
[50224] slot update_slots: id  3 | task 24 | 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)
[50224] slot update_slots: id  3 | task 24 | n_tokens = 0, memory_seq_rm [0, end)
[50224] slot update_slots: id  3 | task 24 | prompt processing progress, n_tokens = 12, batch.n_tokens = 12, progress = 0.750000
[50224] slot update_slots: id  3 | task 24 | prompt done, n_tokens = 18, batch.n_tokens = 18
[50224] slot print_timing: id  3 | task 24 |
[50224] prompt eval time =     317.59 ms /    18 tokens (   17.64 ms per token,    56.68 tokens per second)
[50224]        eval time =    2130.55 ms /    50 tokens (   42.61 ms per token,    23.47 tokens per second)
[50224]       total time =    2448.14 ms /    68 tokens
[50224] slot      release: id  3 | task 24 | stop processing: n_tokens = 67, truncated = 0
Model response (second request)
{"choices":[{"finish_reason":"length","index":0,"message":{"role":"assistant","content":"I don't know your name because I don't have access to your personal information unless you tell me.\n\nIf you'd like, you can tell me your name and I'll remember it for this conversation"}],"created":1776037749,"model":"qwen3.5-35b-a3b-128k","system_fingerprint":"b8769-21a493304","object":"chat.completion","usage":{"completion_tokens":50,"prompt_tokens":18,"total_tokens":68}}...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions