nemo_automodel.components.models.deepseek_v4.vision
nemo_automodel.components.models.deepseek_v4.vision
Vision encoder and aligner used by DeepSeek-V4-Flash-Vision-Exp.
Module Contents
Classes
Functions
Data
API
Bases: Module
Spatially downsample ViT patches and project them into the LLM width.
Downsample encoded patch states.
Parameters:
ViT output with layout [n_h * n_w, vision_dim].
Number of patch rows.
Number of patch columns.
Returns: torch.Tensor
LLM image embeddings with layout
Initialize all checkpoint-free aligner parameters.
Bases: Module
Full bidirectional patch attention with 2D RoPE.
Attend over one image.
Parameters:
Patch states with layout [patches, vision_dim].
Cosine table with layout [patches, 1, head_dim / 2].
Sine table with layout [patches, 1, head_dim / 2].
Returns: torch.Tensor
Attention output with layout [patches, vision_dim].
Bases: Module
Pre-norm attention and MLP residual block.
Transform patch states with layout [patches, vision_dim].
Bases: Module
Bias-free SwiGLU MLP used by each vision block.
Map [patches, vision_dim] back to [patches, vision_dim].
Bases: Module
Linear embedding of flattened RGB patches.
Project [patches, 3, patch_h, patch_w] to [patches, vision_dim].
Bases: Module
Reference RMSNorm with an fp32 scale parameter.
Normalize an input of layout [..., vision_dim].
Bases: Module
DeepSeek ViT: full attention over one image with 2D RoPE.
Encode one image.
Parameters:
Normalized RGB patches with layout
[n_h * n_w, 3, patch_size, patch_size].
Number of patch rows.
Number of patch columns.
Returns: torch.Tensor
Encoded patches with layout [n_h * n_w, vision_dim].
Initialize all checkpoint-free vision parameters.
Apply DeepSeek’s half-split 2D rotary embedding.
Parameters:
Query or key tensor with layout [patches, heads, head_dim].
Cosine table with layout [patches, 1, head_dim / 2].
Sine table with layout [patches, 1, head_dim / 2].
Returns: torch.Tensor
Rotated tensor with the same layout and dtype as x.
Build the reference 2D rotary table.
Returns: torch.Tensor
Cosine and sine tensors with layout [n_h * n_w, 1, dim]. The