Skip to content

Add mlx_metal_set_metallib_path() C API#117

Draft
olilarkin wants to merge 1 commit into
ml-explore:mainfrom
olilarkin:metallib-path
Draft

Add mlx_metal_set_metallib_path() C API#117
olilarkin wants to merge 1 commit into
ml-explore:mainfrom
olilarkin:metallib-path

Conversation

@olilarkin

@olilarkin olilarkin commented May 28, 2026

Copy link
Copy Markdown

What

Exposes the new mlx::core::metal::set_metallib_path() through the C interface as mlx_metal_set_metallib_path(const char* path), following the existing error-handling convention of the other mlx_metal_* wrappers.

Why

Required so Swift / other C consumers can set a custom mlx.metallib path. See the use case in the tracking issue.

Depends on

Companion PRs

Part of a three-PR chain (C++ → C → Swift):

  1. Add metal::set_metallib_path() to override the metallib search path mlx#3597 — C++ set_metallib_path
  2. Add mlx_metal_set_metallib_path() C API #117 — this PR (C API wrapper)
  3. Add GPU.setMetallibPath() for plugin bundle support mlx-swift#416 — Swift GPU.setMetallibPath()

Tracking issue: ml-explore/mlx-swift#415.

Exposes the new set_metallib_path() function through the C interface.
@RNT56

RNT56 commented Jun 25, 2026

Copy link
Copy Markdown

I looked at this while working on the SwiftPM metallib resource PR in mlx-swift.

This is the API I need there. I made a small branch on my fork that rebases this on current mlx-c main and points the MLX dependency at the merged mlx#3597 commit:

RNT56/mlx-c:upstream-pr/metallib-path-c-api

It builds for me with:

  • cmake -S . -B build/metallib-path-api -DMLX_C_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release
  • cmake --build build/metallib-path-api -j2

No need to use my branch directly if you prefer updating this PR here. I just wanted to share it in case it helps move the chain forward.

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