Skip to content

Add support for ministral3 and mistral3 model types#860

Open
sealad886 wants to merge 8 commits intoml-explore:mainfrom
sealad886:main
Open

Add support for ministral3 and mistral3 model types#860
sealad886 wants to merge 8 commits intoml-explore:mainfrom
sealad886:main

Conversation

@sealad886
Copy link
Contributor

This pull request adds support for the new ministral3 and mistral3 model types across the codebase, ensuring they are properly recognized, handled in quantization, and thoroughly tested. The changes also improve consistency in model type remapping and GGUF export logic.

Model support and integration:

  • Added ministral3 and mistral3 model types to the AWQ quantization configuration, ensuring these models are supported during quantization and mapped to the correct configuration (mlx_lm/quant/awq.py).
  • Updated the GGUF export logic to use MODEL_REMAPPING for consistent model type handling and included ministral3 and mistral3 as supported types (mlx_lm/fuse.py). [1] [2]

Testing:

  • Added comprehensive unit tests for both ministral3 and mistral3 models, including model instantiation and prompt cache construction, to ensure correct behavior and compatibility (tests/test_models.py).

Copilot AI and others added 7 commits December 3, 2025 14:28
Co-authored-by: sealad886 <155285242+sealad886@users.noreply.github.com>
Co-authored-by: sealad886 <155285242+sealad886@users.noreply.github.com>
Co-authored-by: sealad886 <155285242+sealad886@users.noreply.github.com>
…prove tests, fix GGUF export

Co-authored-by: sealad886 <155285242+sealad886@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 7, 2026 22:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds recognition and handling for the ministral3 and mistral3 model types across quantization, GGUF export gating, and unit tests so these model variants can be instantiated and processed consistently within mlx_lm.

Changes:

  • Added ministral3/mistral3 entries to AWQ model configuration mapping.
  • Updated GGUF export gating to apply MODEL_REMAPPING and allow ministral3.
  • Added unit tests for ministral3 and mistral3 model construction and prompt-cache creation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_models.py Adds coverage for ministral3 and mistral3 instantiation plus prompt-cache construction.
mlx_lm/quant/awq.py Extends AWQ configuration mapping to support the new model types (including language_model nesting for mistral3).
mlx_lm/fuse.py Uses MODEL_REMAPPING when checking GGUF export support and expands the allowlist.
Comments suppressed due to low confidence (1)

mlx_lm/fuse.py:103

  • convert_to_gguf() derives RoPE metadata from top-level config["rope_theta"]/config["rope_scaling"], but ministral3 uses rope_parameters (see mlx_lm/models/ministral3.py) with rope_theta nested under that dict. As-is, GGUF export for ministral3 will ignore non-default rope_parameters["rope_theta"] and any associated scaling params, producing incorrect metadata for some checkpoints. Consider normalizing the config before calling convert_to_gguf() (e.g., copy rope_parameters["rope_theta"] into rope_theta, and map any scaling fields as needed).
        # Apply MODEL_REMAPPING to match load() behavior
        remapped_type = MODEL_REMAPPING.get(model_type, model_type)
        if remapped_type not in ["llama", "mixtral", "mistral", "ministral3"]:
            raise ValueError(
                f"Model type {model_type} not supported for GGUF conversion."
            )
        weights = dict(tree_flatten(model.parameters()))
        convert_to_gguf(save_path, weights, config, str(save_path / args.gguf_path))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 95 to 100
model_type = config["model_type"]
if model_type not in ["llama", "mixtral", "mistral"]:
# Apply MODEL_REMAPPING to match load() behavior
remapped_type = MODEL_REMAPPING.get(model_type, model_type)
if remapped_type not in ["llama", "mixtral", "mistral", "ministral3"]:
raise ValueError(
f"Model type {model_type} not supported for GGUF conversion."
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says GGUF export supports both ministral3 and mistral3, but this allowlist only adds ministral3. If mistral3 is intended to be supported, GGUF conversion likely also needs special handling because mistral3 configs are nested under text_config and parameter names are prefixed with language_model., which convert_to_gguf()/translate_weight_names() won’t match. Either add the missing mistral3 support end-to-end (flatten config + strip/translate weight prefixes) or update the PR description to reflect that only ministral3 is supported for GGUF export.

Copilot uses AI. Check for mistakes.
Comment on lines +995 to +997
self.model_test_runner(
model, args.model_type, text_config["vocab_size"], text_config["num_hidden_layers"]
)
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model_test_runner(...) call exceeds Black’s default line length and will be reformatted by the pre-commit hook (which runs in CI). Please run pre-commit/Black so the arguments are wrapped consistently with the rest of the file.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants