@@ -737,6 +737,7 @@ def transform(
737737 )
738738
739739 try :
740+ tracer .output .mark_bytecode_tracing_start ()
740741 with tracing (tracer .output .tracing_context ), tracer .set_current_tx ():
741742 tracer .run ()
742743 except exc .UnspecializeRestartAnalysis :
@@ -810,7 +811,10 @@ def log_bytecode(
810811 for attempt in itertools .count ():
811812 CompileContext .get ().attempt = attempt
812813 try :
813- out_code = transform_code_object (code , transform )
814+ with dynamo_timed (
815+ f"compile_attempt_{ attempt } " , log_pt2_compile_event = True
816+ ):
817+ out_code = transform_code_object (code , transform )
814818 break
815819 except exc .RestartAnalysis as e :
816820 if not isinstance (e , exc .TensorifyScalarRestartAnalysis ):
@@ -919,13 +923,14 @@ def count_args(code: CodeType) -> int:
919923 assert output .guards is not None
920924 CleanupManager .instance [out_code ] = output .cleanups
921925 nonlocal cache_entry
922- check_fn = CheckFunctionManager (
923- code ,
924- output ,
925- cache_entry ,
926- hooks .guard_fail_fn if hooks else None ,
927- hooks .guard_filter_fn if hooks else None ,
928- )
926+ with dynamo_timed ("build_guards" , log_pt2_compile_event = True ):
927+ check_fn = CheckFunctionManager (
928+ code ,
929+ output ,
930+ cache_entry ,
931+ hooks .guard_fail_fn if hooks else None ,
932+ hooks .guard_filter_fn if hooks else None ,
933+ )
929934
930935 compile_id_str = str (compile_id ) if compile_id is not None else "Unknown"
931936 annotation_str = "Torch-Compiled Region: " + compile_id_str
0 commit comments