-
Notifications
You must be signed in to change notification settings - Fork 482
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
Allow BF16 dtype support on CPU #1218
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/1218
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c832dd6 with merge base 6e4809a (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hi @sanchitintel! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@ebsmothers Any reason not to do this? |
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.
@sanchitintel Great PR! Could you just run lint for these files?
Hi @joecummings, sorry, I haven't verified this change (and it doesn't look correct). I'll request review after verifying it, and will remove Draft mode for this PR. Thanks! |
55d9518
to
12c2dad
Compare
Hi @joecummings, the PR is now ready for review. Thanks!
|
Thanks for adding this @sanchitintel : ) pretty neat change Perhaps one suggestion while we're here. RE this comment:
it looks like |
Thanks for the PR! I partially agree with @SalmanMohammadi -- So I think we can delete _get_device_type_from_env and just replace its usage here with a call to |
Ah sorry @sanchitintel I did not look at the code for
So this is actually doing something different than our existing |
Thanks for your prompt feedback, @SalmanMohammadi & @ebsmothers! I reverted the change pertaining to |
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.
Looks good, thanks for fixing this!
Description
PyTorch supports BF16 dtype for CPUs. If CPUs don't support some BF16-related ISAs such as AVX512_BF16 & AMX_BF16, BF16 <-> FP32 conversions are done (compute happens in FP32, in these cases).
Changelog
BF16 dtype support check would now return True for CPUs.
It was returning
False
earlier in thequantize.py
recipe if PyTorch was installed without CUDA support and device type was set tocpu
in a config yaml file because no value for thedevice
argument was being provided in the invocation toutils.get_dtype()
, so it was defaulting toNone
, andutils.get_dtype()
was throwing an error about the device not supporting BFloat16 .Added
device
argument in calls toutils.get_dtype()
.Test plan
Verified manually that the quantization recipe on CPU is not failing due to
utils.get_dtype()
returning False.I could add a UT for CPU device, if required. Thanks!