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

Relax constraints for creating a GenericContextWrappingVariable #129091

Closed

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jun 19, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/129091

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 66a1370 with merge base 316c0d3 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
@guilhermeleobas
Copy link
Collaborator Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/guilhermeleobas/55/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/129091)

pytorchmergebot pushed a commit that referenced this pull request Jun 21, 2024
ghstack-source-id: 64ba666252c387d1507a4fab81126c7d9d5a7c65
Pull Request resolved: #129091
@guilhermeleobas guilhermeleobas marked this pull request as ready for review June 21, 2024 17:34
@zou3519 zou3519 requested a review from anijain2305 June 24, 2024 15:35
Comment on lines +883 to +884
self.assertEqual(cnts.frame_count, 1)
self.assertEqual(cnts.op_count, 6)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we turn on fullgraph=True on line 877?

@zou3519 zou3519 requested a review from yanboliang June 24, 2024 15:57
Copy link
Contributor

@yanboliang yanboliang left a comment

Choose a reason for hiding this comment

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

left one comment, otherwise, looks good!

torch/_dynamo/variables/user_defined.py Show resolved Hide resolved
[ghstack-poisoned]
[ghstack-poisoned]
torch/_dynamo/variables/user_defined.py Show resolved Hide resolved
torch/_dynamo/variables/ctx_manager.py Outdated Show resolved Hide resolved
[ghstack-poisoned]
[ghstack-poisoned]
DiweiSun pushed a commit to DiweiSun/pytorch that referenced this pull request Jul 22, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines +333 to +335
and self.value.__new__ == object.__new__
and SideEffects.cls_supports_mutation_side_effects(self.value)
and self.source is not None
Copy link
Collaborator Author

@guilhermeleobas guilhermeleobas Jul 23, 2024

Choose a reason for hiding this comment

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

@zou3519, with these changes, some contexts managers from pytest/unittest are now reaching this elif statement, rather than becoming a graph break. The problematic ones are failing because they check if the test raises a specific exception (assert_raises, assertRaisesRegexHighlighted) but dynamo changes the exception.

With that said, I had to add more than 100 files to dynamo_expected_failure folder. Would it be ok if I just ignore those context managers?

elif (
    issubclass(type(self.value), type)
    and hasattr(
        self.value, "__enter__"
    )  # TODO(voz): These can invoke user code!
    and hasattr(
        self.value, "__exit__"
    )  # TODO(voz): These can invoke user code!
    and self.value.__new__ == object.__new__
    and SideEffects.cls_supports_mutation_side_effects(self.value)
    and self.source is not None
    and self.value not in (assert_raises, assertRaisesRegexHighlight)  # <----- this
):

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My motivation for this change is as while dynamo cannot handle those context managers, the test might be composed of other compilable code that has value. Adding the test to dynamo_expected_failure may hide bugs that we don't catch because the test will be ignored.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yanboliang is there a way to mark a single API from e.g. pytest as skipped?

Copy link
Contributor

Choose a reason for hiding this comment

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

NB: I'm fine with this, we just need to skip 3 decorators here

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Jul 25, 2024
[ghstack-poisoned]
[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants