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
Add logging for NO_SUCH_SUBOBJ #125410
base: main
Are you sure you want to change the base?
Add logging for NO_SUCH_SUBOBJ #125410
Conversation
@@ -828,6 +832,7 @@ def var_getattr(self, tx, name): | |||
subobj = self._getattr_static(name) | |||
except AttributeError: | |||
subobj = NO_SUCH_SUBOBJ | |||
log.warning(f"NO_SUCH_SUBOBJ: {self.value} {name}") |
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.
Why not just log the exception with logging.exception
?
@@ -828,6 +832,7 @@ def var_getattr(self, tx, name): | |||
subobj = self._getattr_static(name) | |||
except AttributeError: | |||
subobj = NO_SUCH_SUBOBJ | |||
log.warning(f"NO_SUCH_SUBOBJ: {self.value} {name}") |
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.
More user-facing? e.g. "Attribute {name} does not exist on {self.value}, falling back to NO_SUCH_SUBOBJ"
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.
Can we also add the log of self.value.__class__
?
Can we also add the fallback warning to pytorch/torch/_dynamo/variables/user_defined.py Lines 801 to 803 in 799f146
|
@@ -828,6 +832,7 @@ def var_getattr(self, tx, name): | |||
subobj = self._getattr_static(name) | |||
except AttributeError: | |||
subobj = NO_SUCH_SUBOBJ | |||
log.warning(f"NO_SUCH_SUBOBJ: {self.value} {name}") |
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 seem like something we should warn on. This is valid user code:
try:
x = foo.x
except AttributeError:
x = None
It would be super annoying to emit a warning for this.
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.
Let's pass exc_info=True too to get the full exception stack trace + exception object.
It's difficult to tell where NO_SUCH_SUBOBJ occurs from current log, which happens often during compiled autograd enablement. This PR should help surface more information.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang