npu.distribute.broadcast
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
√ |
Description
Synchronizes variables across workers in distributed NPU training scenarios. This is the operation interface of the Broadcast collective communication operator.
This API can be used together with the Python communicator management APIs provided by HCCL. For details about the HCCL Python APIs, see HCCL Communicator Management APIs (Python).
Prototype
1 | npu.distribute.broadcast(values, root_rank, fusion=2, fusion_id=0, group="hccl_world_group") |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
values |
Input |
A TensorFlow variable or variable set. For the For the For the For the |
root_rank |
Input |
An int. Rank ID of the root rank. Must be a rank ID in the group. |
fusion |
Input |
An int. Broadcast operator fusion flag. The value can be one of the following:
|
fusion_id |
Input |
An int. Broadcast operator fusion ID. If fusion is set to 2, Broadcast operators with the same fusion_id are fused during network compilation. |
group |
Input |
A string of up to 128 bytes, including the end character. Group name, which can be a user-defined value or hccl_world_group. |
Returns
None
Example
To broadcast the variables on device 0 to the rest devices:
1 2 3 4 5 6 | # rank_id = 0 rank_size = 8 import npu_device as npu x = tf.Variable(tf.random.normal(shape=())) print("before broadcast", x) npu.distribute.broadcast(x, root_rank=0) print("after_broadcast", x) |
Before the broadcast

After the broadcast
