-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Force use of torch.compile on deterministic roi_align implementation #8436
Conversation
Signed-off-by: Edward Z. Yang <[email protected]>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8436
Note: Links to docs will display an error until the docs builds have been completed. ❌ 12 New Failures, 1 Unrelated FailureAs of commit ee25749 with merge base 775dd2d (): NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
cc @qqaatw, I removed the MPS knob because of how memory hungry the eager implementation is, I doubt torch.compile works on MPS. |
Signed-off-by: Edward Z. Yang <[email protected]>
Signed-off-by: Edward Z. Yang <[email protected]>
Signed-off-by: Edward Z. Yang <[email protected]>
Signed-off-by: Edward Z. Yang <[email protected]>
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.
def lazy_compile(**compile_kwargs): | ||
"""Lazily wrap a function with torch.compile on the first call | ||
|
||
This avoids eagerly importing dynamo. |
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.
Am I understanding this correctly?
This avoids eagerly importing dynamo. | |
This avoids eagerly compiling a function at import 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.
Nope. Even with torch.compile at top level it isn't compiled until you call it the first time. But importing dynamo has undesirable side effects for eager mode only users so it's best not to do it.
@@ -232,7 +250,9 @@ def roi_align( | |||
if not isinstance(rois, torch.Tensor): | |||
rois = convert_boxes_to_roi_format(rois) | |||
if not torch.jit.is_scripting(): | |||
if not _has_ops() or (torch.are_deterministic_algorithms_enabled() and (input.is_cuda or input.is_mps)): | |||
if ( | |||
not _has_ops() or (torch.are_deterministic_algorithms_enabled() and (input.is_cuda or input.is_mps)) |
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.
Should we just remove the mps part here since you mentioned MPS doesn't even work with torch.compile?
not _has_ops() or (torch.are_deterministic_algorithms_enabled() and (input.is_cuda or input.is_mps)) | |
not _has_ops() or (torch.are_deterministic_algorithms_enabled() and input.is_cuda) |
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 opted to keep it around, because it was explicitly added by @qqaatw, but I don't really mind either way
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.
Sorry for the late reply! I'm ok with either way that is best for the development. From the mentioned issue it seems only relevant to CUDA, is MPS similarly memory hungry with deterministic algorithm?
…entation (#8436) Summary: Signed-off-by: Edward Z. Yang <[email protected]> Reviewed By: vmoens Differential Revision: D58283855 fbshipit-source-id: 914a91877c193b38f29af450a5935dd1ab5b20d7 Co-authored-by: Nicolas Hug <[email protected]>
Fixes #8168
Signed-off-by: Edward Z. Yang [email protected]