Skip to content

Conversation

@Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Nov 4, 2025

This PR makes snapshot_download download files in parallel all the time. Previously we were not doing it if HF_XET_HIGH_PERFORMANCE=1 was set as environment variable. Goal was to avoid bloating the CPU if Xet starts N threads for each of the X files being downloaded in parallel. We had a similar logic for hf_transfer. However after some discussions on slack (private) and following this gist, it turns out that hf_xet is doing things much more carefully than hf_transfer by reusing the same pool of connections no matter the number of parallel calls. This means that even if snapshot_download starts N threads, they will all share the same Xet resources without freezing the user's machine.

Hence this PR.


Quick benchmark (not a scientific one^^):

HF_XET_HIGH_PERFORMANCE=1 hf download Agent-Ark/Toucan-1.5M

On main: 7'20

On this PR: 3'50

@Wauplin Wauplin requested a review from hanouticelina November 4, 2025 12:53
@HuggingFaceDocBuilderDev

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.

@Wauplin Wauplin merged commit 99bfce1 into main Nov 4, 2025
21 of 22 checks passed
@Wauplin Wauplin deleted the multi-threaded-snapshot-download branch November 4, 2025 14:42
@Wauplin
Copy link
Contributor Author

Wauplin commented Nov 4, 2025

Bypassing approval to avoid conflicts. Happy to open a follow-up PR in case we need to update something.

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.

3 participants