PyTorch Compiler
PyTorch Compiler

TORCH_COMPILE_DEBUG=1 python my_script.pyTORCH_COMPILE_DEBUG=1enables debug logging fortorch.compile, providing insights into the compilation process, optimizations applied, and any potential issues encountered during graph capture and execution.- Generated
triton kernelwill be available intorchinductor/model_*/output_code.pyfile. It’ll also have fx graphs saved intorchinductor/model_*/fx_graphs.pyfile, which can be used to understand the transformations applied to the original PyTorch code during compilation.
- we can also set logging options to control the verbosity and format of the debug output, such as:
import torch
torch._logging.set_logs(graph_code = True, graph_breaks = True)- for more details, check here.
torch._dynamo.reset()torch._dynamo.reset()is a function that resets the state of the PyTorch Dynamo compiler, clearing any cached compiled graphs and allowing for a fresh start in subsequent compilations. This can be useful when you want to ensure that changes to your code are reflected in the compiled output without interference from previously cached results.