Repository navigation
Description
Name and Version
llama-completion --version
version: 7802 (5516b9c)
built with GNU 10.2.1 for Linux aarch64
Operating systems
Linux
GGML backends
CPU
Hardware
NanoPi R6C: Rockchip RK3588S with quad-core Cortex-A76 (2.4GHz) and quad-core Cortex-A55 (1.8GHz), with 8GB LPDDR4X RAM
Models
LFM2.5-1.2B-Instruct-Q4_K_M.gguf
Problem description & steps to reproduce
Environment
-
OS: Debian GNU/Linux (aarch64)
-
Kernel: 6.1.57 aarch64
-
llama.cpp binary: llama-completion
-
Version / build line:
build: 7802 (5516b9c) with GNU 10.2.1 for Linux aarch64
-
Model:
/opt/models/LFM2.5-1.2B-Instruct-Q4_K_M.gguf
Model metadata:
- general.architecture = lfm2
- lfm2.context_length = 128000
- n_layer = 16, n_embd = 2048, n_head = 32
- vocab_size = 65536, file type = Q4_K - Medium
-
Grammar:
/opt/grammars/json.gbnf (generic JSON GBNF, works fine on first run)
-
Binary flags (from
llama-completion --help): supports--prompt-cache,-no-cnv,--simple-io,--grammar-file,--keep,--ctx-sizeetc. [file:189]
Summary
Using an lfm2 model with llama-completion and --prompt-cache:
- First run: completes successfully, creates cache, outputs valid JSON.
- Second run with the same command and prompt:
-
Loads the cache (
session file has exact match for prompt!) -
Then aborts with:
/src/llama-memory-recurrent.cpp:543: GGML_ASSERT(cell.has_seq_id(seq_id)) failed
-
This looks like a bug in the recurrent‑memory + prompt‑cache reuse path for arch = lfm2.
Exact commands and output (minimal)
First run (cache creation, succeeds)
/opt/llama.cpp/build/bin/llama-completion \
--model "/opt/models/LFM2.5-1.2B-Instruct-Q4_K_M.gguf" \
--prompt "$(cat "/opt/prompts/en_rule_01_sunset_offset_prompt.txt")" \
--n-predict 250 --temp 0.05 --threads 7 \
-no-cnv --simple-io --no-display-prompt \
--grammar-file "/opt/grammars/json.gbnf" \
--prompt-cache "/var/cache/llm/prompt.cache.en" \
--keep -1 --ctx-size 8192Key log lines:
build: 7802 (5516b9c16) with GNU 10.2.1 for Linux aarch64
...
print_info: arch = lfm2
print_info: n_ctx_train = 128000
...
llama_context: n_ctx = 8192
llama_context: n_ctx_seq = 8192
...
main: attempting to load saved session from '/var/cache/llm/prompt.cache.en'
main: session file does not exist, will create.
...
generate: n_ctx = 8192, n_batch = 2048, n_predict = 250, n_keep = 2403
{
"command_to_execute": "Lights off",
"schedule_details": {
"type": "fixed_time",
"time_hh_mm": "21:00",
"duration_minutes": 180,
"duration_unit": "minutes",
"duration_description": "3 hours after sunset",
"days_of_week": "*",
"month": "*",
"timezone": "SYSTEM_TIMEZONE_PLACEHOLDER"
}
}
[end of text]
common_perf_print: prompt eval time = 55348.40 ms / 2403 tokens
common_perf_print: total time = 62756.60 ms / 2519 tokens
So: first run + grammar + cache + --keep -1 --ctx-size 8192 works and produces valid JSON.
Second run (same command, crashes on cache reuse)
Same command, immediately after the first:
/opt/llama.cpp/build/bin/llama-completion \
--model "/opt/models/LFM2.5-1.2B-Instruct-Q4_K_M.gguf" \
--prompt "$(cat "/opt/prompts/en_rule_01_sunset_offset_prompt.txt")" \
--n-predict 250 --temp 0.05 --threads 7 \
-no-cnv --simple-io --no-display-prompt \
--grammar-file "/opt/grammars/json.gbnf" \
--prompt-cache "/var/cache/llm/prompt.cache.en" \
--keep -1 --ctx-size 8192Log tail:
...
llama_context: n_ctx = 8192
llama_context: n_ctx_seq = 8192
...
main: attempting to load saved session from '/var/cache/llm/prompt.cache.en'
main: loaded a session with prompt size of 2403 tokens
main: session file has exact match for prompt!
main: unable to resuse common prefix
...
generate: n_ctx = 8192, n_batch = 2048, n_predict = 250, n_keep = 2403
{
/opt/llama.cpp/src/llama-memory-recurrent.cpp:543: GGML_ASSERT(cell.has_seq_id(seq_id)) failed
/opt/llama.cpp/build/bin/libggml-base.so.0(+0x15c00)[0x...]
/opt/llama.cpp/build/bin/libggml-base.so.0(ggml_print_backtrace+0x1ec)[0x...]
/opt/llama.cpp/build/bin/libggml-base.so.0(ggml_abort+0x108)[0x...]
/opt/llama.cpp/build/bin/libllama.so.0(_ZN22llama_memory_recurrent9find_slotERK12llama_ubatch+0x3f8)[0x...]
/opt/llama.cpp/build/bin/libllama.so.0(_ZN22llama_memory_recurrent7prepareERKSt6vectorI12llama_ubatchSaIS1_EE+0x120)[0x...]
/opt/llama.cpp/build/bin/libllama.so.0(_ZN19llama_memory_hybrid10init_batchER18llama_batch_allocrjb+0x3a4)[0x...]
/opt/llama.cpp/build/bin/libllama.so.0(_ZN13llama_context6decodeERK11llama_batch+0x22c)[0x...]
/opt/llama.cpp/build/bin/libllama.so.0(llama_decode+0x10)[0x...]
/opt/llama.cpp/build/bin/llama-completion(+0x2af2c)[0x...]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0xe8)[0x...]
/opt/llama.cpp/build/bin/llama-completion(+0x30528)[0x...]
Aborted
So the cache is found, prompt size matches, but reusing it via the recurrent‑memory path hits GGML_ASSERT(cell.has_seq_id(seq_id)).
Workarounds tried
All below still crash on second run:
--prompt-cache-roon second run--keep -1(shown above)--ctx-size 8192(shown above)- Tried
--ctx-checkpoints 0 --cache-ram -1, but these are rejected as invalid arguments in this example binary.
Disabling --prompt-cache entirely avoids the crash but also removes the caching benefit.
Expected vs actual
- Expected: Second and subsequent runs with the same
--prompt-cacheshould reuse the cached prefix safely and complete without assertions. - Actual: First run OK; second run with the same flags and prompt crashes in
llama_memory_recurrent.cppwhen reusing the cached session.
This seems closely related to other prompt‑cache/KV issues where reload of processed prompts triggers asserts in internal cache code (e.g. #15215), but here it’s specifically in the llama_memory_recurrent path for arch = lfm2.[page:0][web:213]
### First Bad Commit
_No response_
### Relevant log output
<details>
<summary>Logs</summary>
<!-- Copy-pasted short logs go into the "console" area here -->
```console
Activity
ggerganov commentedon Jan 23, 2026
Should be fixed with #19045
Please test it thoroughly and ideally with non-recurrent models to confirm the functionality works as expected.
jenskastensson commentedon Jan 31, 2026