Skip to content

Enable JACCL - #502

Merged
davidkoski merged 1 commit into
ml-explore:mainfrom
ronaldmannak:enable-JACCL
Oct 16, 2026
Merged

davidkoski merged 1 commit into
ml-explore:mainfrom
ronaldmannak:enable-JACCL

Conversation

@ronaldmannak

Copy link
Copy Markdown
Contributor

Proposed changes

Builds MLX's JACCL backend (RDMA over Thunderbolt 5) on macOS. Until now
mlx-swift always built the no_jaccl.cpp stub, so MLXDistributed.Backend.jaccl
could never form a group.

What changed

  • New Source/Cmlx/mlx-conditional/jaccl_conditional.cpp compiles the JACCL
    backend and its library when the SDK has <infiniband/verbs.h> (macOS 26.2
    SDK and later), and the no_jaccl.cpp stub otherwise. iOS, visionOS, tvOS,
    Mac Catalyst and older SDKs keep the stub. Linux doesn't build
    mlx-conditional and is unchanged.
  • Package.swift and the Xcode project stop compiling no_jaccl.cpp directly
    (the wrapper includes it) and add jaccl/lib to the header search paths.
  • testUnavailableBackendsReportFalse no longer checks JACCL on macOS, where
    availability now depends on the SDK and the macOS version.

The deployment target is unchanged. Unlike MLX's CMake, this doesn't require a
26.2 deployment target: JACCL loads librdma.dylib at runtime, so on macOS
before 26.2 isAvailable(.jaccl) returns false.

Notes

  • Sandboxed apps need entitlement com.apple.security.temporary-exception.iokit-user-client-class set to IORDMAFamilyUC

Next steps

Checklist

  • 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)

@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.

Change looks good, thank you!

@davidkoski
davidkoski merged commit 31c03d9 into ml-explore:main Oct 16, 2026
7 checks passed
eejd pushed a commit to eejd/mlx-swift that referenced this pull request Oct 18, 2026
Brings in ml-explore#501 (leak when _updateInternal replaces an array with siblings),
ml-explore#502 (enable JACCL) and ml-explore#486 (asArray crash on zero-size arrays). No conflicts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
aleroot added a commit to aleroot/mlx-swift that referenced this pull request Oct 28, 2026
Since ml-explore#502 every macOS build whose SDK ships <infiniband/verbs.h> links
the JACCL distributed backend (RDMA over Thunderbolt 5), and dead
stripping cannot remove it: `distributed::init("any")` reaches
`jaccl::init`, and `MLXDistributed.Group` and the sharded MLXNN layers
keep that path alive. An app that never forms a Thunderbolt cluster has
no way to opt out. On a minimal MLX + MLXNN executable (release,
stripped) the backend costs 1,065,280 bytes, 841 KB of them `__text`.

Add a `JACCL` package trait, enabled by default, so an app can leave it
out with `traits: []`:

- `Package.swift` declares the trait and defines `MLX_USE_JACCL` for
  Cmlx when it is enabled. SwiftPM passes traits to Swift targets only,
  so C++ needs the explicit define.
- `jaccl_conditional.cpp` requires `MLX_USE_JACCL` and compiles the
  `no_jaccl.cpp` stub otherwise.
- `Cmlx.xcconfig` always defines `MLX_USE_JACCL`, so the Xcode project
  and its xcframeworks build as before.
- `testUnavailableBackendsReportFalse` also asserts that `.jaccl` is
  unavailable on macOS when the trait is disabled.
- `install.md` documents the trait and that SwiftPM enables the union of
  the traits that dependents request.

The define follows the `MLX_USE_ACCELERATE` naming.

Default on keeps the behaviour of ml-explore#502. The define states only the
choice; platform and SDK gating stay in `jaccl_conditional.cpp`, so iOS,
tvOS and visionOS keep building the stub whatever the trait. The CMake
build keeps mlx's own JACCL gating.
aleroot added a commit to aleroot/mlx-swift that referenced this pull request Oct 28, 2026
Since ml-explore#502 every macOS build whose SDK ships <infiniband/verbs.h> links
the JACCL distributed backend (RDMA over Thunderbolt 5), and dead
stripping cannot remove it: `distributed::init("any")` reaches
`jaccl::init`, and `MLXDistributed.Group` and the sharded MLXNN layers
keep that path alive. An app that never forms a Thunderbolt cluster has
no way to opt out. On a minimal MLX + MLXNN executable (release,
stripped) the backend costs 1,065,280 bytes, 841 KB of them `__text`.

Add a `JACCL` package trait, enabled by default, so an app can leave it
out with `traits: []`:

- `Package.swift` declares the trait and defines `MLX_USE_JACCL` for
  Cmlx when it is enabled. SwiftPM passes traits to Swift targets only,
  so C++ needs the explicit define.
- `jaccl_conditional.cpp` requires `MLX_USE_JACCL` and compiles the
  `no_jaccl.cpp` stub otherwise.
- `Cmlx.xcconfig` always defines `MLX_USE_JACCL`, so the Xcode project
  and its xcframeworks build as before.
- `install.md` documents the trait and that SwiftPM enables the union of
  the traits that dependents request.

The define follows the `MLX_USE_ACCELERATE` naming.

Default on keeps the behaviour of ml-explore#502. The define states only the
choice; platform and SDK gating stay in `jaccl_conditional.cpp`, so iOS,
tvOS and visionOS keep building the stub whatever the trait. The CMake
build keeps mlx's own JACCL gating.
davidkoski pushed a commit that referenced this pull request Oct 28, 2026
Since #502 every macOS build whose SDK ships <infiniband/verbs.h> links
the JACCL distributed backend (RDMA over Thunderbolt 5), and dead
stripping cannot remove it: `distributed::init("any")` reaches
`jaccl::init`, and `MLXDistributed.Group` and the sharded MLXNN layers
keep that path alive. An app that never forms a Thunderbolt cluster has
no way to opt out. On a minimal MLX + MLXNN executable (release,
stripped) the backend costs 1,065,280 bytes, 841 KB of them `__text`.

Add a `JACCL` package trait, enabled by default, so an app can leave it
out with `traits: []`:

- `Package.swift` declares the trait and defines `MLX_USE_JACCL` for
  Cmlx when it is enabled. SwiftPM passes traits to Swift targets only,
  so C++ needs the explicit define.
- `jaccl_conditional.cpp` requires `MLX_USE_JACCL` and compiles the
  `no_jaccl.cpp` stub otherwise.
- `Cmlx.xcconfig` always defines `MLX_USE_JACCL`, so the Xcode project
  and its xcframeworks build as before.
- `install.md` documents the trait and that SwiftPM enables the union of
  the traits that dependents request.

The define follows the `MLX_USE_ACCELERATE` naming.

Default on keeps the behaviour of #502. The define states only the
choice; platform and SDK gating stay in `jaccl_conditional.cpp`, so iOS,
tvOS and visionOS keep building the stub whatever the trait. The CMake
build keeps mlx's own JACCL gating.
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