mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #625] Vision (CPU path): offer a Q8_0 mmproj and a higher image-token cap #295
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#295
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
@Niko1221 commented on GitHub (Oct 4, 2026):
Thanks, partly done in 0.1.39. Setup takes
--vision-tokens N(for exampleSTART-HERE.bat --setup --vision cpu --vision-tokens 768), the most image tokens a picture becomes. It is kept in the run config'svision.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 thatvision.mmprojcan 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.@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:
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
@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.
@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.