nemo_automodel.components.models.mistral3_vlm
nemo_automodel.components.models.mistral3_vlm
FP8-native Mistral3 VLM custom model registration (dawn-ridge 128B).
Importing this module installs a resolver hook on
_resolve_custom_model_cls_for_config (nemo_automodel/_transformers/
model_init.py) that routes FP8-native Mistral3 VLM configs to
Mistral3FP8VLMForConditionalGeneration. The model registry is not
overwritten, so non-FP8 Mistral3 VLMs keep the stock mistral4.model
path and there is no regression for other users.
Submodules
nemo_automodel.components.models.mistral3_vlm.modelnemo_automodel.components.models.mistral3_vlm.state_dict_adapter
Package Contents
Classes
Functions
Data
API
Bases: _HFMistral3ForConditionalGeneration
Full-VLM (vision + text) FP8 loader for Mistral3ForConditionalGeneration.
Used when the user instantiates through
NeMoAutoModelForImageTextToText.from_pretrained on an FP8-native
Mistral3 VLM checkpoint (e.g. dawn-ridge-128B).
Forward pass with memory-efficient fused cross-entropy (cut-CE) support.
Overrides HF’s Mistral3ForConditionalGeneration.forward so the
train_ft recipe can enable FusedLinearCrossEntropy. The recipe
only does so when (a) forward exposes a logits_to_keep parameter
and (b) calling the model returns an output that carries the FINAL hidden
states (full sequence) while logits cover only the kept positions.
HF’s stock forward gates hidden_states on a per-call
output_hidden_states kwarg (which the recipe does not pass) and emits
the full per-layer tuple. Here we instead resolve output_hidden_states
from the text sub-config and surface the inner model’s last_hidden_state
(the single [B, S, H] tensor fed to lm_head) directly, which is
what get_final_hidden_states consumes.
Parameters:
Input token IDs [B, S].
Optional image pixel values for the vision tower.
Optional attention mask.
Optional position indices.
Optional cached key/values.
Optional pre-computed embeddings.
Optional labels for loss computation.
Whether to use KV caching.
Number of final logits to compute (0=all, N=last N tokens).
Optional image sizes for the vision tower.
Whether to surface the final hidden states on the
output (defaults to the text sub-config’s output_hidden_states).
Additional arguments forwarded to the base model.
Returns: Mistral3CausalLMOutputWithPast
class:~transformers.models.mistral3.modeling_mistral3.Mistral3CausalLMOutputWithPast
Claim FP8-native and dequantized Mistral3 VLM configs.
Matches Mistral3Config (outer VLM) with a ministral3 text backbone
and either no quantization config or quantization_config.quant_method == 'fp8'. Consolidated checkpoints are saved in BF16 without the
source FP8 metadata and still require this class’s rotary-buffer reinit.
Tie lm_head to the active text embedding when requested.
Prepend an FP8-Mistral3 VLM check to _resolve_custom_model_cls_for_config.