Repository navigation
Studio: stop chats with images from blocking other chats on GGUF models - #12236
Conversation
|
Codex review has converged on this PR.
|
NilayYadav
left a comment
There was a problem hiding this comment.
Review + reproduction evidence
Pinned review: 45faa5ff6201d29d6c83d155eb7f2c872f6e2714. No blocking findings.
I reproduced two chats at once on a vision GGUF on fresh upstream main (Modal L4, unsloth/Qwen3-VL-2B-Instruct-GGUF Q4_K_M, 4 slots, 175104 ctx, Chromium 1440x900). Chat A has an image attached and asks for a long reply; chat B is plain text and is sent a few seconds later in a second tab.
- main
501b15f/ fix reverted (run): chat B shows only "Generating..." 10 s after sending and still has no reply 7 minutes later while A keeps decoding. The llama-server log (Settings > Logs) has onegot exception: {"error":{"code":500,"message":"Invalid base64 value"}}per image request (5 of 5). Over/v1/chat/completions, B's time to first token is 10.48 / 7.93 / 10.13 s when A has an image, 2.26 s when A is text only. In CI the new test fails withassert 30000 == (20 + 4224): the count falls back to the whole pool. - PR head (run): chat B is fully answered while A is still streaming. The llama-server log has 0 exception lines. B's time to first token is 0.99 / 1.09 / 1.01 s with an image in A.
test_gguf_admission_token_count.py: 29 passed (on main the new test is the only failure, 28 passed).
- Unchanged paths: a single text chat (45 prompt tokens) and a single image chat (308 prompt tokens) give byte-identical replies at temperature 0 on both sides, and the image answer still reads the picture ("SLOTH 42", red square, blue circle). Two concurrent text chats stream together on both sides.
- Cost: an image request now makes two local calls (
/apply-templatethen/tokenize) where main made one failing call. Single image chat time to first token is 1.39 s on both sides. - The only red job on the CI head arm,
test_every_playwright_driver_is_invoked_by_ci(playwright_user_message_time.pynot wired into CI), fails the same way on the reverted arm and comes from main.
Conclusion: the issue is real on main and this fixes it. Chats with images no longer take the whole shared cache, and nothing else changes. Not covered by hand: the MCP screenshot tool loop and audio/video parts. Code tracing shows they take the same stripped path.
Replace the mock llama-server test with a direct assertion on what the admission count forwards: the contract is that no media part reaches llama-server's count, not that one placeholder fails one imitated base64 check.
|
Pushed one small test-only commit on top (62026e4); the production fix is unchanged.
Also confirmed on a live llama-server (Qwen3.5-0.8B GGUF + mmproj, 16k ctx): before the fix the image chat's count fell back to the whole 16384-token pool and logged "Invalid base64 value"; with it the count is 17 text tokens + the 4224 image allowance, and a max-resolution 2048x2048 image really costs 4115 tokens, so images are not undercounted. |
|
Codex review and CI converged on the current head
The earlier |
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Root cause confirmed against llama-server's media parsing and reproduced live; the count now excludes media and keeps the per-image allowance. Codex converged and CI passed on the current head.

With a vision GGUF model, every request in a chat that holds an image (an MCP screenshot or an attached picture) logs "Invalid base64 value" from llama-server. The image is still read correctly, but other chats wait until that chat finishes, then take over its slot, so its next turn reprocesses its history. This came in with #10794.
Before a request starts, Studio counts its prompt tokens with llama-server, and for that count it replaced each image with the text "[image]", which llama-server rejects. A failed count reserves the whole shared cache for that one request. Images are now left out of the count, like the other prompt counts already do, and each image still gets its usual flat token allowance on top.
#12080 changes how MCP image data is decoded, a different path that does not touch this count.
Fixes #12058