mindspore.mint.distributed.all_gather_object
- mindspore.mint.distributed.all_gather_object(object_list, obj, group=None)[source]
Aggregates Python objects in a specified communication group.
Note
Similar to
mindspore.mint.distributed.all_gather(), but Python objects can be passed in.Only support PyNative mode, Graph mode is not currently supported.
Warning
This interface will implicitly use the pickle module, which is not secure. The core reason is that deserialization can execute arbitrary code, and attackers can trigger system command execution by constructing malicious objects. Therefore, the caller must ensure the security of the data used by the interface on their own.
- Parameters
- Raises
TypeError – group is not a str.
TypeError – If size of object_list is not equal to group size.
RuntimeError – If device target is invalid, or backend is invalid, or distributed initialization fails.
- Supported Platforms:
Ascend
Examples
Note
Before running the following examples, you need to configure the communication environment variables.
For Ascend devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies. Please see the msrun startup for more details.
This example should be run with 2 devices.
>>> from mindspore.mint.distributed import init_process_group, get_rank >>> from mindspore.mint.distributed import all_gather_object >>> init_process_group() >>> rank = get_rank() >>> obj = ["test", {1: 2}] >>> object_gather_list=[None, None] >>> all_gather_object(object_gather_list, obj[rank]) >>> print(object_gather_list) # rank_0 ['test', {1: 2}] # rank_1 ['test', {1: 2}]