engine: do not load the vision tower in a build without a media decoder

With --mm-max-patches auto, a container that carries a vision tower gets 16384
patches and the tower on the card. A build without a media decoder
(RAD_WITH_FFMPEG off: mm::decoder_available() is false) refuses every media
part -- MultimodalBridge::accepts() says no -- so the tower can never run a
pass; it only holds card memory the routed experts are short of. On
Qwen3.8-Flash-Next at tp 2 on two R9700 that is 857 MiB a rank, about 800
expert units a rank, which the routed GEMMs then read from the pinned pool over
the link instead of from the card.

The automatic choice is now 0 in such a build, with an info line and a
decision-table entry that say why; the audio encoder's automatic size already
follows --mm-max-patches 0. An explicit --mm-max-patches N still loads the
tower. The flag's help and the GUIDE row say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 authored and StillDeadcode committed 2026-11-17 18:19:58 +01:00
1 parent 7bd195d394
commit 73f94b4345
3 files changed
+20 -4

No files matched your search

+3 -2
View File
@@ -232,8 +232,9 @@ static const Flag g_flags[] = {
" never access; repeatable" },
{ "--served-model-name", "NAME", "the model id /v1/models lists and responses carry; default the container's name" },
{ "--mm-max-patches", "N", "patches one encoder pass carries, and so the largest image (a patch is 16x16\n"
"pixels). Default `auto`: 16384 when the container carries a vision tower. 0\n"
"serves text only and keeps the tower off the card" },
"pixels). Default `auto`: 16384 when the container carries a vision tower (0 in a build\n"
"without a media decoder, which would refuse every media part). 0 serves text\n"
"only and keeps the tower off the card" },
{ "--image-gen-max-pixels", "N", "an image generator's largest image, in pixels (1048576: 1024 x 1024).\n"
" Default: the model's. Its per-image buffers, and the activation\n"
" arena with them, are sized for it; larger requests are refused" },
+16 -1
View File
@@ -26,6 +26,7 @@
#include "mem/vram_budget.h"
#include "kvstream/bringup.h"
#include "kvstream/plan.h"
#include "mm/media.h"
#include "runtime/arena.h"
#include "runtime/kvbind.h"
#include "runtime/xprefetch.h"
@@ -1315,18 +1316,32 @@ int Engine::declare() {
const bool tower = rad_meta_geti(&meta_, "vision_config.patch_size", 0) > 0 ||
rad_meta_geti(&meta_, "vision_config.image_size", 0) > 0;
cfg_.mm_max_patches = (enc && *enc) || (!file_ && tower) ? 16384 : 0;
/* A build with no media decoder (RAD_WITH_FFMPEG) refuses every media part, so a tower it
* loaded could never run a pass: it would only hold card memory the routed experts are
* short of. Qwen3.8-Flash-Next at tp 2 on two R9700: 857 MiB a rank, about 800 expert
* units a rank that the routed GEMMs then read from the pinned pool over the link instead
* of from the card. An explicit --mm-max-patches still loads the tower. */
const bool undecodable = cfg_.mm_max_patches > 0 && !mm::decoder_available();
if (undecodable) cfg_.mm_max_patches = 0;
/* Whole output rows a pass: the plugin's merge, when it states one. */
RadArchProbe pb{};
(void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs);
if (cfg_.mm_max_patches > 0 && pb.enc_merge > 1)
cfg_.mm_max_patches -= cfg_.mm_max_patches % pb.enc_merge;
if (cfg_.mm_max_patches == 0 && tower)
if (undecodable)
RAD_INFO("media: off -- the model carries a vision tower, but this build has no media "
"decoder (RAD_WITH_FFMPEG) and would refuse every media part, so the tower "
"is not loaded and its card memory goes to the experts and the cache; "
"--mm-max-patches N loads it all the same");
else if (cfg_.mm_max_patches == 0 && tower)
RAD_INFO("media: off -- the checkpoint has a vision tower but this container was "
"converted without its weights; convert again to serve images and video");
decide("--mm-max-patches", std::to_string(cfg_.mm_max_patches),
cfg_.mm_max_patches > 0
? "the model carries a vision tower: 16384 patches is a 2048 x 2048 image, the "
"largest one encoder pass takes"
: undecodable ? "the model carries a vision tower, but this build has no media "
"decoder to feed it"
: tower ? "the checkpoint has a vision tower but this container was converted "
"without its weights"
: "the model carries no vision tower");
+1 -1
View File
@@ -2424,7 +2424,7 @@ switch is set with `true`. The fleet's own keys (a model's `aliases`, `priority`
| `server.api-key-env: NAME` | — | read the API key from the environment variable `NAME` instead of the file, so the key is not written where the configuration is kept or shown; an unset or empty `NAME` refuses startup like an empty `server.api-key` |
| `server.allow-host: NAME` | — | a `Host` name the keyless loopback-only routes accept besides the loopback names; a list for several (§6.6) |
| `server.trusted-proxy: CIDR` | — | a network whose sockets may name the client behind them, via `X-Forwarded-For`, for the log; vouching changes attribution, never access; a list for several (§6.6) |
| `mm-max-patches: N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.18) |
| `mm-max-patches: N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower, and 0 in a build without a media decoder (`RAD_WITH_FFMPEG`: it would refuse every media part, so the tower is not loaded and its card memory goes to the experts; an explicit N loads it); 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.18) |
| `override-chat-template: PATH` | container's | a Jinja chat template file served in place of the container's. The reply format (reasoning markers, tool calls) is derived from it too, unless the architecture plugin declares one. An unreadable or empty file stops startup |
| `max-queued-requests: N` | 8 × `max-num-seqs` | requests admitted and unfinished at once; past it, 429 |
| `server.http-threads: N` | one per hardware thread, at least 4 | HTTP workers kept while idle |