That’s very detailed and helpful explanations!
Now I know that compiled functions are __compiled_fn_xxx
in globals()
, and I also see the __resume_at_xxx
for graph breaks.
After I use the C Extension rather than the C++ Extension, compilation goes smoothly. And the explanation of _PyEval_RequestCodeExtraIndex
is great! I used to wrongly think code->co_extra
stores additional data directly. Now I understand that it can store multiple data entries, via the use of index.
The indices used by pytorch (cache_entry_extra_index
and dynamic_frame_state_extra_index
) are private and cannot be accessed elsewhere. Would you like me to submit a pull request to add private APIs _debug_get_cache_entry
for debugging usage? I managed to extract the guards and modified bytecode from compiled function, which I find really useful to understand and check the captured code of torchdynamo! Exposing the API in python makes it much more easier to inspect and manipulate for in-depth development. Of course, I flaged the API by _debug
to indicate this is for debug only.