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

fix: FakeTensors appearing in get_attr calls #2669

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Mar 5, 2024

Description

  • Register all constants as model parameters, which do not get fake-ified by the active FakeTensor context
  • Buffers and other constant registrations can be fake-ified, which is problematic for TRT tracing

Fixes #2658

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
  • [ - ] I have added tests to verify my fix or my feature
    • Pending CI verification on existing models
  • [ 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

@gs-olive gs-olive self-assigned this Mar 5, 2024
@github-actions github-actions bot added component: lowering Issues re: The lowering / preprocessing passes component: conversion Issues re: Conversion stage component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Mar 5, 2024
- Register all constants as model parameters, which do not get
fake-ified by the active FakeTensor context
- Buffers and other constant registrations can be fake-ified, which is
problematic for TRT tracing
Copy link
Collaborator

@zewenli98 zewenli98 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 to me! I'm just wondering if PyTorch has documentation to illustrate what kind of types will be fake-ified?

@gs-olive
Copy link
Collaborator Author

gs-olive commented Mar 8, 2024

Thanks for the review - I haven't found any concrete documentation on this topic; this is mainly a workaround that I've found to work for a few key models and not break others. This documentation on FakeTensor is what I am using currently.

@bowang007 bowang007 self-requested a review March 18, 2024 22:59
Copy link
Collaborator

@bowang007 bowang007 left a comment

Choose a reason for hiding this comment

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

LGTM.

@bowang007
Copy link
Collaborator

@gs-olive can you merge this one?
This can make us a lot easier every time using the nightly container.
Thanks!

This was referenced Mar 18, 2024
@gs-olive
Copy link
Collaborator Author

Since testing is not working in CI, running the Dynamo test suite locally to verify

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.

LGTM

@gs-olive gs-olive merged commit 766c270 into pytorch:main Mar 20, 2024
11 of 23 checks passed
@gs-olive gs-olive deleted the draft_fixes_2658 branch March 20, 2024 01:10
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: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Issue in conversion when parameters/buffers are moved during compilation
5 participants