b4d57c6d49682094efe22fbe2c03fa2c4973869f,fairseq/trainer.py,Trainer,train_step,#Trainer#Any#Any#,496

Before Change



        overflow = False
        try:
            if self.tpu and self.data_parallel_world_size > 1:
                import torch_xla.core.xla_model as xm

                gradients = xm._fetch_gradients(self.optimizer.optimizer)
                xm.all_reduce(
                    "sum", gradients, scale=1.0 / self.data_parallel_world_size
                )

            with torch.autograd.profiler.record_function("multiply-grads"):
                // multiply gradients by (// GPUs / sample_size) since DDP
                // already normalizes by the number of GPUs. Thus we get
                // (sum_of_gradients / sample_size).

After Change


        try:
            with torch.autograd.profiler.record_function("reduce-grads"):
                self.optimizer.all_reduce_grads(self.model)
                if utils.has_parameters(self.criterion):
                    self.optimizer.all_reduce_grads(self.criterion)

            with torch.autograd.profiler.record_function("multiply-grads"):
                // multiply gradients by (data_parallel_size / sample_size) since
                // DDP already normalizes by the number of data parallel workers.
                // Thus we get (sum_of_gradients / sample_size) at the end.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: pytorch/fairseq
Commit Name: b4d57c6d49682094efe22fbe2c03fa2c4973869f
Time: 2020-11-05
Author: myleott@fb.com
File Name: fairseq/trainer.py
Class Name: Trainer
Method Name: train_step


Project Name: allenai/allennlp
Commit Name: 87a61ad92a9e0129e5c81c242f0ea96d77e6b0af
Time: 2020-08-19
Author: akshita23bhagia@gmail.com
File Name: allennlp/training/metrics/pearson_correlation.py
Class Name: PearsonCorrelation
Method Name: get_metric


Project Name: open-mmlab/mmcv
Commit Name: 50a33950a4b23c614152696e6f979ae978233432
Time: 2020-10-14
Author: swanxinjiang@gmail.com
File Name: mmcv/runner/hooks/sync_buffer.py
Class Name: SyncBuffersHook
Method Name: after_epoch