Repository navigation
Fix missing stream in gather matmul indices cast - #4687
Merged
Merged
Conversation
zcbenz
approved these changes
Oct 14, 2026
3 tasks done
ronaldmannak
pushed a commit
to PicoMLX/mlx
that referenced
this pull request
Oct 16, 2026
(cherry picked from commit bebd642)
ronaldmannak
added a commit
to PicoMLX/mlx-swift
that referenced
this pull request
Oct 16, 2026
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>
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.
indices_or_defaultcasts indices without forwarding the caller’s stream, sogather_mm,gather_qmm, andgather_qqmmon a non-default stream insert extra cross-stream fences per call and stall the caller’s stream. This PR passes the caller’s stream to the cast.