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

feat: add a pre-AOT lowering pass to remove detach ops #2756

Closed
wants to merge 1 commit into from

Conversation

zewenli98
Copy link
Collaborator

Description

Added a pre-AOT lowering pass to remove detach ops

Fixes #2657

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@zewenli98 zewenli98 self-assigned this Apr 16, 2024
@github-actions github-actions bot added component: lowering Issues re: The lowering / preprocessing passes component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: torch_compile labels Apr 16, 2024
@zewenli98 zewenli98 removed component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: torch_compile labels Apr 16, 2024
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Looks good - if possible, could a model with an explicit detach() call be added as a test case?

@zewenli98 zewenli98 requested a review from gs-olive April 17, 2024 01:10
@github-actions github-actions bot added component: tests Issues re: Tests component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: torch_compile labels Apr 17, 2024
@apbose
Copy link
Collaborator

apbose commented Apr 17, 2024

Overall looks good to me. Is there any use case for which this lowering pass has been added?

Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

I've implemented your fix (refactored it a bit) as a part of https://github.com/pytorch/TensorRT/pull/2756/files. Can you take a look and make these changes?
We need to add this pass to both torch.compile and torch.export as well.

@zewenli98
Copy link
Collaborator Author

Overall looks good to me. Is there any use case for which this lowering pass has been added?

Yes, in the vLLM, without this lowering pass, it causes some errors during compilation.

@zewenli98
Copy link
Collaborator Author

I've implemented your fix (refactored it a bit) as a part of https://github.com/pytorch/TensorRT/pull/2756/files. Can you take a look and make these changes? We need to add this pass to both torch.compile and torch.export as well.

Where can I find your implementation? The link seems not including your change.

@peri044
Copy link
Collaborator

peri044 commented Apr 22, 2024

I've implemented your fix (refactored it a bit) as a part of https://github.com/pytorch/TensorRT/pull/2756/files. Can you take a look and make these changes? We need to add this pass to both torch.compile and torch.export as well.

Where can I find your implementation? The link seems not including your change.

My bad, here's the correct link : #2763

@github-actions github-actions bot added documentation Improvements or additions to documentation component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: converters Issues re: Specific op converters component: build system Issues re: Build system labels Apr 24, 2024
@zewenli98 zewenli98 reopened this Apr 24, 2024
@github-actions github-actions bot removed documentation Improvements or additions to documentation component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: converters Issues re: Specific op converters component: build system Issues re: Build system component: runtime labels Apr 24, 2024
@zewenli98
Copy link
Collaborator Author

Hi @peri044 I checked your PR and found you made a lot of changes like pre_export_lowering and post_lowering with the help of PassManager. I will rebase on your PR after it gets merged.

Besides, I noticed that _pretraced_backend() in backends.py and compile() in _compiler.py are pretty similar. Why do we need the separate functions?

@peri044
Copy link
Collaborator

peri044 commented May 17, 2024

Hi @peri044 I checked your PR and found you made a lot of changes like pre_export_lowering and post_lowering with the help of PassManager. I will rebase on your PR after it gets merged.

Besides, I noticed that _pretraced_backend() in backends.py and compile() in _compiler.py are pretty similar. Why do we need the separate functions?

We use the same function now #2763. Closing this PR now

@zewenli98 zewenli98 closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests component: torch_compile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨[Feature] Lowering pass to remove detach operator
5 participants