Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/twinkle/utils/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ def gather_object(object: Any, device_mesh: DeviceMesh, process_group=None):
output_objects = [object]
group_size = 1
if dist.is_available() and dist.is_initialized():
if Platform.device_prefix() == 'npu':
if Platform.device_prefix() == 'npu' and not device_mesh.has_dim('fsdp'):
# On NPU, letting Python object collectives use the default HCCL
# group previously hung in 8-card metric collection at
# ``dist.all_gather_object(...)``. Reuse Megatron's dedicated Gloo
# DP group instead. When CP is enabled we must pick the DP+CP
# variant, otherwise the rank span for metric aggregation is wrong.
if importlib.util.find_spec('megatron.core') is not None:
from megatron.core import parallel_state as mpu
process_group = mpu.get_data_parallel_group_gloo(
with_context_parallel=getattr(device_mesh, 'cp_world_size', 1) > 1)
if mpu.model_parallel_is_initialized():
process_group = mpu.get_data_parallel_group_gloo(
with_context_parallel=getattr(device_mesh, 'cp_world_size', 1) > 1)
group_size = dist.get_world_size(group=process_group)
if group_size > 1:
output_objects = [None for _ in range(group_size)]
Expand Down
Loading