Skip to content

Allow overriding the mlx.metallib search path for plugin-bundle embedding #415

Description

@olilarkin

Summary

There is currently no public way to tell MLX where to find mlx.metallib at runtime. When MLX is embedded inside a plugin bundle (e.g. an Audio Unit or VST3), the host application owns the main bundle, so MLX's default metallib search paths (colocated / SwiftPM resource bundle / main bundle) don't resolve and Metal initialization fails.

Proposal

Add an API to set an explicit mlx.metallib path before the Metal device initializes. If set, it is tried first and falls back to the existing search logic if loading fails — so default behavior is unchanged when unset.

This spans three layers:

  • mlx (C++)mlx::core::metal::set_metallib_path(const std::string&)
  • mlx-c (C)mlx_metal_set_metallib_path(const char*)
  • mlx-swift (Swift)GPU.setMetallibPath(_ path: String)

Use case

Running MLX-Swift inside AU/VST3 audio plugins, where the standard bundle-relative search paths point at the host app rather than the plugin.

PRs

Implemented as a dependency chain (C++ → C → Swift). The submodule bumps in the mlx-swift PR should be re-pointed to the merged upstream commits once the lower PRs land.

  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 mlx-c#117 — C API wrapper
  3. Add GPU.setMetallibPath() for plugin bundle support #416 — Swift GPU.setMetallibPath()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions