VisionConfig

Struct VisionConfig 

Source
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: usize

Number of ViT transformer blocks (depth=27).

§hidden_size: usize

ViT hidden dimension (1152).

§num_heads: usize

Number of attention heads (16).

§patch_size: usize

Spatial patch size in pixels (16).

§temporal_patch_size: usize

Temporal patch size: still images are replicated this many times (2).

§spatial_merge_size: usize

2×2 spatial merge: this many patch-lengths merged into one token (2).

§intermediate_size: usize

ViT MLP intermediate size (4304).

§out_hidden_size: usize

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: u32

Placeholder 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: u32

Placeholder 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

Source

pub fn merger_input_size(&self) -> usize

Dimension of the merger input (spatial_merge_size² × hidden_size).

Trait Implementations§

Source§

impl Clone for VisionConfig

Source§

fn clone(&self) -> VisionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VisionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.