-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove the need for the config to be in the subfolder #2044
Conversation
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. |
optimum/modeling_base.py
Outdated
@@ -380,27 +381,24 @@ def from_pretrained( | |||
) | |||
model_id, revision = model_id.split("@") | |||
|
|||
config_folder = ( | |||
subfolder if find_files_matching_pattern(model_id, cls.config_name)[0].parent == subfolder else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_files_matching_pattern
may return an empty list, causing a crash here
(Edit: I now see this PR is still in draft mode, oops)
I did some testing with this branch and wrote about it here: huggingface/optimum-intel#923 (comment)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Edit: This seems to be related to the integration between I'm testing some more, and I think this is resulting in some issues with local models (a clone of this model), although perhaps the issue could be from import tempfile
from pathlib import Path
from huggingface_hub import HfApi
from optimum.intel import OVModelForFeatureExtraction
model_id = "sentence-transformers-testing/stsb-bert-tiny-openvino"
# hub model
ov_model = OVModelForFeatureExtraction.from_pretrained(model_id, subfolder="openvino", file_name="openvino_model.xml")
print("Hub model:", ov_model)
# local model
api = HfApi()
with tempfile.TemporaryDirectory() as tmpdirname:
local_dir = Path(tmpdirname) / "model"
api.snapshot_download(repo_id=model_id, local_dir=local_dir)
ov_model = OVModelForFeatureExtraction.from_pretrained(local_dir, subfolder="openvino", file_name="openvino_model.xml")
print("Remote model:", ov_model) with Outputs:
Note that it's trying to load The issue is only for local models, as remote loading still seems to work fine. Edit: I believe the issue originates here: if subfolder:
model_cache_path = model_path / subfolder / file_name
else:
model_cache_path = model_path / file_name Although I'm not really sure why this didn't pop up earlier.
|
Thanks for taking the time to tests it @tomaarsen, the issue here seems to indeed come from the fact that |
I created a quick PR for OpenVINO on the
|
logger.info( | ||
f"{cls.config_name} not found in the specified subfolder {subfolder}. Using the top level {cls.config_name}." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: Nevermind, I think we should remove the logger.setLevel(logging.INFO)
that exist in 2 places in optimum
:
Otherwise I always see e.g.
Framework not specified. Using pt to export the model.
Using the export variant default. Available variants are:
- default: The default ONNX variant.
***** Exporting submodel 1/1: MPNetModel *****
Using framework PyTorch: 2.5.0.dev20240807+cu121
config.json not found in the specified subfolder onnx. Using the top level config.json.
Compiling the model to CPU ...
See the original comment here:
logger.info( | |
f"{cls.config_name} not found in the specified subfolder {subfolder}. Using the top level {cls.config_name}." | |
) | |
logger.debug( | |
f"{cls.config_name} not found in the specified subfolder {subfolder}. Using the top level {cls.config_name}." | |
) |
Any chance I can convince you to reduce this to debug
?
I recognize that it's taken from
optimum/optimum/modeling_base.py
Lines 267 to 269 in 2c0476e
logger.info( | |
f"config.json not found in the specified subfolder {subfolder}. Using the top level config.json." | |
) |
where info
is used, but I feel like the setting is a bit different. This new info
will be triggered every time someone loads an ONNX or OpenVINO model with Sentence Transformers (as those automatically save their modeling files in subfolders away from the configuration).
Another reason that I'd like it to be reduced to debug
is because (for some reason?) the info
-level logs are shown by default in Optimum. Or do I just have a weird/non-normal setup? I don't think I'm setting set_verbosity_info()
or TRANSFORMERS_VERBOSITY
.
<Logger optimum (INFO)>
<Logger transformers (WARNING)>
<Logger accelerate (WARNING)>
I'm usually getting quite a lot of logs from optimum
already.
The |
No description provided.