fix: catch HfHubHTTPError in safetensors auto_conversion thread - #44440
Closed
weiguangli-io wants to merge 1 commit into
Closed
fix: catch HfHubHTTPError in safetensors auto_conversion thread#44440weiguangli-io wants to merge 1 commit into
weiguangli-io wants to merge 1 commit into
Conversation
The background auto-conversion thread would raise unhandled HfHubHTTPError exceptions when a model repository has discussions disabled. This caused noisy error output during normal model loading. Two changes: - Catch HfHubHTTPError in previous_pr() when iterating discussions, logging a debug message instead of propagating the exception - Set ignore_errors_during_conversion=True for the background thread so any remaining errors are silently suppressed Fixes huggingface#44403
Member
|
Opening PRs to random issues when people are still discussing the issue is not actually helpful! |
This was referenced May 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the noisy
HfHubHTTPErrorexception output that appears when loading a transformer model from a repository that has discussions disabled.Root cause
The
previous_pr()function insafetensors_conversion.pycallsget_repo_discussions()which raisesHfHubHTTPError(403 Forbidden) when a repo has discussions disabled. This exception propagated up through the backgroundThread-auto_conversionthread, producing a scary traceback during normal model loading.Changes
src/transformers/safetensors_conversion.py: Wrap theget_repo_discussions()iteration inprevious_pr()with atry/except HfHubHTTPErrorblock, logging a debug-level message instead of propagating the exception.src/transformers/modeling_utils.py: Changeignore_errors_during_conversionfromFalsetoTruefor the background auto-conversion thread, since this thread is a best-effort optimization for future loads and should never produce user-visible error output.Fixes #44403
Before
After
馃 Generated with Claude Code