Practical overview
When it fits
Use Depyf when a PyTorch workload already uses torch.compile and you need to inspect its generated code or trace compiler output in a debugger.
Who it is for
- PyTorch developers investigating how torch.compile transforms their code.
- Machine-learning researchers examining compiler graphs, bytecode or generated kernels.
- Developers adapting or debugging workloads that use torch.compile.
Documented uses
- Write compiler artifacts to a directory for inspection.
- Review transformed Python code, bytecode, graph representations and compiled function files.
- Use a debugger to step through generated files.
- Investigate compiler behavior while adapting PyTorch code.
Requirements & limits
The project is distributed as Python software through pip and its public GitHub repository. The repository lists an MIT license.
- The README recommends PyTorch 2.2.0 or newer, with PyTorch nightly recommended.
- The repository lists Python versions 3.7 through 3.11.
- Dumped bytecode may need additional imported modules, including transformers, to load.
- Depyf’s output includes artifacts from multiple compiler stages, such as AOTAutograd graphs and Inductor kernel wrappers.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Save torch.compile artifacts for inspection
Capture generated compiler details in a directory using Depyf’s documented context manager.
Before you start
- Python 3.7–3.11, as listed in the repository README.
- PyTorch 2.2.0 or newer; PyTorch nightly is recommended.
- Depyf installed with pip.
- A Python program containing code compiled with torch.compile.
Steps
Install the stable package with the command below, or use the documented nightly install command from the repository.
pip install depyfImport depyf in the program and wrap the function-running code in
with depyf.prepare_debug("./dump_src_dir"):, as shown in the README.Run the program and inspect the generated files in
./dump_src_dir.
Expected outcome
The directory can contain transformed Python code, bytecode, computation graphs and compiled function artifacts for torch.compile functions.
Guide limitations
- The project recommends PyTorch 2.2.0 or newer and prefers PyTorch nightly.
- Loading a dumped bytecode file may import modules such as transformers; install any required modules before loading it.
- The README advises using the latest documentation for usage guidance.
Step through generated files with a debugger
Use Depyf’s documented debug context manager to set breakpoints in generated compilation files.
Before you start
- Depyf, PyTorch 2.2.0 or newer, and a program using torch.compile.
- A debugger used to launch the program.
Steps
Wrap the code to be inspected in
with depyf.prepare_debug("./dump_src_dir"):and run it to create the compilation files.Wrap the code to debug in
with depyf.debug():.Launch the script through a debugger and set breakpoints in the generated files under the chosen output directory.
Expected outcome
Depyf pauses the program for breakpoint setup, allowing the debugger to step through generated compilation files.
Guide limitations
- The repository recommends PyTorch 2.2.0 or newer and says PyTorch nightly is recommended.
- The README’s example uses both context managers and a debugger; it does not specify debugger products or configuration.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 6 November 2026
- Original website title
- thuml/depyf · Official homepage title · retained in its source language

