Skip to content

Fix threaded compile cache cleanup - #3628

Merged
zcbenz merged 2 commits into
ml-explore:mainfrom
lucasnewman:fix-threaded-compile-cache-cleanup
Jun 5, 2026
Merged

zcbenz merged 2 commits into
ml-explore:mainfrom
lucasnewman:fix-threaded-compile-cache-cleanup

Conversation

@lucasnewman

Copy link
Copy Markdown
Contributor

When mx.compile is used as a decorator but the compiled function is first invoked on another thread, the invocation thread’s compiler cache could keep Python output metadata until unsafe thread teardown. This change makes sure we register cache cleanup in the invoking thread too.

Resolves #3619

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix looks good to me, thanks!

Comment thread python/src/transforms.cpp Resolved
Comment thread python/src/transforms.cpp Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Segfault from compiled function that returns multiple outputs from custom Metal kernel calls

2 participants