-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Enables bfloat16 x [float16, complex64, complex128] type promotion #43324
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
Conversation
| self.assertEqual((bf + scalar).dtype, torch.bfloat16) | ||
| self.assertEqual((scalar + bf).dtype, torch.bfloat16) | ||
| self.assertEqual(scalar + bf, bf + scalar) | ||
| with self.assertRaises(RuntimeError): |
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.
can you add a complex scalar to the for loop above? That seems to capture the intent of this test.
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.
Good idea. I also simplified the loop.
| self.assertEqual(bf + t, t + bf) | ||
| if dtype in (torch.float16, torch.float32, torch.float64, torch.cfloat, torch.cdouble): | ||
| # Handles bfloat16 x float16 -> float32 promotion | ||
| expected_dtype = dtype if dtype != torch.half else torch.float32 |
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.
can you rationalize?
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.
Rationalized.
facebook-github-bot
left a comment
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.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
💊 CI failures summary and remediationsAs of commit f4922f4 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
Implements bfloat16 type promotion consistent with JAX (see https://jax.readthedocs.io/en/latest/type_promotion.html), addressing issue #43049.
Existing tests, after updates, are sufficient to validate the new behavior.
cc @xuhdev