Skip to content

Conversation

@Jckwind
Copy link
Contributor

@Jckwind Jckwind commented Nov 21, 2025

Proposed changes

  • Guard scheduler stream/thread vectors with a creation mutex to keep stream IDs unique under concurrency.
  • Protect Metal stream_map_ with shared/unique locking and stable pointers to prevent races/rehash invalidation; centralize command buffer creation.
  • Add a regression test for concurrent CPU stream creation.

Checklist

  • 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
Copy link
Collaborator

zcbenz commented Jan 18, 2026

MLX does not support multi-thread use cases, we don't oppose making changes for thread safety if it overall improves code quality but I don't think this can be categorized as such.

@zcbenz zcbenz closed this Jan 18, 2026
@Jckwind
Copy link
Contributor Author

Jckwind commented Jan 18, 2026

cool with me - I’ve made my fork of MLX thread and stream safe.

@Jckwind Jckwind deleted the threadsafe-stream-creation branch January 18, 2026 15:08
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.

2 participants