-
Notifications
You must be signed in to change notification settings - Fork 422
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
Workaround at::scalar_tensor with BFloat16. #2536
Conversation
495ef58
to
60a6b6d
Compare
Do you think this also affects normal float16, or is specifically related to bfloat16 using more bits for precision? |
@cjolivier01 It might :P Since XLA doesn't support Half so it doesn't matter much here I think. I'll try to send a fix on pytorch side. |
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.
Thanks!
@@ -226,8 +226,13 @@ xla::ComputationClient::DataPtr GetDeviceData(const at::Tensor& tensor, | |||
xla::ComputationClient::DataPtr GetDeviceData(at::Scalar value, | |||
at::ScalarType scalar_type, | |||
const Device& device) { | |||
return GetDeviceData(at::scalar_tensor(value, at::TensorOptions(scalar_type)), | |||
device); | |||
// Workaround since at::scalar_tensor doesn't support bfloat16 yet. |
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.
This should be a utility function in torch_util.cpp/h, and a bug open with a reminder to remove the hack once scalar_tensor supports bfloat16.
Actually, it may be argued that this should be in pytorch main directly.
value, at::TensorOptions(scalar_type == at::ScalarType::BFloat16 | ||
? at::ScalarType::Float | ||
: scalar_type)); | ||
if (scalar_type == at::ScalarType::BFloat16) t = t.to(scalar_type); |
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.
This requires brackets around the single statement 😉
fixes #2535