pub struct VisionConfig {
pub depth: usize,
pub hidden_size: usize,
pub num_heads: usize,
pub patch_size: usize,
pub temporal_patch_size: usize,
pub spatial_merge_size: usize,
pub intermediate_size: usize,
pub out_hidden_size: usize,
pub deepstack_visual_indexes: Vec<usize>,
pub image_pad_token_id: u32,
pub video_pad_token_id: u32,
pub max_pixels: Option<usize>,
}Expand description
Vision encoder configuration for Qwen3-VL models.
Fields§
§depth: usizeNumber of ViT transformer blocks (depth=27).
ViT hidden dimension (1152).
num_heads: usizeNumber of attention heads (16).
patch_size: usizeSpatial patch size in pixels (16).
temporal_patch_size: usizeTemporal patch size: still images are replicated this many times (2).
spatial_merge_size: usize2×2 spatial merge: this many patch-lengths merged into one token (2).
intermediate_size: usizeViT MLP intermediate size (4304).
Projection output dimension = LLM hidden_size (2048).
deepstack_visual_indexes: Vec<usize>Layer indices after which deepstack mergers are applied ([8, 16, 24]).
image_pad_token_id: u32Placeholder token ID that marks where vision embeddings get spliced into the text embedding stream. Qwen3-VL uses 151655; Qwen3.6 uses 248056. When 0 the runtime falls back to the legacy Qwen3-VL value.
video_pad_token_id: u32Placeholder token ID for VIDEO frames, the temporal sibling of
Self::image_pad_token_id. Qwen3.6/3.8 use 248057. A distinct token
is what lets the position builder tell a video item from an image one
in the token stream, which matters because their MRoPE treatment
differs: an image holds T constant across its whole pad run, a video
advances T once per temporal group. When 0 the runtime falls back to
the family default.
max_pixels: Option<usize>Resolved vision AREA bound in pixels: the operator’s
--vision-max-pixels, else the checkpoint’s preprocessor_config.json,
else None.
★ THE SINGLE SOURCE OF TRUTH, and it exists because there used to be
two. The CPU preprocessor clamped every image to 1280px on the long
side while the GPU encoder allocated its buffers for 6400 patches —
exactly 1280×1280 — with nothing in the code connecting them. They
agreed only by coincidence, so raising one on 2026-08-14 made every
image above 1280px fail an H2D copy with CUDA_ERROR_INVALID_VALUE
from deep inside the scheduler.
Both now derive from this field, resolved once at config load, before
the encoder is constructed. None keeps the historical behaviour on
both sides.
Implementations§
Source§impl VisionConfig
impl VisionConfig
Sourcepub fn merger_input_size(&self) -> usize
pub fn merger_input_size(&self) -> usize
Dimension of the merger input (spatial_merge_size² × hidden_size).
Trait Implementations§
Source§impl Clone for VisionConfig
impl Clone for VisionConfig
Source§fn clone(&self) -> VisionConfig
fn clone(&self) -> VisionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more