ml-explore / ml-explore/mlx

Metal shader pipeline states not released when compiled functions are erased

Open
#3,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
28.5k
Forks
2.3k
Avg merge
3d 8h
Merged PRs (30d)
62

Description

When a compiled function is removed from CompilerCache (via compile_erase or compile_clear_cache), the associated Metal shader libraries and pipeline states in Device::library_kernels_ are not released. They persist until process exit.

Device::clear_library() exists but is never called from the compile cache cleanup path.

Found while investigating Metal resource accumulation in a long-running process that creates and discards compiled functions over time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at CompilerCache cleanup through compile_erase and compile_clear_cache, then trace how Device::library_kernels_ and Device::clear_library() are used. Confirm the cleanup path releases the associated Metal shader libraries and pipeline states when compiled functions are removed, rather than retaining them until process exit.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.