Loading fairseq/fp16_trainer.py +6 −0 Changes for fairseq/fp16_trainer.py: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -130,6 +130,12 @@ class FP16Trainer(Trainer): overflow = DynamicLossScaler.has_overflow(grad_norm) self.scaler.update_scale(overflow) if overflow: if self.scaler.loss_scale <= self.args.min_loss_scale: raise Exception(( 'Minimum loss scale reached ({}). Your loss is probably exploding. ' 'Try lowering the learning rate, using gradient clipping or ' 'increasing the batch size.' ).format(self.args.min_loss_scale)) raise OverflowError('setting loss scale to: ' + str(self.scaler.loss_scale)) return grad_norm Loading fairseq/options.py +2 −0 Changes for fairseq/options.py: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -210,6 +210,8 @@ def add_optimization_args(parser): help='learning rate shrink factor for annealing, lr_new = (lr * lr_shrink)') group.add_argument('--min-lr', default=1e-5, type=float, metavar='LR', help='minimum learning rate') group.add_argument('--min-loss-scale', default=1e-4, type=float, metavar='D', help='minimum loss scale (for FP16 training)') return group Loading Loading
fairseq/fp16_trainer.py +6 −0 Changes for fairseq/fp16_trainer.py: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -130,6 +130,12 @@ class FP16Trainer(Trainer): overflow = DynamicLossScaler.has_overflow(grad_norm) self.scaler.update_scale(overflow) if overflow: if self.scaler.loss_scale <= self.args.min_loss_scale: raise Exception(( 'Minimum loss scale reached ({}). Your loss is probably exploding. ' 'Try lowering the learning rate, using gradient clipping or ' 'increasing the batch size.' ).format(self.args.min_loss_scale)) raise OverflowError('setting loss scale to: ' + str(self.scaler.loss_scale)) return grad_norm Loading
fairseq/options.py +2 −0 Changes for fairseq/options.py: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -210,6 +210,8 @@ def add_optimization_args(parser): help='learning rate shrink factor for annealing, lr_new = (lr * lr_shrink)') group.add_argument('--min-lr', default=1e-5, type=float, metavar='LR', help='minimum learning rate') group.add_argument('--min-loss-scale', default=1e-4, type=float, metavar='D', help='minimum loss scale (for FP16 training)') return group Loading