diff --git a/torch/_dynamo/convert_frame.py b/torch/_dynamo/convert_frame.py index c1740f41505..62a42d2b5d3 100644 --- a/torch/_dynamo/convert_frame.py +++ b/torch/_dynamo/convert_frame.py @@ -27,7 +27,7 @@ import torch import torch._logging from torch._guards import compile_context, CompileContext, CompileId, tracing from torch._logging import structured -from torch._utils_internal import signpost_event +from torch._utils_internal import compiletime_sl_profile_meta, signpost_event from torch.fx.experimental.symbolic_shapes import ( ConstraintViolationError, GuardOnDataDependentSymNode, @@ -441,6 +441,7 @@ def register_bytecode_hook(hook: BytecodeHook) -> RemovableHandle: return handle +@compiletime_sl_profile_meta(phase_name="_compile") @_use_lazy_graph_module(config.use_lazy_graph_module) @maybe_cprofile def _compile( diff --git a/torch/_inductor/compile_fx.py b/torch/_inductor/compile_fx.py index 25f7b2978aa..d03d231b44c 100644 --- a/torch/_inductor/compile_fx.py +++ b/torch/_inductor/compile_fx.py @@ -46,7 +46,7 @@ from torch._inductor.utils import BoxedBool, count_tangents from torch._logging import trace_structured from torch._ops import OpOverload from torch._subclasses.fake_tensor import FakeTensor -from torch._utils_internal import signpost_event +from torch._utils_internal import compiletime_sl_profile_meta, signpost_event from torch.fx.experimental.symbolic_shapes import free_unbacked_symbols from torch.fx.passes.fake_tensor_prop import FakeTensorProp @@ -1339,6 +1339,7 @@ def compile_fx( graph, joint_inputs, **kwargs, compiler="inductor" ) + @compiletime_sl_profile_meta(phase_name="bw_compiler") @dynamo_utils.dynamo_timed @dynamo_utils.maybe_cprofile def bw_compiler(model: torch.fx.GraphModule, example_inputs: List[torch.Tensor]): diff --git a/torch/_utils_internal.py b/torch/_utils_internal.py index 69849208814..8cf4b1826a6 100644 --- a/torch/_utils_internal.py +++ b/torch/_utils_internal.py @@ -62,6 +62,18 @@ def throw_abstract_impl_not_imported_error(opname, module, context): ) +# Meta only, act as nop otherwise. +def compiletime_sl_profile_meta(phase_name): + def compiletime_sl_profile_inner(function): + @functools.wraps(function) + def wrapper_function(*args, **kwargs): + return function(*args, **kwargs) + + return wrapper_function + + return compiletime_sl_profile_inner + + # Meta only, see # https://www.internalfb.com/intern/wiki/ML_Workflow_Observability/User_Guides/Adding_instrumentation_to_your_code/ #