-
Notifications
You must be signed in to change notification settings - Fork 63
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
added mse_loss
#218
added mse_loss
#218
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Hi @mruberry!
test_directives=(
DecorateInfo(
pytest.mark.skip,
"test_core_vs_torch_consistency",
dtypes=(datatypes.bfloat16,),
devicetypes=(devices.DeviceType.CPU,),
),
DecorateInfo(
pytest.mark.skip,
"test_phantom_grad_vs_torch_consistency",
dtypes=(datatypes.bfloat16, datatypes.float16,),
devicetypes=(devices.DeviceType.CPU,),
),
), How do I know if PyTorch supports this or not? |
These skips make a lot of sense. I wouldn't worry about supporting grad by adding
This may be an interesting follow-up issue for a separate PR that targets optimizing this operation's grad formula, but I think this issue may disappear on this PR if this PR doesn't add the grad formula. |
Cool PR, @k223kim! Let's take this PR out of "draft," — I think it's ready for review! I added some inline comments, particularly about understanding what's happening with the broadcasting better. I'm curious to hear more about that! I suggest remove the custom |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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 looks really good, @k223kim. There are mostly clean-up changes that should be simple to make. There is a test that's failing:
FAILED thunder/tests/test_ops.py::test_core_vs_torch_consistency_mse_loss_nvfuser_cuda_float16 - AssertionError: Tensor-likes are not close!
Mismatched elements: 1 / 32 (3.1%)
Greatest absolute difference: 0.00048828125 at index (1, 9) (up to 1e-05 allowed)
Greatest relative difference: 0.0014553070068359375 at index (1, 9) (up to 0.001 allowed)
and that's OK, the deviation is pretty small. This PR just needs to update the OpInfo to account for this by increasing that test's tolerance. An example of how this is done can be found here:
lightning-thunder/thunder/tests/opinfos.py
Line 4394 in e0ab648
DecorateInfo( |
Essentially, a decorator is specified in the OpInfo and it is automatically added to the generated test. In this case it looks like the decorator needs to set
custom_comparator(partial(assert_close, atol=1e-3, rtol=1e-2)),
If that doesn't work we can increase the test tolerance even more. Let me know if you have any questions about this!
Hi @mruberry! Thanks for the detailed comments :) it's helping me a lot! I can add the following to DecorateInfo(
custom_comparator(partial(assert_close, atol=1e-3, rtol=1e-2)),
executors=("nvfuser",),
dtypes=(datatypes.float16,),
) However, my concern is that, I am not able to reproduce the error that you have shown above. Would this be an issue? (on my end, all tests are passing..) |
I understand, and that's OK, we want to see the CI passing, and the CI and your local hardware may have some differences that cause a small precision difference. |
Hey @mruberry ! |
Absolutely a separate PR would be great. The reason to add a custom grad formula would be to improve performance. So it'd be nice if the PR showed performance of mse_loss forward->backward before the PR, and then after the PR, so we can be sure it improves performance. (Benchmarking with CUDA devices can be a little tricky, but basically you want to run the operations, sync the CUDA device with the CPU, and measure that time.) |
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.
Cool! Nice work, @k223kim!
Before submitting
What does this PR do?
Fixes #174 .
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
YES!