nemo_automodel.components.models.qwen3_vl.model
nemo_automodel.components.models.qwen3_vl.model
Dense Qwen3-VL integration with in-forward context-parallel multimodal sharding.
Module Contents
Classes
Data
API
Bases: HFCheckpointingMixin, HFQwen3VLForConditionalGeneration
Dense Qwen3-VL with a DeepStack-aware context-parallel forward path.
Encode and scatter Qwen3-VL visual features before sequence sharding.
Images and videos share one vision-tower call when both are present. This preserves collective ordering under FSDP and lets CP vision frame sharding partition their combined frame stream once.
Parameters:
Token ids of shape [batch, sequence] containing image
and video placeholder ids.
Text embeddings of shape [batch, sequence, hidden].
Optional image patch rows of shape
[image_patch_rows, patch_dim] in image-entry order.
Optional video patch rows of shape
[video_patch_rows, patch_dim] in video-entry/frame order.
Optional image grid tensor of shape [num_images, 3].
Optional video grid tensor of shape [num_videos, 3].
Returns: torch.Tensor
A tuple containing updated embeddings of shape “[batch, sequence,
Raises:
ValueError: If patch rows are provided without matching grid metadata, or grid metadata is provided without patch rows.
Shard token embeddings and ragged DeepStack inputs in matching order.
Parameters:
Full-sequence embeddings [batch, sequence, hidden].
Optional full-sequence visual mask
[batch, sequence].
Optional tensors shaped
[visual_tokens, hidden], one per DeepStack injection layer.
Returns: torch.Tensor
Local embeddings [batch, local_sequence, hidden], the matching
Raises:
TypeError: Ifvisual_pos_masksis not boolean.ValueError: If mask and DeepStack shapes are inconsistent.
Run Qwen3-VL, including its in-forward CP multimodal path.
Named tensor arguments preserve the Hugging Face
Qwen3VLForConditionalGeneration.forward layouts. The internal CP path
consumes inputs_embeds of shape [batch, local_sequence, hidden],
visual_pos_masks of shape [batch, local_sequence], and DeepStack
tensors of shape [local_visual_tokens, hidden].
Return Qwen3-VL’s aux-only sharder and full-sequence mRoPE positions.
Embedding, vision encoding, DeepStack construction, and differentiable
sequence sharding run inside :meth:forward per microbatch. This hook
only computes metadata and selects the round-robin CP strategy, so it
does not touch model weights or create an autograd graph shared across
microbatches.
Parameters:
Full-sequence input mapping. input_ids has shape
[batch, sequence]; optional grid metadata has shape
[num_media, 3].
Accepted for the common model-hook contract; unused by the round-robin Qwen3-VL strategy.
Returns: dict[str, Any]
Mapping containing a :class:ContextParallelSharder, optional
Raises:
ValueError: Ifinput_idsis missing or multimodal position metadata is incomplete.
Tie the language head to the active text embedding when configured.