Fix: Prevent crashes when HuggingFace is unreachable#152
Open
mpecanha wants to merge 1 commit intojamiepine:mainfrom
Open
Fix: Prevent crashes when HuggingFace is unreachable#152mpecanha wants to merge 1 commit intojamiepine:mainfrom
mpecanha wants to merge 1 commit intojamiepine:mainfrom
Conversation
Implements offline mode patch for API stability issues: - Add hf_offline_patch.py to monkey-patch huggingface_hub - Force cache-only lookups before mlx_audio imports - Create symlink from original Qwen repo to MLX community version when only MLX version is cached This fixes: - Issue jamiepine#150: Internet required even with cached models - Issue jamiepine#151: API crashes when HF network fails The patch ensures that if models are locally cached, no network requests are made to HuggingFace during speech generation.
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.
Voicebox Offline Mode Fix
Problem
Voicebox crashes when generating speech if HuggingFace is unreachable, even when models are fully cached locally.
Root Cause:
mlx-community/Qwen3-TTS-12Hz-1.7B-Base-bf16(MLX optimized version)mlx_audio.tts.load()tries to fetchconfig.jsonfrom original repoQwen/Qwen3-TTS-12Hz-1.7B-BaseRemoteDisconnectedRelated Issues:
Solution
Two-part fix:
1. Monkey-patch huggingface_hub (
backend/utils/hf_offline_patch.py)2. Symlink original repo to MLX version (
ensure_original_qwen_config_cached())Qwen/Qwen3-TTS-12Hz-1.7B-Basecache doesn't existmlx-community/Qwen3-TTS-12Hz-1.7B-Base-bf16does existFiles Changed
backend/backends/mlx_backend.py- Added patch imports at topbackend/utils/hf_offline_patch.py- New patch moduleTesting
To test this fix:
make buildBuild Instructions
Notes
mlx_backend.pyis importedVOICEBOX_OFFLINE_PATCH=0to disable the patchPatch contributed by community