-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Get, save, and load module information for each operator #42133
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
Conversation
[ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit da42c7c (more details on the Dr. CI page):
🕵️ 3 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
module_names[module._ivalue()] = getSubModuleName(module, prefix); | ||
for (NameModule s : module.named_children()) { | ||
constructRelativeNamesForModules(s.value, prefix + "." + s.name); | ||
std::string newPrefix = (!has_duplicated_function) ? |
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.
Instead of calling has_duplicated_function, maybe we can say class_types_are_not_unique. Also put a comment suggesting why is this necessary? Give an example, like when doing traced module vs scripted module with two instances of same type what can happen, and what we are doing for that.
for (NameModule s : module.named_children()) { | ||
constructRelativeNamesForModules(s.value, prefix + "." + s.name); | ||
std::string newPrefix = (!has_duplicated_function) ? | ||
module_names[module._ivalue()] + "." + s.name : module_names[module._ivalue()] + "."; |
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.
When has_duplicated_function=true, I suggest add something like .
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 you clarify your suggestion a bit? Also, since we decided not to save module info the two cases differently, I believe that we don't need to check for has_duplicated_function
here. Is that correct?
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 you clarify your suggestion a bit? Also, since we decided not to save module info the two cases differently, I believe that we don't need to check for
has_duplicated_function
here. Is that correct?
Are you talking about not checking has_duplicated_function
for this PR or after the other PR
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.
When has_duplicated_function=true, I suggest add something like .
My first comment had trail off. I meant when has_duplicated_function=true, add "." or something like that.
if (has_duplicated_function) { | ||
SourceRange r = frame.second; | ||
if (r.source()) { | ||
if (auto orig = r.source()->findSourceRangeThatGenerated(r)) { | ||
r = *orig; | ||
} | ||
} | ||
if (auto file_line_col = r.file_line_col()) { | ||
std::string filename; | ||
size_t line, col; | ||
std::tie(filename, line, col) = *file_line_col; | ||
scopeString += "(" + filename + ":" + c10::to_string(line) + ":" + c10::to_string(col) + ")"; | ||
} | ||
} |
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.
Not clear to me why we should do this? If we decide that this might help, then it is probably best to split it out into a helper function with comments and fn name that suggests what it will do.
But let's first clarify what does this do.
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.
That was for adding source range info in the case of a scripted module, as @ZolotukhinM suggested before. But I think I'm gonna remove it now as we decided not to do things differently for the two types of modules.
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.
Make it a separate function in that case, atleast, till we resolve it.
|
||
visitBlock(graph->block()); | ||
if (has_duplicated_function) { | ||
std::cout << "WARNING: There are some duplicated module instances." << std::endl; |
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 is not clear. Maybe say your module seems to have two instances of the same type. Current debugging does not support distinguishing the two instances of the same type yet. Thus debugging information maybe incomplete. Or something to the effect.
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.
Yes, I'll fix that. One small question: Since it's a warning, is it ok to directly print it directly to std::cout
like 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.
Good question. I missed this. I think there is something like TORCH_WARN
or torch_debug soemthing. I will have to check.
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
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 is really good Tai. Thanks for making this change.
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
py::arg("filename"), | ||
py::arg("_extra_files") = ExtraFilesMap()) | ||
py::arg("_extra_files") = ExtraFilesMap(), | ||
py::arg("_save_debug_info_in_bytecode") = false) |
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.
Is this covered by tests from Python side? The tests could be added in test/mobile/test_lite_script_module.py.
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 added Python tests. Since we have no access to the internal C++ object, I basically check if the outputs still match when we enable debug info saving and if module info strings are contained in the debug info buffer. Let me know if that suffices.
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
Differential Revision: [D22803740](https://our.internmc.facebook.com/intern/diff/D22803740) [ghstack-poisoned]
@taivu1998 merged this pull request in ccd9f32. |
Stack from ghstack:
Differential Revision: D22803740