Skip to content
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

Enable torch.compile support for torch 2.0.0 pre release #2256

Merged
merged 2 commits into from
Apr 21, 2023

Conversation

morgandu
Copy link
Contributor

We are currently locked on an alpha version of torch 2.0.0. TorchServe (HEAD) was working for us before the PT2 refactor when the base_handler was deciding PT2, as below:

    try:
        import torch._dynamo

        pt2_enabled = True

Creating a minor PR for enable torch2.0.0 alpha pre release to use torch.compile.

@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Merging #2256 (6a14ef3) into master (627d4b7) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 6a14ef3 differs from pull request most recent head c5a34b9. Consider uploading reports for the commit c5a34b9 to get more accurate results

@@           Coverage Diff           @@
##           master    #2256   +/-   ##
=======================================
  Coverage   70.40%   70.40%           
=======================================
  Files          75       75           
  Lines        3392     3392           
  Branches       57       57           
=======================================
  Hits         2388     2388           
  Misses       1001     1001           
  Partials        3        3           
Impacted Files Coverage Δ
ts/torch_handler/base_handler.py 55.50% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@agunapal agunapal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msaroufim I wonder if the fix should be to change the logic to just check for >= 2 in 2.x.x

@agunapal
Copy link
Collaborator

agunapal commented Apr 21, 2023

@morgandu Could you please share whats the context of this alpha release. Also, the proposed fix would mean torch.compile wouldn't work on 2.0.0?

@msaroufim
Copy link
Member

@agunapal for context this PR is needed for the new TPU support, I believe this PR is correct and will return True in the case of torch__version__ = 2.0.0 since that's considered greater than an alpha release

@morgandu
Copy link
Contributor Author

@morgandu Could you please share whats the context of this alpha release. Also, the proposed fix would mean torch.compile wouldn't work on 2.0.0?

@agunapal we are currently fixed on using a particular version of torch 2.0.0, which is an alpha pre release version. According to the packaging.version comparison. '2.0.0a0' < '2.0.0'. However, I believe dynamo is enabled in '2.0.0a0'.

So this change should enable the torch.compile support for users on any pre release of 2.0.0, but not lower, and it will not affect users on 2.0.0 official release / post release and other future versions above 2.0.0.

@cloud-tpu-inference-github-bot cloud-tpu-inference-github-bot added kokoro:run Triggers a kokoro presubmit on a new pull request and removed kokoro:run Triggers a kokoro presubmit on a new pull request labels Apr 21, 2023
@morgandu
Copy link
Contributor Author

All green but I don't have write access so can't merge myself. Please help merge this PR. Thanks!

@msaroufim msaroufim merged commit e2b4511 into pytorch:master Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants