Expand description
MiMo-V2.6 vision: image and video preprocessing, prompt-id expansion for
the image/video placeholders, and the MiMo ViT (visual.*).
Reference semantics are the upstream processor (MiMoProcessor) and the
HF MiMoVisionTransformer, with the merger taken as vLLM/sglang build it
(RMSNorm, no biases — the checkpoint carries only ln_q.weight and the
two merger matrices). Conventions that are easy to get wrong:
- Resize is
F.interpolate(bilinear, align_corners=False)on 0..255, with no antialias and no rounding back to 8 bit, then ImageNet mean/std in 0..255 units.smart_resizeuses factor 32 and has an upscale branch for a side below 32 that skips the aspect check. - Every image is two identical frames (T = 2), and each patch row is the Conv3d kernel flattened as (c, tt, py, px).
- Rows are in merge-block order (t, block row, block col, mh, mw). Window blocks of type 1 run in column order: whole merge units are listed by (t, block col, block row), the RoPE tables are permuted the same way, and the band |i−j| ≤ 64 is taken over chunk-local indices in the CURRENT order. Frames are independent chunks in every block.
- Sinks add to key 0’s logit (HF, vLLM
sinks_bias_key0), they are not an extra softmax column like the text model’s sinks. Beyond query 64 key 0 is masked and the sink does nothing.CMF_MIMO_VIT_SINK(key0|column|off) switches it for A/B only. - GQA 32/8, head_dim 64 (
qk_channels), not hidden/heads = 40.
Weights are read by source name from any CMF that carries them — the
<stem>.mm.cmf companion or a single-file multimodal CMF — through
MimoVit::from_model. Dense (F32/F16/BF16) matrices become exact f32
GEMM operands; quantized ones (q4tp, q8_2f) stay mapped on the engine’s
kernels, CPU or GPU.
The tower is unusually sensitive to weight quantization (G4.1, measured
against the exact tower on 5 fixture images): q4tp gives a mean row cosine
of 0.935, GPTQ-rounded q4tp 0.976, q8_2f 0.995 (CPU, int8 activations) to
0.998 (Vulkan). Every matrix group fails at q4tp on its own except the
merger. The residual reaches ~4e5 in the last block, which is also why
GEMM inputs are range-guarded (Lin::mm).
Structs§
- Mimo
Processor Config - The processor knobs, read from
config.json(processor_configplus the vision geometry). Missing fields take the upstream processor’s defaults. - Mimo
Vision Config vision_configgeometry.- MimoVit
- The MiMo vision transformer and its patch merger.
- Visual
Input - One preprocessed image or video: the patch rows fed to the ViT, the patch grid, and (video) the per-frame timestamps in seconds.
- Y4mInfo
- The Y4M stream layout needed to seek to a frame.
Enums§
- Sink
Mode - How the per-head sinks enter the windowed blocks.
- Video
Source - A silent video given as decoded frames: a directory of images with an
explicit frame rate, or a Y4M stream (
ffmpeg -i in.mp4 -pix_fmt yuv420p out.y4m). mp4 decoding is out of scope for v1. - Visual
Kind - What a visual item is; it decides the placeholder and its expansion.
Constants§
- AUDIO_
END_ ID - AUDIO_
PAD_ ID - AUDIO_
START_ ID - IMAGE_
PAD_ ID - MM_
CONFIG_ TENSOR - Name of the U8 blob that carries the checkpoint’s full
config.json. - VIDEO_
END_ ID - VIDEO_
PAD_ ID - VIDEO_
START_ ID - VISION_
END_ ID - VISION_
START_ ID
Functions§
- column_
permutation - Row permutation into column order: merge units listed by (t, b, a),
each unit’s
m²rows kept together.perm[dst] = src. - expand_
prompt_ ids - Expand the rendered prompt’s media placeholders.
- format_
timestamp f"{int(ts // 60):02d}:{int(ts % 60):02d}"on the float32 timestamp, with torch’s float floor-division/remainder. Minutes are not wrapped.- gpu_
attention_ dispatches - Full-attention frame chunks this process ran through
gpu::dit_attention(so a timing on a live backend cannot be mistaken for the host path). - has_
vision - Whether
modelcarries the vision tower. - prepare_
image - Preprocess one image: smart_resize (factor 32), bilinear resize on
0..255, standardize, duplicate to T frames, patchify.
max_pixelsoverridesimage_max_pixels(the--image-max-pixelsknob). - prepare_
video - Sample, decode and preprocess a video source.
- prepare_
video_ frames - Preprocess already-sampled frames with their timestamps: per-frame pixel budget from the sampled count, even padding (repeat the last frame and its timestamp), one smart_resize for all frames, standardize, and pair consecutive frames as temporal patches.
- read_
mm_ config - The checkpoint
config.jsonstored in the file asMM_CONFIG_TENSOR. - resize_
bilinear F.interpolate(x, size=(out_h,out_w), mode="bilinear", align_corners=False)on a planar[c][h][w]f32 image, no antialias. Taps nest as torch does: interpolate along W on the two source rows, then along H.- sample_
frames - The sampled frame indices and their timestamps:
unique(int64(linspace(0, total−1, n)))andfloat32(idx) / fps_src. - smart_
nframes - Frame count for
totalsource frames atvideo_fps(sglangsmart_nframeswith the processor defaults):total / fps_src · fps, clamped to[min_frames, max_frames]andtotal, floored to even. - smart_
resize - MiMo’s
smart_resize(processorMiMoProcessor.smart_resize), returning(height, width). Note the upscale branch: when the short side is belowfactorboth sides are scaled up first and the aspect check is skipped. - video_
max_ pixels - Per-frame pixel ceiling for
n_sampledframes:max(min_pixels, min(total_max · T // n, max_pixels)).