From 17e2721354d89923f858a94c06bf1110ef1f7499 Mon Sep 17 00:00:00 2001 From: Robert Karl Date: Sun, 18 Oct 2026 00:33:59 -0700 Subject: [PATCH] frontend: picture row budget as upstream's installer set it (300 on the CPU, 1024 on the GPU); --mmproj-gpu refused without a GPU backend An uncapped 1920x1080 screenshot is 2040 rows and took 146 s on the A6000 VM's Ryzen 7 1700. Upstream's setup.py gave strata-vision --max-tokens 300 on the CPU and 1024 on the GPU; the same defaults here, --image-max-tokens overrides. The front end's ggml has no GPU backend (the engines bring their own CUDA), so --mmproj-gpu now fails at start instead of running on the CPU under a GPU label. Co-Authored-By: Claude Fable 5.1 --- frontend/strata_context.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/strata_context.cpp b/frontend/strata_context.cpp index 3e65324..ab15a19 100644 --- a/frontend/strata_context.cpp +++ b/frontend/strata_context.cpp @@ -18,6 +18,7 @@ #include "llama.h" #include "log.h" #include "gguf.h" +#include "ggml-backend.h" #include "mtmd.h" #include "mtmd-helper.h" @@ -432,6 +433,12 @@ struct strata_context_impl { err = "the model has no <|image_pad|> token; pictures are supported for the Qwen family only so far"; return false; } + if (p.mmproj_use_gpu && ggml_backend_dev_by_type(GGML_BACKEND_DEVICE_TYPE_GPU) == nullptr) { + // ggml in this build has no GPU backend (the engines bring their own CUDA; llama.cpp's ggml is built + // without it), so mtmd would silently run on the CPU + err = "--mmproj-gpu: this build's ggml has no GPU backend; the encoder can only run on the CPU"; + return false; + } mtmd_context_params cp = mtmd_context_params_default(); // the request parser (server-common) replaces each image_url part by a marker that is random per process // (get_media_marker); mtmd must look for that same marker, as server-context.cpp sets it @@ -441,9 +448,10 @@ struct strata_context_impl { cp.warmup = p.mmproj_use_gpu; // on the card, allocate the work buffers now, not at the first picture cp.n_threads = p.cpuparams.n_threads > 0 ? p.cpuparams.n_threads : std::max(1u, std::thread::hardware_concurrency() / 2); - if (p.image_max_tokens > 0) { - cp.image_max_tokens = p.image_max_tokens; - } + // the picture's row budget: upstream's installer gave the CPU encoder 300 tokens and the GPU one 1024 + // (setup.py VISION); the encoder's attention is quadratic in it (a 1920x1080 screenshot uncapped is 2040 + // rows: 146 s on a Ryzen 7 1700). --image-max-tokens overrides. + cp.image_max_tokens = p.image_max_tokens > 0 ? p.image_max_tokens : (p.mmproj_use_gpu ? 1024 : 300); if (p.image_min_tokens > 0) { cp.image_min_tokens = p.image_min_tokens; } @@ -456,8 +464,8 @@ struct strata_context_impl { vision_width = proj_width; image_pad_id = pad[0]; p_mmproj_gpu = p.mmproj_use_gpu; - LOG_INF("vision: %s, rows of %d, encoder on the %s (%d CPU threads), image_pad=%d\n", - p.mmproj.path.c_str(), vision_width, cp.use_gpu ? "GPU" : "CPU", cp.n_threads, image_pad_id); + LOG_INF("vision: %s, rows of %d, encoder on the %s (%d CPU threads), at most %d rows a picture, image_pad=%d\n", + p.mmproj.path.c_str(), vision_width, cp.use_gpu ? "GPU" : "CPU", cp.n_threads, cp.image_max_tokens, image_pad_id); return true; }