Skip to content

Fix typo in SwiftPM Linux exclude path for metal/cross_entropy.cpp - #523

Merged
davidkoski merged 1 commit into
ml-explore:mainfrom
octu0:fix-linux-cross-entropy-exclude
Nov 9, 2026
Merged

davidkoski merged 1 commit into
ml-explore:mainfrom
octu0:fix-linux-cross-entropy-exclude

Conversation

@octu0

@octu0 octu0 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Fix a typo in the noMetalCmlxExcludes list in Package.swift.

The entry for the Metal cross-entropy kernel was spelled mxl/mlx/backend/metal/cross_entropy.cpp instead of mlx/mlx/backend/metal/cross_entropy.cpp. Because the path didn't match, the file was not excluded on Linux, and the SwiftPM build of Cmlx failed:

Source/Cmlx/mlx/mlx/backend/metal/device.h:5:10: fatal error: 'Metal/Metal.hpp' file not found
    5 | #include <Metal/Metal.hpp>
      |          ^~~~~~~~~~~~~~~~~
[98/259] Compiling cross_entropy.cpp

noMetalCmlxExcludes is used by both the Linux CUDA and the Linux CPU-only (SPM_CUDA=0) configurations, so both are affected. The typo was introduced in #508 and first shipped in 0.33.0. Linux CI builds with CMake, which is probably why it went unnoticed.

Testing

I built the package with SwiftPM in a Linux container (swift:6.3-noble, arm64, CPU-only), with and without this change:

docker run --rm -it -v "$PWD":/src swift:6.3-noble bash
apt-get update && apt-get install -y libblas-dev liblapacke-dev libopenblas-dev gfortran
cd /src
SPM_CUDA=0 swift build --scratch-path /tmp/build --target MLX
Result
main (5f117a2) Cmlx fails while compiling backend/metal/cross_entropy.cpp ('Metal/Metal.hpp' file not found)
this PR the Metal cross_entropy.cpp is excluded, and the build of target MLX completes

Note: I did not verify the CUDA configuration, because I don't have a CUDA toolkit in this environment. It uses the same exclude list, so the fix applies there too.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

  The noMetalCmlxExcludes entry was spelled "mxl/mlx/backend/metal/cross_entropy.cpp",
  so the file was not excluded on Linux and the SwiftPM build failed with:

    mlx/backend/metal/device.h:5:10: fatal error: 'Metal/Metal.hpp' file not found

  The typo was introduced in ml-explore#508 and first shipped in 0.33.0

@davidkoski davidkoski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Just waiting on CI.

I think we have a gap in the CI actually -- we have linux cmake builds but no swiftpm builds.

@davidkoski
davidkoski merged commit a557dd6 into ml-explore:main Nov 9, 2026
7 checks passed
ronaldmannak added a commit to ronaldmannak/mlx-swift that referenced this pull request Nov 15, 2026
Brings in main through a557dd6 (upstream ml-explore#510, ml-explore#512, ml-explore#513, ml-explore#514, ml-explore#517,
ml-explore#518, ml-explore#519, ml-explore#523).

Conflicts:
- CMakeLists.txt: keep the PicoMLX/mlx-c pico/integration pin.
- Cmlx.xcconfig: keep MLX_VERSION 0.32.5 and add main's MLX_USE_JACCL=1.
- ModuleTests.swift, DistributedNNTests.swift: take main's Swift Testing
  versions. The integration side held this fork's copies of ml-explore#510 and ml-explore#512,
  whose code matches main's; main has since converted those files.

The Cmlx/mlx and Cmlx/mlx-c submodules stay on pico/integration, which
already contain the v0.32.4 and v0.8.0 commits main points at.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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