主机:
- AMD 7900XTX 24G (Vulkan驱动)
- AMD 9600x + 32G内存
- llama.cpp version: 9293 (1acee6bf8) + Hermes Agent v0.14.0 (2026.5.16)
llama.cpp 启动参数:
~/llama.cpp/build/bin/llama-server -m models/Qwen/MTP/Qwen3.6-27B-Q4_K_M.gguf \
--spec-type draft-mtp --spec-draft-n-max 3 \
--flash-attn --n-gpu-layers 99 on --threads 6 --parallel 1 \
-ctk q8_0 -ctv q4_0 --ctx-size 96000 \
-b 3072 -ub 1024 --no-warmup --no-mmap \
--host 0.0.0.0 --port 8080 \
--reasoning off --jinja --chat-template-file models/Qwen/chat_template.jinja
MTP加持下,本地跑 Qwen3.6-27B-Q4_K_M 速度50+tokens/s,搭配hermes很够用。但是每聊那么几句,控制台总是输出上下文缓存不命中的信息,类似:
17.27.663.317 W slot update_slots: id 0 | task 2894 | forcing full prompt re-processing due to lack of cache data (likely due to SWA or hybrid/recurrent memory, see https://github.com/ggm-org/llama.cpp/pull/13194#issuecomment-2868343055)
17.27.663.319 W slot update_slots: id 0 | task 2894 | erased invalidated context checkpoint (pos_min = 51198, pos_max = 51198, n_tokens = 51199, n_swa = 0, pos_next = 0, size = 231.851 MiB)
......
然后就是缓慢的 prompt processing 和 created context checkpoint 过程。持续几十秒到几分钟不等,显卡风扇呼呼转。 聊得越久,context越大,出现得越频繁。这种情况非常影响思路连贯性,乃至情绪。研究了几个晚上,问遍国内外AI模型,尝试了各种参数组合,都不得其果。
昨天意外刷到了 Qwen-Fixed-Chat-Templates 的介绍,一番试用后,发现效果明显,聊了近一个小时,反复网络搜索+工具调用,缓存不命中的情况只出现个位数次数。感觉流畅很多,不敢独享,记录下来,希望对遇到类似问题的朋友有用。
特别感谢 https://huggingface.co/froggeric/Qwen-Fixed-Chat-Templates 作者。下载方式:
hf download froggeric/Qwen-Fixed-Chat-Templates chat_template.jinja --local-dir models/Qwen
至于它的原理,Huggingface 页面上有详细介绍。我偷懒让Gemini去总结,回复如下:
