Expose Cmlx product + enable jaccl distributed backend#2
Open
anupsv wants to merge 1 commit into
Open
Conversation
anupsv
added a commit
to Layr-Labs/d-inference
that referenced
this pull request
May 21, 2026
Picks up Layr-Labs/mlx-swift#2 which exposes the Cmlx library product and enables the jaccl distributed backend that provider-swift's ClusterSession / EncryptedPipelineInference depend on. Without this bump, CI's fresh `swift build -c debug` fails with: product 'Cmlx' required by package 'provider-swift' target 'ProviderCore' not found in package 'mlx-swift'. Tracking issue for the upstream deviation: #193. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
Downstream consumers (e.g. d-inference's provider-swift) need direct access to the underlying mlx-c symbols for distributed-group setup and custom collective ops. This commit: 1. Adds `Cmlx` to the package's library products so callers can declare `.product(name: "Cmlx", package: "mlx-swift")`. The target already exists; only the public product entry was missing. 2. Enables the jaccl distributed backend by un-excluding its source files (jaccl.cpp, mesh.cpp, ring.cpp, utils.cpp) and excluding the `no_jaccl.cpp` stub instead. jaccl is the Apple-Silicon-friendly collective backend used for cluster pipeline inference over Thunderbolt 5; the other distributed backends (mpi, ring, nccl) remain excluded since they're not supported on macOS. 3. Surfaces `mlx-c-distributed_group.h` and `mlx-c-distributed.h` in the umbrella `Cmlx.h` so the C distributed-group API is reachable from Swift via the Cmlx module. No behavior change for existing consumers — MLX, MLXNN, MLXRandom etc. continue to work exactly as before. Build size grows by the jaccl sources (~600 LOC of C++).
anupsv
added a commit
to Layr-Labs/d-inference
that referenced
this pull request
May 21, 2026
Picks up Layr-Labs/mlx-swift#2 which exposes the Cmlx library product and enables the jaccl distributed backend that provider-swift's ClusterSession / EncryptedPipelineInference depend on. Without this bump, CI's fresh `swift build -c debug` fails with: product 'Cmlx' required by package 'provider-swift' target 'ProviderCore' not found in package 'mlx-swift'. Tracking issue for the upstream deviation: #193.
edefe35 to
fa6a4e8
Compare
anupsv
added a commit
to Layr-Labs/d-inference
that referenced
this pull request
May 21, 2026
Force-pushes on Layr-Labs/mlx-swift#2 and Layr-Labs/mlx-swift-lm#24 landed new SHAs (fa6a4e8, c2fbbdc) — bump the submodule pointers to match.
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.
Summary
Enables the Swift package layer of MLX to compile the
mlx-c/mlx/c/distributed*.cppC wrappers and the jaccl backend, and exposes the existingCmlxtarget as a public library product. This lets downstream Swift consumers (e.g. d-inferenceprovider-swift) link against the C distributed-group API and use jaccl for Mac-to-Mac cluster pipeline inference over Thunderbolt 5.Upstream context (worth reading before merging)
This change deviates from upstream's stance — the original Package.swift comment reads
// do not build distributed support (yet). The "(yet)" tracks ml-explore/mlx-swift#371 ("Add distributed communication framework for multi-device tensor parallelism", open since 2026-03-15), which un-excludes the same files and adds polished Swift bindings (DistributedGroup,MLXDistributed.allSum/.send/.recv/ etc., plus sharded NN layers).We're enabling the backend on our fork ahead of ml-explore#371 merging because the d-inference cluster work already depends on it (commit
d1266de3in d-inference, the encrypted pipeline inference stack). If/when ml-explore#371 lands upstream, we'll rebase our fork onto the upstream API and drop any local Swift bindings that overlap.Known jaccl issues we accept
backend="any"picks ring instead of jacclWhat's in this PR
Package.swiftmlx-c/mlx/c/distributed.cppanddistributed_group.cpp(the C API wrappers that backmlx_c_distributed_group_*); un-exclude jaccl backend sources (jaccl.cpp,mesh.cpp,ring.cpp,utils.cpp) and exclude theno_jaccl.cppstub instead; add.library(name: "Cmlx", targets: ["Cmlx"])to theproducts:list. Other backends (mpi, ring, nccl) remain excluded.Source/Cmlx/include-framework/Cmlx.hmlx-c-distributed_group.handmlx-c-distributed.hin the Cmlx umbrella header so the distributed-group symbols are reachable when downstream code importsCmlx.Net: 2 files, +7 / -8 lines. No behavior change for existing
MLX,MLXNN,MLXRandom,MLXFast,MLXOptimizers,MLXFFT,MLXLinalgconsumers. Build size grows by the jaccl sources (~600 LOC of C++).Test plan
swift buildsucceeds on macOS 14+ (Apple Silicon)provider-swift)Cmlx+mlx_c_distributed_group_*calls succeed in d-inference'sClusterDiscovery/MLXDistributedmodules