Update fp8_meta amax when copying into Float8Tensor#567
Merged
ptrendx merged 4 commits intoNVIDIA:mainfrom Dec 16, 2023
Merged
Conversation
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Collaborator
Author
|
/te-ci pytorch |
ptrendx
reviewed
Dec 14, 2023
Member
|
The view issue is why the views are not really supported for Float8Tensors. |
8 tasks
Collaborator
Author
|
/te-ci pytorch |
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Collaborator
Author
|
/te-ci pytorch |
ptrendx
approved these changes
Dec 16, 2023
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.
While debugging a convergence issue with LLaMa SFT and NVIDIA-NeMo/NeMo#7909, I've identified a subtle bug when a model with FP8 params loads a checkpoint. When the model is first initialized, it generates random weights and stores the amax value in
fp8_meta. However, this amax becomes meaningless when we load the checkpoint and overwrite the weight values. The amax histories are used in the forward pass to update the scaling factors, resulting in bogus scaling factors that clip many FP8 values to the maxval or underflow them to zero.This PR changes the behavior of copying into a
Float8Tensorso that it updates the latest amax history if it has anfp8_meta. This is similar to how the FP8 cast kernel updates the latest amax history. This should fix the issue I'm seeing with LLaMa SFT, but it's not an entirely clean solution. In particular, it can't protect the user from abusingfp8_meta(e.g. loading a checkpoint in the middle of training will result in a bogus amax history, with or withoutFloat8Tensor). It might also result in unexpected amax updates when multiple tensors share the samefp8_meta, e.g. copying into a tensor subview will affect the full tensor's amax history.