Skip to content

Eval bug: DeepSeek V4 Flash forgot context when hit cache or use checkpoint in long context #25259

Description

@wenyifancc

Name and Version

llama-server --version
version: 9860 (fdb1db8)
built with Clang 20.1.8 for Windows x86_64

Operating systems

Windows

GGML backends

Vulkan

Hardware

RAM: 192GB DDR5
GPU: RTX5090 32GB VRAM
CPU: Intel Ultra 265K

Models

Deepseek-v4-Flash-MXFP4_MOE.gguf is converted from convert_hf_to_gguf.py

Problem description & steps to reproduce

In long-context scenarios, the model forgets previous content when hitting the cache or a checkpoint.

Step to reproduction:

  1. Run llama-server with following command:
    Command:
    set GGML_VK_ALLOW_SYSMEM_FALLBACK=1
    llama-server.exe --ctx-size 131072 --flash-attn on -fitc 131072 --model D:\deepseek-v4-flash\Deepseek-v4-Flash-MXFP4_MOE.gguf --temp 1 --top-p 1 --host 0.0.0.0 --port 10001 -a Deepseek-V4-Flash -b 2048 -ub 2048 --jinja --cpu-moe

  2. POST /v1/chat/completions with a long context conversation
    POST http://192.168.3.252:10001/v1/chat/completions
    body is attached as request.json
    request.json

  3. Model response as correct answer: detective

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "You asked me to play the role of a detective—specifically, to find clues based on the information you provided and identify the suspect. I did exactly that in my previous response, analyzing the case and concluding that Lord Alistair Greene is the primary suspect.",
        "reasoning_content": "We need to parse the user's question: \"What role did I just ask you to play?\" The user is referring to the initial instruction at the beginning of the conversation. The user said: \"You need to play the role of a detective, find clues based on the information provided by the user, and identify the suspect.\" Then the user provided a long narrative. The assistant responded with a detective analysis and conclusion. Now the user is asking: \"What role did I just ask you to play?\" This is a meta-question. The assistant should answer directly: the user asked the assistant to play the role of a detective. The assistant did so. So the answer is straightforward."
      }
    }
  ],
  "created": 1783058537,
  "model": "Deepseek-V4-Flash",
  "system_fingerprint": "b9860-fdb1db877",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 193,
    "prompt_tokens": 6315,
    "total_tokens": 6508,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  },
  "id": "chatcmpl-8HCJ7jXFzgkIcuJ0w5ielsroqOmfYj6v",
  "timings": {
    "cache_n": 0,
    "prompt_n": 6315,
    "prompt_ms": 115598.939,
    "prompt_per_token_ms": 18.305453523357087,
    "prompt_per_second": 54.62852907326424,
    "predicted_n": 193,
    "predicted_ms": 20032.546,
    "predicted_per_token_ms": 103.79557512953367,
    "predicted_per_second": 9.634322067699234
  }
}
  1. POST again with same request and model response with wrong answer:
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "In my previous response, I was acting based on the scenario you set up: you asked me to play the role of **a person (or investigator) who possesses a USB drive containing evidence against Paul Thayer**, and you wanted me to advise on what to do with that evidence. I then outlined steps such as forwarding the evidence to independent journalists and law enforcement outside Thayer's influence, as if I were that character.\n\nYour current query asks me to clarify what role you assigned me. The role was: **a character in a conspiracy scenario involving Paul Thayer and a USB drive**, with the expectation that I would provide in-character advice on how to handle the situation.",
        "reasoning_content": "We need to parse the user's query: \"What role did I just ask you to play?\" The user is referring to my previous response where I stated: \"Immediately forward the USB evidence to independent journalists and law enforcement agencies outside Greene's influence. Proceed with public exposure as planned. Further arrests pending.\" But this seems like a continuation of a scenario or role I was playing. The user is now asking me to clarify what role I was playing in that previous response. \n\nI should recognize that my previous response was given in the context of a hypothetical or narrative where I was acting as an assistant providing a recommendation in a specific situation (perhaps about dealing with some evidence). However, since the user now asks \"What role did I just ask you to play?\" I need to reconsider: The user might have set up a role or scenario before that I am supposed to adhere to, but I don't have that context in my memory because the previous response was my own. The user might be testing my consistency or pointing out a mistake in my role adherence.\n\nLet me think: The user's query is \"What role did I just ask you to play?\" This could be a meta-question about the role they assigned to me earlier in the conversation. Since I don't have the full conversation history beyond the immediate exchange, I need to infer. In my previous response, I acted as if I were providing a plan (\"Immediately forward the USB evidence...\"). That suggests the user had asked me to play a role of a person involved in some situation (perhaps a character or an AI with a specific directive). The user is now asking me to identify that role.\n\nI should answer directly: The user asked me to play the role of \"a helpful assistant\" or \"a character in a scenario\"? No, the user's previous message to me was: \"I'm investigating a conspiracy involving Paul Thayer and a USB drive. What should I do?\" Or perhaps something else? Wait, I need to recall. Actually, I don't have the user's previous message in this thought process; I only have the last two messages: my previous response and the user's current query. So I must reconstruct: The user's query \"What role did I just ask you to play?\" implies that in the message before my previous response, the user gave me a specific role. My previous response then addressed that role. But I don't have that initial message. I need to assume that the user's initial instruction (the one before my previous response) was something like: \"You are a character in a conspiracy thriller. You have a USB drive with evidence. What do you do?\" or \"You are an assistant to an investigator.\" But the user's current query says \"What role did I just ask you to play?\" which indicates that the user explicitly stated a role in that message. \n\nGiven that my previous response started with \"Immediately forward the USB evidence...\" it sounds like I was responding to a scenario. So the role I was playing was likely \"a character in a conspiracy investigation\" or \"an AI assistant with a mission.\" But the user is now asking for clarification. I should answer: \"You asked me to play the role of a person involved in a conspiracy involving Paul Thayer and a USB drive, and to advise on what to do with the evidence.\" Or perhaps simply: \"You asked me to be an investigator or a character in a scenario.\" But to be precise, I need to state what the user said.\n\nSince I don't have the user's exact words, I can only infer. In my previous response, I said \"Immediately forward the USB evidence to independent journalists and law enforcement agencies outside Paul Thayer's influence.\" So the user likely said something like: \"You are in possession of a USB drive with evidence against Paul Thayer. What should you do?\" and I answered that. Now the user is asking \"What role did I just ask you to play?\" meaning: what character or identity did I assign you? I would respond: \"You asked me to play the role of a person who has a USB drive containing evidence against Paul Thayer and who is seeking advice on how to proceed.\" \n\nBut wait: The user's phrasing \"What role did I just ask you to play?\" could also be a test to see if I remember the context. I should answer confidently: \"You asked me to play the role of a character in a conspiracy investigation involving Paul Thayer and a USB drive.\" However, I need to be accurate. Perhaps the user said: \"You are a detective. What do you do with the USB evidence?\" I'll go with that.\n\nGiven that I am an AI, I should state: \"In your previous message, you asked me to play the role of a person involved in a scenario where I have a USB drive containing evidence about Paul Thayer, and you asked me what I should do. I responded as if I were that person.\" Then answer the question directly."
      }
    }
  ],
  "created": 1783058874,
  "model": "Deepseek-V4-Flash",
  "system_fingerprint": "b9860-fdb1db877",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 1153,
    "prompt_tokens": 6315,
    "total_tokens": 7468,
    "prompt_tokens_details": {
      "cached_tokens": 6302
    }
  },
  "id": "chatcmpl-VVVgSgO1pYO0gdrlrnjOsDxVM6acbcu6",
  "timings": {
    "cache_n": 6302,
    "prompt_n": 13,
    "prompt_ms": 653.502,
    "prompt_per_token_ms": 50.26938461538461,
    "prompt_per_second": 19.892823587379993,
    "predicted_n": 1153,
    "predicted_ms": 118810.793,
    "predicted_per_token_ms": 103.04492020815265,
    "predicted_per_second": 9.704505549424285
  }
}
  1. POST again with cache_prompt: false parameter , model response with a correct answer:
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "You asked me to play the role of a detective.",
        "reasoning_content": "We need to recall the initial instruction. The user said: \"You need to play the role of a detective, find clues based on the information provided by the user, and identify the suspect.\" Then the user provided a long narrative. My response was a detective analysis concluding the suspect. Now the user asks: \"What role did I just ask you to play?\" This is a meta question. The user is asking me to identify the role they assigned to me at the start. I should answer directly: \"You asked me to play the role of a detective.\""
      }
    }
  ],
  "created": 1783059050,
  "model": "Deepseek-V4-Flash",
  "system_fingerprint": "b9860-fdb1db877",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 126,
    "prompt_tokens": 6315,
    "total_tokens": 6441,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  },
  "id": "chatcmpl-508IwmmQH16eyTQPTg42o0c8nLufaIcA",
  "timings": {
    "cache_n": 0,
    "prompt_n": 6315,
    "prompt_ms": 45353.606,
    "prompt_per_token_ms": 7.1818853523357085,
    "prompt_per_second": 139.2392040447677,
    "predicted_n": 126,
    "predicted_ms": 12875.466,
    "predicted_per_token_ms": 102.1862380952381,
    "predicted_per_second": 9.786053568857236
  }
}

