nemo_automodel.components.models.kimi_k3.multimodal
nemo_automodel.components.models.kimi_k3.multimodal
Native top-level Kimi K3 vision-language model.
Module Contents
Classes
Functions
Data
API
Bases: KimiK3ForConditionalGeneration
Kimi K3.1 vision-language model: Kimi K3 with gated DSA on the full-attention layers.
The architecture differs from Kimi K3 only through text_config.dsa_config, which
KimiMLAAttention reads to attach
a sparse-attention indexer to the listed layers.
Bases: KimiK3ForCausalLM
Kimi K3 MoonViT3d tower, projector, and native KDA/MLA language model.
Encode packed pixel_values using grid_thws image/video geometry.
Merge compact HF placeholders or pre-expanded training image tokens.
Parameters:
Per-image tensors of shape [image_tokens, hidden], in batch order. Each image_tokens count follows spatial patch merging.
Tensor of shape [batch, sequence, hidden].
Tensor of shape [batch, sequence], with either one media placeholder per image or one per projected image token.
Binary or indexed document mask of shape [batch, sequence].
Optional unshifted targets of shape [batch, sequence].
Returns: torch.Tensor
Embeddings [batch, expanded_sequence, hidden], binary or indexed document mask,
Run text-only or multimodal K3 inputs.
Parameters:
Token IDs [batch, sequence], or PP activations [batch, sequence, hidden] after the first pipeline stage.
PP residual starts [batch * sequence, blocks, hidden].
Flattened image patches [patches, channels, patch_h, patch_w].
Image geometry [images, 3], ordered time, height, width.
Canonical packed image geometry [images, 3].
Image geometry [images, 2] from the native VLM collator; a [images, 3] time-height-width grid is also accepted.
Binary or indexed document mask [batch, sequence].
Optional positions [batch, sequence].
Optional embeddings [batch, sequence, hidden].
Optional unshifted targets [batch, sequence], with ignore_index at unsupervised positions. Native recipes compute loss externally.
Trailing logit count or sequence indices [selected_tokens].
Whether to return final hidden states.
Whether CP left the primary token stream intact for image embedding before contiguous sequence sharding.
Optional source index of each CP sequence position [batch, padded_sequence], set when CP moved masked tokens behind valid ones.
Text-backbone metadata, following KimiK3ForCausalLM.forward.
Returns: CausalLMOutputWithPast | torch.Tensor | tuple[torch.Tensor, torch.Tensor]
Causal LM output with logits [batch, expanded_sequence, vocab] and
Describe global media token inputs and local CP stage activations.
Parameters:
Whether this is the first pipeline stage.
Number of sequences per pipeline microbatch.
Global input token count before CP padding and slicing.
Floating point dtype of pipeline activations.
Returns: tuple[torch.Tensor, ...]
Input and output meta tensors. Only first-stage token IDs retain
Initialize text and vision after distributed materialization.
Return zero-based positions within each document, skipping masked tokens.
Masked tokens inside a document, such as deliberately masked fake-image spans, do not advance positions or start a new document.
Parameters:
Binary or indexed document mask [batch, sequence].
Returns: torch.Tensor
Positions [batch, sequence], with masked positions set to one.