Server: multimodal sessions lose all KV reuse on a tail token mismatch — no common-prefix rewind, no disk-KV fallback, no continued disk stores
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- ai-infra-agents, backend, performance
Hướng nghiên cứu
Bắt đầu trong ds4_server.c, xung quanh live-miss fallback, và so sánh cách xử lý token không khớp của DS4 với path memory-rewind của GLM ở gần đó. Sau đó kiểm tra các guard đa phương thức xung quanh kv_cache_store_current và kv_cache_try_load. Hoàn tất khi token cuối đa phương thức không khớp có thể tái sử dụng tiền tố chung hoặc KV trên đĩa thay vì prefill lạnh từ token 0, đồng thời các checkpoint được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Title: Server: multimodal sessions lose all KV reuse on a tail token mismatch — no common-prefix rewind, no disk-KV fallback, no continued disk stores
Observed on: 6289c51 (current main), DeepSeek V4 Flash Vision-Exp MXFP4, --vision server mode, --batched-session 2, disk KV enabled (--kv-disk-dir, 1 TB budget).
Summary
For multimodal (vision) chat requests, KV reuse works perfectly while the
conversation round-trips exactly (multimodal live kv hit identity=fingerprint-match,
sub-second turns on a ~335k-token prompt). But as soon as one request diverges
from the live session by even a handful of tokens at the tail, the server falls
back to a full cold prefill from token 0 — three reuse mechanisms that exist for
text sessions are all unavailable or inert for multimodal ones:
-
No common-prefix rewind on live token-mismatch. The live-prefix check
computes the common prefix length but only accepts it on an exact full match:ds4-server: live kv cache miss live=340263 prompt=340551 common=340144 vision=match reason=token-mismatch ds4-server: chat ctx=0..340551:340551 TOOLS prompt start99.96% of the prompt (340,144 / 340,551 tokens) was identical to the live
session, yet the server restarted prefill from 0. The GLM path right above
it does exactly this kind of rewind (rewound GLM live prefix from %d to %d,
memory-rewindcache source). The DS4 path is all-or-nothing:cached = common == old_pos && j->req.prompt.len >= old_pos ? common : 0; -
Disk KV load is gated off for multimodal requests (ds4_server.c, request
path around the live-miss fallback):if (!multimodal && s->kv.enabled && cached == 0 && old_pos >= s->kv.opt.min_tokens) { kv_cache_store_current(s, slot, "evict"); } if (!multimodal && cached == 0) { disk_cached = kv_cache_try_load(...); }So a vision session that misses the live cache never consults the disk store
at all, even when a matching checkpoint exists. -
No
continueddisk checkpoints are written during multimodal cold
prefills. Onc0a6119the same workload logged
kv cache stored tokens=... reason=continuedevery ~30k tokens during a long
prefill. On6289c51, three full ~330k-token prefills (18 minutes each)
wrote zero checkpoints — so even if (2) were reachable, there would be
nothing fresh to load. (The text-prefix memory path did resume one later
turn at 100,352 of 346,533 tokens, so partial reuse is not entirely dead,
but the deep disk checkpoints are never written.)
Trigger
A coding-agent client (OpenAI chat-completions, tools, one screenshot per turn)
occasionally re-serializes the previous assistant reply slightly differently
than the server's generated token stream (thinking/DSML round-trip). The
divergence lands inside the previous reply's tail (e.g. 119 tokens before the
end of a 340,263-token history). With text sessions this costs nothing; with a
vision session every such turn is a full ~330k prefill ≈ 18 minutes on an
M3 Ultra.
Suggested fixes
- On live token-mismatch with
vision=match, rewind the DS4 session to
common(same approach as the existing GLMmemory-rewindpath) instead of
discarding the whole session. - Allow disk-KV load/store for multimodal sessions (store text-prefix KV even
if image embeddings can't be serialized; the embedding cache already covers
re-encoding cheaply).
Sanitized log excerpt
21:47:24 multimodal live kv hit images=1 cached=334535 prompt=334603 identity=fingerprint-match
21:47:25 chat ctx=334535..334603:68 TOOLS prompt done 1.041s # ~1 s turns while round-trip is exact
...
21:55:10 live kv cache miss live=340263 prompt=340551 common=340144 vision=match reason=token-mismatch
21:55:10 chat ctx=0..340551:340551 TOOLS prompt start # full 18-min prefill, zero continued stores
(Happy to provide longer excerpts privately if useful.)
- Ngôn ngữ chính
- C
- Star
- 24.1k
- Fork
- 2.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của antirez/ds4
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
antirez/ds4#1189 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
antirez/ds4#1173 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
antirez/ds4#1032 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
ROCm build fails: host-side `rsqrtf()` in `rocm/ds4_rocm_deepseek4_vision.cuh`Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
antirez/ds4#1019 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zephyrproject-rtos/zephyr#123881 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
ly05010419/MacNativeGames#1252 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Component - Build
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Description of the bugĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
HarbourMasters/Lighthouse#655 ·
Maintainer thường phản hồi trong vòng 1 ngày