Describe the bug
The c++ compile cache should be thread safe -- whatever mutable state is behind mlx::core::detail::compile should be thread safe so it can safely be called from multiple threads (common in Swift, maybe C++).
See also:
To Reproduce
See:
Note that the fix for this was to protect the inner function that mutates the arguments (as that is where the crash was observed), during discussion with @awni we think that the cache of graphs also needs locking (or whatever technique is appropriate) as it is also mutable state.
Expected behavior
Inner state of mlx::core should be thread safe or documented as not (like MLXArray).
Desktop (please complete the following information):
- OS Version: macOS15
- Version 0.23.1
Describe the bug
The c++ compile cache should be thread safe -- whatever mutable state is behind
mlx::core::detail::compileshould be thread safe so it can safely be called from multiple threads (common in Swift, maybe C++).See also:
To Reproduce
See:
Note that the fix for this was to protect the inner function that mutates the arguments (as that is where the crash was observed), during discussion with @awni we think that the cache of graphs also needs locking (or whatever technique is appropriate) as it is also mutable state.
Expected behavior
Inner state of mlx::core should be thread safe or documented as not (like MLXArray).
Desktop (please complete the following information):