nemo_automodel.components.models.hy_v4_flash.vision
nemo_automodel.components.models.hy_v4_flash.vision
Hy4-flash vision tower: patch embedding, ViT blocks and the spatial-merge projector.
Semantics follow HYV4VLVisionModel of the transformers reference (PR 50903): a learned position grid
interpolated with an explicit scale_factor of (size + 0.1) / grid (this shifts the sampling grid relative to
size=), full bidirectional attention inside each image, an RMSNorm + 2x2 conv merge + 1x1 conv projector, and one
image_newline embedding appended to every merged row. Module names follow the released vit.* keys, which
the state-dict adapter therefore leaves unchanged.
Module Contents
Classes
API
Bases: Module
Spatial-merge projector: RMSNorm, 2x2 conv, GELU, 1x1 conv, plus a newline embedding per merged row.
Merge and project hidden_states [patches, hidden] per image (frames are merged independently).
Returns [tokens, out_hidden]; each frame of grid_thw [images, 3] gives (h/m) * (w/m + 1) tokens.
Bases: Module
Bidirectional multi-head attention with biases.
Attend inside each image: hidden_states [patches, hidden], lengths the patch count of each image.
Bases: Module
Pre-norm ViT block.
Run the block on a tensor of shape [patches, hidden].
Bases: Module
Conv patch embedding plus an interpolated learned position grid.
Embed flat patches into [patches, hidden].
pixel_values has shape [patches, channels * patch_size * patch_size], row-major per image, and grid_thw
[images, 3] holds the (time, height, width) patch counts.
Learned grid resampled to height x width patches.
Returns: torch.Tensor
Tensor of shape [height * width, hidden].
Bases: Module
GELU MLP named like the release (dense_h_to_4h / dense_4h_to_h).
Apply the MLP to a tensor of shape […, hidden].
Bases: Module
vit: embeddings, blocks and the perceive projector.
Encode images into language-width tokens [tokens, out_hidden], the images’ tokens concatenated.
pixel_values has shape [patches, channels * patch_size * patch_size] and grid_thw [images, 3].
Initialize as the reference does: zero biases, unit norm weights, normal everything else.