nemo_automodel.components.models.inkling2.vision
nemo_automodel.components.models.inkling2.vision
Native Inkling2 image encoder with independent per-image SDPA attention.
The tensor contracts follow the released Inkling-2-Small checkpoint configuration. This implementation uses ordinary Torch modules and SDPA, preserving the released weight names for bounded checkpoint loading.
Module Contents
Classes
API
Bases: Module
Full attention with separate horizontal and vertical rotary coordinates.
Attend over one image, including CLS; never mix different images.
Parameters:
Compute-dtype [tokens, hidden] features.
Integer [tokens, 2] (y, x) coordinates; CLS uses zero.
Returns: torch.Tensor
Projected features with the same shape and dtype as hidden.
Bases: Module
Image transformer before spatial merging and text projection.
Encode one image’s native patches.
Parameters:
[height * width, native_patch_size ** 2 * 3] rows in native row-major patch order, as consumed by the embeddings.
Native patch rows of the image.
Native patch columns of the image.
Returns: torch.Tensor
New [height * width, hidden] features in the same row-major patch order, without
Bases: Module
Native patch projection, interpolated positions and a learned class token.
Embed one image’s native patches and add interpolated positions.
Parameters:
Tensor of shape [height * width, native_patch_size ** 2 * 3]. Rows follow the native patch grid in row-major order; each row flattens patch height, patch width and RGB channels, in that order. Its device and dtype must match the patch projection.
Native patch rows of the image.
Native patch columns of the image.
Returns: torch.Tensor
New [1 + height * width, hidden] tokens in the projection dtype, with the class
Bases: Module
Encode merged image patches into one text feature per image-body token.
Project independent images into text embeddings.
Parameters:
BF16 normalized patches [patches, temporal, side, side, 3], where side = native_patch_size * adapter_merge_size. Input is unchanged.
Integer [images, 3] grid metadata (1, rows, columns). Grids and patches follow the same image order; metadata may be on CPU or GPU.
Returns: torch.Tensor
Compute-dtype [patches, text_hidden] features, in row-major merged-patch order.
Initialize all parameters and regenerate nonpersistent normalization buffers.
Bases: Module
Pre-LayerNorm attention and GELU branches with learned LayerScale.
Apply one pre-LayerNorm attention and feed-forward block.
Parameters:
[tokens, hidden] features of one image, class token first.
Integer [tokens, 2] (y, x) patch coordinates; the class token uses zero.
Returns: torch.Tensor
New [tokens, hidden] features; the inputs are unchanged.
Bases: Module
Learned channel scale on a vision residual branch.
Scale a residual branch per channel.
Parameters:
[tokens, hidden] branch output.
Returns: torch.Tensor
New [tokens, hidden] features, each channel multiplied by the learned [hidden]
Bases: Module
The image encoder’s ordinary GELU feed-forward block.
Apply the GELU feed-forward block.
Parameters:
[tokens, hidden] features in the block’s dtype.
Returns: torch.Tensor
New [tokens, hidden] features; the input is unchanged.