Skip to content
FastVideo
Esc
↑↓navigate↵open⌘Jpreview
On this page

mistral3

HF-backed Mistral3 text encoder wrapper for full Flux2.

fastvideo.models.encoders.mistral3.Mistral3TextConfig

Mistral3TextConfig(arch_config: TextEncoderArchConfig = Mistral3TextArchConfig(), prefix: str = 'mistral3', quant_config: QuantizationConfig | None = None, lora_config: Any | None = None, is_chat_model: bool = True, treat_empty_as_dot: bool = False, *, _resolved_attention_backend: AttentionBackendEnum | None = None, chat_template_enable_thinking: bool = False)

Top-level config for the Mistral3 full Flux2 text encoder.

fastvideo.models.encoders.mistral3.TextEncoder

TextEncoder(config: TextEncoderConfig)

Base for native encoders with a model-specific forward output contract.

fastvideo.models.encoders.mistral3.TextEncoder.forward

forward(*args: Any, **kwargs: Any) -> TextEncoderOutputT

fastvideo.models.encoders.mistral3.Mistral3ForConditionalGeneration

Mistral3ForConditionalGeneration(config: Mistral3TextConfig)

Loads the Transformers Mistral3 implementation for Flux2 text encoding.

Source
class Mistral3ForConditionalGeneration(TextEncoder):
    """Loads the Transformers Mistral3 implementation for Flux2 text encoding."""
supports_hf_from_pretrained = True

def __init__(self, config: Mistral3TextConfig) -> None:
    super().__init__(config)
    self.config = config

@classmethod
def from_pretrained_local(
    cls,
    model_path: str,
    model_config: Mistral3TextConfig,
    dtype: torch.dtype,
    device: torch.device,
) -> nn.Module:
    from transformers import AutoModelForImageTextToText

    model = AutoModelForImageTextToText.from_pretrained(
        model_path,
        local_files_only=True,
        torch_dtype=dtype,
        low_cpu_mem_usage=True,
    ).eval()
    if device.type != "cpu":
        model = model.to(device)
    return model

def forward(self, *args: Any, **kwargs: Any) -> Any:
    raise NotImplementedError("Mistral3ForConditionalGeneration is loaded through Transformers "
                              &quot;via from_pretrained_local().&quot;)</code></pre></details>

fastvideo.models.encoders.mistral3.Mistral3ForConditionalGeneration.from_pretrained_local

from_pretrained_local(model_path: str, model_config: Mistral3TextConfig, dtype: torch.dtype, device: torch.device) -> nn.Module
Source
@classmethod
def from_pretrained_local(
    cls,
    model_path: str,
    model_config: Mistral3TextConfig,
    dtype: torch.dtype,
    device: torch.device,
) -> nn.Module:
    from transformers import AutoModelForImageTextToText
model = AutoModelForImageTextToText.from_pretrained(
    model_path,
    local_files_only=True,
    torch_dtype=dtype,
    low_cpu_mem_usage=True,
).eval()
if device.type != &quot;cpu&quot;:
    model = model.to(device)
return model</code></pre></details>

fastvideo.models.encoders.mistral3.Mistral3ForConditionalGeneration.forward

forward(*args: Any, **kwargs: Any) -> Any
Source
def forward(self, *args: Any, **kwargs: Any) -> Any:
    raise NotImplementedError("Mistral3ForConditionalGeneration is loaded through Transformers "
                              "via from_pretrained_local().")

Was this page helpful?