# Interactively explore what torch.compile does to your code!

**URL:** <https://dev-discuss.pytorch.org/t/interactively-explore-what-torch-compile-does-to-your-code/1576>\
**Category:** compiler\
**Created:** [October 15, 2023, 12:01pm UTC](https://dev-discuss.pytorch.org/t/interactively-explore-what-torch-compile-does-to-your-code/1576 "2023-10-15T12:01:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![youkaichao](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/youkaichao/32/1278_2.png) [@youkaichao](https://dev-discuss.pytorch.org/u/youkaichao)\
**Post date:** [October 15, 2023, 12:01pm UTC](https://dev-discuss.pytorch.org/t/interactively-explore-what-torch-compile-does-to-your-code/1576/1 "2023-10-15T12:01:12Z")

</div>

`torch.compile` dynamically translates your python code into modified bytecode, and it is rather difficult to precisely understand what the modified bytecode does.

To help (me) understand what `torch.compile` does to the original code, I created a [jupyter notebook](https://github.com/youkaichao/depyf/blob/master/explain_pt2.ipynb) together with a bytecode decompiler `depyf`. And it supports you to interactively explore what torch.compile does to your code!

Some screenshots:

You can see guarding conditions:

 ![guards](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/d/ddb2702559cc1f71760ee889c7063f46cc008a09.png)

You can see compiled code:

 ![compiled_code](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/9/9b21274baf94088871d35f579171893eb2de4411.png)

You can see compiled subgraph:

 ![compiled_subgraph](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/9/96d428eaedc501ae62c5cd456922cef9b3b1f6b8.png)

You can see other referenced functions, like `resume` functions:

 ![referenced_func](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/f/f644d18b9e2378a45c7473dd2e8a5ca117d63856.png)

Explore anything you like!
