未验证 提交 083853cd 编写于 作者: Z zhaoyingli 提交者: GitHub

[Auto Parallel] fix lazyinit (#46355) (#46382)

上级 cc3e7cd8
...@@ -341,6 +341,7 @@ class ProgramHelper(object): ...@@ -341,6 +341,7 @@ class ProgramHelper(object):
try: try:
return self.proxy_layer.startup_program return self.proxy_layer.startup_program
except Exception as err: except Exception as err:
self._logger.warning("`lazy init` failed.")
if isinstance(err, AssertionError): if isinstance(err, AssertionError):
return self.concrete_program.startup_program return self.concrete_program.startup_program
raise err raise err
......
...@@ -105,9 +105,13 @@ class Parallelizer: ...@@ -105,9 +105,13 @@ class Parallelizer:
format(time.time() - time0, self._mode)) format(time.time() - time0, self._mode))
else: else:
# Apply pre optimization passes # Apply pre optimization passes
# self._apply_pre_optimization(serial_main_program, time0 = time.time()
# serial_startup_program, None, None, self._apply_pre_optimization(serial_main_program,
# None) serial_startup_program, None, None,
None)
self._logger.info(
"within parallel apply_pre_optimization time: {}, mode {}".
format(time.time() - time0, self._mode))
# Do logical partition # Do logical partition
time0 = time.time() time0 = time.time()
partitioner = Partitioner(self._dist_context, rank) partitioner = Partitioner(self._dist_context, rank)
...@@ -176,7 +180,7 @@ class Parallelizer: ...@@ -176,7 +180,7 @@ class Parallelizer:
# apply amp pass # apply amp pass
# FIXME we disenable amp for eval since it has a little bug with # FIXME we disenable amp for eval since it has a little bug with
# eval program and which will be fixed in future # eval program and which will be fixed in future
if self._mode == 'train' and self._strategy.amp.enable: if self._strategy.amp.enable:
config = copy.deepcopy(self._strategy.amp.to_dict()) config = copy.deepcopy(self._strategy.amp.to_dict())
config["dist_context"] = self._dist_context config["dist_context"] = self._dist_context
config["params_grads"] = params_grads config["params_grads"] = params_grads
......
...@@ -36,7 +36,7 @@ class LazyInitHelper(object): ...@@ -36,7 +36,7 @@ class LazyInitHelper(object):
""" """
if self._state: if self._state:
return return
assert framework.in_dygraph_mode( assert framework._non_static_mode(
), "LazyInit.enable() is only available in dygraph mode." ), "LazyInit.enable() is only available in dygraph mode."
self._state = True self._state = True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册