profile.profile
profile_recursive_module
def profile_recursive_module(func, enable_trace=False, *args, **kwargs)
Profile recursive module execution with CUDA NVTX tracing.
This function enables detailed performance profiling by wrapping the target function with NVTX range markers. When enable_trace is True, it pushes a new NVTX range for each function call and pops it on return, providing hierarchical profiling information.
Arguments:
func
Callable - Function to profileenable_trace
bool - Whether to enable NVTX tracing*args
- Variable length positional arguments for the target function**kwargs
- Arbitrary keyword arguments for the target function
Returns:
Any
- The result of the target function execution
Notes:
Requires torch.cuda.nvtx for tracing. Uses sys.settrace to monitor function calls.