You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With --spec-type draft-dflash and an mmproj model, every image request stalls (~500 s) and then returns HTTP 500. Text-only requests with the same configuration work and speculate correctly. Root cause: a positional hole in the draft KV cache — mtmd image chunks advance the target context without being mirrored into the 1D draft KV cache, so llama_decode(ctx_dft) rejects the non-consecutive positions.
A community fix (z-lab#1, +74/−5 in common/speculative.cpp, zero-fills the hole) is crash-eliminating on CUDA in our testing (7/7 image regression + stability PASS, HTTP 500 gone) but provides no speculative benefit on image requests (draft/accept counters stay 0 for images; tolerated draft: llama_decode returned -1 is still logged), and a general position-gap case (non-consecutive positions across requests) can still terminate the server. Nothing here is claimed as fixed upstream.
init: the tokens of sequence 0 in the input batch have inconsistent sequence positions:
- the last position stored in ... KV cache ... is X
- the tokens for sequence 0 ... have a starting position of Y
it is required that the sequence positions remain consecutive: Y = X + 1
process: llama_decode(ctx_dft) failed rc=-1 (n_tokens=..., offset=...)
srv update_slots: decode() failed: failed to process speculative batch -> HTTP 500
Send any image in a chat-completions request → observe the ~500 s stall then HTTP 500. The same request with --spec-type none (or without mmproj) succeeds.
Root cause
mtmd image chunks are decoded directly into the target context by the mtmd helper and never pass common_speculative_process() (the PR spec : add DFlash2 support (local convolution + candidate selector) #27342 DFlash path) — the draft KV cache therefore has a positional hole (M-RoPE targets use non-linear image positions; even a single-ubatch chunk injects draft rows at bogus positions, per the z-lab fix description).
The 1D draft KV cache requires consecutive positions; the hole fails the consecutive check in llama_decode(ctx_dft) (rc=-1) → HTTP 500.
Residual on CUDA: image requests still log 14+ tolerated draft: llama_decode returned -1 position-mismatch failures per request and run without speculative benefit — draft/accept counters stay 0 across all image tests, so images decode at full target speed (no vision speedup). Pure-text requests with the same binary speculate at ~100% acceptance.
Remaining blocker: cross-request position gaps (non-consecutive positions spanning slots/requests) still terminate the server (exit -1). The z-lab patch covers the single mtmd hole only, not general position-gap handling.
Ask
Is there a path to a general fix (draft-KV position remapping / gap support) so DFlash2 can also speculate on image requests?
Maintainer guidance on where gap-tolerant draft-KV handling belongs (draft-KV refactor vs process() special-casing)?
Summary
With
--spec-type draft-dflashand an mmproj model, every image request stalls (~500 s) and then returns HTTP 500. Text-only requests with the same configuration work and speculate correctly. Root cause: a positional hole in the draft KV cache — mtmd image chunks advance the target context without being mirrored into the 1D draft KV cache, sollama_decode(ctx_dft)rejects the non-consecutive positions.A community fix (z-lab#1, +74/−5 in
common/speculative.cpp, zero-fills the hole) is crash-eliminating on CUDA in our testing (7/7 image regression + stability PASS, HTTP 500 gone) but provides no speculative benefit on image requests (draft/accept counters stay 0 for images; tolerateddraft: llama_decode returned -1is still logged), and a general position-gap case (non-consecutive positions across requests) can still terminate the server. Nothing here is claimed as fixed upstream.Environment
5ecbe1ac17ec0484c5b44af0bd580cdc9c428ed4(local build, MSVC 19.44, CUDA 12.4, sm_86)empero-ai/Qwen3.8-27B-Ridge-GGUFQwen3.8-27B-Ridge-3.7bpw.gguf(IQ2_M) +mmproj-Qwen3.8-27B-BF16.ggufincoai/Qwen3.8-27B-DFlash2-GGUFQwen3.8-27B-DFlash2-Q4_K_M.gguf(1,143,006,752 bytes; SHA-25618a380efc9b7ed8d88677fc895f5c11ae170653434ee378f7348f715c14d0594)Failure log (image request, draft-dflash)
Repro (llama-server)
Send any image in a chat-completions request → observe the ~500 s stall then HTTP 500. The same request with
--spec-type none(or without mmproj) succeeds.Root cause
common_speculative_process()(the PR spec : add DFlash2 support (local convolution + candidate selector) #27342 DFlash path) — the draft KV cache therefore has a positional hole (M-RoPE targets use non-linear image positions; even a single-ubatch chunk injects draft rows at bogus positions, per the z-lab fix description).llama_decode(ctx_dft)(rc=-1) → HTTP 500.Upstream corroboration
llama_decode(ctx_dft) failed rc=-1, same position-mismatch log; works without--spec-type draft-dflash.Evaluation of the z-lab fix on CUDA (this report)
common/speculative.cpp); skips embedding batches in the DFlashprocess()and zero-fills the draft-cache positional hole (log:draft cache hole for seq 0: [46, 62) - seeding with zero features).draft: llama_decode returned -1position-mismatch failures per request and run without speculative benefit — draft/accept counters stay 0 across all image tests, so images decode at full target speed (no vision speedup). Pure-text requests with the same binary speculate at ~100% acceptance.Ask
process()special-casing)?Cross-links: #26108 (same failure, Qwen3.6-27B), PR #27342 (DFlash2; comment thread confirms M-RoPE rejection), z-lab#1 (zero-fill fix, Metal-validated), companion issue CUDA batched-verification parity.