Repository navigation
Use custom fork that resolves GPU locks - #1489
Conversation
The mlx 0.30.6 upgrade introduced mlx-cuda-13 as a new dependency on Linux. This caused two nix flake check failures: 1. autoPatchelf RPATH errors: mlx-cuda-13's libmlx.so links against CUDA libraries (libnccl, libcublasLt, libnvrtc, libcudnn) that live deep inside nvidia wheel packages at non-standard paths (lib/python3.13/site-packages/nvidia/cu13/lib/). The standard buildInputs mechanism only searches <pkg>/lib/, so autoPatchelf couldn't find them. Fix: use addAutoPatchelfSearchPath in preFixup to recursively discover the .so files, and ignore libcuda.so.1 which is a driver stub only present on hosts with NVIDIA GPUs. 2. mkVirtualEnv file collisions: mlx-cpu and mlx-cuda-13 both ship overlapping files under mlx/ site-packages (e.g. libmlx.so), and nvidia-cudnn-cu12/cu13 collide under nvidia/ site-packages. Fix: use venvIgnoreCollisions with fnmatch patterns to keep the first path encountered, which is sufficient for type-checking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey @rltakashige — the fence.cpp fix in your address-rdma-gpu-locks branch is excellent. We've been hitting exactly this Fence::wait deadlock on our 4× Mac Studio M3 Ultra cluster for weeks and independently traced it down to the same root cause (RDMA DMA writes not visible to GPU spin-wait due to DMB ISH only covering the inner shareable domain). Have you considered submitting the DSB SY fix as a PR to upstream ml-explore/mlx? It's a very targeted 1-line change in fence.cpp with a clear rationale — should be an easy review for the MLX team. The change in the exo PR bundles it with the hanning() function and other unrelated bits — splitting just the fence fix into a clean upstream PR would:
We have detailed crash data and stack traces from our testing that could support the PR description if helpful (SIGABRT in check_error(MTL::CommandBuffer*), Fence::wait deadlocks on 4-node tensor parallel, AMCC interrupt correlation from macOS 26.2, etc.) Your prior PR #3033 (jaccl small recv) went through cleanly — this one should too. |
AlexCheema
left a comment
There was a problem hiding this comment.
LGTM — ARM64 DSB SY barrier fix is correct, pinned in uv.lock + nix by commit SHA. Must upstream to ml-explore/mlx. CI green.
ab78c95 to
f9555c9
Compare
This reverts commit facf2d4.
Reverts #1489 Goddammit Claude...
PR #1489 Review: "Use custom fork that resolves GPU locks"SummaryThis PR switches the macOS MLX dependency from the upstream PyPI release (v0.30.6) to a custom fork (rltakashige/mlx-jaccl-fix-small-recv @ CI: All 6 checks passing. Note: This appears to be an updated version of PR #1453, with a newer fork commit and additional Nix fixes. Files Changed (6)
Detailed Analysis1. MLX Fork Switch (pyproject.toml, uv.lock, nix/mlx.nix, flake.nix)
Positives:
Concerns:
2. Nix Linux Fixes (python/parts.nix)
Assessment: This is solid Nix packaging work. The commit message (by JakeHillion/Claude) clearly explains both problems and solutions. The collision handling via fnmatch patterns is reasonable — keeping the first path encountered is fine for type-checking environments. 3. README.md
Assessment: Good quality-of-life improvements. Comparison with PR #1453This PR (#1489) supersedes #1453 with:
Overall AssessmentPositives:
Concerns:
Recommendation: The core change (fork with GPU lock fix) addresses a real problem and has been manually validated. The Nix fixes are solid. Main risk is long-term maintenance of the personal fork — would be good to clarify the upstream plan. |
Same as #1489 . Had to revert and redo thanks to Claude. --------- Co-authored-by: Jake Hillion <jake@hillion.co.uk> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Motivation
There is an issue on Macs that means that an explicit synchronization is necessary for memory to be updated from L1 cache. This means that GPU locks can occur when a spin wait does not see the updated timestamp.
Changes
Updated in my own personal fork.
Why It Works
https://github.com/ARM-software/acle/releases
Test Plan
Manual Testing
Tested manually that no GPU locks occur (even with multiple simultaneous instances running) and that the performance differential is negligible (267 vs 269 tps on Llama 3.2 1B at an approx 10k context.)
I have seen a GPU lock, specifically when sending a particularly large chat completion while the model was loading. However, I have since been unable to reproduce and this may be something I did wrong. Please do create an issue and tag me if any GPU locks do occur.