Repository navigation
MLX v0.32.3 with JACCL for the Pico stack - #8
ronaldmannak wants to merge 9 commits into
Conversation
Moves the mlx submodule from v0.32.2 to v0.32.3, which fixes the assertion in ReduceScatter::eval_cpu (ml-explore/mlx#4557) that aborted sumScatter in a group larger than one, and JACCL's ring all_gather (ml-explore/mlx#4443). mlx-c moves to 0.7.0 plus ml-explore/mlx-c#137, which passes the global_scale argument MLX v0.32.3 added to gather_qmm and keeps the C API unchanged. That commit is not on ml-explore/mlx-c yet, so the submodule points at PicoMLX/mlx-c (branch pico/0.32.3) until ml-explore#137 lands. - Regenerated mlx-generated and include-framework with tools/update-mlx.sh. - New MLX sources: mlx/memory.cpp and the Metal cross_entropy.cpp and gated_delta_update.cpp are built; Package.swift excludes the new Metal files without Metal and the new CUDA cusolver_utils.cpp and wddm.cpp without CUDA. The Xcode project's exception lists gain the new benchmarks, tests, CUDA files, Metal kernels and generated headers. - CMakeLists.txt fetches v0.32.3 and no longer applies cmake/mlx.patch: both CUDA fixes in it are upstream in v0.32.3 (ml-explore/mlx#4480, ml-explore/mlx#4514). - CODE_OF_CONDUCT.md left the mlx repository; its exclude entries go too. - FP8Tests: v0.32.3 decodes the E4M3FN NaN bytes 0x7F and 0xFF to NaN (ml-explore/mlx#4376), as the format defines; the test's reference decoder now does too, compares with equalNaN, and checks both NaNs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca6971b742
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| GIT_REPOSITORY "https://github.com/ml-explore/mlx.git" | ||
| GIT_TAG "v0.32.2" | ||
| PATCH_COMMAND ${mlx_patch}) | ||
| GIT_TAG "v0.32.3") |
There was a problem hiding this comment.
Pin CMake to the compatible mlx-c revision
When building through CMake, this pins MLX 0.32.3 while the mlx-c FetchContent block below still downloads the old official ebc88f1 revision. That wrapper predates MLX 0.32.3's required global_scale argument to gather_qmm, so its generated call no longer compiles; unlike SwiftPM, the CMake build bypasses the newly pinned PicoMLX submodule containing the compatibility fix. Update the CMake mlx-c repository and revision to the compatible fork commit as well.
Useful? React with 👍 / 👎.
| "mlx/mlx/backend/cuda/conv.cpp", | ||
| "mlx/mlx/backend/cuda/cublas_utils.cpp", | ||
| "mlx/mlx/backend/cuda/cudnn_utils.cpp", | ||
| "mlx/mlx/backend/cuda/cusolver_utils.cpp", |
There was a problem hiding this comment.
Link cuSOLVER in CUDA SwiftPM builds
With SPM_CUDA enabled, this new cusolver_utils.cpp is included in the Cmlx target and the new cholesky.cu is compiled by the CUDA plugin, but the CUDA linkerSettings still list cuDNN, cuBLAS, NVRTC, and the CUDA runtime without cusolver. The cuSOLVER calls therefore remain unresolved when a SwiftPM CUDA executable links; add the corresponding cuSOLVER library to the CUDA linker settings.
Useful? React with 👍 / 👎.
MLX v0.32.3 precompiles gather_mm_offsets and gated_delta_update even in JIT mode (mlx/backend/metal/kernels/CMakeLists.txt), and tools/fix-metal-includes.sh, which mirrors that list, did not have them. Without gather_mm_offsets in the metallib, any gather_mm with sorted right-hand indices, as MoE models run, stopped the process with "Unable to load kernel gather_mm_offsets". The list gains both, and mlx-generated/metal gains the two kernels. GatherMMTests runs that path against a plain matmul; without the kernel it crashes with that error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…— iteration 1 - CMakeLists.txt fetched upstream mlx-c ebc88f1, whose gather_qmm wrapper does not compile against MLX v0.32.3. It now fetches PicoMLX/mlx-c d7fbf0a, the submodule's commit (0.7.0 plus ml-explore/mlx-c#137). - CUDA SwiftPM builds now link cusolver, which MLX v0.32.3's cholesky.cu and cusolver_utils.cpp call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Two new commits on this branch, pushed as
Evidence (local; this fork's Actions jobs report
Not verified: a full CMake |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c2d2c78dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| GIT_REPOSITORY "https://github.com/ml-explore/mlx.git" | ||
| GIT_TAG "v0.32.2" | ||
| PATCH_COMMAND ${mlx_patch}) | ||
| GIT_TAG "v0.32.3") |
There was a problem hiding this comment.
Link cuSOLVER in the CMake CUDA path
When MLX_BUILD_CUDA=ON, updating the fetched MLX revision to v0.32.3 brings in cholesky.cu and cusolver_utils.cpp, but the CUDA dependency promotion in target_link_libraries(mlxc PUBLIC ...) still omits CUDA::cusolver. The SwiftPM path now links cusolver for these same sources, while CMake consumers that use CUDA Cholesky can encounter unresolved cuSOLVER symbols; add CUDA::cusolver to the CMake promotion list.
Useful? React with 👍 / 👎.
| "mlx/mlx/backend/cuda/scaled_dot_product_attention.cpp", | ||
| "mlx/mlx/backend/cuda/slicing.cpp", | ||
| "mlx/mlx/backend/cuda/utils.cpp", | ||
| "mlx/mlx/backend/cuda/wddm.cpp", |
There was a problem hiding this comment.
Exclude WDDM source from Linux CUDA builds
When SPM_CUDA enables the Linux CUDA configuration, that branch does not append noCudaCmlxExcludes, so adding wddm.cpp only to this list still leaves it in the CUDA-enabled build. This is the Windows/DXGI implementation—upstream v0.32.3 CMake adds it only under WIN32—and compiling it on Linux pulls in Windows-only APIs and breaks the SwiftPM CUDA build. Exclude it alongside delayload.cpp in the Linux CUDA branch.
Useful? React with 👍 / 👎.
|
|
||
| import Foundation | ||
| import MLX | ||
| import MLXRandom |
There was a problem hiding this comment.
Add MLXRandom to the Xcode test target
When MLXTests is built from the checked-in xcode/MLX.xcodeproj, this new import cannot be resolved because that project defines and links only the MLX, MLXNN, and MLXOptimizers targets; it has no MLXRandom target or framework reference. The synchronized test group automatically includes this file, so the project test target now fails with no such module 'MLXRandom', even though the SwiftPM test scheme works through its package dependency graph. Either avoid MLXRandom in this test or add the corresponding Xcode target and dependency.
Useful? React with 👍 / 👎.
In MLX v0.32.3, integer floor_divide (ml-explore/mlx#4515) built its logical_and on the calling thread's own default stream. When the result was evaluated on any other thread, the process stopped with "There is no Stream(gpu, N) in current thread". mlx-swift-lm's MoE gather sort calls floorDivide on integer indices and evaluates on its generation thread, so every MoE generation in PicoCore crashed. The mlx submodule now points at PicoMLX/mlx pico/0.32.3: v0.32.3 plus the one-line fix that passes the stream through. CMake fetches the same commit. v0.32.4 replaces this code with a FloorDivide primitive (ml-explore/mlx#4642). StreamTests.testIntegerFloorDivideEvaluatesOnAnotherThread builds an integer floorDivide on one thread and reads it on another. Without the fix it stops the process with that error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndom import — iteration 2 - CMake's CUDA build promotes CUDA::cusolver to a public dependency of mlxc, as it does for MLX's other private CUDA libraries. MLX v0.32.3 links it privately for cholesky.cu and cusolver_utils.cpp. - SwiftPM's Linux CUDA build excludes cuda/wddm.cpp. Upstream builds it only on Windows, and it calls Windows-only APIs. - GatherMMTests no longer imports MLXRandom. The module is deprecated (MLXRandom lives in MLX), and the Xcode project's MLXTests target doesn't link it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Two more commits, now at
Evidence (local, at
Not verified: both CUDA changes. There's no CUDA host here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1288278be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| GIT_TAG "v0.32.2" | ||
| PATCH_COMMAND ${mlx_patch}) | ||
| GIT_REPOSITORY "https://github.com/PicoMLX/mlx.git" | ||
| GIT_TAG "712dbd34939e902f7dbb844bf3ddaf3cf4c77f20") |
There was a problem hiding this comment.
Remove the deleted patch check from CUDA CI
In the linux_build_cmake_cuda job from .github/workflows/pull_request.yml, .github/scripts/build-linux-cuda-cmake.sh still runs git -C _deps/mlx-src apply --reverse --check "$PWD/../cmake/mlx.patch" and exits on failure. This change deletes that patch while replacing it with the pinned MLX revision; git apply -h documents --check as checking patch applicability, and invoking it with this deleted path returns can't open patch ... No such file or directory. Consequently every Linux CUDA CMake CI run now exits immediately after configuration, so the obsolete verification must be removed or updated.
Useful? React with 👍 / 👎.
…tion 3 build-linux-cuda-cmake.sh still checked that cmake/mlx.patch was applied to the fetched MLX. That patch is gone, since both of its fixes ship in v0.32.3 (ml-explore/mlx#4480, #4514), so the check failed every Linux CUDA CMake run right after configure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Remove the deleted patch check from CUDA CI (4292104554): fixed in The other open threads, for whoever resolves them (this repo's hooks don't let me reply in threads):
🤖 Addressed by Claude Code |
The same class of bug as integer floor_divide: an MLX op built on the calling thread's own default stream instead of the stream it was given. Evaluating the result on any other thread stops the process with "There is no Stream(gpu, N) in current thread". PicoMLX/mlx pico/0.32.3 cherry-picks both upstream fixes from v0.32.4: - ml-explore/mlx#4687: gather_mm and gather_qmm cast non-uint32 indices to uint32 without the stream. MoE layers that route with int32 indices hit it. - ml-explore/mlx#4663: layer_norm's CPU fallback multiplied without the stream, and SDPA's boolean-mask fallback (CUDA only, since Metal takes boolean masks directly) built its where without it. StreamTests gains testGatherMMWithInt32IndicesEvaluatesOnAnotherThread and testLayerNormOnTheCPUEvaluatesOnAnotherThread. Without #4687, the gather test stops the process with that error. Without #4663, the CPU layer_norm evaluation never returns: the test fails after 30 seconds, and then the process stops with the same error. The floor_divide test now shares their helper, which waits at most 30 seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MLX's version() returns the MLX_VERSION define. MLX's CMake reads it
from mlx/version.h, but mlx-swift passes it itself, in Package.swift and
Cmlx.xcconfig, and it was still "0.32.0". So this branch reported 0.32.0
while it built v0.32.3.
Both now say 0.32.3. tools/update-mlx.sh copies the version from
mlx/version.h on every update, so it can't go stale again.
VersionTests reads mlx/version.h and expects mlx_version() to match it.
Before this change it fails: ("0.32.0") is not equal to ("0.32.3").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Evidence (local, at
|
The mlx-swift that the Pico stack builds against: upstream mlx-swift 0.32.3 with MLX core moved to v0.32.3, plus the JACCL backend. The base branch
pico/0.32.3is upstream's 0.32.3 tag, so this PR shows only our commits.What changed
Update MLX to v0.32.3 (2202554)
mlxsubmodule v0.32.2 → v0.32.3. This fixes theReduceScatter::eval_cpuassertion (ml-explore/mlx#4557), which abortedsumScatterin any group larger than one. It also fixes JACCL's ringall_gather(ml-explore/mlx#4443). Upstream mlx-swift 0.32.3 still carries MLX v0.32.2.mlx-c→ 0.7.0 plusml-explore/mlx-c#137. MLX v0.32.3 added aglobal_scaleargument togather_qmm, which broke mlx-c's generated wrapper. move to v0.18.0 of mlx ml-explore/mlx-swift#137 passesstd::nullopt, so the C API stays the same. move to v0.18.0 of mlx ml-explore/mlx-swift#137 isn't merged yet, so.gitmodulespoints mlx-c at PicoMLX/mlx-c (pico/0.32.3) for now.mlx-generatedandinclude-frameworkwithtools/update-mlx.sh.mlx/memory.cppand the Metalcross_entropy.cpp/gated_delta_update.cpp.Package.swiftexcludes the new Metal files in builds without Metal, and the new CUDAcusolver_utils.cpp/wddm.cppin builds without CUDA. The Xcode project's exception lists gain the new benchmarks, tests, CUDA files, Metal kernels and generated headers.CMakeLists.txtfetches v0.32.3 and no longer appliescmake/mlx.patch. Both of the patch's CUDA fixes are in v0.32.3 (ml-explore/mlx#4480, #4514).Enable JACCL (ca6971b):
ml-explore/mlx-swift#502, cherry-picked unchanged.Build MLX v0.32.3's two new precompiled Metal kernels (c4bad90)
gather_mm_offsetsandgated_delta_update.tools/fix-metal-includes.shcopies MLX's list of always-built kernels, and that copy didn't have these two. Withoutgather_mm_offsets, anygatherMMwith sorted right-hand indices (the MoE path) stopped the process withUnable to load kernel gather_mm_offsets.mlx-generated/metal.Review fixes (4c2d2c7)
d7fbf0a, the same commit as the submodule, instead of upstreamebc88f1, which doesn't compile against v0.32.3.cusolver, whichcholesky.cuandcusolver_utils.cppcall.Build MLX with the stream fix for integer floor_divide (18032ac)
floor_divide(ml-explore/mlx#4515) builds itslogical_andwithout the caller's stream. The op lands on the calling thread's own default stream, a thread-local one. Evaluating the result on any other thread stopped the process withThere is no Stream(gpu, N) in current thread. mlx-swift-lm's MoE gather sort callsfloorDivideon integer indices and evaluates on its generation thread, so every MoE generation in PicoCore crashed. lldb traced the stream back tofloor_divide→logical_and.mlxsubmodule now points at PicoMLX/mlxpico/0.32.3(712dbd3): v0.32.3 plus that one-line fix..gitmodulespoints mlx at PicoMLX/mlx, and CMake fetches the same commit.FloorDivideprimitive (ml-explore/mlx#4642), so the fork commit doesn't carry forward.Review fixes (d128827)
CUDA::cusolverto a public dependency ofmlxc.cuda/wddm.cpp.GatherMMTestsdrops the deprecatedimport MLXRandom, which the Xcode project's test target can't resolve.Review fix (2160192): the Linux CUDA CMake CI script no longer checks for the deleted
cmake/mlx.patch.Build MLX with v0.32.4's two other missing-stream fixes (544eef9)
pico/0.32.3(f21a959) adds two cherry-picks from v0.32.4. Both fix the same class of bug asfloor_divide.ml-explore/mlx#4687coversgather_mm/gather_qmm, which cast int32 indices without the stream; MoE routing can hit it.ml-explore/mlx#4663coverslayer_norm's CPU fallback, plus SDPA's boolean-mask fallback (CUDA only).Report MLX's own version, and keep it in sync on updates (a67e1aa)
mlx_version()reported "0.32.0", because mlx-swift hard-codes theMLX_VERSIONdefine, which MLX's CMake reads frommlx/version.h.Package.swiftandCmlx.xcconfignow say0.32.3.tools/update-mlx.shcopies the version frommlx/version.hon every update.Test changes
FP8Tests.testFromFP8DecodesE4M3Bytes: MLX v0.32.3 decodes the E4M3FN NaN bytes0x7Fand0xFFto NaN, as the format defines (ml-explore/mlx#4376). v0.32.2 decoded them as ±480. The test's reference decoder now returns NaN for those bytes, the comparison usesequalNaN: true, and the test checks both NaNs explicitly. The old test passes on v0.32.2 and fails on v0.32.3 without this change.GatherMMTests.testGatherMMWithSortedRightIndicesMatchesMatmul: runs the grouped gather path and compares the result with a plainmatmul. Without the kernel it crashes withUnable to load kernel gather_mm_offsets. The tolerance is 1e-2 because either side may run at TF32 precision on chips with neural accelerators. A wrong gather would be off by far more than that.StreamTests: each test builds an op on one thread and evaluates it on another, waiting at most 30 seconds.testIntegerFloorDivideEvaluatesOnAnotherThread: without the fix, the process stops withThere is no Stream(gpu, 1) in current thread.testGatherMMWithInt32IndicesEvaluatesOnAnotherThread: without #4687, the process stops with the same error.testLayerNormOnTheCPUEvaluatesOnAnotherThread: without #4663, the test fails with "the evaluation never returned", and then the process stops with that error.VersionTests.testMLXVersionMatchesTheMLXSources: expectsmlx_version()to matchmlx/version.h. Before a67e1aa it fails with("0.32.0") is not equal to ("0.32.3"). At a67e1aa: 389 SwiftPM tests and 390 Xcode-project tests pass, and the iOS build succeeds.Evidence
On this Mac (macOS 27.0.1, Xcode 27.0), at 544eef9. At d128827,
xcodebuild test -project xcode/MLX.xcodeproj -scheme MLXalso compiledMLXTests(that scheme executes 0 tests here):xcodebuild test -scheme mlx-swift-Package -destination 'platform=macOS' -only-testing:MLXTests -skipPackagePluginValidation -skipMacroValidation→Executed 388 tests, with 2 tests skipped and 0 failures,** TEST SUCCEEDED **. That count includes the 11DistributedTests,GatherMMTestsand the three newStreamTestscases.isAvailable(.jaccl) = trueandisAvailable(.ring) = true.xcodebuild build -scheme mlx-swift-Package -destination 'generic/platform=iOS'→** BUILD SUCCEEDED **.xcodebuild build -project xcode/MLX.xcodeproj -scheme MLX -destination 'platform=macOS'→** BUILD SUCCEEDED **.mlx v0.32.3andmlx-c d7fbf0a, and all 26 mlx-c sources compiled with CMake's own generated commands. I didn't re-run CMake after the mlx fetch moved to PicoMLX/mlxf21a959. That commit is the head of the fork'spico/0.32.3branch.swift-format lint --stricton the changed Swift files: clean.skipping, so the local runs above are the only evidence.Not done on purpose
gated_delta_update_nax.metalunder the macOS 27 Metal SDK (no matching member function for call to 'get_destination_cooperative_tensor'). That kernel only builds in MLX's non-JIT NAX branch, and SwiftPM/Xcode builds never compile it.Tests/MLXIntegrationTests/Generatedstill name 0.32.2. Regenerating them needs Python mlx.gated_delta_update,matrix_transpose, …) aren't wrapped, because mlx-c doesn't expose them yet.🤖 Generated with Claude Code