-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NF4] .to()
fixes
#1312
base: main
Are you sure you want to change the base?
[NF4] .to()
fixes
#1312
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1312
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit f309aea with merge base 26648c2 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
||
|
||
@implements_torch_function(torch.Tensor.cuda) | ||
def function_cuda(*args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this func not work call_from_inner_tensors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call_from_inner_tensors()
does not call the method on .scaler_mean
and .nf4
attribute, hence I use __tensor_flatten__
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. That's another anti-pattern since call_from_inner_tensors is typically applied for all the tensors and not just specific to sharding properties. But this makes sense. Maybe we should just like update it and have a flag that says ignore sharding or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, thank you. Yeah, I really didn't like the to calling dequant secretly, so I think this more aligns with what we've seen in the rest of the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I also penned some of my thoughts in #1310.
To clarify, this PR does not change the behavior "to calling dequant secretly (when dtype is specified)". Apart from fixes for .scaler_mean
and .nf4
attributes, this PR only changes .cuda()
behavior to not dequantize (previously .cuda()
will propagate to aten._to_copy
, which dequantize), so it's more consistent with .cpu()
as well as the general "not dequantize when dtype is not specified".
@ebsmothers Are there any ways to validate this against some tune flows to make sure it doesn't break anything? |
Fixes #1310