-
Notifications
You must be signed in to change notification settings - Fork 25.1k
[JIT] script if tracing fix #40468
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
[JIT] script if tracing fix #40468
Conversation
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.
@eellison 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 fcfd2e6 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
return fn(*args) | ||
return fn(*args, **kwargs) | ||
|
||
compiled_fn = script(wrapper.__original_fn) |
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.
caching already occurs when we compile a fn, so this was unnecessary
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.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Currently, torchvision annotates `batched_nms` with `torch.jit.script` so the function gets compiled when it is traced and ONNX will work. Unfortunately, this means we are eagerly compiling batched_nms, which fails if torchvision isn't built with `torchvision.ops.nms`. As a result, torchvision doesn't work on torch hub right now. `_script_if_tracing` could solve our problem here, but right now it does not correctly interact with recursive compilation. This PR fixes that bug. Pull Request resolved: pytorch#40468 Reviewed By: jamesr66a Differential Revision: D22195771 Pulled By: eellison fbshipit-source-id: 83022ca0bab6d389a48a478aec03052c9282d2b7
Summary: Currently, torchvision annotates `batched_nms` with `torch.jit.script` so the function gets compiled when it is traced and ONNX will work. Unfortunately, this means we are eagerly compiling batched_nms, which fails if torchvision isn't built with `torchvision.ops.nms`. As a result, torchvision doesn't work on torch hub right now. `_script_if_tracing` could solve our problem here, but right now it does not correctly interact with recursive compilation. This PR fixes that bug. Pull Request resolved: #40468 Reviewed By: jamesr66a Differential Revision: D22195771 Pulled By: eellison fbshipit-source-id: 83022ca0bab6d389a48a478aec03052c9282d2b7 Co-authored-by: Elias Ellison <eellison@fb.com>
Currently, torchvision annotates
batched_nms
withtorch.jit.script
so the function gets compiled when it is traced and ONNX will work. Unfortunately, this means we are eagerly compiling batched_nms, which fails if torchvision isn't built withtorchvision.ops.nms
. As a result, torchvision doesn't work on torch hub right now._script_if_tracing
could solve our problem here, but right now it does not correctly interact with recursive compilation. This PR fixes that bug.