Force use of torch.compile on deterministic roi_align implementation#8436
Force use of torch.compile on deterministic roi_align implementation#8436NicolasHug merged 8 commits intopytorch:mainfrom
Conversation
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
🔗 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 <ezyang@meta.com>
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
| 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.
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.
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.
| 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.
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.
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.
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 <ezyang@meta.com> Reviewed By: vmoens Differential Revision: D58283855 fbshipit-source-id: 914a91877c193b38f29af450a5935dd1ab5b20d7 Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
Fixes #8168
Signed-off-by: Edward Z. Yang ezyang@meta.com