未验证 提交 566bbf0c 编写于 作者: R Ruibiao Chen 提交者: GitHub

Update FLAGS for standalone executor (#45127)

* Update FLAGS for standalone executor

* Update FLAGS_FORCE_USE_PROGRAM_CACHE
上级 9aecf286
......@@ -394,19 +394,9 @@ def _to_name_str(var):
def _is_enable_standalone_executor():
"""
Whether to use experimental executor `StandaloneExecutor`.
"""
flag = False
from ..distributed.fleet import fleet
# use standalone_executor by default if not distributed
if fleet._role_maker is None and framework._enable_standalone_executor_ is None:
framework._enable_standalone_executor_ = 1
if framework._enable_standalone_executor_ in [1, '1', True, 'True', 'true']:
flag = True
return flag
return framework._enable_standalone_executor_ is None or framework._enable_standalone_executor_ in [
1, '1', True, 'True', 'true'
]
def _prepare_fleet_executor():
......@@ -1289,6 +1279,17 @@ class Executor(object):
# [-0.44514108 -0.2345845 ]]
"""
# Temporary FLAGS, just for testing the performance of program cache
force_use_program_cache = os.environ.get(
'FLAGS_FORCE_USE_PROGRAM_CACHE', None)
if force_use_program_cache is not None:
use_program_cache = force_use_program_cache in [
1, '1', True, 'True', 'true'
]
warnings.warn(
f"use_program_cache is force set to {use_program_cache} by FLAGS_FORCE_USE_PROGRAM_CACHE",
UserWarning)
try:
res = self._run_impl(program=program,
feed=feed,
......@@ -1399,45 +1400,70 @@ class Executor(object):
place, core.CustomPlace):
return False
use_standalone_executor_for_compiled_program = os.environ.get(
'FLAGS_CONVERT_GRAPH_TO_PROGRAM',
None) in [1, '1', True, 'True', 'true']
# Only support fleet when 'FLAGS_CONVERT_GRAPH_TO_PROGRAM' is set to true
from paddle.distributed.fleet import fleet
if fleet._role_maker is not None and not use_standalone_executor_for_compiled_program:
warnings.warn("Standalone executor is not used for fleet",
UserWarning)
return False
compiled = isinstance(program, compiler.CompiledProgram)
if compiled:
# Unsupported case 1 : the CompiledProgram is constructed by Graph
if program._program is None:
warnings.warn("Standalone executor is not used for Graph",
UserWarning)
return False
# Unsupported case 2: data parallel
if program._is_data_parallel and len(
program._get_places(place, program._places)) != 1:
warnings.warn(
"Standalone executor is not used for data parallel",
UserWarning)
return False
# Unsupported case 3 : parallel graph
if core.globals()['FLAGS_enable_parallel_graph'] in [
1, '1', True, 'True', 'true'
]:
warnings.warn(
"Standalone executor is not used for parallel graph",
UserWarning)
return False
# Unsupported case 4: inference
if program._is_inference:
warnings.warn(
"Standalone executor is not used for inference",
UserWarning)
return False
# Unsupported case 5: CUDA Graph
if program._build_strategy is not None and program._build_strategy.allow_cuda_graph_capture:
warnings.warn(
"Standalone executor is not used for CUDA Graph",
UserWarning)
return False
# Unsupported case 6: distributed
if program._build_strategy is not None and (
program._build_strategy.is_distribution
or program._build_strategy.num_trainers > 1):
warnings.warn(
"Standalone executor is not used for distribution",
UserWarning)
return False
# Unsupported case 6 : disabled by FLAGS_CONVERT_GRAPH_TO_PROGRAM
if os.environ.get('FLAGS_CONVERT_GRAPH_TO_PROGRAM',
None) not in [1, '1', True, 'True', 'true']:
return False
return True
return use_standalone_executor_for_compiled_program
else:
if isinstance(program._graph, compiler.CompiledProgram):
warnings.warn("Standalone executor is not used for Graph",
UserWarning)
return False
assert isinstance(program, Program)
return True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册