get_rank_id

Description

Obtains the rank ID of a device in a group.

Prototype

def get_rank_id(group="hccl_world_group")

Parameters

Parameter

Input/Output

Description

group

Input

A string containing a maximum of 128 bytes, including the end character.

Group name, which is user-defined. If no argument is passed, the default value hccl_world_group is used.

Returns

An int for the rank ID of the group to which the device belongs

Constraints

  • This API must be called after the initialization of collective communication is complete.
  • The caller rank must be within the range defined by the group argument passed to this API call. Otherwise, the API call fails.
  • After the create_group call, call this API to obtain the rank ID of a process in a group.
  • If hccl_world_group is passed, the rank ID of the process in hccl_world_group is returned.

Applicability

Atlas Training Series Product

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
3
from npu_bridge.npu_init import *
create_group("myGroup", 4, [0, 1, 2, 3])
rankId = get_rank_id("myGroup")