Skip to content

Commit

Permalink
fix sync optimizer bug (#391)
Browse files Browse the repository at this point in the history
fix sync optimizer compatibility with pai-tf
  • Loading branch information
chengmengli06 authored Jun 25, 2023
1 parent 3e9e499 commit 10668aa
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions easy_rec/python/model/easy_rec_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ def _train_model_fn(self, features, labels, run_config):
logging.info('sync_replicas: num_worker_replias = %d' %
run_config.num_worker_replicas)
if pai_util.is_on_pai():
extra_args = {
'sparse_accumulator_type': self.train_config.sparse_accumulator_type
}
optimizer = tf.train.SyncReplicasOptimizer(
optimizer,
replicas_to_aggregate=run_config.num_worker_replicas,
total_num_replicas=run_config.num_worker_replicas,
sparse_accumulator_type=self.train_config.sparse_accumulator_type)
else:
extra_args = {}
optimizer = sync_replicas_optimizer.SyncReplicasOptimizer(
optimizer,
replicas_to_aggregate=run_config.num_worker_replicas,
total_num_replicas=run_config.num_worker_replicas,
**extra_args)
optimizer = sync_replicas_optimizer.SyncReplicasOptimizer(
optimizer,
replicas_to_aggregate=run_config.num_worker_replicas,
total_num_replicas=run_config.num_worker_replicas)
hooks.append(
optimizer.make_session_run_hook(run_config.is_chief, num_tokens=0))

Expand Down

0 comments on commit 10668aa

Please sign in to comment.