[GH-ISSUE #625] Vision (CPU path): offer a Q8_0 mmproj and a higher image-token cap #295

Closed
opened 2026-11-04 01:41:44 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @Thxeverybody on GitHub (Oct 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/625

Context
setup.py hardcodes VISION = {"gpu": {"max_tokens": 1024}, "cpu": {"max_tokens": 300}} and always downloads mmproj-Qwen3.8-Flash-Next-BF16.gguf (~0.9 GB). On single-GPU AMD setups (e.g. an RX 9070 XT, 16 GB, also driving the desktop) vision runs on the CPU per --vision cpu — so the encoder is RAM/CPU-bound, and the 300-token image cap limits detail for charts, small text and screenshots.

Observation
strata-vision passes the mmproj straight to mtmd_init_from_file(), and the vendored mtmd supports quantized vision weights — the F32-only check in clip.cpp covers only vector/scalar metadata, not the tower weights. I run this model's mmproj quantized to Q8_0 under llama.cpp at higher image resolutions with good results. On x86 there is no native BF16 GEMM in ggml (BF16 → F32 conversion + F32 matmul), while Q8_0 has optimized AVX-512 dot-product kernels — so a Q8_0 tower should actually encode faster on the CPU at half the memory (~460 MB vs ~908 MB). Q8_0 is generally treated as near-lossless for vision encoders. The engine side is unaffected: it only reads the f32 embeddings (.sve), whose shape doesn't change with the mmproj quantization.

Proposal
Offer a Q8_0 mmproj alongside the BF16 one in the HF repo (or a documented one-liner with llama-quantize, or a --mmproj q8_0 setup flag).
Raise/make configurable the CPU vision token cap. serve/server.py already forwards vision.max_tokens to --max-tokens; only the preset hardcodes 300. The code's own comment measures one CPU encode at “~6 s at 1,024 tokens” — with a Q8_0 tower that seems acceptable as a documented option (e.g. --vision cpu-high, or an image_tokens key).
Optional: expose mtmd's image_min_tokens next to image_max_tokens for upscaling small images.
Suggested validation
Same image set at 300 / 768 / 1024 image tokens, BF16 vs Q8_0 mmproj: CPU encode time, peak RSS, and a small accuracy check (chart reading, OCR). Happy to test on an RX 9070 XT (gfx1201) / Ryzen 9700X and report numbers.

This issue was drafted with support of qwen3.8-flash-next-iq3_s under Strata and Hermes

Originally created by @Thxeverybody on GitHub (Oct 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/625 Context setup.py hardcodes VISION = {"gpu": {"max_tokens": 1024}, "cpu": {"max_tokens": 300}} and always downloads mmproj-Qwen3.8-Flash-Next-BF16.gguf (~0.9 GB). On single-GPU AMD setups (e.g. an RX 9070 XT, 16 GB, also driving the desktop) vision runs on the CPU per --vision cpu — so the encoder is RAM/CPU-bound, and the 300-token image cap limits detail for charts, small text and screenshots. Observation strata-vision passes the mmproj straight to mtmd_init_from_file(), and the vendored mtmd supports quantized vision weights — the F32-only check in clip.cpp covers only vector/scalar metadata, not the tower weights. I run this model's mmproj quantized to Q8_0 under llama.cpp at higher image resolutions with good results. On x86 there is no native BF16 GEMM in ggml (BF16 → F32 conversion + F32 matmul), while Q8_0 has optimized AVX-512 dot-product kernels — so a Q8_0 tower should actually encode faster on the CPU at half the memory (~460 MB vs ~908 MB). Q8_0 is generally treated as near-lossless for vision encoders. The engine side is unaffected: it only reads the f32 embeddings (.sve), whose shape doesn't change with the mmproj quantization. Proposal Offer a Q8_0 mmproj alongside the BF16 one in the HF repo (or a documented one-liner with llama-quantize, or a --mmproj q8_0 setup flag). Raise/make configurable the CPU vision token cap. serve/server.py already forwards vision.max_tokens to --max-tokens; only the preset hardcodes 300. The code's own comment measures one CPU encode at “~6 s at 1,024 tokens” — with a Q8_0 tower that seems acceptable as a documented option (e.g. --vision cpu-high, or an image_tokens key). Optional: expose mtmd's image_min_tokens next to image_max_tokens for upscaling small images. Suggested validation Same image set at 300 / 768 / 1024 image tokens, BF16 vs Q8_0 mmproj: CPU encode time, peak RSS, and a small accuracy check (chart reading, OCR). Happy to test on an RX 9070 XT (gfx1201) / Ryzen 9700X and report numbers. This issue was drafted with support of qwen3.8-flash-next-iq3_s under Strata and Hermes
Author
Owner

@Niko1221 commented on GitHub (Oct 4, 2026):

Thanks, partly done in 0.1.39. Setup takes --vision-tokens N (for example START-HERE.bat --setup --vision cpu --vision-tokens 768), the most image tokens a picture becomes. It is kept in the run config's vision.max_tokens, and a setup run again keeps it. Above the default, setup only adds a note on the encode time; it does not cap anything. DETAILS.md now also says that vision.mmproj can point to a Q8_0 mmproj of this model. A setup run again keeps your own mmproj file there. We don't host a Q8_0 mmproj yet. Your measurements would decide that: the same images at 300 / 768 / 1024 tokens, BF16 vs Q8_0, with CPU encode time, peak RSS and a small accuracy check. Please post them here.

<!-- gh-comment-id:5979961182 --> @Niko1221 commented on GitHub (Oct 4, 2026): Thanks, partly done in 0.1.39. Setup takes `--vision-tokens N` (for example `START-HERE.bat --setup --vision cpu --vision-tokens 768`), the most image tokens a picture becomes. It is kept in the run config's `vision.max_tokens`, and a setup run again keeps it. Above the default, setup only adds a note on the encode time; it does not cap anything. DETAILS.md now also says that `vision.mmproj` can point to a Q8_0 mmproj of this model. A setup run again keeps your own mmproj file there. We don't host a Q8_0 mmproj yet. Your measurements would decide that: the same images at 300 / 768 / 1024 tokens, BF16 vs Q8_0, with CPU encode time, peak RSS and a small accuracy check. Please post them here.
Author
Owner

@Thxeverybody commented on GitHub (Oct 4, 2026):

Measured, as requested. Setup: RX 9070 XT (16 GB) driving the desktop, so vision on the CPU —
Ryzen 7 9700X, 128 GB DDR5-6000, 4 encoder threads, Linux, engine 0.1.39, IQ3_S at 128K context, 49-60 tok/s
loaded and serving alongside (the engine holds its usual VRAM share when the encoder runs).
mmproj files: the BF16 one from the HF repo vs a Q8_0 quant of the same projector —
mradermacher/Qwen3.8-Flash-Next-Uncensored-GGUF, mmproj-Q8_0.

Encode time (steady state, warm 2nd encode of the same image) and peak RSS of the encoder:

cap BF16 Q8_0 RSS BF16 / Q8_0
300 6.1–13.1 s 6.3–6.4 s 1016 / 738 MiB
768 34.0–34.2 s 35.3–36.4 s 1100 / 821 MiB
1024 66.7–67.5 s 67.7–68.3 s 1155 / 876 MiB

Process start to READY was ~0.4 s for both (mmap). Q8_0 is the faster and lighter path at the
CPU default cap (BF16's 300-token numbers were unstable, up to 2× slower — BF16 weights need a
F32 conversion path on x86 where Q8_0 has native dot-product kernels); above 768 they are within
~3 % of each other. Q8_0 saves ~280 MiB RSS consistently, which matters next to a filled engine.

Accuracy — (a) embedding fidelity, per-token cosine BF16 vs Q8_0, same image and cap:
mean 0.997–0.999 in all 9 combinations (worst single token 0.76, one outlier), so the quantization
is effectively lossless at the embeddings the engine actually consumes. (b) End-to-end through the
server at Q8_0@768, three synthetic test images with known ground truth: bar chart with title and
five small value labels — title and all 5 values correct; four colored shapes with positions —
all 4 correct; small text lines (28 px and 18 px) — the exact token in the first line and line 2
correct, line 3 duplicated line 2 instead (the only miss, at 18 px). No Q8_0-specific errors.

Conclusion: a hosted Q8_0 mmproj would be an easy win for CPU-vision users — same quality,
less RAM, faster at the default cap. (mradermacher's repo already has one; hosting/pointing to a
same-pack quant would save users that detour.) Test images and the two scripts are reproducible;
happy to share them or re-run anything (e.g. on GPU vision or with more images).

This bench was drafted with support of qwen3.8-flash-next-iq3_s under Strata and Hermes

<!-- gh-comment-id:5981833272 --> @Thxeverybody commented on GitHub (Oct 4, 2026): Measured, as requested. Setup: RX 9070 XT (16 GB) driving the desktop, so vision on the CPU — Ryzen 7 9700X, 128 GB DDR5-6000, 4 encoder threads, Linux, engine 0.1.39, IQ3_S at 128K context, 49-60 tok/s loaded and serving alongside (the engine holds its usual VRAM share when the encoder runs). mmproj files: the BF16 one from the HF repo vs a Q8_0 quant of the same projector — [mradermacher/Qwen3.8-Flash-Next-Uncensored-GGUF, mmproj-Q8_0](https://huggingface.co/mradermacher/Qwen3.8-Flash-Next-Uncensored-GGUF/blob/main/Qwen3.8-Flash-Next-Uncensored.mmproj-Q8_0.gguf). **Encode time (steady state, warm 2nd encode of the same image)** and **peak RSS** of the encoder: | cap | BF16 | Q8_0 | RSS BF16 / Q8_0 | |---:|---:|---:|---:| | 300 | 6.1–13.1 s | **6.3–6.4 s** | 1016 / **738** MiB | | 768 | 34.0–34.2 s | 35.3–36.4 s | 1100 / **821** MiB | | 1024 | 66.7–67.5 s | 67.7–68.3 s | 1155 / **876** MiB | Process start to READY was ~0.4 s for both (mmap). Q8_0 is the faster and lighter path at the CPU default cap (BF16's 300-token numbers were unstable, up to 2× slower — BF16 weights need a F32 conversion path on x86 where Q8_0 has native dot-product kernels); above 768 they are within ~3 % of each other. Q8_0 saves ~280 MiB RSS consistently, which matters next to a filled engine. **Accuracy** — (a) embedding fidelity, per-token cosine BF16 vs Q8_0, same image and cap: mean 0.997–0.999 in all 9 combinations (worst single token 0.76, one outlier), so the quantization is effectively lossless at the embeddings the engine actually consumes. (b) End-to-end through the server at Q8_0@768, three synthetic test images with known ground truth: bar chart with title and five small value labels — title and all 5 values correct; four colored shapes with positions — all 4 correct; small text lines (28 px and 18 px) — the exact token in the first line and line 2 correct, line 3 duplicated line 2 instead (the only miss, at 18 px). No Q8_0-specific errors. Conclusion: a hosted Q8_0 mmproj would be an easy win for CPU-vision users — same quality, less RAM, faster at the default cap. (mradermacher's repo already has one; hosting/pointing to a same-pack quant would save users that detour.) Test images and the two scripts are reproducible; happy to share them or re-run anything (e.g. on GPU vision or with more images). This bench was drafted with support of qwen3.8-flash-next-iq3_s under Strata and Hermes
Author
Owner

@Niko1221 commented on GitHub (Oct 6, 2026):

In 0.1.40: DETAILS recommends a Q8_0 encoder for --vision cpu, gives the llama-quantize command and our fidelity numbers (embedding cosine 0.9988 and 0.9987 on two pictures at 300 tokens), and setup prints a tip. Thank you for the measurements. Keeping this open until a Q8_0 file is hosted next to the BF16 one.

<!-- gh-comment-id:6010900479 --> @Niko1221 commented on GitHub (Oct 6, 2026): In 0.1.40: DETAILS recommends a Q8_0 encoder for --vision cpu, gives the llama-quantize command and our fidelity numbers (embedding cosine 0.9988 and 0.9987 on two pictures at 300 tokens), and setup prints a tip. Thank you for the measurements. Keeping this open until a Q8_0 file is hosted next to the BF16 one.
Author
Owner

@Niko1221 commented on GitHub (Oct 7, 2026):

Shipped. --vision-tokens is in 0.1.39, and 0.1.40 adds --min-tokens and the Q8_0 mmproj tip and docs, based on your measurements that Q8_0 is smaller and as good. We do not host a Q8_0 file yet. Closing; thank you for the numbers.

<!-- gh-comment-id:6037722986 --> @Niko1221 commented on GitHub (Oct 7, 2026): Shipped. --vision-tokens is in 0.1.39, and 0.1.40 adds --min-tokens and the Q8_0 mmproj tip and docs, based on your measurements that Q8_0 is smaller and as good. We do not host a Q8_0 file yet. Closing; thank you for the numbers.
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#295
No description provided.