Module vision_encoder

Module vision_encoder 

Source
Expand description

Qwen3-VL vision encoder: 27-block ViT + DeepStack mergers.

Processes patch embeddings (BF16) through a ViT backbone, extracts intermediate hidden states at deepstack indices [8, 16, 24, 27], applies 2×2 spatial merges + 2-layer MLPs, and concatenates the four outputs. Result: [num_patches, out_hidden_size=2048] BF16 ready for LLM embedding.

Structs§

MergerLayer
ViTBlock
VisionEncoder
VisionScratch
The ViT’s per-image scratch buffers, allocated as one group.

Constants§

IMAGE_PAD_TOKEN_ID
VIDEO_PAD_TOKEN_ID
Fallback <|video_pad|> id, used when the checkpoint’s config declares none. Qwen3-VL’s video token sits directly after its image token, and the same holds for Qwen3.6/3.8 (248056 / 248057) — but a checkpoint that declares its own always wins, exactly as for the image token.