set_split_strategy_by_idx
Description
Sets a backward gradient splitting strategy in a collective communication group based on the gradient index ID to implement AllReduce fusion and optimize the collective communication performance.
Prototype
def set_split_strategy_by_idx(idxList, group="hccl_world_group")
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
idxList |
Input |
A list. Index ID list of gradients.
|
group |
Input |
A string. Group name, which can be a user-defined value or hccl_world_group. Defaults to hccl_world_group. |
Returns
None
Constraints
- The caller rank must be within the range defined by the group argument passed to this API call. Otherwise, the API call fails.
- If you do not call the gradient splitting API to set the splitting strategy, the default backward gradient splitting strategy is used.
Default splitting strategy: two segments with the first taking up 96.54% of the gradient data size, and the second segment taking up 3.46% (In some cases, there is only one segment).
Applicability
Example
The following is only a code snippet and cannot be executed. For details about how to call the HCCL Python APIs to perform collective communication, see Sample Code.
1 2 | from npu_bridge.npu_init import * set_split_strategy_by_idx([20, 100, 159], "group") |