Skip to content

Fix HF_HUB_OFFLINE=1 for Gaudi backend #3193

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

Merged
merged 3 commits into from
May 6, 2025
Merged

Fix HF_HUB_OFFLINE=1 for Gaudi backend #3193

merged 3 commits into from
May 6, 2025

Conversation

regisss
Copy link
Collaborator

@regisss regisss commented Apr 25, 2025

What does this PR do?

Fixes #3192.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

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.

@regisss regisss marked this pull request as ready for review May 2, 2025 07:24
@regisss regisss requested a review from Narsil May 2, 2025 07:24
@regisss
Copy link
Collaborator Author

regisss commented May 2, 2025

@Narsil I added a small change to router/src/server.rs. I realized the cache path was sometimes not set properly.

It appears that, when we have HF_HUB_OFFLINE=1, the cache is set to HUGGINGFACE_HUB_CACHE:

let cache = std::env::var("HUGGINGFACE_HUB_CACHE")

If HUGGINGFACE_HUB_CACHE is not defined, it will default to Cache::default(), which is equal to ~/.cache/huggingface/.

The issue here is that it can happen that HUGGINGFACE_HUB_CACHE is not set while HF_HOME is. In that case, the default above completely ignores HF_HOME. An easy fix is to change the default from Cache::default() to Cache::from_env() (see the definition here), which will take HF_HOME into account and will fall back to Cache::default() anyway if HF_HOME is not defined.

@Narsil Narsil merged commit f208ba6 into main May 6, 2025
32 of 33 checks passed
@Narsil Narsil deleted the fix_gaudi_hub_offline branch May 6, 2025 08:47
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.

Gaudi backend doesnt work with HF_HUB_OFFLINE=1
2 participants