From c3634c6b0a45430e083deca42b796568514b6d81 Mon Sep 17 00:00:00 2001 From: ShenLiang Date: Mon, 15 Mar 2021 11:45:51 +0800 Subject: [PATCH] fix amp bug of fleet (#31532) --- python/paddle/distributed/fleet/base/fleet_base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/paddle/distributed/fleet/base/fleet_base.py b/python/paddle/distributed/fleet/base/fleet_base.py index f4075e92c4c..19ba637cc96 100644 --- a/python/paddle/distributed/fleet/base/fleet_base.py +++ b/python/paddle/distributed/fleet/base/fleet_base.py @@ -637,6 +637,11 @@ class Fleet(object): self._user_defined_strategy = copy.deepcopy(strategy) self._context = {} + + # TODO(shenliang03): This is a temporary solution to support amp. In the case of a dynamic graph, + # the optimizer is returned directly. This problem will be fixed in the future. + if paddle.fluid.framework.in_dygraph_mode(): + return optimizer return self @dygraph_only -- GitLab