Repository navigation
Ring distributed backend - #1784
Merged
Merged
Conversation
awni
reviewed
Jan 22, 2025
awni
left a comment
Member
There was a problem hiding this comment.
Really nice, I didn't read the actual ring.cpp yet but I think the API changes look great.
One high-level question, is there anyway to test this back-end in CI?
Member
Author
|
Yeah 100%. I should have added that actually. Will do. It doesn't actually need thunderbolt connections any socket will do. I regularly test for correctness using the loop back interface which will be the CI test as well. |
awni
approved these changes
Jan 27, 2025
awni
left a comment
Member
There was a problem hiding this comment.
LGTM!! This is good to go right?
Member
Author
|
Yeah it is good to go. I am writing docs for it in a different PR and there will be more PRs improving the performance and adding features (these should be limited in |
angeloskath
force-pushed
the
ring-backend
branch
from
January 28, 2025 01:04
3bcd7cc to
8289a68
Compare
1 task done
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.
Initial version of a custom ring reduce backend. It can be used with Ethernet as well but the main focus is on thunderbolt because:
The comparison is as follows for a 4-way all reduce using 4 M2 Ultras:

The bandwidth is computed as
total bytes * 3/4 * 2 / timethe3/4is due to the ring reduce actually sending less than 2*B bytes on the wire.In terms of time per all reduce

which means that for 2GB all reduce we go from 1.3 seconds over Ethernet and 0.45s with MPI to 0.27s with our reduce.
Things to note:
mx.distributed.init()takes abackendargument and initializes the corresponding backend. If no argument is provided it tries to initialize in orderring > mpi. The reason is that ring will fail ifMLX_HOSTFILEandMLX_RANKis not provided while mpi may succeed and "hide" the rest of the backends.mx.distributed.init()called for a 2nd time without an argument returns the previously initialized backend. This allows the rest of the code to remain unchanged and agnostic of the communication group.Finally, I am in the process of preparing another PR with changes in the docs and possibly a launcher for this backend so people don't have to write their own shell scripts to launch with this backend.