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

+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");