ding.utils.linklink_dist_helper¶
ding.utils.linklink_dist_helper
¶
DistContext
¶
Overview
A context manager for linklink distribution
Interfaces:
__init__, __enter__, __exit__
__init__()
¶
Overview
Initialize the DistContext
__enter__()
¶
Overview
Initialize linklink distribution
__exit__(*args, **kwargs)
¶
Overview
Finalize linklink distribution
Arugments:
- args (:obj:Tuple): The arguments passed to the __exit__ function.
- kwargs (:obj:Dict): The keyword arguments passed to the __exit__ function.
get_rank()
¶
Overview
Get the rank of linklink model, return 0 if use FakeLink.
.. note::
Reference import_helper.try_import_link and linklink.get_rank.
get_world_size()
¶
Overview
Get the world_size of linklink model, return 0 if use FakeLink.
.. note::
Reference import_helper.try_import_link and linklink.get_world_size.
broadcast(value, rank)
¶
Overview
Use linklink.broadcast and raise error when using FakeLink
Arguments:
- value (:obj:obj): the value to board cast
- rank (:obj:int): the rank to broadcast on
allreduce(data, op='sum')
¶
Overview
Call linklink.allreduce on the data
Arguments:
- data (:obj:obj): the data to reduce
- op (:obj:str): the operation to perform on data, support ['sum', 'max']
allreduce_async(data, op='sum')
¶
Overview
Call linklink.allreduce_async on the data
Arguments:
- data (:obj:obj): the data to reduce
- op (:obj:str): the operation to perform on data, support ['sum', 'max']
get_group(group_size)
¶
Overview
Get the group segmentation of group_size each group
Arguments:
- group_size (:obj:int) the group_size
dist_mode(func)
¶
Overview
Wrap the function so that in can init and finalize automatically before each call
Arguments:
- func (:obj:Callable): the function to wrap
dist_init(method='slurm', device_id=0)
¶
Overview
Init the distribution
Arguments:
- method (:obj:str): Support ['slurm', 'single_node`]
- device_id (:obj:int): Default device when using single_node method
dist_finalize()
¶
Overview
Finalize linklink, see linklink.finalize()
simple_group_split(world_size, rank, num_groups)
¶
Overview
Split the group according to worldsize, rank and num_groups
Arguments:
- world_size (:obj:int): The world size
- rank (:obj:int): The rank
- num_groups (:obj:int): The number of groups
.. note::
With faulty input, raise array split does not result in an equal division
synchronize()
¶
Overview
Synchronize the process
Full Source Code
../ding/utils/linklink_dist_helper.py