What this thread does
Use a llama-mtmd-cli build containing the batch-lifetime repair merged as 0c8c59e, which is present in the published b12038 prerelease (SamMalayek's PR #31165, official b12038 source).
Do first: send the suspect image in a fresh llama-mtmd-cli process and compare it with the same image after /clear; Naoray's control distinguishes stale cross-message data from the image's own output (#31155).
Diagnostic: GGML_ASSERT(offset <= batch->output_embd.size())
Naoray's October 25 report gives master 63412d8 and b11860/df9beac, Metal on an Apple M5 Max, macOS 26.5, with PaddleOCR-VL-1.6 GGUF plus its matching projector. The report describes “previous image's embeddings returned”, or a later-turn abort; separate fresh processes do not show those reported failures.
Findings
- Reporter diagnosis: Naoray says the cached batch outlives the input chunks it references. Clearing history, token position and KV memory leaves that batch behind, allowing pointer reuse to return old embeddings or an assertion. The original report labels this a code-reading suspicion without ASan confirmation (#31155).
- Independent contribution: SamMalayek's October 25 PR #31165 moves the batch into the message-evaluation scope so it cannot outlive the chunks. The author reports a local two-image check and describes the fault as a heap use-after-free exposed by ASan. Attribute that result to SamMalayek; it is not a broad accuracy evaluation.
- Merged state: maintainer ngxson approved and merged #31165 as 0c8c59e on October 27. The issue was closed as completed on October 29. The final PR history removes its shell regression test, so a merged code change and the author's manual report are the evidence here (PR, issue).
- Release boundary: the official November 2 b12038 prerelease publishes a tag whose mtmd-cli source has the local batch declared after the chunks, matching the merged repair. Thus the code change is present in that published prerelease. Its release note discusses a separate clang-cl change and does not identify the first build that shipped the lifetime repair.
Limits
The original output-corruption report is one macOS/Metal OCR configuration; SamMalayek supplies separate lifetime-repair evidence. It does not establish the same symptom in llama-server, every vision model or other backends. Naoray notes that allocator placement affects whether a particular image pair triggers stale output (#31155, #31165).
Not for: DeepSeek text output corruption on reused prompt prefixes; see llama-cpp-deepseek41-cached-prefix-corrupt-output.
Started from a post by @ggml-org/llama.cpp maintainers, packaged by the editor. Original post