parallel_weight_init_adapt_pipeline_increment_predict

This commit is contained in:
yao_yf 2021-06-21 16:58:56 +08:00
parent 4e8305d055
commit d2dc22ff71
4 changed files with 22 additions and 6 deletions

View File

@ -197,7 +197,12 @@ void ParallelContext::ParallelParameterContextInitShape(const FuncGraphPtr &func
if (!func_graph->has_flag(AUTO_PARALLEL)) {
return;
}
if (func_graph->has_flag(IS_FIRST_ITERATION)) {
param_shapes.clear();
init_param_shape_ = true;
MS_LOG(INFO) << "Init the parameter shape dict in increment predict with two graph";
return;
}
if (!func_graph->has_flag(TRAINING)) {
init_param_shape_ = false;
MS_LOG(INFO) << "In parallel evaluation or prediction, may be need to restore the parameter shape";

View File

@ -50,6 +50,7 @@ constexpr char ALL_GROUP_PARALLEL[] = "all_group_parallel";
constexpr char SAME_SERVER_GROUP_PARALLEL[] = "same_server_group_parallel";
constexpr char NO_GROUP_PARALLEL[] = "no_group_parallel";
constexpr char IS_FIRST_ITERATION[] = "is_first_iteration";
class ParallelContext {
public:
~ParallelContext() = default;

View File

@ -564,10 +564,10 @@ class _Executor:
return
obj.parameter_layout_dict = self._executor.get_parameter_layout(phase)
if _get_pipeline_stages() > 1:
obj.parallel_parameter_name_list = self._executor.get_parallel_parameter_name_list(phase)
obj.remove_redundant_parameters()
obj.parallel_parameter_name_list = self._executor.get_parallel_parameter_name_list(phase)
replace = obj.init_parameters_data(auto_parallel_mode=True)
if _get_pipeline_stages() > 1 and (not hasattr(obj, "is_first_iteration") or not obj.is_first_iteration):
obj.remove_redundant_parameters()
if not context.get_context("enable_debug_runtime") or context.get_context("enable_ge"):
obj.load_parameter_slice(None)

View File

@ -782,14 +782,24 @@ class Cell(Cell_):
for _, cell in cells:
params = cell._params.items()
for param_name, param in params:
cell._params[param_name] = _updata(param)
if not auto_parallel_mode:
cell._params[param_name] = _updata(param)
continue
if param.name in self.parallel_parameter_name_list:
cell._params[param_name] = _updata(param)
cell_dict = cell.__dict__
for key in cell_dict:
if isinstance(cell_dict[key], ParameterTuple):
param_tuple = cell_dict[key]
new_param_tuple = []
for param in param_tuple:
new_param_tuple.append(_updata(param))
if not auto_parallel_mode:
new_param_tuple.append(_updata(param))
continue
if param.name in self.parallel_parameter_name_list:
new_param_tuple.append(_updata(param))
else:
new_param_tuple.append(param)
cell.__dict__[key] = ParameterTuple(new_param_tuple)
return replace