-
Notifications
You must be signed in to change notification settings - Fork 545
[WIP] Build C++ & Python tracing support for PyTorch/XLA ops #3348
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
base: master
Are you sure you want to change the base?
Conversation
…intercept and generate traces
Sample output of
|
@@ -0,0 +1,36 @@ | |||
import torch | |||
import torch_xla | |||
#torch_xla._XLAC._ltc_init_ts_backend() #TOREMOVE |
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.
please remove 😄
stack = traceback.format_list(stack) | ||
if (len(stack) > 1): | ||
second_frame = str(stack[-2]).replace( | ||
"/usr/local/google/home/miladmo/anaconda3/envs/pytorch1/bin/ipython", |
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.
If you have to hardcode the path, maybe use something like /tmp
instead of your home dir.
@@ -128,6 +130,15 @@ int64_t XLATensorImpl::size(int64_t d) const { | |||
} | |||
|
|||
void XLATensorImpl::SetupSizeProperties() { | |||
if (getPythonPrinter() && !disablePrinter()) { |
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.
so if I understand correctly, this will ensure that whenever tensor.size()
is called, we log the python frame and C++ frame if printer is set. I think it is a useful tool but I am not sure if it is a good idea for us to merge the change in this file into the master. I think it make a lot of sense of add the binding and documents, but this part to me feel like a debugging feature for developer.
Unless we are at a stage where we expect user to dump this info and do debugging, I felt like it might be better to leave this in a separate branch?
}; | ||
getPythonPrinter() = printer; | ||
}); | ||
m.def("_print_text", |
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.
what's the use of this function?
This PR is a software tool to enable tracing PyTorch/XLA ops at Python and C++ levels combined.
As an immediate use case, the
size
op is traced to showcase the approach. Understanding the utility ofsize
at a detailed level is an important aspect of supporting Dynamic Shape in PyTorch / XLA and in Lazy Tensor Core (LTC).