[Paper Review] Adaptive Loss Scaling for Mixed Precision Training
This paper proposes adaptive loss scaling, a method that dynamically computes layer-wise loss scaling values during mixed precision training to prevent gradient underflow without manual hyperparameter tuning. By automatically adjusting scale per layer based on gradient statistics, it achieves faster convergence and higher accuracy than fixed loss scaling and even FP32 training in some cases, especially for deep models and large-batch training.
Mixed precision training (MPT) is becoming a practical technique to improve the speed and energy efficiency of training deep neural networks by leveraging the fast hardware support for IEEE half-precision floating point that is available in existing GPUs. MPT is typically used in combination with a technique called loss scaling, that works by scaling up the loss value up before the start of backpropagation in order to minimize the impact of numerical underflow on training. Unfortunately, existing methods make this loss scale value a hyperparameter that needs to be tuned per-model, and a single scale cannot be adapted to different layers at different training stages. We introduce a loss scaling-based training method called adaptive loss scaling that makes MPT easier and more practical to use, by removing the need to tune a model-specific loss scale hyperparameter. We achieve this by introducing layer-wise loss scale values which are automatically computed during training to deal with underflow more effectively than existing methods. We present experimental results on a variety of networks and tasks that show our approach can shorten the time to convergence and improve accuracy compared to the existing state-of-the-art MPT and single-precision floating point
Motivation & Objective
- To address the instability and poor convergence in mixed precision training caused by gradient underflow in FP16.
- To eliminate the need for manual hyperparameter tuning of a fixed loss scale across models and training stages.
- To improve the usability and reliability of mixed precision training by adapting loss scaling per layer and iteration.
- To achieve training performance competitive with or better than full-precision (FP32) training in terms of accuracy and convergence speed.
- To reduce total training time by avoiding multiple hyperparameter search rounds required by fixed loss scaling.
Proposed method
- The method introduces layer-wise loss scaling values that are computed dynamically during training based on the distribution of activation gradients.
- For each layer, the loss scale is calculated as the inverse of the (0.01N)-th smallest absolute gradient value, where N is the gradient size, to limit underflow to at most 1%.
- The loss scale is updated periodically (e.g., every 100 iterations) to adapt to changing gradient statistics across training stages.
- The approach uses FP32 for weight updates and batch normalization, while activations and gradients are stored in FP16, maintaining computational efficiency.
- The method avoids overflow and excessive rounding errors by keeping the loss scale within a safe range based on gradient magnitude statistics.
- It integrates seamlessly into existing deep learning frameworks without requiring architectural changes.
Experimental results
Research questions
- RQ1Can dynamic, layer-specific loss scaling improve the stability and convergence of mixed precision training compared to fixed loss scaling?
- RQ2Does adaptive loss scaling reduce the need for manual hyperparameter tuning across different models and datasets?
- RQ3Can adaptive loss scaling achieve better model accuracy than both fixed loss scaling and full-precision (FP32) training?
- RQ4How does adaptive loss scaling affect training speed and total training time, especially when compared to multiple rounds of hyperparameter search?
- RQ5To what extent does adaptive loss scaling mitigate gradient underflow across different layers and training iterations?
Key findings
- Adaptive loss scaling achieved the highest mAP of 80.31% on SSD512 with a batch size of 32, surpassing both the FP32 baseline (79.50%) and fixed loss scaling (80.17%).
- For ResNet-50, adaptive loss scaling achieved 79.24% test accuracy, outperforming the best fixed scale (79.11%) and avoiding the accuracy drop seen with fixed scale 128.
- The method reduced underflow rates significantly—especially in deeper layers—by adapting scale per layer, as shown in Figure 4(b).
- The maximum standard deviation of gradients under adaptive scaling was about 20 times lower than under fixed scaling, reducing accumulation error and improving stability.
- With a 100-iteration update frequency, the overhead of computing loss scales was reduced to just 0.27% of total training time, making it efficient.
- The approach eliminated the need for multiple training runs to tune the loss scale, reducing total training time compared to fixed scaling with hyperparameter search.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.