nemo_automodel.components.models.qwen3_8_flash_next.vision
nemo_automodel.components.models.qwen3_8_flash_next.vision
Image inputs of Qwen3.8-Flash-Next: the vision tower and multimodal rotary positions.
The reference vision stack of this family (Qwen4ExpVisionModel in Transformers)
is the Qwen3.5-MoE tower with different sizes only, so the released
Qwen3_5MoeVisionModel is used as is. Video inputs are not implemented.
Module Contents
Classes
Functions
Data
API
Bases: Qwen3_5MoeVisionModel
Qwen3-VL-style vision tower: 3D patch embedding, 2D rotary blocks and a 2x2 patch merger.
Tensor layout
forward(hidden_states, grid_thw) takes flattened patches
[patches, in_channels * temporal_patch_size * patch_size * patch_size]
of every image in order and the per-image unmerged patch grid
[images, 3] as (frames, height, width). pooler_output holds the
merged features [patches / spatial_merge_size ** 2, out_hidden_size]
in the same order; last_hidden_state is [patches, hidden_size].
Parameters:
Vision architecture configuration. deepstack_visual_indexes
must be empty: the tower returns only its final merged features.
Initialize every weight and the rotary frequencies with the reference initializer.
Build the three-axis rotary positions of rows that mix text and images.
Each row is read left to right over its valid tokens with a running start
position. A text run of n tokens takes the next n positions on all
three axes. An image whose merged grid is (frames, rows, cols) and that
starts at position p gets p + frame on the temporal axis,
p + row on the height axis and p + col on the width axis, in
frame, row, column raster order; the token after it continues at
p + max(rows, cols). Padding keeps position zero on every axis.
Parameters:
Integer tensor [batch, sequence]; 0 marks a text
token and 1 an image placeholder.
Integer tensor [images, 3] with the unmerged
(frames, height, width) patch counts of every image, in order of
appearance over the rows of the batch.
Optional tensor [batch, sequence]; nonzero marks a
real token. None treats every token as real.
Side of the square of patches merged into one language token.
Returns: torch.Tensor
Long tensor [3, batch, sequence] on the device of
Raises:
ValueError: If an image placeholder run does not have the token count of its grid, or the number of runs differs from the number of grids.NotImplementedError: If a token type other than text or image appears.