Repository navigation
Fix Metal command queue retention when a worker thread initializes MLX - #4936
Conversation
e72b8e4 to
31f0853
Compare
31f0853 to
2707e2d
Compare
zcbenz
left a comment
There was a problem hiding this comment.
Didn't know the API and it makes things much more reliable! Can you use it to implement the is_main_thread utility instead?
|
Done. Moved |
cdbde11 to
a646ddc
Compare
zcbenz
left a comment
There was a problem hiding this comment.
Thanks for the update, please consider opening PRs from personal accounts in future because we are unable to rebase or edit the PR from org account even when you enabled it.
|
@zcbenz unfortunately |
zcbenz
left a comment
There was a problem hiding this comment.
This is a lot better than what we did, thanks for the nice work!
ml-explore#4936) (cherry picked from commit 4b15eff)
When a worker is the first thread to use MLX,
is_main_thread()remembers that worker's thread ID. After the worker exits, macOS can reuse the ID.get_command_encoders()can then put later workers' Metal command encoders in the process-lifetime map instead of their thread-local maps. Their command queues stay alive after the workers exit.Updates
is_main_thread()to check for the process main thread on Apple platforms and Linux.