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
Conversation
Improves `benchmarks/dynamo/microbenchmarks/dynamo_microbenchmarks.py` from 8.6s to 7.3s. [ghstack-poisoned]
🔗 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 FailuresAs of commit 948acde with merge base 5030913 (): 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] = {} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
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
Stack from ghstack (oldest at bottom):
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