Skip to content

fix(server): prevent GGML_ABORT when prompt cache pos_min == -1 for non-standard attention architectures#1

Merged
nisparks merged 1 commit into
nisparks:wip/deepseek-v4-supportfrom
tokencube:fix/prompt-cache-pos-min-abort
May 6, 2026
Merged

fix(server): prevent GGML_ABORT when prompt cache pos_min == -1 for non-standard attention architectures#1
nisparks merged 1 commit into
nisparks:wip/deepseek-v4-supportfrom
tokencube:fix/prompt-cache-pos-min-abort

Conversation

@xczhanjun

Copy link
Copy Markdown

Problem

When using non-standard attention architectures (e.g. DeepSeek V4 Flash with CSA+HCA), llama_memory_seq_pos_min() may return -1 even when n_past > 0. The custom KV cache layout is incompatible with standard prompt cache restoration, causing a hard crash:

server-context.cpp:2428: GGML_ABORT("pos_min == -1, but n_past > 0 - should not happen")

This happens consistently with --parallel > 1 --cont-batching on DeepSeek V4 Flash, typically on the 2nd-4th concurrent request.

Fix

Replace GGML_ABORT with graceful fallback: set n_past = 0 and pos_next = 0 to force full prompt re-evaluation. This mirrors the existing do_reset path for SWA/hybrid/recurrent memory models. 4-line change.

Testing

  • Hardware: 8×A100 80GB NVLink
  • Model: DeepSeek V4 Flash (FP8/FP4 GGUF, 284B/13B active)
  • 60+ concurrent requests: 3 rounds of ab -n 20 -c 4
  • Config: --parallel 4 --cont-batching --ctx-size 32768
  • Result: Zero crashes. Fallback triggers correctly, server recovers and continues serving.

Compatibility

Backward-compatible. Standard architectures unaffected (pos_min returns valid value, fallback never triggers). Non-standard architectures gracefully degrade instead of crashing.


Upstream issue reference: ggml-org#13833 (comment)

When non-standard attention architectures (e.g. DeepSeek V4 Flash CSA+HCA)
are used, llama_memory_seq_pos_min() may return -1 even with n_past > 0.
The custom KV cache layout is incompatible with standard prompt cache
restoration, causing a hard crash.

Replace GGML_ABORT with graceful fallback: set n_past=0 and pos_next=0
to force full prompt re-evaluation, same as the SWA/hybrid memory path.

Verified: 60+ concurrent requests on 8xA100, zero crashes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
xczhanjun added a commit to tokencube/llama.cpp that referenced this pull request May 2, 2026
…k V4

Rebrands user-visible llama.cpp → zllama.io across WebUI constants,
page titles, MCP identifiers, localStorage keys, and HTTP Server header.
Adds APP_NAME import to chat page. Applies prompt cache pos_min==-1
graceful fallback patch (nisparks#1) to prevent GGML_ABORT.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nisparks nisparks merged commit 3a244f6 into nisparks:wip/deepseek-v4-support May 6, 2026
1 check passed
nisparks added a commit that referenced this pull request May 6, 2026
PR #1 (tokencube) added a smaller and better fix at the abort site
itself: when llama_memory_seq_pos_min returns -1 mid-request, fall
back to full prompt re-evaluation instead of aborting. With that
fallback in place the heavy-handed startup-time cache disable is
no longer needed -- the cache stays useful for full-prefix matches
even on non-PART models, and the rare prefix-mismatch path now
gracefully degrades.

Reverts the Force the prompt cache off in that case to avoid a
confusing GGML_ABORT block from 70689ee.
@xczhanjun

xczhanjun commented May 6, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants