Skip to content

Fix mlcd auto config/model/mapping issues#44730

Merged
ydshieh merged 3 commits intomainfrom
fix_mlcd
Mar 16, 2026
Merged

Fix mlcd auto config/model/mapping issues#44730
ydshieh merged 3 commits intomainfrom
fix_mlcd

Conversation

@ydshieh
Copy link
Copy Markdown
Collaborator

@ydshieh ydshieh commented Mar 15, 2026

What does this PR do?

It's unclear why the config class has model_type = "mlcd_vision_model" but the model on the hub has "model_type": "mlcd".

This leads to the following failures (load from hub --> save locally --> local locally)

from transformers import MLCDVisionConfig, AutoConfig, AutoImageProcessor, AutoModel

ckpt = "DeepGlint-AI/mlcd-vit-bigG-patch14-336"
local_ckpt = "ckpt_mlcd"

config = AutoConfig.from_pretrained(ckpt)
config.save_pretrained(local_ckpt)
AutoConfig.from_pretrained(local_ckpt)  --> will fail

model = AutoModel.from_pretrained(ckpt)
model.save_pretrained(local_ckpt)
model_local = AutoModel.from_pretrained(local_ckpt) --> will fail too (after comment out the above one)

The error is

The checkpoint you are trying to load has model type mlcd_vision_model but Transformers does not recognize this architecture. ...

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

("donut-swin", "donut"),
("kosmos-2", "kosmos2"),
("kosmos-2.5", "kosmos2_5"),
("mlcd_vision_model", "mlcd"),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This part is in SPECIAL_MODEL_TYPE_TO_MODULE_NAME.

This is also necessary to make the tiny model creation script work for this model

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we add a comment why it's needed, because from config code only it's not clear

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This one is quite clear: it maps the model type to the model module.

If we want to add comment, it's more at

# This is tied to the processing `-` -> `_` in `model_type_to_module_name`. For example, instead of putting
# `transfo-xl` (as in `CONFIG_MAPPING_NAMES`), we should use `transfo_xl`.
DEPRECATED_MODELS = []

SPECIAL_MODEL_TYPE_TO_MODULE_NAME = OrderedDict[str, str](

("mistral3", "Mistral3Config"),
("mixtral", "MixtralConfig"),
("mlcd", "MLCDVisionConfig"),
("mlcd_vision_model", "MLCDVisionConfig"),
Copy link
Copy Markdown
Member

@zucchini-nlp zucchini-nlp Mar 16, 2026

Choose a reason for hiding this comment

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

hmm config also has mlcd_vision_model, so prob we don't need mlcd one line above

model_type = "mlcd_vision_model"
base_config_key = "vision_config"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unless there are models with both keys saved on the hub

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the problem is that, on the hub, the model type is "mlcd", like

https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-448/blob/main/config.json

https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-336/blob/main/config.json

if we remove the "mlcd part", loading from the hub will cause problem I believe.

(but maybe we can add a short comment on the repeated entries ...)

Copy link
Copy Markdown
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Ah, it's the other way round! I am not sure if we can nudge MLCD repo to fix it, so imo we can workaround on our side

("donut-swin", "donut"),
("kosmos-2", "kosmos2"),
("kosmos-2.5", "kosmos2_5"),
("mlcd_vision_model", "mlcd"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we add a comment why it's needed, because from config code only it's not clear

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto

@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44730&sha=31a553

@ydshieh ydshieh enabled auto-merge March 16, 2026 11:21
@ydshieh ydshieh disabled auto-merge March 16, 2026 11:22
@ydshieh ydshieh added this pull request to the merge queue Mar 16, 2026
Merged via the queue into main with commit 30adbf3 Mar 16, 2026
29 checks passed
@ydshieh ydshieh deleted the fix_mlcd branch March 16, 2026 12:12
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