Skip to content

Conversation

@scottzh8
Copy link

@scottzh8 scottzh8 commented Nov 1, 2025

What does this PR do?

This PR improves error visibility when loading model configurations via PretrainedConfig._get_config_dict.

Previously, any ValueError raised deep in the Hugging Face Hub stack (for example, when the hf_transfer package was missing) was caught by a generic except Exception and rethrown as a vague OSError.

With this change, ValueErrors are explicitly caught and wrapped in an OSError that preserves the original message, making it much easier to diagnose environment and dependency issues.

Example improvement:

Before:
OSError: Can't load the configuration of 'mobicham/Qwen2.5-VL-3B-Instruct_int8wo_ao'. 
If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name...

After:
OSError: Fast download using 'hf_transfer' is enabled (HF_HUB_ENABLE_HF_TRANSFER=1) 
but 'hf_transfer' package is not available in your environment. Try `pip install hf_transfer`.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Rocketknight1
Copy link
Member

Hmn, I think this makes sense in some cases, but the problem is that it might make a lot of errors start surfacing in deep internal code and users might not know that this just means something like "you have a directory with the same name as the repo" or something. cc @ArthurZucker @Cyrilvallez WDYT?

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.

2 participants