Loss Scaling for Deep Neural Network Training Stability

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Deep neural networks face numerical issues such as denormalization and zeroing of values when trained using reduced precision hardware, leading to instability and inefficiency in computations.

Innovation Solution

The solution involves scaling gradient values during training to shift denormal values into a normal range and compensating for scaling effects to prevent impact on weight updates, allowing for efficient reduced precision computations without affecting other training processes.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If reduced precision (FP16) is used for training deep neural networks, then memory usage and computation time are reduced, but numerical stability deteriorates due to denormalization and zeroing of values

Engineering Contradiction:
Improvetraining speedVSAvoidnumerical stability
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent applies loss scaling before the backward pass to prevent numerical issues during gradient computation. By pre-scaling the loss value, the gradient computations in reduced precision maintain better numerical stability, avoiding denormalization and zeroing problems that would otherwise occur during training.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent dynamically adjusts the loss scale factor based on the detected numerical conditions during training. When denormal or zero values are detected in gradients, the loss scale is modified to restore numerical stability, allowing continuous training in reduced precision without losing accuracy or stability.

Inventive Principle:
Principle #35Parameter changes

2Productivity

If reduced precision arithmetic is used, then throughput and performance are improved, but computation accuracy deteriorates

Engineering Contradiction:
ImprovethroughputVSAvoidcomputation accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The loss is scaled up before gradient computation to ensure that gradient values remain in a numerically stable range even when using reduced precision FP16 arithmetic. This preliminary scaling prevents loss of precision during the critical gradient calculation phase while maintaining the speed benefits of reduced precision hardware.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an FP32 accumulator as an intermediary for gradient computation. Gradients are computed in reduced precision but accumulated in higher precision, and the loss scale factor acts as a mediator to bridge between reduced precision computation and full precision weight updates, preserving accuracy while utilizing fast reduced precision hardware.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If loss scaling is applied to maintain numerical stability, then training stability is improved, but complexity of the training process increases

Engineering Contradiction:
Improvetraining stabilityVSAvoidprocess complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The training system automatically monitors gradient values for denormal or zero conditions and self-adjusts the loss scale factor without requiring external intervention. This automated monitoring and adjustment mechanism maintains training stability while minimizing the additional complexity burden on the user, as the system manages the scaling dynamically based on actual numerical conditions.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS11842280B2Loss-scaling for deep neural network training with reduced precision
Publication Date: 2023.12.12 NVIDIA CORP
  • US11842280B2 patent drawing
  • US11842280B2 patent drawing
  • US11842280B2 patent drawing

AI summary

In training a deep neural network using reduced precision, gradient computation operates on larger values without affecting the rest of the training procedure. One technique trains the deep neural network to develop loss, scales the loss, computes gradients at a reduced precision, and reduces the magnitude of the computed gradients to compensate for scaling of the loss. In one example non-limiting arrangement, the training forward pass scales a loss value by some factor S and the weight update reduces the weight gradient contribution by 1/S. Several techniques can be used for selecting scaling factor S and adjusting the weight update.