Skip to content

Find SwiftPM metallib bundle near test binary#3562

Open
RNT56 wants to merge 1 commit into
ml-explore:mainfrom
RNT56:pr/swiftpm-metallib-bundle-lookup
Open

Find SwiftPM metallib bundle near test binary#3562
RNT56 wants to merge 1 commit into
ml-explore:mainfrom
RNT56:pr/swiftpm-metallib-bundle-lookup

Conversation

@RNT56
Copy link
Copy Markdown

@RNT56 RNT56 commented May 19, 2026

Summary

Fixes SwiftPM package/test layouts where default.metallib is copied to the generated SWIFTPM_BUNDLE.bundle next to the test binary, but MLX only checks nested bundle locations.

This keeps the existing lookup order and adds:

  • direct lookup for SWIFTPM_BUNDLE.bundle next to the current binary, walking a few parent directories
  • direct lookup when NSBundle.allBundles() already contains the SwiftPM resource bundle

Validation

  • pre-commit run --all-files passed
  • validated through the mlx-swift SwiftPM packaging branch:
    • swift test --filter StreamTests/testDeviceType passes after applying this MLX loader patch and generating default.metallib
    • the same test failed before this patch with Failed to load the default metallib

@RNT56 RNT56 force-pushed the pr/swiftpm-metallib-bundle-lookup branch from 93232ea to 1a75e1a Compare May 19, 2026 00:15
@zcbenz
Copy link
Copy Markdown
Collaborator

zcbenz commented May 21, 2026

Ping @davidkoski for review.

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