-
Notifications
You must be signed in to change notification settings - Fork 237
Added cache_dir argument #2212
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
Added cache_dir argument #2212
Conversation
… for re-using local cache when possible.
@@ -173,6 +173,12 @@ def parse_args(): | |||
default=42, | |||
help="Text-to-image specific parameter that defines the seed value.", | |||
) | |||
parser.add_argument( | |||
"--cache-dir", |
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.
--cache-dir
is a generic name but option enabled for text hf text models only. Does it make sense to rename it to --hf-cache-dir
and support other model types (text-to-image
, visual-text
etc)?
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.
Pull Request Overview
This pull request adds a new cache_dir argument to support re-using a local Huggingface cache during model loading.
- Updated argument parsing in the CLI to include cache_dir.
- Modified load_text_hf_pipeline, load_text_model, and load_model to accept and pass along the cache_dir argument.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
tools/who_what_benchmark/whowhatbench/wwb.py | Added cache_dir argument to the CLI and passed its value to downstream calls in main. |
tools/who_what_benchmark/whowhatbench/model_loaders.py | Updated function signatures for model loaders (e.g., load_text_hf_pipeline, load_text_model, load_model) to accept cache_dir. |
Comments suppressed due to low confidence (1)
tools/who_what_benchmark/whowhatbench/model_loaders.py:381
- Consider adding the cache_dir argument to the call of load_text2image_model for consistency with the text model loaders, if the HF-based text-to-image pipeline supports cache reuse.
return load_text2image_model(model_id, device, ov_options, use_hf, use_genai)
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.
As far as I know caching of HF models is enabled by default at /home/<username>/.cache/huggingface/hub
. The default model cache location can be changed with a HF_HUB_CACHE
env. variable. More info here: https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache .
So if the default cache location doesn't suit you for some reason, I believe you can run wwb like this:
$ HF_HUB_CACHE=<some_path> wwb ...
@cc-crisan Have you tried the approach above? If so, what are the reasons the additional argument is still required?
I tried it in a different context and it did not seem to be working. But I was expecting it to work with HF_HUB_OFFLINE=true, and in that context, it wouldn't get the revision (commit_hash) from the huggingface website (default it 'main') so it failed a regex match looking for a 40-characters string. I will re-test it and let you know. |
My colleague, @rvuia, found a workaround by specifying a direct path to the cached model. That plus HF_HUB_OFFLINE set on true seem to be working. I'll close this PR as there is no need to change wwb.py. |
Added cache_dir argument for re-using local cache when possible.