Repository navigation
Conversation
|
Hi @yitizi, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
38b85f3 to
c6e2c27
Compare
|
thanks for the PR, actually I already had a half-working version on my side with a slightly different approach, having a chained hash on a block of fixed size token, which allow better detecting reusable prompt from disk. but it's still not perfect, so I want to improve it further also, I spotted some more refactoring need to be done along the way, so I didn't push my PR the overall idea from this PR is already contained in my local version and I want to make the code more organized before eventually pushing it. you can keep the PR as-is for now, but note that it will eventually replaced. therefore, I won't dive too deep into this PR, and I won't proceed my review further. thanks for your understanding cc @ServeurpersoCom for visibility |
|
Tested on macOS / Metal, which I don't think is covered above. Build break on macOS.
key << "|mtime=" << (ec ? 0 : (long long) modified.time_since_epoch().count()) << "\n";I have submitted a PR to yours with this fix yitizi#1 Measurements. M5 Max (128GB), Metal, Qwen3.8-Flash-Next 125B-A6B at ~90GB. It is a hybrid model (36 GDN recurrent + 12 attention layers) running with a speculative draft context, so both recurrent and draft state have to survive the round trip. They do.
Restoring is free at startup: 6.0 s to first listen on a restart against 9.0 s cold. Disk cost was roughly 900 MiB per 33k-token prompt. One note on the directory layout. On startup a server removes every entry whose cache key does not match its own (the |
Assisted-by: Codex Assisted-by: Claude Opus 5
c6e2c27 to
6deebd4
Compare
The macOS build break is fixed — the whole ternary is now wrapped in Root cause was libc++ rather than macOS as such: libc++ defines To keep it from happening again, I added a check that compiles the server On the multi-model cache directory: my GPU can barely hold a single model, so For context — ngxson mentioned he already has similar work locally, so this PR Thanks again for catching this. |
|
Separately — a report on another PR probably applies here too: @colinrgodsey hit a kernel livelock while saving ~22k tokens of state: the file This PR does the same thing — server-context.cpp:396 hands the mapping pointer @ngxson — flagging it in case your version uses the same mmap-write pattern. |
|
On meaningful names, would suggest renaming the flags: Because Some of this may sound nit-picky, but it's important, since:
|
|
Livelock reproduced by me on AMD RDNA3 + Vulkan. Command line $ nice -n +19 ~/llama.cpp/build/bin/llama-server --model Qwen3.8-27b-Dense-Imatrix-IQ3_M.gguf -c 0 -fa 1 --cache-type-k q4_0 --cache-type-v q4_0 --webui-mcp-proxy --ui-mcp-proxy -ngl 99 --load-mode mmap --lazy-mode on --temp 0.3 --top-k 20 --top-p 0.95 --min-p 0.05 --repeat-penalty 1.0 --presence-penalty 0.0 --parallel 4 --no-op-offload --spec-type ngram-mod --spec-ngram-mod-n-match 16 --spec-ngram-mod-n-min 2 --spec-ngram-mod-n-max 128 --kv-unified -t 20 --cache-prompt --reasoning-preserve --cache-reuse 128 --cache-ram 12288 --fit 1 --cache-disk ~/.cache/llama.cpp/kv.cache --cache-disk-max 16384 Reproduced only on generation, never in prefill --load-mode reproduced on any Workaround: --parallel 2 (or more) while true; do curl -s -X POST http://localhost:8080/completion -H "Content-Type: application/json" -d '{"prompt":"a","n_predict":1,"temperature":0,"cache_prompt":false}' >/dev/null; sleep 60; doneOR any running prompt. |
The flag takes a filesystem directory, not a block device, so "disk" is a misnomer; it also collides with a plausible future raw-device cache. Rename --cache-disk/--cache-disk-max to --cache-dir/--cache-dir-max (env LLAMA_ARG_CACHE_DIR/_MAX) to match the existing --cache-ram/--cache-reuse family, and clarify in the help text that this is not the model download cache directory. Suggested by @lee-b. No behavior change. Assisted-by: Codex Assisted-by: Claude Opus 5
Thanks for the suggestion — adopted and pushed ( I went with the shorter form rather than One thing worth noting: this PR will likely be superseded in the end. @ngxson |
…092) Apply ggml-org/llama.cpp PR 28092 verbatim onto this pinned base commit. Source: ggml-org#28092 Base: 911f6cd (master, 2026-09-18) Author of the patch: yitizi (upstream); applied here unmodified. Adds llama-server flags --cache-dir PATH and --cache-dir-max N: a disk-backed prompt cache that persists across restarts, replacing the RAM-only cache (--cache-ram, upstream default 8192 MiB). Stock b11034 has no --cache-dir, so our ModelServe native-Windows track boots this build via -Bin.
|
Writing GPU state straight into MAP_SHARED file mappings can livelock the kernel, so use a host buffer with pwrite/pread instead might be better? Especially noticable in systems with UMA like gfx1151 StrixHalo cache files stay in the page cache after writes and reads, which takes memory from the GPU on those kind of systems |
Overview
Implements a persistent prompt cache that supports hybrid/SWA context
checkpoints, restores automatically across process restarts, and provides
corrupt-entry cleanup and LRU eviction bounded by disk size.
Closes #20697
Requirements