Skip to content

[BUG] c++ compile cache should be thread safe #2086

@davidkoski

Description

@davidkoski

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions