Repository navigation
Add a JACCL package trait to opt out of the JACCL backend - #517
Merged
Merged
Conversation
Contributor
Author
|
@davidkoski please have look and see if it makes sense. I think not every app needs that extra megabyte... |
Member
|
Yeah, seems reasonable. |
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.
aleroot
force-pushed
the
alessio/jaccl-trait
branch
from
October 28, 2026 16:29
9366aff to
f593381
Compare
davidkoski
approved these changes
Oct 28, 2026
davidkoski
left a comment
Member
There was a problem hiding this comment.
Changes look good, thank you.
solderzzc
pushed a commit
to SharpAI/mlx-swift
that referenced
this pull request
Oct 29, 2026
Upstream's JACCL package trait (ml-explore#517) needs tools-version 6.1 or later; the fork manifest was 5.12, so the manifest no longer parsed after the sync. Keep Swift 5 language mode (what 5.12 implied) via swiftLanguageModes. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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]>
goodmai
pushed a commit
to goodmai/mlx-swift
that referenced
this pull request
Nov 29, 2026
- Rebased onto main (5f117a2, keeping ml-explore#517 JACCL trait, ml-explore#518 empty vector array fix, ml-explore#519 Swift Testing) - Bump Source/Cmlx/mlx submodule from 36969c09 (v0.32.4) to cfc675e9 (v0.32.5) - Regenerate Source/Cmlx/mlx-generated and Source/Cmlx/include-framework via ./tools/update-mlx.sh - Update tools/update-mlx-xcodeproj.sh for backend/common/custom_kernel.h + config.h (0 missing <Cmlx/...> headers) - Override mlx-c/mlx/c/fast.cpp with Source/Cmlx/mlx-c-overrides/fast_v0325.cpp (1-line window_size = -1 fix from ml-explore/mlx-c#145) across macOS and Linux CUDA, excluding mlx-c-overrides on Linux CPU with no duplicate exclude - Update MLX_VERSION to 0.32.5 in Package.swift and xcode/xcconfig/Cmlx.xcconfig
goodmai
pushed a commit
to goodmai/mlx-swift
that referenced
this pull request
Nov 29, 2026
- Rebased onto main (5f117a2, keeping ml-explore#517 JACCL trait, ml-explore#518 empty vector array fix, ml-explore#519 Swift Testing) - Bump Source/Cmlx/mlx submodule from 36969c09 (v0.32.4) to cfc675e9 (v0.32.5) - Regenerate Source/Cmlx/mlx-generated and Source/Cmlx/include-framework via ./tools/update-mlx.sh - Update tools/update-mlx-xcodeproj.sh for backend/common/custom_kernel.h + config.h (0 missing <Cmlx/...> headers) - Override mlx-c/mlx/c/fast.cpp with Source/Cmlx/mlx-c-overrides/fast_v0325.cpp (1-line window_size = -1 fix from ml-explore/mlx-c#145) across macOS and Linux CUDA, excluding mlx-c-overrides on Linux CPU with no duplicate exclude - Update MLX_VERSION to 0.32.5 in Package.swift and xcode/xcconfig/Cmlx.xcconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Follow up on #502, a new
JACCLpackage trait, enabled by default:An app that does not run distributed MLX can now leave the JACCL backend (RDMA over Thunderbolt 5) out of its binary.
Why
Since #502 every macOS build whose SDK ships
<infiniband/verbs.h>compiles JACCL into Cmlx, and the linker cannot dead strip it:distributed::init("any")falls back tojaccl::init, andMLXDistributed.Groupand the sharded MLXNN layers keep that path reachable. So every macOS app pays for the backend, although JACCL forms a group only on a Thunderbolt 5 cluster configured through theJACCL_*environment variables.Most apps that embed MLX never do that: a chat app, an on-device assistant, an iPhone app that also ships a Mac version. For them JACCL is about 1 MB of code they can never run, and today they have no way to opt out. Apps distributed through the App Store, where download size matters, feel this most.
The trait also makes the choice explicit. Today the only gate is
__has_include(<infiniband/verbs.h>), so whether an app gets JACCL depends on which SDK it is built with, not on what the app needs. iOS, tvOS and visionOS build the stub now only because their SDKs do not ship the header. With the trait, an app states what it wants once.mlx-swift-lm
SwiftPM enables the union of the traits that dependents request. mlx-swift-lm depends on mlx-swift with the default traits, so for its consumers JACCL stays enabled even if the app itself passes
traits: []. If this set of changes is accepted, a follow up in mlx-swift-lm can forward the choice with a trait of its own, in the same way asFoundationModelsIntegration, so that an app built on mlx-swift-lm can control this too. Most apps reach MLX through mlx-swift-lm, so that is where the saving lands in practice.Measured sizes
Minimal executable linking
MLXandMLXNN, release,-dead_strip, stripped, Xcode 27.1:JACCLtrait__textChecklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes