Adds dst.dtype information in copy_ method of quantized tensors.#2120
Closed
zobeideThePlayer wants to merge 6 commits intoNVIDIA:mainfrom
Closed
Adds dst.dtype information in copy_ method of quantized tensors.#2120zobeideThePlayer wants to merge 6 commits intoNVIDIA:mainfrom
zobeideThePlayer wants to merge 6 commits intoNVIDIA:mainfrom
Conversation
Signed-off-by: Zhiyi Su <dantesuu@gmail.com>
timmoon10
previously approved these changes
Aug 26, 2025
Collaborator
timmoon10
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix.
Collaborator
|
/te-ci pytorch |
timmoon10
reviewed
Aug 26, 2025
Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Signed-off-by: ZhiyiDanielSu <35579247+zobeideThePlayer@users.noreply.github.com>
ptrendx
approved these changes
Sep 17, 2025
Member
|
/te-ci pytorch |
Member
|
/te-ci pytorch |
Member
|
Duplicated by #2673 |
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.
Description
Fixes a bug that causes precision issues in mix-precision training.
Current implementation of copy_ method in QuantizedTensor class does not properly pass the dst.dtype information when src is a QuantizedTensor and dst is not. This may cause precision concerns under certain circumstances, for instance:
(1) main-stream precision is bfloat16
(2) model is initialized with FP8 format
(3) master weights in optimizers are kept at high precision, i.e., float32
(4) when continue training from a checkpoint but optimizer stats are not loaded/provided, master weights must be initialized from model weights
In above conditions and alike, model weights will be dequantized to bfloat16 (the dtype recorded in quantizer object) and then copied to master weight (of float32 precision), where the trailing 16 bits info are lost.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: