Repository navigation
Skip SuperOffload's eager CPU step on non-finite gradients - #8771
Draft
vineethsaivs wants to merge 1 commit into
Draft
vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
On an fp16 overflow step() rolls back the CPU Adam step that already ran during backward. The rollback inverts the update algebraically, so an inf or nan gradient leaves nan exp_avg and exp_avg_sq and resets the weight to 0, and every later step for those elements is nan. Do not take the eager step on a sub-group whose gradient is not finite; step() sees the overflow and only rolls back the sub-groups that were stepped. Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With SuperOffload and fp16, one overflow step permanently breaks the affected weights: they are reset to 0 and their Adam moments become nan, so every later update for them is nan.
Without gradient clipping,
partition_gradsruns the CPU Adam step during backward, andstep()rolls it back when it finds the overflow. The rollback inverts the update ((exp_avg - (1 - beta1) * grad) / beta1), which isinf - inffor an inf gradient, and the kernel sets the non-finite param to 0.Fix: skip the eager step for a sub-group whose fp32 gradient is not finite.
step()still detects the overflow and, since #8638, only rolls back the sub-groups that were submitted.Test: new unit test in
test_invalid_grad_norm.pyfails on master (both sub-groups stepped) and passes here; the file gives 18 passed, 1 skipped. On CPU,DeepSpeedCPUAdamstep + rollback with grad[inf, 0.2, 0.3]gives param[0.0, ...]and exp_avg[nan, ...]. Not run on a Grace Hopper machine.