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

[dynamo] Optimize VariableTracker.__post_init__ #122034

Closed
wants to merge 4 commits into from

Conversation

Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 8.6s to 7.3s.

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Mar 16, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 948acde with merge base 5030913 (image):
💚 Looks good so far! There are no failures yet. 💚

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

Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 8.6s to 7.3s.

[ghstack-poisoned]
Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 8.6s to 7.3s.

[ghstack-poisoned]
@@ -30,7 +30,7 @@ class ParentsTracker:

def __init__(self):
# logically this is a set, but we use a dict to ensure deterministic ordering
self.parents: Dict[ParentsTracker, bool] = dict()
self.parents: Dict[ParentsTracker, bool] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a ruff rule for this is we want. to enable it codebase wide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be fine with this.

@@ -1939,13 +1939,13 @@ def __call__(self, tx, value) -> VariableTracker:
if isinstance(value, VariableTracker):
# This is always valid to call, and useful for recursive calls.
return value
if isinstance(value, dataclasses._HAS_DEFAULT_FACTORY_CLASS):
elif isinstance(value, dataclasses._HAS_DEFAULT_FACTORY_CLASS):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the above statement has a return in it, I'm not sure it's actually an optimization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't matter, it is just a style thing.

Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 8.6s to 7.3s.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Mar 18, 2024
Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 7.3s to 6.7s.

Pull Request resolved: #122035
Approved by: https://github.com/Skylion007
ghstack dependencies: #122032, #122033, #122034
pytorchmergebot pushed a commit that referenced this pull request Mar 18, 2024
Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py`
from 6.7s to 5.6.

Pull Request resolved: #122038
Approved by: https://github.com/Skylion007
ghstack dependencies: #122032, #122033, #122034, #122035
@github-actions github-actions bot deleted the gh/jansel/269/head branch April 18, 2024 01:52
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

3 participants