Multimodal Pipeline¶
With gRPC workers, SMG runs the multimodal front end for the engine. It fetches each image or video, preprocesses it the way the model's reference processor does, expands the prompt's placeholder tokens to the right length, and sends the encoder tensors to the worker. vLLM gRPC workers can instead receive the media URLs and process them on the engine.
Overview¶
Router-Side Preprocessing¶
The default. SMG fetches, decodes, and preprocesses media in Rust, following each model's reference processor, and sends ready-to-encode tensors.
Worker-Side Processing¶
vLLM gRPC workers that advertise a media processor receive media URLs instead and run vLLM's own processor (in process or in a Redis sidecar) or, on the Rust servicer, SMG's own pipeline.
Reference-Rate Video¶
Clips are sampled at the model's reference frame rate, decoded with ffmpeg or OpenCV, and preprocessed in parallel.
Transport Options¶
Tensors travel inline in the gRPC message, through same-host shared memory, or over an RDMA pixel lane to TokenSpeed workers.
Request Flow¶
SMG accepts media on these APIs:
| API | Media input |
|---|---|
Chat Completions (/v1/chat/completions) |
image_url, video_url, audio_url, and input_audio content parts in any non-assistant message |
Messages (/v1/messages) |
image blocks with a base64 or url source, in user messages |
Responses (/v1/responses) |
input_image content parts that carry an image_url |
Media URLs can be http://, https://, or base64 data: URLs.
On the gRPC path, a media request goes through these steps:
- Plan and validate. SMG collects the media parts in prompt order and picks the model's processor from the model name and its
config.jsonmodel_type. A modality the model does not take, or more items than the per-request limit, is rejected before anything is fetched; so is a request whose model has no processor, unless its media can go to a worker that processes media itself (see below). - Render and check anchors. The chat template renders one placeholder anchor per item (for example
<|image_pad|>for Qwen3-VL). After tokenizing, SMG checks that the prompt holds exactly one anchor per item. - Choose where to process.
--mm-processingdecides between the router and a vLLM worker (see Where Media Is Processed). - Fetch and decode. Items are fetched concurrently. Images are decoded and videos are sampled into frames.
- Preprocess and expand. The model's processor turns each item into encoder tensors and a feature-token count. SMG replaces each anchor with the model's full placeholder run, including any per-frame markers and timestamps.
- Select a worker. The request is refused if the selected engine does not accept one of its modalities.
- Assemble and send. The tensors are serialized for that engine and sent inline, through shared memory, or over RDMA. With
--multimodal-max-inflight-bytesset, the request first reserves room for its media.
A model SMG has no processor for can still serve media when the media go to a worker that processes them itself (see Where Media Is Processed). The decision is made before any render or fetch, by the chat template the request renders through: a template that takes message content as a list of parts writes the engine's own placeholders into the prompt, so the request goes on to the worker, and SMG checks no anchors of its own — the worker's engine checks its placeholders against the media it fetches. A template that takes one string per message leaves the anchors to SMG, which knows none for this model, so the request is refused with 400 multimodal_not_supported, with a message naming the request's modalities and the model.
A checkpoint can ship one template for requests that declare tools and another for the rest; the decision follows the template this request renders through (see Chat Templates and Native Renderers). The rule is the same on Chat Completions, the Messages API (/v1/messages/count_tokens included) and the Responses API.
The processor configuration (config.json, preprocessor_config.json, and, when present, processor_config.json and video_preprocessor_config.json) comes from the tokenizer bundle the gRPC worker serves, or from the tokenizer source (a local directory or a Hugging Face download).
Where Media Is Processed¶
--mm-processing decides, per request, whether SMG preprocesses the media or forwards media references to a vLLM gRPC worker that processes them itself (smg-project/smg#2399, #2400). Only vLLM gRPC workers process references; every other engine receives router-preprocessed media.
| Mode | Behavior |
|---|---|
auto (default) |
Forward references when the request is forwardable, the model supports worker-side expansion, and every registered worker of the model is a vLLM gRPC worker that advertises a media processor — or, on an EPD pool, every encode worker of the model is a vLLM worker that advertises a media processor and the encoder-cache transfer; the prefill and decode workers consume the expanded identity and need no processor (see EPD). Otherwise preprocess on the router. |
router |
Always preprocess on the router. |
worker |
Forward references. A request with per-item hints (fps, max_long_side_pixel) is preprocessed on the router instead when SMG can apply the hints itself (it has a processor for the model's family and every media part is an image_url or video_url), and refused with 400 multimodal_hint_unsupported_in_worker_mode when it cannot. Any other request that cannot be forwarded is refused with 400; when no worker of the model advertises a media processor, SMG returns 503 no_media_ref_capable_worker. |
A request is forwardable when every media part is an image_url or video_url without per-item hints (fps, max_long_side_pixel), or an audio part (audio_url, or input_audio, which is forwarded as a base64 data: URL). Audio is forwarded only when the model supports worker-side expansion of its audio anchor (Gemma 4, for example), and only to a worker running --mm-processor inprocess or redis: a worker running SMG's own pipeline (smg) takes image and video references, never audio.
The flag falls back to SMG_MM_PROCESSING (deprecated; env support ends in the next minor release), then auto. An unreadable SMG_MM_PROCESSING stops the gateway at startup.
In auto, SMG consults every registered worker of the model, healthy or not, so a health flap does not move a model between modes. Each decision is counted in smg_mm_processing_total{model,mode,reason}, with reason config, plan_not_forwardable, model_not_opted_in, auto_none (no registered workers), auto_uniform, or auto_mixed.
On the worker path:
- The request carries the unexpanded prompt (one anchor per item) and the media URLs in prompt order.
- An inline
data:URL larger thanSMG_IMAGE_MAX_INPUT_BYTES,SMG_VIDEO_MAX_INPUT_BYTES, orSMG_AUDIO_MAX_INPUT_BYTES(each capping its own modality) is refused withmedia_ref_too_large. - Every URL scheme must be one the selected worker advertises in its
mm_media_ref_schemeslabel:http,https, anddata, plusfilewhen vLLM runs with--allowed-local-media-path(never with thesmgprocessor). - Direct ZMQ workers and TokenSpeed EPD encode workers never take references. On a vLLM EPD pool, forwarded references go to the encode workers, which fetch and process the media themselves (see EPD).
Worker-Side Processing on vLLM¶
A vLLM gRPC worker processes references when its servicer runs a media processor:
SMG_VLLM_MM_PROCESSOR=inprocess \
vllm serve Qwen/Qwen3-VL-8B-Instruct --grpc --allowed-media-domains example.comThe servicer reads each setting below from its --mm-* flag, and otherwise from the matching SMG_VLLM_MM_* variable. The smg-grpc-servicer package adds the flags to both gRPC launchers' parsers (vllm serve --grpc and python -m vllm.entrypoints.grpc_server) as a vllm.general_plugins plugin, so either form works on the worker's command line.
On a launcher that offers the flag, a value read from the matching variable logs a deprecation warning, and env support there ends in the next minor release. SMG_VLLM_MM_TURBOJPEG, SMG_VLLM_MM_FETCH_TIMEOUT_MS, SMG_VLLM_MM_VIDEO_FETCH_TIMEOUT_MS, and SMG_MM_ALLOW_PRIVATE_MEDIA_HOSTS are the exceptions: they stay supported settings beside their flags and never log the warning. Where the flags are absent — a VLLM_PLUGINS setting that leaves the smg-servicer plugin out, or a servicer built directly rather than by a launcher — the variables are the supported settings and no warning is logged.
| Servicer flag | Env fallback | Default | Description |
|---|---|---|---|
--mm-processor |
SMG_VLLM_MM_PROCESSOR |
off |
off, inprocess (fetch and process inside the vLLM process), redis (hand jobs to a sidecar), or smg (SMG's own pipeline, Rust servicer only) |
--mm-max-inflight |
SMG_VLLM_MM_MAX_INFLIGHT |
64 |
Multimodal jobs the worker runs at once, whichever processor runs; once as many are waiting, further requests are shed with a retryable error |
--mm-max-items |
SMG_VLLM_MM_MAX_ITEMS |
unset | Overrides the per-modality item limits the worker takes from vLLM's --limit-mm-per-prompt |
--mm-max-item-bytes |
SMG_VLLM_MM_MAX_ITEM_BYTES |
32 MiB | Cap on one inline data: payload |
--mm-fetch-timeout-ms |
SMG_VLLM_MM_FETCH_TIMEOUT_MS |
10000 |
Download budget per image or audio URL (smg processor only); must be positive |
--mm-video-fetch-timeout-ms |
SMG_VLLM_MM_VIDEO_FETCH_TIMEOUT_MS |
30000 |
Download budget per video URL (smg processor only); must be positive |
--mm-redis-url |
SMG_VLLM_MM_REDIS_URL |
redis://127.0.0.1:6379/0 |
Sidecar Redis (redis mode) |
--mm-sidecar-timeout-ms |
SMG_VLLM_MM_SIDECAR_TIMEOUT_MS |
30000 |
How long the worker waits for a sidecar result |
--mm-sidecar-max-queue |
SMG_VLLM_MM_SIDECAR_MAX_QUEUE |
256 |
Fail fast once this many jobs are queued for the sidecar |
--mm-sidecar-namespace |
SMG_VLLM_MM_SIDECAR_NAMESPACE |
derived | Overrides the Redis key namespace |
SMG_VLLM_MM_MAX_VIDEO_FRAMES (env only; default 0, which leaves it to vLLM's --media-io-kwargs) caps the frames a video is sampled to.
The worker advertises its processor in the mm_processor, mm_processor_source, and mm_media_ref_schemes labels, which appear in GET /workers. An engine started with --language-model-only never advertises one. With inprocess and redis, vLLM's own --allowed-media-domains, --allowed-local-media-path, --media-io-kwargs, --limit-mm-per-prompt, and VLLM_*_FETCH_TIMEOUT govern fetching on the worker; without --allowed-media-domains the worker fetches from any host. The smg processor fetches with SMG's own connector instead (see SMG's Pipeline on the Rust Servicer).
Failures keep their cause. The caller's own mistakes (a bad URL, a disallowed host, an oversized payload) come back as 400, and a saturated worker or a sidecar that is down or overloaded as a retryable 503. A sidecar timeout is not retried, because the worker already spent the whole budget on that input.
Each processor answers a fetch that fails on the wire — a name that does not resolve, a refused connection, a timeout, an origin 5xx — in its own way. The redis sidecar answers with a 400 whose message includes fetch_failed. smg reports whose fault the fetch is, so the request gets the same 400-or-502 split as on the router path (see Errors).
How inprocess answers depends on the servicer that runs it. On the deprecated Python servicer, every fetch that fails on the wire is a retryable 503. The Rust servicer, the default, reports whose fault the fetch is, as smg does: a name the resolver says does not exist, a refused connection, or a TLS handshake the origin fails is a 400, and a timeout or an origin 5xx is a 502, both under media_fetch_failed. A failure that names the worker itself rather than the reference's host — its proxy, its own resolver, its routes or egress rules — stays a retryable 503 even on the Rust servicer, since another worker may fetch what this one cannot.
On the Rust servicer, inprocess also answers the caller's other media mistakes under the router path's codes, each a 400: invalid_multimodal_request for a reference refused before the download or bytes that do not decode, media_fetch_failed for a download the origin refused (a 4xx) or redirected to a disallowed host, and media_too_large for media over a size cap.
Redis Media-Processing Sidecar¶
The sidecar moves fetching and processing out of the vLLM process (smg-project/smg#2401). It is a GPU-free process that runs next to the worker with a private Redis: it pops jobs, fetches with vLLM's MediaConnector, runs vLLM's multimodal processor over the unexpanded prompt, and pushes full tensors back.
pip install "smg-grpc-servicer[vllm,vllm-redis]"
python -m smg_grpc_servicer.vllm.mm_sidecar --model Qwen/Qwen3-VL-8B-Instruct \
--redis-url redis://127.0.0.1:6379/0 --allowed-media-domains example.com
SMG_VLLM_MM_PROCESSOR=redis SMG_VLLM_MM_REDIS_URL=redis://127.0.0.1:6379/0 \
vllm serve Qwen/Qwen3-VL-8B-Instruct --grpc- The sidecar takes
--redis-url(falls back toSMG_VLLM_MM_REDIS_URL, then localhost),--namespace(falls back toSMG_VLLM_MM_SIDECAR_NAMESPACE),--concurrency(default2), and vLLM's engine flags. It has no timeout flag: the worker's--mm-sidecar-timeout-mstravels with each job as its deadline (smg-project/smg#2651). - The worker and the sidecar must agree on the model, vLLM version, dtype, video backend, media and processor kwargs, and
--limit-mm-per-prompt(pass it to both; the sidecar's limit is the one that applies). The worker advertisesmm_processor=redisonly while a sidecar with a matching fingerprint keeps itshellokey alive (refreshed every 5 seconds, 15-second TTL). SMG reads the label when it registers the worker, so start the sidecar first: a worker registered while no sidecar was up keeps the model on the router path inautountil that worker is registered again. - Jobs and results travel over Redis lists under
smg:mm:v1:{namespace}, and results expire after 120 seconds. An encoded result at or aboveSMG_VLLM_MM_MAX_RESULT_BYTES(default 512 MiB, lowered to Redis'sproto-max-bulk-lenwhen that is smaller) is not pushed; the request fails with a 400 whose message includesmedia_too_large.
SMG's Pipeline on the Rust Servicer¶
--mm-processor smg runs SMG's own media pipeline — the same fetch, decode, preprocess, and placeholder expansion the router runs for --mm-processing router — inside the worker, with no Python on the request path (smg-project/smg#2741). The resulting batches reach the engine as a router-preprocessed request's would. The mode exists only in the Rust vLLM servicer and, like that servicer, exists since v1.12.0; the Python servicer refuses the value at startup with an error pointing to --servicer-impl rust / SMG_VLLM_SERVICER_IMPL=rust.
SMG_VLLM_SERVICER_IMPL=rust SMG_VLLM_MM_PROCESSOR=smg \
vllm serve Qwen/Qwen3-VL-8B-Instruct --grpc- The worker serves the model families SMG's pipeline supports (see Supported Models); a multimodal model outside them is refused at startup, while a text-only model ignores the setting as it does the other processors. The router still decides per model whether to forward references at all (see Where Media Is Processed):
smgchanges what runs once references arrive, not which models they are forwarded for. - The pipeline takes image and video references, never audio: a request carrying audio is placed on the model's
inprocessorredisworkers instead. - The pipeline reads the model's
config.jsonand preprocessor configs from the model directory, or from the tokenizer directory the launcher resolved. The engine'smm_processor_kwargsare applied as overrides of the preprocessor config; a key the config has no field for fails the launch rather than being ignored. - The worker advertises
mm_processor=smgandmm_media_ref_schemes=http,https,data, and fetches from any host.--mm-fetch-timeout-msand--mm-video-fetch-timeout-msset its download budgets (10 and 30 seconds by default); each budget covers one URL's fetch, from connecting through the last byte, not decoding or inference. vLLM's--allowed-media-domainsand--allowed-local-media-pathdo not apply, andfileURLs are never accepted. --mm-max-inflightand--mm-max-item-bytesapply as above.--mm-max-itemsoverrides the model's built-in per-request limits rather than vLLM's--limit-mm-per-prompt, but the engine's limits stay a ceiling: where the engine reports them, the pipeline never admits more items of a modality than the engine's own server takes.SMG_VLLM_MM_MAX_VIDEO_FRAMEScan lower, never raise, the engine frame budget Gemma 4 clips are sampled under (see Frame Sampling). The Redis sidecar settings are not used.- An engine that normalizes pixels on device (vLLM's
mm_device_do_normalize, on by default for the Qwen-VL family) takes rawuint8pixels, and the pipeline writes those for it. A model whose processor produces only normalized floats is refused at startup under that setting: start the engine with--mm-device-do-normalize=falseor useinprocess. Otherwise pixels are written in the engine's own dtype. - The in-flight cap, the saturation refusal, and the PD prefill leg's
media_identitybehave as with the Python backends.
Supported Models¶
SMG picks a model's processor from the model name and its config.json model_type. These families have vision support. Most families set no per-request media count of their own (no limit of its own below): such a modality is bounded by the deployment's media-count settings, never above the per-request limit the model's workers advertise for their engine; with neither, the context length is the practical bound. The counts in the table are the limits a family keeps of its own:
| Model family | Images | Video | Worker-side expansion on vLLM |
|---|---|---|---|
Qwen3-VL, Qwen3.5, Qwen3.6, Qwen4-Exp (qwen4_exp) |
No limit of its own | No limit of its own ¹ | Images and video |
| Qwen2-VL, Qwen2.5-VL | No limit of its own | — | — |
| Qwen3-Omni | No limit of its own | No limit of its own | — |
| MiniMax-M3 | 200 | 20 clips ¹ | Images and video ² |
| Muse Spark ⁴ | No limit of its own | No limit of its own | — |
| Nemotron-H Omni ⁴ | No limit of its own | No limit of its own | — |
| GLM-5.3-Flash | 64 | 2 clips ¹ | Images |
| Kimi-K3 | No limit of its own | — | — ³ |
| Kimi-K2.5 | 10 | — | — |
| DeepSeek-V4.1 | No limit of its own | — | — |
| Gemma 4 ⁵ | No limit of its own | No limit of its own ¹ | Images, video, and audio |
| Llama 4 | 8 | — | Images |
| LLaVA 1.5, LLaVA-NeXT | 4 | — | — |
| Phi-3 and Phi-3.5 vision | 4 | — | — |
| Inkling | No limit of its own (when the checkpoint enables its vision tower) | — | — |
¹ When the checkpoint declares the tokens its video layout needs.
² vLLM currently sizes some MiniMax-M3 images differently from SMG, so answers on the two paths can differ (smg-project/smg#2609).
³ Kimi-K3 media stay on the router path: vLLM's Kimi-K3 processor expands a different anchor than the one SMG renders (smg-project/smg#2644).
⁴ Muse Spark and Nemotron-H Omni media are served on TokenSpeed workers only: the tensors are packed in a layout the other engines do not read. Each Muse Spark checkpoint's config declares the modalities it takes: images with image_token_id, video with video_token_id, and audio with the audio tower (an audio_config plus audio_token_id). Every Nemotron-H Omni checkpoint takes images and video, and a checkpoint whose config carries the sound tower (sound_config) also takes audio; a config whose vision or sound geometry differs from the one SMG's processors implement for the family is refused rather than served with the wrong grids.
⁵ Each Gemma 4 checkpoint's config declares the modalities it takes: images with image_token_id (and its begin/end marker tokens), video with video_token_id, and audio with the audio tower (an audio_config plus audio_token_id).
Audio (audio_url, input_audio) is accepted only on TokenSpeed workers for Qwen3-Omni, Qwen3-ASR, Inkling, Muse Spark, and Nemotron-H Omni, and only on the vLLM worker path for Gemma 4. None of these families sets an audio-clip count of its own: SMG_AUDIO_MAX_COUNT and the engine's advertised limit bound the count. Muse Spark serves audio on checkpoints that ship the audio tower; each clip is resampled to 24 kHz and zero-padded to a whole number of audio tokens (1,920 samples per token), and the clip's placeholder run in the prompt is that token count.
Nemotron-H Omni serves audio on checkpoints whose config carries the sound tower (sound_config). Each audio input is resampled to the sound tower's sampling_rate and split into clips of at most 30 seconds, and its placeholder run in the prompt is one token per encoder position — each clip's mel frames (one per 160 samples) after the encoder's 8x subsampling. Audio longer than 600 seconds is refused, matching vLLM's default audio-decode limit.
Gemma 4 serves audio on checkpoints that ship the audio tower. SMG has no audio preprocessor for the family, so its clips are never preprocessed on the router: they are forwarded as media references (an input_audio part as a base64 data: URL) to a worker running --mm-processor inprocess or redis, and the engine's own processor fetches and expands them (see Where Media Is Processed).
Engine Support¶
| gRPC engine | Images | Video | Audio | What SMG sends |
|---|---|---|---|---|
| vLLM | ✓ | ✓ | Media references only | Preprocessed tensors with per-item content hashes, or media references on the worker path |
| TokenSpeed | ✓ | ✓ | ✓ | Preprocessed tensors, one set per item |
| SGLang | ✓ | ✗ | ✗ | Preprocessed float32 pixel tensors plus the original image bytes |
| TensorRT-LLM | ✓ | ✗ | ✗ | The original image bytes |
| MLX | ✗ | ✗ | ✗ | — |
vLLM and TokenSpeed take several modalities in one request, such as images and video together. A modality the selected engine does not take is refused with 400 multimodal_not_supported.
Video¶
Decoding¶
SMG decodes video on the gateway. The default build runs ffprobe and ffmpeg, which must be on the gateway's PATH; without them a video request fails with ffmpeg executable not found. Builds with the opencv-video feature decode with OpenCV first and fall back to ffmpeg. The SMG container image is built with opencv-video and ships ffmpeg; the PyPI wheels are built without opencv-video.
| Setting | Default | Description |
|---|---|---|
SMG_VIDEO_DECODE_BACKEND |
auto |
auto, opencv (needs opencv-video), or ffmpeg |
SMG_VIDEO_PROCESS_TIMEOUT_SECS |
30 |
Time limit for each ffprobe or ffmpeg run and each OpenCV decode |
SMG_VIDEO_MAX_DECODED_BYTES |
1 GiB | Cap on a clip's decoded RGB frames |
Concurrent decodes share one CPU budget: each ffmpeg or OpenCV decode gets fewer threads as more run at once (smg-project/smg#2583).
Frame Sampling¶
| Default | Per-request override | |
|---|---|---|
| Frame rate | The model's reference rate: 1 fps for MiniMax-M3, the video processor config's fps for Muse Spark (default 2), 2 fps for other models. Gemma 4 and Nemotron-H Omni sample by frame count, not rate (see below). |
video_url.fps, from 0.2 to 5.0 |
| Frame count | Clip duration times the frame rate, kept within 4 to 768 frames. Muse Spark instead follows the checkpoint's video processor config, GLM-5.3-Flash its family's own loader rule, and Gemma 4 and Nemotron-H Omni follow vLLM's default loader rule of at most 32 frames (see below). | — |
| Frame placement | Spread evenly from the first frame to the last. MiniMax-M3 takes one frame per interval from the start and always keeps the last frame, as its reference does. GLM-5.3-Flash picks frames with its family's loader walk, and Gemma 4 and Nemotron-H Omni keep every frame of a clip within their 32-frame budget (see below). | — |
| Frame size | Set by the model's processor | video_url.max_long_side_pixel: a multiple of 28 from 150 to 3584, applied to the decoded frames |
fps and max_long_side_pixel are MiniMax-M3 extensions to the OpenAI content part, and SMG applies them for any model. A part with any of these hints is never forwarded to a worker: even under --mm-processing worker, a request carrying one is preprocessed on the router when SMG can apply the hints itself, and refused with 400 multimodal_hint_unsupported_in_worker_mode when it cannot (SMG has no processor for the model's family, or the request also carries audio).
image_url.max_long_side_pixel caps an image's long side. On MiniMax-M3, any positive value is accepted, and an image without the hint gets the default cap of 2016. SMG plans the output size from the source dimensions, keeping the aspect ratio: an image whose long side exceeds the cap is shrunk to the cap; otherwise an image whose short side is below 112 is enlarged until that side reaches 112, even if its long side then exceeds the cap. Both sides are then rounded to the nearest multiple of 28 to fit the patch grid, which can also leave the final long side slightly above the cap. An image whose planned size exceeds 12,845,056 pixels is refused with media_too_large before it is decoded.
On other model families, image_url.max_long_side_pixel must be a positive multiple of 28 and only shrinks an image whose long side exceeds it. Video frames follow the rule in the table above for every model.
{"type": "video_url", "video_url": {"url": "https://example.com/clip.mp4", "fps": 1.0}}Models whose reference processor lays video out in timestamped blocks get the same layout from SMG: Qwen3-VL, GLM-5.3-Flash, Gemma 4, and MiniMax-M3 prompts carry one timestamped block per frame or per temporal group of sampled frames — for GLM-5.3-Flash, each block covers a temporal group of two sampled frames. For MiniMax-M3, SMG also applies the pixel budget per frame and stamps each temporal group with the time of its first sampled frame, as its reference does.
GLM-5.3-Flash clips follow the family's own loader rule rather than the 4-to-768-frame window: the clip's duration times the sampling rate, truncated to a whole number of frames, up to 2,048. The frames are placed the way the model's reference loader walks a clip — one frame each time the clip's clock reaches the next sampling instant, with the instants spaced at twice the rate, then re-spread evenly when the walk's count misses the target — and each distinct frame is kept once, in temporal groups of two (an odd count repeats the last frame, as the model's processor does). A per-request fps hint still overrides the 2 fps rate; a rate the checkpoint's video processor config states does not move it. A clip shorter than one sampling interval (1 / rate seconds: half a second at the default rate) gives the rule no frame to pick, so it is refused with 400 media_fetch_failed before any frames are decoded.
Gemma 4 clips follow vLLM's default loader rule rather than the 4-to-768-frame window: a clip of at most 32 frames keeps every frame, and a longer clip keeps 32 frames spread evenly from the first to the last. The rule counts frames, not seconds, so a per-request fps hint is accepted but does not change which frames are kept. On a worker running SMG's own pipeline, the budget is the engine's own in place of the 32 — vLLM's --media-io-kwargs video.num_frames when the engine sets it (a non-positive count keeps every frame), else that loader's default — so a clip costs the same tokens as on the engine's own server; SMG_VLLM_MM_MAX_VIDEO_FRAMES can only lower that budget. An engine option that changes how the loader picks frames (a positive video.fps, another loader backend) fails that worker's start rather than sampling differently from the engine. Each sampled frame's placeholder group in the prompt is stamped with the frame's time as MM:SS — the frame's source index over the clip's frame rate, or its ordinal at 24 fps when the decoder reports no rate.
Nemotron-H Omni clips are sampled under the same vLLM default loader rule as Gemma 4 — a clip of at most 32 frames keeps every frame, a longer clip keeps 32 spread evenly from the first to the last, and a per-request fps hint is accepted but does not change which frames are kept. The prompt lays the sampled frames out in temporal groups of two (a final odd frame forms a group of its own): each group opens with a text line stamping its frames, such as Frame 1 sampled at 0.00 seconds and frame 2 sampled at 0.49 seconds:, followed by the group's image-token run. A frame's stamped time is its source index times the clip's frame interval (1,000 divided by the clip's own frame rate, truncated to whole milliseconds), printed in seconds to two decimals. A clip whose decoder reports no frame rate cannot be stamped, so it is refused.
Muse Spark clips follow the checkpoint's video processor config rather than the 4-to-768-frame window: frames are sampled evenly across the clip at the config's fps (default 2), in whole temporal groups of temporal_patch_size frames (default 2), up to the config's num_frames (default 96; the released checkpoints raise it). A per-request fps hint still overrides the sampling rate. The prompt carries one token block per temporal group, stamped with the time of the group's first sampled frame in the config's frame_timestamp_format (default Time: {timestamp:.1f}s; Time: {timestamp:.2f}s on the released checkpoints).
Several clips in one request are preprocessed in parallel (smg-project/smg#2595), and on vLLM a request can carry images and video together (smg-project/smg#2581).
Limits and Safety¶
Media Counts¶
A few model families keep built-in per-request limits; most declare their media without a count of their own (see Supported Models). Either way, SMG never sends more items than the per-request limit the model's workers advertise for their engine: vLLM's --limit-mm-per-prompt or SGLang's --limit-mm-data-per-request, carried in the mm_item_limits worker label as <modality>=<count> pairs (for example audio=1,image=8,video=2).
SMG consults every registered worker of the model, healthy or not: the smallest limit advertised for a modality applies, and the check runs before any media is fetched, so a request never depends on which worker is picked.
These deployment settings replace a family's own count:
| Setting | Scope | Description |
|---|---|---|
--mm-per-request-image-limit |
Images, every model | Replaces each model's image limit (at least 1), for example to match the engine's --limit-mm-per-prompt. Takes precedence over SMG_IMAGE_MAX_COUNT (smg-project/smg#2381). |
SMG_IMAGE_MAX_COUNT, SMG_VIDEO_MAX_COUNT, SMG_AUDIO_MAX_COUNT |
One modality, every model | Environment overrides that raise or lower the limit; unset, zero, or non-numeric values are ignored (smg-project/smg#2153). |
Neither setting enables a modality the model does not support, and neither raises the limit above what the workers advertise: when you raise a limit, raise the engine's own limit to match. On the worker path, the vLLM worker also enforces its own item limits.
Sizes and Timeouts¶
| Limit | Default | Setting |
|---|---|---|
| Encoded image | 256 MiB | SMG_IMAGE_MAX_INPUT_BYTES |
| Encoded video | 256 MiB | SMG_VIDEO_MAX_INPUT_BYTES |
| Encoded audio | 256 MiB | SMG_AUDIO_MAX_INPUT_BYTES |
| Decoded image | 512 MiB | Fixed; the libjpeg-turbo path checks it before allocating (smg-project/smg#2569) |
| MiniMax-M3 planned image pixels | 12,845,056 | Fixed; the output size planned from the source dimensions is checked before the image is decoded (see Frame Sampling) |
| Decoded video frames | 1 GiB | SMG_VIDEO_MAX_DECODED_BYTES |
| Inkling image patches per request | 32,768 | in_patch_limit in the preprocessor config (smg-project/smg#2102) |
| Feature tokens per media item | The engine's encoder budget | Not an SMG setting; the smallest mm_encoder_budget a model's workers advertise (see Per-Item Encoder Budget) |
| Media fetch | 10 seconds per image or audio URL, 30 per video URL | --mm-fetch-timeout-ms, --mm-video-fetch-timeout-ms (SMG_MM_FETCH_TIMEOUT_MS, SMG_MM_VIDEO_FETCH_TIMEOUT_MS) |
Per-Item Encoder Budget¶
A multimodal engine sizes its encoder cache for the largest single item its own processor can produce and never schedules an item above that budget: a request carrying one would sit in the engine with no output until the client gives up. vLLM gRPC workers advertise the budget in the mm_encoder_budget label — the "budget of N tokens" of the engine's encoder-cache start-up line — counted in feature tokens, the per-item count that preprocessing produces (step 5 under Request Flow).
When SMG preprocesses the media, it holds every item to the smallest budget the model's registered workers advertise, healthy or not, and refuses an item above it with 400 multimodal_item_too_large. The message names the item, its feature-token count — for a video, also the frames it was sampled to — and the budget in the same units:
video item 2 of 2 is 192001 feature tokens (900 sampled frames), above the
192000-token encoder budget the engine can place for one item; sample fewer
frames (a lower fps) or send a shorter clipAn image is held to the budget twice: on the count its header's dimensions alone give, before any of the request's images is decoded or any tensor built, and again on the count its preprocessing produced. A video or audio item is checked on the produced count only. To bring an item under the budget, send a smaller image, sample fewer frames (a lower per-request fps, see Frame Sampling), or send a shorter clip; the budget itself is the engine's own, not an SMG setting.
When none of a model's workers advertises a budget — a text-only engine, an engine whose budget cannot be derived, or an engine other than vLLM over gRPC — SMG does not check items, and an oversized one is left to the engine. On the worker path, a worker running --mm-processor smg holds forwarded items to its own engine's budget before they reach the engine and refuses them with a 400 naming the same numbers; with inprocess and redis, vLLM's own front end enforces its budget.
In-Flight Media Budget¶
--multimodal-max-inflight-bytes caps the bytes of preprocessed media SMG holds for engines at once (smg-project/smg#2585). A request that fits waits up to 2 seconds for room and then gets 429 multimodal_inflight_budget. A request larger than the whole budget gets 413 multimodal_payload_too_large right away. A waiting request still holds its media, and the waiting queue is capped at one budget (a request that would overfill it gets 429 right away), so size memory for about twice the value. Unset leaves the budget unbounded; 0 is refused.
Errors¶
Multimodal errors use the standard error body ({"error": {"type": ..., "code": ..., "message": ...}}), and the code is also sent in the X-SMG-Error-Code header.
| Status | Code | Cause |
|---|---|---|
| 400 | unsupported_content_part |
A content part type the gRPC path does not know |
| 400 | invalid_multimodal_request |
The model does not take the modality, the request has too many items, or the model has no multimodal processor under --mm-processing router (the other modes may send its media to a worker that processes media itself — see Request Flow); an over-limit refusal names the limit and what set it (for example the request carries 11 image items, above this model's limit of 10 (--mm-per-request-image-limit)) |
| 400 | multimodal_prompt_contract_mismatch |
The rendered prompt does not hold exactly one anchor per media item: a chat template that drops media, or a literal anchor token in user text |
| 400 | media_fetch_failed |
The request's own media failed: a URL that cannot be parsed or resolved, a host that refuses the connection, an origin 4xx, a malformed data: URL, a payload that is not the media it claims to be, a clip too short for the model's video sampling (see Frame Sampling), or an invalid fps or max_long_side_pixel |
| 400 | media_too_large |
The media is over a size cap: its encoded bytes, its decoded bytes, a MiniMax-M3 image's planned size over the pixel budget, or the image decoder's own limits (see Sizes and Timeouts) |
| 400 | multimodal_item_too_large |
One media item needs more feature tokens than the engine can place for a single item; the message names the item's feature-token count and the budget (see Per-Item Encoder Budget) |
| 400 | multimodal_processing_failed |
Preprocessing failed, or a processing failure the media codes do not cover |
| 400 | multimodal_not_supported |
The selected engine does not take the modality; media references cannot reach the worker (ZMQ, TokenSpeed EPD encode workers, or audio to a worker running the gateway's own smg pipeline); or the model has no processor and the chat template the request renders through takes one string per message, so nothing would anchor the media in the prompt — refused before any render or fetch (see Request Flow) |
| 400 | multimodal_worker_processing_unsupported_model |
--mm-processing worker, and vLLM cannot expand the model's anchor |
| 400 | multimodal_hint_unsupported_in_worker_mode |
--mm-processing worker, and a part carries an fps or max_long_side_pixel hint that SMG cannot apply itself (it has no processor for the model's family, or the request also carries audio); a hinted request SMG can serve is preprocessed on the router instead |
| 400 | media_ref_too_large |
Worker path: an inline data: payload is above the byte cap |
| 400 | media_ref_scheme_not_accepted |
Worker path: the selected worker does not fetch that URL scheme |
| 413 | multimodal_payload_too_large |
The request's media exceed the whole in-flight budget |
| 429 | multimodal_inflight_budget |
The in-flight budget stayed full for 2 seconds, or the queue waiting for it was full |
| 500 | multimodal_processing_failed |
The gateway's own failure: a decoder it cannot run (for example no ffmpeg on the gateway), a scratch file or decoder process that failed on the gateway's side, or a decode or preprocessing task that died |
| 502 | media_fetch_failed |
The media's host failed for now: the fetch timed out, the origin answered 5xx, or the transfer broke |
| 503 | no_media_ref_capable_worker |
--mm-processing worker, and no worker of the model advertises a media processor |
While no_media_ref_capable_worker holds for a model with a worker that reports a vision encoder, the ready body of /readiness names the model under models_without_media_processing; the status stays ready, and the model leaves the list once a worker of it that processes media references registers.
The status under media_fetch_failed tells whose fault the failure is: a 400 is the request's own mistake to fix; a 502 is the media host's trouble for now, so the client can retry later. SMG itself never retries the request — another attempt would fetch from the same host — and a worker that reports a media failure stays healthy and in rotation: the failure never counts against its circuit breaker. The split applies wherever SMG's own pipeline fetches — on the router or on a worker running --mm-processor smg — and, on the Rust servicer, to a --mm-processor inprocess fetch that fails for the reference's own reason. The Python servicer's inprocess and the redis sidecar answer as described under Worker-Side Processing on vLLM.
When a worker reports a failed fetch under this split, the message the client reads is the gateway's own sentence for whose fault it is: the 400 says to check the reference and what it leads to; the 502 says the host did not answer in time or failed, and a retry may succeed. The worker's own words stay on the gateway's log line. Every other media failure a worker reports, such as invalid_multimodal_request or media_too_large, keeps the worker's words, which describe the request's payload.
Prefill-decode deployments add three codes, listed under Prefill-Decode Disaggregation.
Performance¶
- Fetch once. Parts of one request whose payload is identical byte for byte — the same URL, inline
data:URL, bytes, or file path — with the same settings share one fetch and decode, so an image repeated as several identical data URLs is fetched and decoded once (smg-project/smg#2586). Newer than v1.11.0, duplicates are matched by comparing payloads (looked up by their kind and length, falling back to digests once several distinct payloads share one length) rather than hashing every payload up front (smg-project/smg#2767). - Data URL fast path.
data:image/...URLs go straight to the base64 decoder without a full URL parse, which matters for large inline images (smg-project/smg#2648). - Parallel preprocessing. Modality batches are preprocessed concurrently. Within a batch, processors built on the Qwen-VL pipeline (Qwen2-VL through Qwen3-VL, Qwen3-Omni, MiniMax-M3) split the images across cores (smg-project/smg#2582), and video clips run in parallel (smg-project/smg#2595). Newer than v1.11.0, a batch's still-encoded images are also decoded in parallel on the preprocessing pool before preprocessing starts — a repeated image only once — instead of one photo after another (smg-project/smg#2767).
- Pixel cache.
--mm-pixel-cache-mbgives SMG a host-memory LRU cache of preprocessed images, keyed by the image's content hash and a fingerprint of the model and its preprocessing config. It serves single-image requests and, for the Qwen2-VL, Qwen2.5-VL, and Qwen3-VL family processors, requests with fewer than 32 images, where each image is cached on its own and a repeated image is preprocessed once (smg-project/smg#2602). The cache is off by default. - JPEG decoding. When
libturbojpegis installed on the gateway host, JPEGs are decoded with libjpeg-turbo using Pillow's defaults, so the pixels match what vLLM computes. Without it, SMG uses a pure-Rust decoder that can differ by a few levels per pixel.
Tensor Transport¶
--multimodal-tensor-transport chooses how preprocessed tensors reach the worker:
| Mode | Behavior |
|---|---|
inline (default) |
Tensor bytes travel in the gRPC message. |
shm |
Tensors of at least --multimodal-shm-min-bytes (default 64 KiB) go through /dev/shm whenever SMG can write it. You assert that the worker shares it. |
auto |
Like shm, but only when the worker is verified to share SMG's /dev/shm: its shm_namespace_id label (<boot_id>:<st_dev of /dev/shm>) must equal SMG's own. |
rdma |
Pixel tensors for TokenSpeed workers travel over the NIXL RDMA pixel lane. Other tensors, and other engines, stay inline. |
A failed shared-memory write falls back to inline and is counted in smg_mm_shm_write_failures_total. The two flags fall back to SMG_MM_TENSOR_TRANSPORT and SMG_MM_SHM_MIN_BYTES (legacy names SMG_TOKENSPEED_MM_TENSOR_TRANSPORT and SMG_TOKENSPEED_MM_SHM_MIN_BYTES). The transport is chosen gateway-wide. The worker spec has multimodal_tensor_transport and multimodal_shm_min_bytes fields, and SMG consults them for the worker that runs the vision encoder (the encode worker in EPD) since v1.12.0; v1.11.0's worker registration did not copy them onto the worker (see the Admin API). The RDMA lane is also on or off for the whole gateway.
| Engine | inline |
shm and auto |
rdma |
|---|---|---|---|
| vLLM (gRPC) | ✓ | ✓ | Falls back to inline |
| TokenSpeed (gRPC, including EPD encode workers) | ✓ | ✓ | ✓ (with an mm-rdma build) |
| SGLang, TensorRT-LLM (gRPC) | ✓ | Inline only | Inline only |
| vLLM, TokenSpeed, SGLang (direct ZMQ) | ✓ | Inline only | Inline only |
RDMA Pixel Lane¶
The RDMA lane stages each pixel tensor in a pre-registered host-memory arena and hands the TokenSpeed worker a small descriptor; the worker pulls the pixels with a one-sided RDMA read.
- Build the
smgbinary with themm-rdmaCargo feature (NIXL). A default build compiles an inert exporter, so every tensor stays inline. - Turn the lane on with
--multimodal-tensor-transport rdma(or the legacy--mm-pixel-rdma), and set--rdma-listen-ipto the gateway's RDMA address. Without a listen IP, the lane stays off. - The arena defaults to 64 slots of 32 MiB (2 GiB).
SMG_RDMA_POOL_SLOTSandSMG_RDMA_SLOT_BYTESresize it (a slot must hold one image's pixels), andSMG_RDMA_LISTEN_PORT(default18515) sets the listener port. - A slot the worker never releases is reclaimed after a TTL derived from the worker's longest hold:
SMG_RDMA_LANDING_WAIT_S(default 120) plusSMG_RDMA_READ_TIMEOUT_S(default 60) plus 30 seconds.--rdma-slot-ttl-soverrides it only with a value longer than that hold. - A tensor that cannot be staged falls back to shared memory or inline.
Encoder Input Width¶
vLLM workers receive the pixel tensor as float32 unless SMG_VLLM_ENCODER_INPUT_DTYPE asks for bfloat16 or float16, or the worker carries a multimodal_encoder_dtype label (smg-project/smg#2591). The vLLM servicer accepts half-precision media since smg-project/smg#2590. TokenSpeed workers receive the width they advertise, or bfloat16 when they advertise none; SMG_TOKENSPEED_ENCODER_INPUT_DTYPE and the per-modality SMG_TOKENSPEED_IMAGE_ENCODER_INPUT_DTYPE, SMG_TOKENSPEED_VIDEO_ENCODER_INPUT_DTYPE, and SMG_TOKENSPEED_AUDIO_ENCODER_INPUT_DTYPE override it. SGLang always receives float32.
Other Paths¶
Direct ZMQ Backends¶
vLLM, TokenSpeed, and SGLang workers reached over the direct ZMQ backend take router-preprocessed media, sent inline. Media references, shared memory, and RDMA are not available on this wire. See ZMQ Workers.
On TokenSpeed, media whose image_grid_thw or video_grid_thw tensors feed M-RoPE positions are served only for the Qwen3.5 lineage (Qwen3.5, Qwen3.5-MoE, Qwen4-Exp): SMG computes the lineage's M-RoPE position table itself, as the engine's input processor would, provided the engine's handshake declares the checkpoint's spatial_merge_size, image_token_id, and video_token_id. When a lineage engine's handshake omits any of them, every multimodal request is refused with a 400. Media of other M-RoPE families (such as Qwen3-VL or Qwen3-Omni) are refused with a 400; serve those models over gRPC. Muse Spark's grid tensors only describe the vision patch layout, so its images and video pass.
On SGLang, images — the one modality the engine takes — are served with the same payload a gRPC SGLang worker gets; video and audio are refused with 400 multimodal_not_supported (see Engine Support).
Prefill-Decode Disaggregation¶
With prefill-decode disaggregation, media are normally processed once, for the prefill leg:
- Router path. The prefill worker gets the pixels. On vLLM and TokenSpeed, the decode worker gets each item's identity (content hashes, placeholder ranges, and M-RoPE grid tensors) but not the pixels; on SGLang it gets no media data (smg-project/smg#2243, #2365, #2366). The exception is vLLM with
n > 1: there is no KV handoff, so the decode leg keeps the full payload and encodes the media itself. On vLLM, the decode worker keys its cached KV blocks by the content hashes (through the cache salt when no grid tensors travel), so two different images behind the same text cannot share cached KV blocks. - Worker path (vLLM). The prefill worker processes the references and returns the processed identity with its result. SMG builds the decode leg from it, so the decode worker does not fetch or process the media again (smg-project/smg#2627). With
n > 1there is no KV handoff, so the decode leg keeps the references and processes them itself. - Language-model-only decode workers. vLLM decode workers started with
--language-model-onlyreportsupports_vision=falseand get the prefill-expanded prompt plus the content hashes, with no media payload (smg-project/smg#2640). Three combinations cannot be served and are refused with a non-retryable 400: models that need M-RoPE grids (pd_decode_language_model_only_mrope), media references (pd_decode_language_model_only_media_refs), andn > 1(pd_decode_language_model_only_n_samples).
See PD Disaggregation for how the legs are paired and dispatched.
EPD (Encode-Prefill-Decode)¶
--epd-disaggregation (gRPC vLLM or TokenSpeed workers) adds encode workers that run the media encoding ahead of prefill, listed with --encode <url> [bootstrap_port] and picked by --encode-policy (default consistent_hashing).
On TokenSpeed, SMG still fetches and preprocesses the media, then sends each item's pixels to an encode worker. The encode worker runs the vision tower and ships the embeddings to the prefill worker over Mooncake, so the prefill request carries no pixels. Pixels reach encode workers inline, through shared memory, or over the RDMA lane.
On vLLM, the encode worker processes the media itself and hands the encoder cache to the prefill worker through the engines' encoder-cache (EC) connector: forwarded media references go to the encode worker (see Where Media Is Processed), which answers with the expanded prompt and the transfer handles before prefill runs; under --mm-processing router, the encode worker takes the preprocessed pixels instead. Multimodal requests require n=1. See EPD (Encode-Prefill-Decode) for the worker requirements and error codes.
Observability¶
--log-mm-timing (env fallback SMG_LOG_MM_TIMING, deprecated) logs smg_mm_timing lines at INFO: a per-request breakdown (media_fetch_decode_ms, preprocess_ms, token_expand_ms, total_ms) plus video decode and tensor transport events.
| Metric | Labels | Description |
|---|---|---|
smg_mm_processing_total |
model, mode, reason |
Multimodal requests by where their media was processed (router or worker) and why |
smg_mm_tensors_total |
runtime, path |
Tensors sent to vLLM and TokenSpeed workers, by transport path (inline, shm, remote) |
smg_mm_tensor_bytes_total |
runtime, path |
Bytes of those tensors |
smg_mm_shm_write_failures_total |
runtime |
Shared-memory writes that failed and fell back to inline |
smg_admission_queue_rejected_total |
reason |
Includes multimodal_inflight (429) and multimodal_too_large (413) refusals |
GET /workers shows the labels behind these decisions: mm_processor, mm_processor_source, mm_media_ref_schemes, mm_item_limits, mm_encoder_budget, supports_vision, and shm_namespace_id. See the Metrics Reference for every metric.
Configuration Summary¶
| Flag | Default | Description |
|---|---|---|
--mm-processing |
auto |
Where media for vLLM gRPC workers is processed: auto, router, or worker |
--mm-per-request-image-limit |
Model limit | Image limit applied to every model |
--multimodal-max-inflight-bytes |
Unbounded | Cap on preprocessed media held in flight (429 when busy, 413 when too large) |
--mm-pixel-cache-mb |
0 (off) |
Pixel cache budget in MiB |
--multimodal-tensor-transport |
inline |
inline, shm, auto, or rdma |
--multimodal-shm-min-bytes |
65536 |
Smallest tensor sent through shared memory |
--mm-pixel-rdma |
Off | Legacy switch for the RDMA lane |
--rdma-listen-ip |
Unset | RDMA listener IP; the lane needs it |
--rdma-slot-ttl-s |
Derived | RDMA slot TTL override |
--log-mm-timing |
Off | Per-request multimodal timing logs |
--mm-processing, --mm-pixel-cache-mb, --mm-pixel-rdma, --rdma-listen-ip, --rdma-slot-ttl-s, and --log-mm-timing replace SMG_* variables that still work as deprecated fallbacks until the next minor release (smg-project/smg#2625). With smg serve, prefix router flags with --router-, for example --router-mm-processing router. See Multimodal Configuration for the full list.
Example¶
Start a vLLM gRPC worker with a vision model and point SMG at it:
python -m vllm.entrypoints.grpc_server \
--model Qwen/Qwen3-VL-8B-Instruct \
--host 0.0.0.0 \
--port 50051
smg launch \
--worker-urls grpc://localhost:50051 \
--model-path Qwen/Qwen3-VL-8B-Instruct \
--port 30000Send an image with a chat completion:
curl http://localhost:30000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-VL-8B-Instruct",
"messages": [{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"}},
{"type": "text", "text": "Describe this image in one sentence."}
]
}],
"max_tokens": 64
}'usage.prompt_tokens includes the expanded image placeholder run. To send a local file, pass it as a base64 data URL such as data:image/jpeg;base64,....