Skip to content
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

Enabling hf_transfer use. #1272

Merged
merged 8 commits into from
Dec 22, 2022
Merged

Enabling hf_transfer use. #1272

merged 8 commits into from
Dec 22, 2022

Conversation

Narsil
Copy link
Contributor

@Narsil Narsil commented Dec 16, 2022

This enables optional faster download using hf_transfer: https://github.com/huggingface/hf_transfer

  • Only enabled is when using env variable HF_TRANSFER=1 (makes it easy to disable).
  • Disable other form of parallelism when using HF_TRANSFER (this might lead to threads slowing each other down).

With it enabled, the download might look "slow" because most of the time can be taken while moving from a tmpfs to actual disk the model files.
This is deemed out of scope for now.

hf_transfer provides no feedback during download, again this can be added later if we want to grow the spec for this.

@Narsil Narsil requested review from Wauplin and sgugger December 16, 2022 13:13
@Wauplin Wauplin requested a review from julien-c December 16, 2022 13:16
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 16, 2022

The documentation is not available anymore as the PR was closed or merged.

@Narsil
Copy link
Contributor Author

Narsil commented Dec 16, 2022

@Wauplin I can safely ignore codecov right ?

@Wauplin
Copy link
Contributor

Wauplin commented Dec 16, 2022

@Wauplin I can safely ignore codecov right ?

Yes no worries !

@codecov
Copy link

codecov bot commented Dec 16, 2022

Codecov Report

Base: 83.94% // Head: 83.72% // Decreases project coverage by -0.21% ⚠️

Coverage data is based on head (bcc374b) compared to base (c580233).
Patch coverage: 31.57% of modified lines in pull request are covered.

❗ Current head bcc374b differs from pull request most recent head fc7902d. Consider uploading reports for the commit fc7902d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1272      +/-   ##
==========================================
- Coverage   83.94%   83.72%   -0.22%     
==========================================
  Files          47       47              
  Lines        4622     4640      +18     
==========================================
+ Hits         3880     3885       +5     
- Misses        742      755      +13     
Impacted Files Coverage Δ
src/huggingface_hub/utils/__init__.py 100.00% <ø> (ø)
src/huggingface_hub/file_download.py 86.62% <20.00%> (-1.91%) ⬇️
src/huggingface_hub/utils/_runtime.py 61.40% <40.00%> (-0.99%) ⬇️
src/huggingface_hub/_snapshot_download.py 92.45% <50.00%> (-3.55%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Narsil, following up on your PR. I made a few changes (renamed the env variable to HF_HUB_ENABLE_HF_TRANSFER, mentioned it in the docs and added more debug info).
I tested it locally and got a 1.3x speed up when downloading this file but as said in the call, my bottleneck is the network bandwith anyway.

Otherwise PR looks good to me now. Will wait from other reviews here.

@Wauplin Wauplin requested a review from LysandreJik December 19, 2022 15:45
@LysandreJik
Copy link
Member

I don't have any problems regarding the implementation. Still, I'm not too sure about adding an optional rust dependency for a speedup that seems to affect setups with high-speed bandwidth links (if I understand correctly from the internal comments). Is the idea that we would only use this internally?

I don't think it would have community usage anyway, given that it would be particularly useful for larger artifacts, and I would think progress bars are imperative to large downloads as they would otherwise feel like shooting in the dark.

@julien-c
Copy link
Member

yes my understanding is this is mostly (or only) for internal use (Inference API notably)

@Wauplin
Copy link
Contributor

Wauplin commented Dec 19, 2022

As I see it, this is mostly for internal purposes. I have documented it only at 1 place in an "advanced" section and with warnings on the fact that it's "experimental" (understand "use it if you want but don't complain"). I don't think we will ever promote it out loud but having it is still relevant IMO
(that's also why I haven't added it as an extra dependency in setup.py)

@julien-c
Copy link
Member

For the sake of discussion, we could also monkey-patch this internally, no (potentially adding hooks to hfh so it's trivial to monkey-patch)?

@Narsil
Copy link
Contributor Author

Narsil commented Dec 20, 2022

I would like also to mention @apolinario which thinks it could be very useful for Spaces (People tend to include the model files directly in the space because it's faster, but putting strain on the spaces infra as far as I understand).

The caveat for spaces, is that by default for CPU there is a limits:cpu which caps CPU usage and throttles hf_transfer which leads to similar or slower download speeds. But for all GPU and CPU upgrades, there is a benefit.
If you want to check out https://huggingface.co/spaces/Narsil/hf_transfer_showcase

The actual benefit will depend on the kind of instance used to host the space (and neighboring usage of the node).
The larger the instance the better it is.

@McPatate is also playing with DL speeds because the security scanner spends most of its time downloading (it's written in node, so wouldn't benefit directly from this, and it's already capping its network, but Luc recently upgraded the machines with the intended goal to get better network).

Clearly the biggest win was this anyway: #1267

@LysandreJik
Copy link
Member

Ok in that case, if you feel strongly and think it won't hut maintenance @Wauplin, let's merge it in!

@Wauplin
Copy link
Contributor

Wauplin commented Dec 22, 2022

Let's merge it then :)

@Wauplin Wauplin merged commit 71a9d28 into main Dec 22, 2022
@Wauplin Wauplin deleted the hf_transfer branch December 22, 2022 07:52
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.

5 participants