MLX
 
Loading...
Searching...
No Matches
distributed_impl.h
Go to the documentation of this file.
1// Copyright © 2024 Apple Inc.
2
3#pragma once
4
6
8
12class GroupImpl {
13 public:
14 virtual ~GroupImpl() {}
15
16 virtual int rank() = 0;
17 virtual int size() = 0;
18 virtual std::shared_ptr<GroupImpl> split(int color, int key = -1) = 0;
19
20 virtual void all_sum(const array& input, array& output, Stream stream) = 0;
21 virtual void all_gather(const array& input, array& output, Stream stream) = 0;
22 virtual void send(const array& input, int dst, Stream stream) = 0;
23 virtual void recv(array& out, int src, Stream stream) = 0;
24};
25
26/* Perform an all reduce sum operation */
27void all_sum(Group group, const array& input, array& output, Stream stream);
28
29/* Perform an all gather operation */
30void all_gather(Group group, const array& input, array& output, Stream stream);
31
33void send(Group group, const array& input, int dst, Stream stream);
34
36void recv(Group group, array& out, int src, Stream stream);
37
38} // namespace mlx::core::distributed::detail
Definition array.h:24
Abstract base class of a distributed group implementation.
Definition distributed_impl.h:12
virtual void all_sum(const array &input, array &output, Stream stream)=0
virtual void all_gather(const array &input, array &output, Stream stream)=0
virtual void send(const array &input, int dst, Stream stream)=0
virtual void recv(array &out, int src, Stream stream)=0
virtual ~GroupImpl()
Definition distributed_impl.h:14
virtual std::shared_ptr< GroupImpl > split(int color, int key=-1)=0
Definition distributed.h:12
void all_sum(Group group, const array &input, array &output, Stream stream)
void send(Group group, const array &input, int dst, Stream stream)
Send an array to the dst rank.
void recv(Group group, array &out, int src, Stream stream)
Recv an array from the src rank.
void all_gather(Group group, const array &input, array &output, Stream stream)
Definition stream.h:9
A distributed::Group represents a group of independent mlx processes that can communicate.
Definition distributed.h:24