1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[GH-ISSUE #62] Magistral support #30

Closed
opened 2026-11-01 04:16:42 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @matrix07012 on GitHub (Dec 2, 2025).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/62

Would it be possible to support Magistral-Small-2509?
Unrecognized configuration class <class 'transformers.models.mistral3.configuration_mistral3.Mistral3Config

Originally created by @matrix07012 on GitHub (Dec 2, 2025). Original GitHub issue: https://github.com/p-e-w/heretic/issues/62 Would it be possible to support Magistral-Small-2509? `Unrecognized configuration class <class 'transformers.models.mistral3.configuration_mistral3.Mistral3Config`
bsakaguchi 2026-11-01 04:16:42 +07:00
Author
Owner

@Vinay-Umrethe commented on GitHub (Dec 2, 2025):

Looking at the model's card the one you are using mistralai/Magistral-Small-2509 seems to be a normal text-generation model and should have worked, but didn't as it doesn't have a transformers OR text-generation pipeline set in it's readme.md which actually is not the cause for error. It suggest it won't work with normal transformers you have.

DO THIS:

pip install --upgrade transformers[mistral-common]

This should also install mistral_common >= 1.8.5


IF THAT DOESN'T WORK I THINK YOU WOULD HAVE TO MANUALLY CHANGE THESE LINES AFTER THIS INSTALLATION.

where ever your heretic-llm package is installed like in site-packages

change AutoModelForCausalLM to Mistral3ForConditionalGeneration as this seems to be a little different architecture.

src/model.py

from torch.nn import ModuleList
from transformers import (
    AutoModelForCausalLM, # change this to Mistral3ForConditionalGeneration in line 14
    AutoTokenizer,
    BatchEncoding,
    PreTrainedTokenizerBase,
    TextStreamer,

            try:
                self.model = AutoModelForCausalLM.from_pretrained( # also this one at line 61 i guess
                    settings.model,
                    dtype=dtype,
                    device_map=settings.device_map,
                    trust_remote_code=self.trusted_models.get(settings.model),
                )

AND

    def reload_model(self):
        dtype = self.model.dtype

        # Purge existing model object from memory to make space.
        self.model = None
        empty_cache()

        self.model = AutoModelForCausalLM.from_pretrained( # HERE TOO...
            self.settings.model,
            dtype=dtype,
            device_map=self.settings.device_map,
            trust_remote_code=self.trusted_models.get(self.settings.model),
        )
<!-- gh-comment-id:3601897983 --> @Vinay-Umrethe commented on GitHub (Dec 2, 2025): Looking at the model's card the one you are using `mistralai/Magistral-Small-2509` seems to be a normal `text-generation` model and should have worked, but didn't as it doesn't have a `transformers `OR `text-generation` pipeline set in it's readme.md which actually is _not_ the **cause** for error. It suggest it won't work with normal transformers you have. DO THIS: ```bash pip install --upgrade transformers[mistral-common] ``` > This should also install [mistral_common >= 1.8.5](https://github.com/mistralai/mistral-common/releases/tag/v1.8.5) --- IF THAT DOESN'T WORK I THINK YOU WOULD HAVE TO MANUALLY CHANGE THESE LINES AFTER THIS INSTALLATION. where ever your `heretic-llm` package is installed like in `site-packages` change `AutoModelForCausalLM` to `Mistral3ForConditionalGeneration` as this seems to be a little different architecture. `src/model.py` ```python from torch.nn import ModuleList from transformers import ( AutoModelForCausalLM, # change this to Mistral3ForConditionalGeneration in line 14 AutoTokenizer, BatchEncoding, PreTrainedTokenizerBase, TextStreamer, ``` --- ```python try: self.model = AutoModelForCausalLM.from_pretrained( # also this one at line 61 i guess settings.model, dtype=dtype, device_map=settings.device_map, trust_remote_code=self.trusted_models.get(settings.model), ) ``` **AND** ```python def reload_model(self): dtype = self.model.dtype # Purge existing model object from memory to make space. self.model = None empty_cache() self.model = AutoModelForCausalLM.from_pretrained( # HERE TOO... self.settings.model, dtype=dtype, device_map=self.settings.device_map, trust_remote_code=self.trusted_models.get(self.settings.model), ) ```
Author
Owner

@Vinay-Umrethe commented on GitHub (Dec 2, 2025):

it's also a vision model too, so not sure if it would work with these configs.

I can suggest you, if this still doesn't work you can change AutoModelForCausalLM TO AutoModelForImageTextToText and use

OpenGVLab/InternVL3_5-30B-A3B-HF Model Which is nearly the same as the other model you are trying on.

I have tried it's smaller variants and they work great even on CPU inference tests.

SO might fit into your requirments it's a good model.

<!-- gh-comment-id:3601928061 --> @Vinay-Umrethe commented on GitHub (Dec 2, 2025): it's also a vision model too, so not sure if it would work with these configs. I can suggest you, if this still doesn't work you can change `AutoModelForCausalLM` TO `AutoModelForImageTextToText` and use `OpenGVLab/InternVL3_5-30B-A3B-HF` Model Which is nearly the same as the other model you are trying on. I have tried it's smaller variants and they work great even on CPU inference tests. **SO might fit into your requirments it's a good model.**
Author
Owner

@matrix07012 commented on GitHub (Dec 2, 2025):

That sadly didn't work,

Loading model Magistral-Small-2509...
Loading checkpoint shards: 100%|███████████████████████████████████████████████████████| 10/10 [00:22<00:00,  2.22s/it]
Some parameters are on the meta device because they were offloaded to the cpu.
Failed (Kwargs ['add_generation_prompt'] are not supported by `MistralCommonTokenizer.apply_chat_template`.)

but thanks for the tip. I wasn't aware of InternVL.

<!-- gh-comment-id:3602272482 --> @matrix07012 commented on GitHub (Dec 2, 2025): That sadly didn't work, ``` Loading model Magistral-Small-2509... Loading checkpoint shards: 100%|███████████████████████████████████████████████████████| 10/10 [00:22<00:00, 2.22s/it] Some parameters are on the meta device because they were offloaded to the cpu. Failed (Kwargs ['add_generation_prompt'] are not supported by `MistralCommonTokenizer.apply_chat_template`.) ``` but thanks for the tip. I wasn't aware of InternVL.
Author
Owner

@Vinay-Umrethe commented on GitHub (Dec 2, 2025):

ok, the problem can be due to it's tokenizer, and the model is not so supported by transformers.

So you can re-install normal transformers latest one, and change to AutoModelForImageTextToText and use InternVL3.5 Series Models which are supported by transformers and are fast.

<!-- gh-comment-id:3602477029 --> @Vinay-Umrethe commented on GitHub (Dec 2, 2025): ok, the problem can be due to it's tokenizer, and the model is not so supported by transformers. So you can re-install normal transformers latest one, and change to `AutoModelForImageTextToText` and use InternVL3.5 Series Models which are supported by transformers and are fast.
Author
Owner

@p-e-w commented on GitHub (Oct 12, 2026):

This almost certainly works now as Transformers has been updated many times since.

<!-- gh-comment-id:6124553385 --> @p-e-w commented on GitHub (Oct 12, 2026): This almost certainly works now as Transformers has been updated many times since.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#30
No description provided.