未验证 提交 5ad38fe5 编写于 作者: M minghaoBD 提交者: GitHub

[auto-compression-asp] support fleet training and asp+distillation in auto compression (#1139)

* Update README.md

* Update README.md

* Update README.md

* [auto-compression-asp] support fleet training and asp+distillation in auto compression
上级 009b0a9f
...@@ -248,6 +248,8 @@ class AutoCompression: ...@@ -248,6 +248,8 @@ class AutoCompression:
if train_config.amp_config is not None: if train_config.amp_config is not None:
strategy.amp = True strategy.amp = True
strategy.amp_configs = { ** train_config.amp_config} strategy.amp_configs = { ** train_config.amp_config}
if train_config.asp_config is not None:
strategy.asp = True
return strategy return strategy
def _prepare_program(self, program, feed_target_names, fetch_targets, def _prepare_program(self, program, feed_target_names, fetch_targets,
......
...@@ -278,7 +278,8 @@ def build_distill_program(executor, ...@@ -278,7 +278,8 @@ def build_distill_program(executor,
loss.stop_gradient = False loss.stop_gradient = False
if 'prune_algo' in config: ### prune & asp if 'prune_algo' in config: ### prune & asp
if config['prune_algo'] == 'asp': if config['prune_algo'] == 'asp' and not train_config.get(
'use_fleet'):
optimizer = pruner.decorate(optimizer) optimizer = pruner.decorate(optimizer)
optimizer.minimize(loss) optimizer.minimize(loss)
elif 'prune_strategy' in config: ###unstructure prune elif 'prune_strategy' in config: ###unstructure prune
...@@ -414,6 +415,8 @@ def build_prune_program(executor, ...@@ -414,6 +415,8 @@ def build_prune_program(executor,
'prune_params_name'] is not None and param.name not in config[ 'prune_params_name'] is not None and param.name not in config[
'prune_params_name']: 'prune_params_name']:
excluded_params_name.append(param.name) excluded_params_name.append(param.name)
if "teacher_" in param.name:
excluded_params_name.append(param.name)
pruner.set_excluded_layers(train_program_info.program, pruner.set_excluded_layers(train_program_info.program,
excluded_params_name) excluded_params_name)
elif config['prune_algo'] == 'transformer_pruner': elif config['prune_algo'] == 'transformer_pruner':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册