Repository navigation
Add new distributed functions - #139
Closed
ronaldmannak wants to merge 1 commit into
Closed
ronaldmannak wants to merge 1 commit into
ronaldmannak wants to merge 1 commit into
Conversation
4 tasks done
4 tasks done
Member
|
@ronaldmannak would you mind allowing edits from maintainers? There are few changes I would like to make before merging |
Contributor
Author
|
@andresy Yes, absolutely. No problem. I'm a bit lost what should be generated and what not, so go ahead. Thanks! |
Member
|
Hmm somehow I cannot push changes there - maybe because it is an organization-own fork? |
Merged
Contributor
Author
|
Weird. I don't know how GitHub handles orgs. But I see you fixed it by creating a new PR. Perfect |
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.
This PR implements #134 except for the null-stream changes that I believe need to be generated.
Added
mlx_distributed_clear_backends()bindsclear_backends().mlx_distributed_init_with_all_gather(...)bindsinit(strict, bk, factory)for JACCL, with the factory flattened into one callback plus
payloadanddtor, as inmlx_closure_new_func_payload. A non-zero return from thecallback fails the init.
dtorruns exactly once, including on failure.mlx_distributed_group_get_rank()andmlx_distributed_group_get_size()return a status and write the value to
res.Note that ml-explore/mlx#4558 changes one case where
mlx_distributed_clear_backends()is needed. On 0.32.3, a non-strictinitalso caches its size-one fallback, so a laterinitreturns that fallback until the backends are cleared. From the next MLX release the fallback is no longer cached. Clearing is still needed to drop a backend that did initialize.Not included: null stream in the
mlx_distributed_*opsThe C++ backend automatically chooses the communication stream (CPU for Ring, MPI, and JACCL, and GPU for NCCL) when the stream parameter is unspecified. Currently, mlx-c requires an explicit stream. We kind of lessened the impact by making
.cputhe default stream in mlx-swift but it would be helpful to update the eight distributed functions to convert an emptymlx_streamhandle (ctx == NULL) intoStreamOrDevice{}, while passing explicit streams through unchanged. I can then update mlx-swift to default tonilinstead of.cpu. Since this is generated code, I assume this must be done by the maintainers.Testing
Compiled against MLX v0.32.2 and checked from a C99 caller with
-pedantic -Wall -Wextra; both files pass clang-format. The functions havenot been tested at runtime.