Skip to content

fix: Repair null bindings issue in TRT Engines #2080

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

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Jul 6, 2023

Description

  • Caused by passing Fake Tensor objects into TRT engines mid-compilation
  • Resolved by replacing all FX modules with TRT equivalents after all TRT compilation is complete. This way, modules are not run on FakeTensors generated during compilation

Fixes #2072

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

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

- Caused by passing Fake Tensor objects into TRT engines mid-compilation
- Resolved by replacing all FX modules with TRT equivalents after all
TRT compilation is complete. This way, modules are not run on
FakeTensors generated during compilation
@gs-olive gs-olive added component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths Story: Dynamo Compile Improvements Issues relating to improvement of the Dynamo compile path labels Jul 6, 2023
@gs-olive gs-olive requested a review from narendasan July 6, 2023 19:13
@gs-olive gs-olive self-assigned this Jul 6, 2023
@github-actions github-actions bot added the component: api [Python] Issues re: Python API label Jul 6, 2023
Comment on lines +144 to 148
trt_modules[name] = trt_mod

# Replace all FX Modules with TRT Modules
for name, trt_mod in trt_modules.items():
setattr(partitioned_module, name, trt_mod)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Set all TRT engine attributes after completion of compilation. Forward passes during compilation are run on the Torch equivalents, not the TRT graphs.

Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM

@gs-olive gs-olive merged commit bd9c29a into pytorch:main Jul 6, 2023
@gs-olive gs-olive deleted the trt_null_binding_fix branch July 6, 2023 21:25
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 Story: Dynamo Compile Improvements Issues relating to improvement of the Dynamo compile path
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Encountered TRT Error in Dynamo compile path
3 participants