Skip to content

Misc. bug: --cache-reuse no longer seems to be caching prompt prefixes #14113

Closed

Description

@ghnp5

Name and Version

Affected:
Version at commit: b7a1746

Not affected:
Version at commit: c6a2c9e

Operating systems

Linux

Which llama.cpp modules do you know to be affected?

llama-server

Problem description & steps to reproduce

I had open this bug in oobabooga/text-generation-webui: oobabooga/textgen#7060

The issue being that prompt prefixes were no longer being used in the following requests.

I confirmed that --cache-reuse 1 was being passed on, so that wasn't the issue.
After reverting to the previous version of the WebUI (which ships an older version of llama.cpp), the prompts started to be cached again.

So, this seems to point to being a bug with llama.cpp.

First Bad Commit

It looks like there may have been a commit between c6a2c9e and b7a1746 that broke --cache-reuse, or that changed its behavior.


EDIT - still broken in today's commit: 2bb0467


EDIT 2 - someone seems to have reported the same thing here: #13576 (comment) (although that PR is not yet merged)

There was another recent change, here: 06a92a1

Activity

  1. ggerganov commented on Jun 11, 2025

    @ggerganov
    Member

    Provide repro steps using llama-server.

  2. ghnp5 commented on Jun 11, 2025

    @ghnp5
    Author

    Hello,

    Thank you for your reply. I use the oobabooga/text-generation-webui project, which bundles a snapshot of llama.cpp (the commits I mentioned above),

    and, from what I saw, this is the command it runs:

    llama-server --model user_data/models/gemma-3-12b-it-qat-UD-Q6_K_XL.guff --ctx-size 32768 --gpu-layers 49 --batch-size 256 --port 60033 --no-webui --threads 10 --threads-batch 10 --rope-freq-scale 0.125 --rope-freq-base 1000000.0 --cache-reuse 1
    

    The model can be downloaded from: https://huggingface.co/unsloth/gemma-3-12b-it-qat-GGUF/tree/main

    I confirm --cache-reuse 1 is present in the parameters, when the cache isn't working.

    I don't know how exactly a Chat Completion call is made to llama-server, but basically, if I make two chat-instruct calls, where the first 1000 characters or so are exactly the same, the prompt will be processed from byte 0, when using the affected commits I mentioned above.

    I'm not providing the cache_prompt parameter, so it should default to true.

    I hope this helps!

  3. ggerganov commented on Jun 11, 2025

    @ggerganov
    Member

    The --cache-reuse parameter is not relevant for this case.

    SWA models like Gemma could exhibit the problem that you describe, but I am fairly certain that I fixed this in #13833. Unless you can provide repro steps, I would assume this is a problem in the oobabooga project.

  4. ghnp5 commented on Jun 11, 2025

    @ghnp5
    Author

    Thank you. This same Gemma model that I'm using works when I use the llama-server version at c6a2c9e

    Apologies - I'm confused why --cache-reuse is not relevant. Isn't this (together with cache_prompt: true) what prevents the prompt prefix from being re-processed on subsequent requests that share the same prefix?

    If I don't include --cache-reuse in the parameters, then the prompt will always be fully processed from the beginning, even on the version that works for me.

    Unless you can provide repro steps

    Please let me know exactly what do you need, for repro steps.

  5. github-actions commented on Jul 27, 2025

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

  6. ghnp5 commented on Aug 5, 2025

    @ghnp5
    Author

    @ggerganov - This is still happening when using the version at https://github.com/ggml-org/llama.cpp/tree/90083283ec254fa8d33897746dea229aee401b37

    It appears that the fix from #14163 did not fix the cache issue.

    Thank you.

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