-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix: MLX thread affinity crash + missing mlx-lm/mlx-audio in dev setup #886
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
Closed
AlexStephenLytton
wants to merge
3
commits into
jamiepine:main
from
AlexStephenLytton:fix/mlx-thread-affinity-and-deps
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
c82185f
fix: MLX thread affinity crash + missing mlx-lm/mlx-audio in dev setup
AlexStephenLytton 7cfa6b8
fix: enable MPS for the PyTorch Qwen3-TTS/CustomVoice engines on Appl…
AlexStephenLytton e0553aa
fix: address CodeRabbit review findings — MPS cache cleanup, MLX unlo…
AlexStephenLytton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: jamiepine/voicebox
Length of output: 10703
🌐 Web query:
PyTorch mps empty_cache availability check torch.backends.mps.is_available docs💡 Result:
In PyTorch, torch.mps.empty_cache is a standard function available as part of the MPS (Metal Performance Shaders) backend [1][2]. It is used to release unoccupied cached memory held by the caching allocator, which can help reclaim memory for other GPU applications [3][2]. Regarding your query about checking availability: 1. MPS Availability Check: To check if MPS is available in your current environment, you should use torch.backends.mps.is_available [4][5]. This function returns a boolean indicating whether the MPS backend is supported and currently available [4][6]. 2. Function Location: Note that while torch.backends.mps.is_available is used for checking availability [4][7], the empty_cache function resides under the torch.mps namespace (i.e., torch.mps.empty_cache) [1][3]. It is not located under torch.backends.mps. Recent updates to PyTorch have also enhanced torch.mps.empty_cache to clear the MPSGraphCache in addition to the standard allocator pool, which is particularly useful for workloads involving variable tensor shapes [8]. Summary of common MPS-related checks: - Check if MPS is available: torch.backends.mps.is_available [4][7] - Check if PyTorch was built with MPS support: torch.backends.mps.is_built [7][6] - Clear MPS cache: torch.mps.empty_cache [1][2]
Citations:
🏁 Script executed:
Repository: jamiepine/voicebox
Length of output: 179
🏁 Script executed:
Repository: jamiepine/voicebox
Length of output: 156
🏁 Script executed:
Repository: jamiepine/voicebox
Length of output: 196
🌐 Web query:
Does torch.mps.empty_cache raise when torch.backends.mps.is_available is false💡 Result:
Yes, calling torch.mps.empty_cache when the MPS (Metal Performance Shaders) backend is not available raises a RuntimeError with the message "Cannot execute emptyCache without MPS backend" [1][2]. Because torch.mps.empty_cache interacts directly with the underlying MPS allocator [3][4], it is not safe to call on non-Apple Silicon devices or environments where the MPS backend is not initialized [1][2]. To avoid this error in cross-platform code, you should guard the call by checking the availability of the backend first [1][5][2]: import torch if torch.backends.mps.is_available: torch.mps.empty_cache
Citations:
Guard the MPS cache clear with a backend availability check.
hasattr(torch, "mps")only checks the namespace;torch.mps.empty_cache()can still raise when MPS isn’t available. Mirror the CUDA branch and gate this ontorch.backends.mps.is_available().🤖 Prompt for AI Agents