Set wired_limit to fix low GPU utilization#65
Merged
ericcurtin merged 1 commit intoJan 8, 2026
Merged
Conversation
otarkhan
force-pushed
the
fix/set-wired-limit-for-gpu-performance
branch
from
January 8, 2026 12:01
0fe0374 to
cc72de2
Compare
Collaborator
|
Thanks for the PR. Looks good. Could we avoid duplicating the code and extract to a shared function? |
Without wired_limit, model weights cannot stay pinned in GPU-accessible memory, causing frequent memory paging and GPU stalls. This results in ~30% GPU utilization instead of ~100%. The fix sets max_recommended_working_set_size as the wired limit before model loading, matching the fix in ml-explore/mlx-lm#652. Changes: - Set wired_limit in MetalWorker.init_device() for v1 engine - Set wired_limit in MetalModelRunner.load_model() for legacy path - Use new mx.set_wired_limit() API with fallback to deprecated API - Add error handling for graceful degradation Signed-off-by: otarkhan <osama.taha1994@gmail.com>
otarkhan
force-pushed
the
fix/set-wired-limit-for-gpu-performance
branch
from
January 8, 2026 13:57
cc72de2 to
7a27935
Compare
Contributor
Author
Done. Didn't want to create a new utils file so I added it to platform |
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.
Summary
Without
wired_limitset, model weights cannot stay pinned in GPU-accessible memory, causing frequent memory paging and GPU stalls. This results in ~30% GPU utilization instead of ~100%.This fix sets
max_recommended_working_set_sizeas the wired limit before model loading, matching the fix in ml-explore/mlx-lm#652.Changes
wired_limitinMetalWorker.init_device()for v1 enginewired_limitinMetalModelRunner.load_model()for legacy pathmx.set_wired_limit()API with fallback to deprecatedmx.metal.set_wired_limit()Test plan