diff --git a/python/paddle/distributed/fleet/base/fleet_base.py b/python/paddle/distributed/fleet/base/fleet_base.py index f4075e92c4c4488ae2ffb8a2c14b34eeee35123b..19ba637cc96809be508a074bab4552bded4e523c 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