Dynamo API
This section documents the PyTorch Dynamo integration for tracing compiled models.
Dynamo Class
Module Instance
The module provides a pre-configured dynamo instance:
from dftracer.python import dynamo
# Use the dynamo decorator
@dynamo.compile
def forward(self, x):
return x * 2
Constants
Internal Classes
CallStackRecord
Backend Functions
create_backend
The create_backend function creates a custom PyTorch compile backend with DFTracer instrumentation.
This allows you to use DFTracer directly with torch.compile().
Example:
from dftracer.python.dynamo import create_backend
import torch
# Create a backend with custom parameters
backend = create_backend(
name="my_model",
epoch=0,
step=0,
enable=True,
autograd=True
)
# Use with torch.compile
model = MyModel()
compiled_model = torch.compile(model, backend=backend)
Utility Functions
create_detailed_op_name
Usage Examples
See PyTorch Dynamo Integration for detailed usage examples and best practices.