deepmodeling / deepmodeling/unimol_tools
[Code scan] Fix Hugging Face from_pretrained path handling
- Dominant language
- Python
- Stars
- 34
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
This issue is a result of a Codex global repository scan.
## Summary
The Hugging Face model constructors resolve weight and dictionary paths and always pass them into the UniMol backend. If resolve_weight_path or resolve_dict_path returns a missing default path or stale repo-relative path, the backend does not enter its auto-download path because pretrained_model_path is not None. _has_transformers_weights also only checks local directories, so Hub model ids or saved HF checkpoints can skip super().from_pretrained() and ignore Transformers weights.
## Code references
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/modeling_unimol.py#L33-L45
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/modeling_unimol.py#L130-L162
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/modeling_unimol.py#L235-L242
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/modeling_unimol.py#L304-L312
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/configuration_unimol.py#L88-L102
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/pretrained/unimol-v1-allh/config.json#L39-L40
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_hf/pretrained/unimol-v1-noh/config.json#L39-L40
## Impact
Packaged HF entries and saved Transformers checkpoints can fail to load on clean installs or silently ignore saved HF weights, depending on whether the stale paths exist locally.
## Suggested fix
Use Transformers helpers such as cached_file or has_file to detect local and remote HF weights, delegate to super().from_pretrained() for real HF checkpoints, and avoid passing missing paths into the backend. Remove stale pretrained_*_path entries from bundled configs or resolve them to local packaged files.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the referenced from_pretrained and _has_transformers_weights sections in unimol_hf/modeling_unimol.py, then compare the path fields in configuration_unimol.py and the bundled config.json files. Check how packaged entries, Hub model IDs, and saved Transformers checkpoints are handled on a clean install. Done means valid HF weights load through the appropriate path, missing paths do not block backend auto-download, and bundled configs no longer contain stale entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- huggingface, python
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100