nemo_automodel.components.models.mistral_large4.multimodal
nemo_automodel.components.models.mistral_large4.multimodal
Image/text execution over the existing Large 4 training backbone.
Module Contents
Classes
Functions
API
Bases: MistralLarge4ForCausalLM
Native multimodal SFT/LoRA with complete images and packed document isolation.
Shares the text backbone, loss, and checkpoint adapter without wrapping a second causal-model root. All vision checkpoint names stay native.
Keep the native vision tower and all image projections on stage zero.
Replace complete image grids and run the existing causal training path.
Parameters:
Global integer [batch, sequence] or packed [tokens]. Required for images; under CP, complete images are spliced before the first stage shards the sequence. Later PP stages take local residuals.
Propagated state in _pipeline_boundary_metas
layouts; non-first stages receive [batch, sequence, hidden]
residuals in input_ids and skip the image encoder.
Optional list of floating [channels, height, width] images in encounter order.
Optional floating [batch, sequence, hidden] or [tokens, hidden], replacing the embedding lookup. IDs remain necessary for image alignment.
Optional nonnegative integers matching token axes; CP sharder supplies [batch, local_sequence] global positions.
Binary keep mask or packed document IDs matching global token axes. CP combines both user padding masks here.
Optional boolean padding mask matching token axes; CP sharder supplies [batch, local_sequence], including CP padding.
Optional integer targets matching token axes, -100 ignored; [batch, local_sequence] under CP. Image tokens and delimiters are masked on a copy before the existing shifted CE.
Zero for all, positive tail length or int64 [kept_positions].
Return final hidden states in addition to logits.
Optional packed integer [documents + 1] boundaries.
Optional real document lengths [batch, documents], with -1000 padding, retained by the packed sharder for document-count validation.
bshd or thd; THD requires cu_seqlens.
Must be false, as in the causal training path.
Prepared integer [batch, local_sequence] document identity for prepared THD execution.
Returns: CausalLMOutputWithPast | torch.Tensor | tuple[torch.Tensor, ...]
CausalLMOutputWithPast with FP32 [batch, kept_sequence, vocab] capped logits,
Encode and project variable-size complete images in encounter order.
Parameters:
Nonempty list of floating [channels, height, width] images on the model device.
Returns: tuple[torch.Tensor, ...]
Per-image floating [merged_rows * merged_columns, text_hidden] features.
Keep complete image/token streams until stage-zero embedding.
Parameters:
Global IDs/masks [batch, sequence], optional embeddings [batch, sequence, hidden], and complete images [channels, height, width].
Number of independently scheduled PP microbatches.
Returns: dict[str, ContextParallelSharder]
Sharder mapping using prepare_cp_inputs’ aux-only contract: primary
Validate complete image grids independently inside each document.
Parameters:
Integer [batch, sequence] or packed [tokens] storage.
Images [channels, height, width], in document/encounter order.
Native vision dimensions and image delimiter IDs.
Optional integer [documents + 1] partition of packed storage.
Optional binary keep mask with input_ids’ shape.
Optional boolean padding mask with input_ids’ shape.
Returns: torch.Tensor
Int64 [total_merged_patches] indices into flattened tokens, on input_ids’