From d82d59e6e731a3de4057249239c90b81360a0e01 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Wed, 9 Dec 2020 13:20:06 +0800 Subject: [PATCH] [cherry-pick] Fix amp support fleet(#29505) --- python/paddle/fluid/contrib/mixed_precision/decorator.py | 2 ++ python/paddle/fluid/optimizer.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/contrib/mixed_precision/decorator.py b/python/paddle/fluid/contrib/mixed_precision/decorator.py index a4279cde42b..37996b6228e 100644 --- a/python/paddle/fluid/contrib/mixed_precision/decorator.py +++ b/python/paddle/fluid/contrib/mixed_precision/decorator.py @@ -66,6 +66,8 @@ class OptimizerWithMixedPrecision(object): self._loss_scaling = None self._init_loss_scaling = init_loss_scaling self._use_dynamic_loss_scaling = use_dynamic_loss_scaling + self._learning_rate = optimizer._learning_rate + self._learning_rate_map = optimizer._learning_rate_map if self._use_dynamic_loss_scaling: self._incr_every_n_steps = incr_every_n_steps self._decr_every_n_nan_or_inf = decr_every_n_nan_or_inf diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index d4468f0193b..684413435c9 100644 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -3751,7 +3751,9 @@ class PipelineOptimizer(object): if framework.in_dygraph_mode(): raise Exception("In dygraph, don't support PipelineOptimizer.") if not isinstance(optimizer, Optimizer) and not isinstance( - optimizer, paddle.optimizer.Optimizer): + optimizer, paddle.optimizer.Optimizer) and not isinstance( + optimizer, paddle.fluid.contrib.mixed_precision.decorator. + OptimizerWithMixedPrecision): raise ValueError("The 'optimizer' parameter for " "PipelineOptimizer must be an instance of " "Optimizer, but the given type is {}.".format( -- GitLab