Skip to content

Fix jaccl ring all_gather: direction 1 slice was not mirrored - #4443

Open
Drifter4242 wants to merge 2 commits into
ml-explore:mainfrom
Drifter4242:pr/jaccl-allgather-direction-fix
Open

Fix jaccl ring all_gather: direction 1 slice was not mirrored#4443
Drifter4242 wants to merge 2 commits into
ml-explore:mainfrom
Drifter4242:pr/jaccl-allgather-direction-fix

Conversation

@Drifter4242

Copy link
Copy Markdown

I confess that Fable found and fixed this bug, and I struggle to understand exactly what the problem is. But since the change is fairly small, I thought it reasonable to create a PR for review.

My understanding is that the all_gather was refactored recently and has a bug.
Both sides were sending the lower half of the slice. Instead it should use the same code as the all_reduce_wire and send upper half in the second direction.

There is also a second bug fix in this PR, where there is a one-line change to a size parameter for ring_pass.

  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: I wrote the PR description, but Fable did all the work. I won't be offended if you close this without using it - I just felt I should pass on the bug fix so it can at least be reviewed.

The 3900 refactor gives all_gather_wire identical wire_offset/wire_end
for both ring directions, so both cover the same lower-half slice of
each peer region and the upper half is never transferred (stale/zero
bytes in the output). all_reduce_wire computes the directional term
lr * n_wires * size_per_wire correctly, which is why all_sum works;
mirror that logic here. Repro: MLX_JACCL_RING=1, 2 ranks: all_gather
corrupts at every size while all_sum passes.
@nastya236

Copy link
Copy Markdown
Collaborator

Thank you, will look into this as soon as possible.

@nastya236

Copy link
Copy Markdown
Collaborator

Do you mind covering it with tests for all_gather?

@nastya236 nastya236 added the await response This pull request is waiting for response from the author. label Sep 1, 2026
…cally

this test uses distinct data at larger sizes. Tested on 2 M3 Ultras with
thunderbolt.
Fable wrote the code and performed the tests. I reviewed the results and wrote the commit message.
@Drifter4242

Copy link
Copy Markdown
Author

I went ahead and wrote a test for it (actually I got Fable to write the test and run it, but I did review the test and results).
The results:

wheel commit test_all_gather test_all_gather_rank_data
A 0.32.3.dev20260901+37c26e575 (PR base) 37c26e5 FAIL (both ranks) FAIL (both ranks)
B 0.32.3.dev20260901+9b6b10c76 (fix) 9b6b10c ok (both ranks) ok (both ranks)

I have 2 M3 Ultras with thunderbolt that I can do the test on. I think the standard mlx CI doesn't do the test on that hardware which is why it got missed.

I hope that's enough. I admit that this isn't my area of expertise.

@zcbenz zcbenz added await verification This pull request is non-trivial and requires a human expert to verify its correctness. and removed await response This pull request is waiting for response from the author. labels Sep 2, 2026
@williamzebrowskI

williamzebrowskI commented Sep 11, 2026

Copy link
Copy Markdown

i'm seeing something very similar on my setup:

4 Mac Studio, running mlx 0.32.1 with jaccl-ring over thunderbolt for distributed pretraining.

i reproduced incomplete/incorrect results from native all_gather with both int32 and float32 arrays, including explicitly evaluated inputs. meanwhile, all_sum passed checks

for now, my workaround is just for small control messages: each rank puts its message into its own section of a zero-filled array, then we use all_sum so every rank gets all four messages. keeping checksums and sequence checks in place. gradient reductions still use native all_sum.

haven't tested this pr's patch yet, so i can't confirm it fixes my 4-Mac studio setup, but the symptoms and the two issues described here line up closely with what I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

await verification This pull request is non-trivial and requires a human expert to verify its correctness. low priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants