From 3b5064d67769ae79f0edebe5dad89a0221c086a0 Mon Sep 17 00:00:00 2001 From: caozhou <48191911+Caozhou1995@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:42:15 +0800 Subject: [PATCH] update instantiate for auto parallel (#46883) --- python/paddle/distributed/auto_parallel/process_group.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/paddle/distributed/auto_parallel/process_group.py b/python/paddle/distributed/auto_parallel/process_group.py index 10ff0d36fce..ba63a716434 100644 --- a/python/paddle/distributed/auto_parallel/process_group.py +++ b/python/paddle/distributed/auto_parallel/process_group.py @@ -21,7 +21,7 @@ from ..collective import _get_global_env from ..collective import _new_ring_id from ...fluid.framework import _non_static_mode from ...fluid.layers.tensor import fill_constant -from paddle.fluid.framework import _enable_legacy_dygraph +from paddle import _legacy_C_ops def get_all_process_groups(): @@ -145,14 +145,15 @@ class ProcessGroup: # TODO(shenliang03): This is a temporary solution to solve the problem of # hang caused by cross-creation of new_group paddle.disable_static() - _enable_legacy_dygraph() paddle.set_device('gpu:%d' % paddle.distributed.ParallelEnv().dev_id) tmp = paddle.to_tensor( [1], dtype="int32") if _non_static_mode() else fill_constant( [0], dtype="int32", value="1") - paddle.distributed.all_reduce(tmp, sync_op=True, group=self) - paddle.distributed.wait(tmp, group=self) + # use legacy ops + _legacy_C_ops.c_allreduce_sum_(tmp, 'use_calc_stream', True, + 'ring_id', self.id) + _legacy_C_ops.c_sync_calc_stream(tmp, tmp) paddle.enable_static() self._is_instantiate = True -- GitLab