[GH-ISSUE #5507] [Engine] pack_gguf.py --mmproj: a text-only chat template silently kills vision #5478

Open
opened 2026-11-07 23:43:57 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Astemiir on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5507

[Engine] pack_gguf.py --mmproj: a text-only chat template silently kills vision

Area: Engine / dsv41 packer

Versions: control 0.1.58, app 0.2.12, pack built from a text-only GGUF conversion of
DeepSeek-V4.1-Flash-1017, projector mmproj-DeepSeek-V4.1-Flash-1017-BF16.gguf (0.97 GB).

Problem

tools/dsv41/pack_gguf.py takes tokenizer.chat_template from the source GGUF as is
(kv.get("tokenizer.chat_template"), only a hard failure when it is missing). When the source
GGUF is a text-only conversion, its template renders message['content'] as a Python
string, so a content list (text + image parts) is serialised as its repr and the marker
<|deepseek_image|> never appears in the prompt.

The pack then looks healthy:

  • --pack-info prints vision 0.97, files: N, all present and long enough;
  • /health reports images: true (the server builds DsPictures from image_token_id +
    vision geometry);
  • the attachment button accepts pictures.

but at request time DsPictures.build() finds zero image markers in the ids and the
picture is dropped/refused — the tower is loaded and never used. Nothing in the log points at
the template.

We hit this while adding the tower to a pack built from a text-only conversion; the fix was to
teach the template to emit the marker for type == "image" parts (render_parts macro), after
which the same pack answered correctly (640×360 picture, prompt_tokens 207 including 182 image
tokens).

Suggested fix

When pack_gguf.py packs vision (--mmproj, or a tower found beside the model) and sets
image_token_id, verify the template:

  1. if IMAGE_TOKEN not in template: — either fail with a clear message
    ("the source GGUF has a text-only chat template; vision would be dead — pass a vision-aware
    chat_template.jinja or patch it"), or apply the minimal injection (part type:image →
    <|deepseek_image|>, part type:text → its text) the way the HF patch_chat_template.py
    does for older downloads.
  2. Add a test that packs a fixture with a template lacking the marker and asserts the packer
    refuses (or patches) it, in the spirit of serve/test_vision_token_limit.py.

Why it matters

The failure mode is silent for the user: every indicator says pictures are on, and only the
answer reveals that the model never saw the image. A one-line check in the packer removes a
whole class of "vision does not work on my pack" reports.

The tower is model-wide

The same 5120-wide projector serves every build of V4.1-Flash-1017 (ISTA-DASLab IQ1_M / IQ2_XXS /
IQ2_XS, Unsloth UD-Q8_K_XL, any GGUF conversion), so a pack built from any of those quants can get
vision this way. Working example with the file, the attach tool and the measurements:
https://github.com/Astemiir/strata-deepseek-v41-vision (MIT).

A side note on the default set

Not part of the bug and nothing to patch: the numbers in docs/DEEPSEEK41.md make 2.25 bpw the better default
wherever the disk and RAM allow it. On disk it is 17 GB more (155 + 111 + 8 = 274 GB against
138 + 111 + 8 = 257 GB) and 4 GB more RAM (ram_gb 44 against 40 in setup.py), while quality is
+7.3% perplexity, +3.2% code and +2.2% agent work, against +15.5%, +8.6% and +5.3% for 2.00. Speed
does not separate them: setup.py already says "about the same speed" for 2.25, and
docs/DEEPSEEK41.md measures four R9700 at 48 t/s on 2.00 and 80 on 2.25 (code, shipped profiles).
2.00 remains the right pick for a 12 GB card with 40 GB of RAM - it reads as the default for the
tight boxes, while 2.25 is the one a 24 GB / 128 GB PC would want to be offered by name.


Reporter context: reproduced on Windows 11, RTX 3090, strata-dsv41 0.1.58, on the ISTA-DASLab 2.25 bpw (IQ2_XS) set, the largest of the three official ones (274 GB of disk against 257 GB for 2.00). The same projector serves the 1.75 and 2.00 sets too.

Originally created by @Astemiir on GitHub (Nov 7, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5507 # [Engine] `pack_gguf.py --mmproj`: a text-only chat template silently kills vision **Area:** Engine / dsv41 packer **Versions:** control 0.1.58, app 0.2.12, pack built from a text-only GGUF conversion of DeepSeek-V4.1-Flash-1017, projector `mmproj-DeepSeek-V4.1-Flash-1017-BF16.gguf` (0.97 GB). ## Problem `tools/dsv41/pack_gguf.py` takes `tokenizer.chat_template` from the source GGUF as is (`kv.get("tokenizer.chat_template")`, only a hard failure when it is missing). When the source GGUF is a **text-only** conversion, its template renders `message['content']` as a Python string, so a content list (text + image parts) is serialised as its `repr` and the marker `<|deepseek_image|>` never appears in the prompt. The pack then looks healthy: - `--pack-info` prints `vision 0.97`, `files: N, all present and long enough`; - `/health` reports `images: true` (the server builds `DsPictures` from `image_token_id` + vision geometry); - the attachment button accepts pictures. but at request time `DsPictures.build()` finds **zero** image markers in the ids and the picture is dropped/refused — the tower is loaded and never used. Nothing in the log points at the template. We hit this while adding the tower to a pack built from a text-only conversion; the fix was to teach the template to emit the marker for `type == "image"` parts (`render_parts` macro), after which the same pack answered correctly (640×360 picture, `prompt_tokens 207` including 182 image tokens). ## Suggested fix When `pack_gguf.py` packs vision (`--mmproj`, or a tower found beside the model) and sets `image_token_id`, verify the template: 1. `if IMAGE_TOKEN not in template:` — either fail with a clear message ("the source GGUF has a text-only chat template; vision would be dead — pass a vision-aware `chat_template.jinja` or patch it"), or apply the minimal injection (part `type:image` → `<|deepseek_image|>`, part `type:text` → its text) the way the HF `patch_chat_template.py` does for older downloads. 2. Add a test that packs a fixture with a template lacking the marker and asserts the packer refuses (or patches) it, in the spirit of `serve/test_vision_token_limit.py`. ## Why it matters The failure mode is silent for the user: every indicator says pictures are on, and only the answer reveals that the model never saw the image. A one-line check in the packer removes a whole class of "vision does not work on my pack" reports. ## The tower is model-wide The same 5120-wide projector serves every build of V4.1-Flash-1017 (ISTA-DASLab IQ1_M / IQ2_XXS / IQ2_XS, Unsloth UD-Q8_K_XL, any GGUF conversion), so a pack built from any of those quants can get vision this way. Working example with the file, the attach tool and the measurements: https://github.com/Astemiir/strata-deepseek-v41-vision (MIT). ## A side note on the default set Not part of the bug and nothing to patch: the numbers in `docs/DEEPSEEK41.md` make 2.25 bpw the better default wherever the disk and RAM allow it. On disk it is 17 GB more (155 + 111 + 8 = 274 GB against 138 + 111 + 8 = 257 GB) and 4 GB more RAM (`ram_gb` 44 against 40 in `setup.py`), while quality is +7.3% perplexity, +3.2% code and +2.2% agent work, against +15.5%, +8.6% and +5.3% for 2.00. Speed does not separate them: `setup.py` already says "about the same speed" for 2.25, and docs/DEEPSEEK41.md measures four R9700 at 48 t/s on 2.00 and 80 on 2.25 (code, shipped profiles). 2.00 remains the right pick for a 12 GB card with 40 GB of RAM - it reads as the default for the tight boxes, while 2.25 is the one a 24 GB / 128 GB PC would want to be offered by name. --- *Reporter context:* reproduced on Windows 11, RTX 3090, `strata-dsv41` 0.1.58, on the **ISTA-DASLab 2.25 bpw (IQ2_XS)** set, the largest of the three official ones (274 GB of disk against 257 GB for 2.00). The same projector serves the 1.75 and 2.00 sets too.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6709594516 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6709871968 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks, this follows the format now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5478
No description provided.