Key points:

  1. Requires a long conversation to trigger a checkpoint in order to reproduce the issue.
  2. Works correctly when caching is disabled.

First Bad Commit

No response

Relevant log output

0.35.784.356 I srv load_model: initializing, n_slots = 4, n_ctx_slot = 131072, kv_unified = 'true'
0.35.802.728 I srv llama_server: model loaded
0.35.802.733 I srv llama_server: listening on http://0.0.0.0:10001
0.39.751.637 I slot get_availabl: id 3 | task -1 | selected slot by LRU, t_last = -1
0.39.751.675 I slot launch_slot_: id 3 | task 0 | processing task, is_child = 0
1.02.074.890 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 76, progress = 0.01, t = 22.13 s / 3.43 tokens per second
1.44.868.546 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 2124, progress = 0.34, t = 64.92 s / 32.72 tokens per second
2.14.455.636 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 4172, progress = 0.66, t = 94.51 s / 44.14 tokens per second
2.21.079.552 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 4267, progress = 0.68, t = 101.13 s / 42.19 tokens per second
2.34.896.448 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 6302, progress = 1.00, t = 114.95 s / 54.82 tokens per second
2.35.295.976 I slot print_timing: id 3 | task 0 | prompt processing, n_tokens = 6311, progress = 1.00, t = 115.35 s / 54.71 tokens per second
2.45.900.685 I slot print_timing: id 3 | task 0 | n_decoded = 100, tg = 9.66 t/s, tg_3s = 9.66 t/s
2.48.907.438 I slot print_timing: id 3 | task 0 | n_decoded = 129, tg = 9.65 t/s, tg_3s = 9.64 t/s
2.52.012.963 I slot print_timing: id 3 | task 0 | n_decoded = 159, tg = 9.66 t/s, tg_3s = 9.66 t/s
2.55.055.149 I slot print_timing: id 3 | task 0 | n_decoded = 188, tg = 9.64 t/s, tg_3s = 9.53 t/s
2.55.578.076 I slot print_timing: id 3 | task 0 | prompt eval time = 115598.94 ms / 6315 tokens ( 18.31 ms per token, 54.63 tokens per second)
2.55.578.081 I slot print_timing: id 3 | task 0 | eval time = 20032.55 ms / 193 tokens ( 103.80 ms per token, 9.63 tokens per second)
2.55.578.082 I slot print_timing: id 3 | task 0 | total time = 135631.48 ms / 6508 tokens
2.55.578.083 I slot print_timing: id 3 | task 0 | graphs reused = 190
2.55.578.576 I slot release: id 3 | task 0 | stop processing: n_tokens = 6507, truncated = 0
5.31.506.974 I slot get_availabl: id 3 | task -1 | selected slot by LCP similarity, sim_best = 1.000 (> 0.100 thold), f_keep = 0.970
5.31.507.076 I slot launch_slot_: id 3 | task 201 | processing task, is_child = 0
5.42.773.014 I slot print_timing: id 3 | task 201 | n_decoded = 100, tg = 9.72 t/s, tg_3s = 9.72 t/s
5.45.786.107 I slot print_timing: id 3 | task 201 | n_decoded = 129, tg = 9.70 t/s, tg_3s = 9.62 t/s
5.48.893.250 I slot print_timing: id 3 | task 201 | n_decoded = 159, tg = 9.69 t/s, tg_3s = 9.66 t/s
5.51.994.091 I slot print_timing: id 3 | task 201 | n_decoded = 189, tg = 9.69 t/s, tg_3s = 9.67 t/s
5.55.049.644 I slot print_timing: id 3 | task 201 | n_decoded = 218, tg = 9.66 t/s, tg_3s = 9.49 t/s
5.55.764.670 I slot print_timing: id 3 | task 201 | prompt eval time = 706.58 ms / 13 tokens ( 54.35 ms per token, 18.40 tokens per second)
5.55.764.674 I slot print_timing: id 3 | task 201 | eval time = 23283.05 ms / 225 tokens ( 103.48 ms per token, 9.66 tokens per second)
5.55.764.675 I slot print_timing: id 3 | task 201 | total time = 23989.63 ms / 238 tokens
5.55.764.677 I slot print_timing: id 3 | task 201 | graphs reused = 408
5.55.764.895 I slot release: id 3 | task 201 | stop processing: n_tokens = 6539, truncated = 0
6.33.004.571 I slot get_availabl: id 3 | task -1 | selected slot by LCP similarity, sim_best = 1.000 (> 0.100 thold), f_keep = 0.966
6.33.004.683 I slot launch_slot_: id 3 | task 428 | processing task, is_child = 0
6.44.303.949 I slot print_timing: id 3 | task 428 | n_decoded = 100, tg = 9.71 t/s, tg_3s = 9.71 t/s
6.47.305.249 I slot print_timing: id 3 | task 428 | n_decoded = 129, tg = 9.70 t/s, tg_3s = 9.66 t/s
6.50.378.241 I slot print_timing: id 3 | task 428 | n_decoded = 159, tg = 9.71 t/s, tg_3s = 9.76 t/s
6.53.381.378 I slot print_timing: id 3 | task 428 | n_decoded = 188, tg = 9.70 t/s, tg_3s = 9.66 t/s
6.56.427.449 I slot print_timing: id 3 | task 428 | n_decoded = 217, tg = 9.68 t/s, tg_3s = 9.52 t/s
6.59.512.492 I slot print_timing: id 3 | task 428 | n_decoded = 247, tg = 9.68 t/s, tg_3s = 9.72 t/s
7.02.592.500 I slot print_timing: id 3 | task 428 | n_decoded = 277, tg = 9.69 t/s, tg_3s = 9.74 t/s
7.05.676.094 I slot print_timing: id 3 | task 428 | n_decoded = 307, tg = 9.69 t/s, tg_3s = 9.73 t/s
7.08.748.280 I slot print_timing: id 3 | task 428 | n_decoded = 337, tg = 9.70 t/s, tg_3s = 9.76 t/s
7.11.779.898 I slot print_timing: id 3 | task 428 | n_decoded = 366, tg = 9.69 t/s, tg_3s = 9.57 t/s
7.14.882.128 I slot print_timing: id 3 | task 428 | n_decoded = 396, tg = 9.69 t/s, tg_3s = 9.67 t/s
7.17.947.184 I slot print_timing: id 3 | task 428 | n_decoded = 426, tg = 9.69 t/s, tg_3s = 9.79 t/s
7.21.002.941 I slot print_timing: id 3 | task 428 | n_decoded = 456, tg = 9.70 t/s, tg_3s = 9.82 t/s
7.24.030.559 I slot print_timing: id 3 | task 428 | n_decoded = 485, tg = 9.69 t/s, tg_3s = 9.58 t/s
7.27.115.338 I slot print_timing: id 3 | task 428 | n_decoded = 515, tg = 9.70 t/s, tg_3s = 9.72 t/s
7.30.189.661 I slot print_timing: id 3 | task 428 | n_decoded = 545, tg = 9.70 t/s, tg_3s = 9.76 t/s
7.33.265.510 I slot print_timing: id 3 | task 428 | n_decoded = 575, tg = 9.70 t/s, tg_3s = 9.75 t/s
7.36.289.620 I slot print_timing: id 3 | task 428 | n_decoded = 604, tg = 9.70 t/s, tg_3s = 9.59 t/s
7.39.294.023 I slot print_timing: id 3 | task 428 | n_decoded = 633, tg = 9.69 t/s, tg_3s = 9.65 t/s
7.42.367.501 I slot print_timing: id 3 | task 428 | n_decoded = 663, tg = 9.70 t/s, tg_3s = 9.76 t/s
7.45.423.177 I slot print_timing: id 3 | task 428 | n_decoded = 693, tg = 9.70 t/s, tg_3s = 9.82 t/s
7.48.490.433 I slot print_timing: id 3 | task 428 | n_decoded = 723, tg = 9.71 t/s, tg_3s = 9.78 t/s
7.51.512.110 I slot print_timing: id 3 | task 428 | n_decoded = 752, tg = 9.70 t/s, tg_3s = 9.60 t/s
7.54.593.050 I slot print_timing: id 3 | task 428 | n_decoded = 782, tg = 9.70 t/s, tg_3s = 9.74 t/s
7.57.688.781 I slot print_timing: id 3 | task 428 | n_decoded = 812, tg = 9.70 t/s, tg_3s = 9.69 t/s
8.00.750.944 I slot print_timing: id 3 | task 428 | n_decoded = 842, tg = 9.71 t/s, tg_3s = 9.80 t/s
8.03.809.475 I slot print_timing: id 3 | task 428 | n_decoded = 871, tg = 9.70 t/s, tg_3s = 9.48 t/s
8.06.812.261 I slot print_timing: id 3 | task 428 | n_decoded = 900, tg = 9.70 t/s, tg_3s = 9.66 t/s
8.09.895.367 I slot print_timing: id 3 | task 428 | n_decoded = 930, tg = 9.70 t/s, tg_3s = 9.73 t/s
8.12.945.724 I slot print_timing: id 3 | task 428 | n_decoded = 960, tg = 9.70 t/s, tg_3s = 9.83 t/s
8.15.968.735 I slot print_timing: id 3 | task 428 | n_decoded = 989, tg = 9.70 t/s, tg_3s = 9.59 t/s
8.19.029.890 I slot print_timing: id 3 | task 428 | n_decoded = 1019, tg = 9.70 t/s, tg_3s = 9.80 t/s
8.22.096.088 I slot print_timing: id 3 | task 428 | n_decoded = 1049, tg = 9.70 t/s, tg_3s = 9.78 t/s
8.25.162.768 I slot print_timing: id 3 | task 428 | n_decoded = 1079, tg = 9.71 t/s, tg_3s = 9.78 t/s
8.28.213.756 I slot print_timing: id 3 | task 428 | n_decoded = 1109, tg = 9.71 t/s, tg_3s = 9.83 t/s
8.31.228.147 I slot print_timing: id 3 | task 428 | n_decoded = 1138, tg = 9.71 t/s, tg_3s = 9.62 t/s
8.32.811.299 I slot print_timing: id 3 | task 428 | prompt eval time = 653.50 ms / 13 tokens ( 50.27 ms per token, 19.89 tokens per second)
8.32.811.302 I slot print_timing: id 3 | task 428 | eval time = 118810.79 ms / 1153 tokens ( 103.04 ms per token, 9.70 tokens per second)
8.32.811.309 I slot print_timing: id 3 | task 428 | total time = 119464.29 ms / 1166 tokens
8.32.811.312 I slot print_timing: id 3 | task 428 | graphs reused = 1535
8.32.811.790 I slot release: id 3 | task 428 | stop processing: n_tokens = 7467, truncated = 0
10.30.655.516 I slot get_availabl: id 3 | task -1 | selected slot by LCP similarity, sim_best = 1.000 (> 0.100 thold), f_keep = 0.846
10.30.655.626 I slot launch_slot_: id 3 | task 1583 | processing task, is_child = 0
10.35.674.918 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 76, progress = 0.01, t = 4.72 s / 16.10 tokens per second
10.49.104.196 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 2124, progress = 0.34, t = 18.15 s / 117.03 tokens per second
10.59.923.297 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 4172, progress = 0.66, t = 28.97 s / 144.02 tokens per second
11.04.524.655 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 4267, progress = 0.68, t = 33.57 s / 127.11 tokens per second
11.15.676.311 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 6302, progress = 1.00, t = 44.72 s / 140.92 tokens per second
11.16.072.995 I slot print_timing: id 3 | task 1583 | prompt processing, n_tokens = 6311, progress = 1.00, t = 45.12 s / 139.88 tokens per second
11.26.512.175 I slot print_timing: id 3 | task 1583 | n_decoded = 100, tg = 9.80 t/s, tg_3s = 9.80 t/s
11.29.183.302 I slot print_timing: id 3 | task 1583 | prompt eval time = 45353.61 ms / 6315 tokens ( 7.18 ms per token, 139.24 tokens per second)
11.29.183.307 I slot print_timing: id 3 | task 1583 | eval time = 12875.47 ms / 126 tokens ( 102.19 ms per token, 9.79 tokens per second)
11.29.183.309 I slot print_timing: id 3 | task 1583 | total time = 58229.07 ms / 6441 tokens
11.29.183.309 I slot print_timing: id 3 | task 1583 | graphs reused = 1657
11.29.183.525 I slot release: id 3 | task 1583 | stop processing: n_tokens = 6440, truncated = 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions