@@ -327,24 +327,27 @@ void DebugUtil::analyze_graph_execution_python_frame(
327
327
} else if (frames[0 ].function == " mark_step" ||
328
328
(frames[0 ].function == " sync" &&
329
329
endsWith (frames[0 ].file , " torch_xla.py" ))) {
330
- if (frames[1 ].function == " next" &&
331
- endsWith (frames[1 ].file , " parallel_loader.py" )) {
330
+ bool called_by_sync =
331
+ frames[0 ].function == " mark_step" && frames[1 ].function == " sync" ;
332
+ int i = called_by_sync ? 2 : 1 ;
333
+ if (frames[i].function == " next" &&
334
+ endsWith (frames[i].file , " parallel_loader.py" )) {
332
335
ss << debug_output_prefix
333
336
<< " mark_step in parallel loader at step end\n " ;
334
- } else if (frames[1 ].function == " __exit__" &&
335
- endsWith (frames[1 ].file , " profiler.py" )) {
337
+ } else if (frames[i ].function == " __exit__" &&
338
+ endsWith (frames[i ].file , " profiler.py" )) {
336
339
ss << debug_output_prefix
337
340
<< " mark_step when exiting a profiler StepTrace region\n " ;
338
- } else if ((frames[1 ].function == " extract_compiled_graph_helper" ||
339
- frames[1 ].function == " extract_internal" ) &&
340
- endsWith (frames[1 ].file , " dynamo_bridge.py" )) {
341
+ } else if ((frames[i ].function == " extract_compiled_graph_helper" ||
342
+ frames[i ].function == " extract_internal" ) &&
343
+ endsWith (frames[i ].file , " dynamo_bridge.py" )) {
341
344
ss << debug_output_prefix
342
345
<< " mark_step when dynamo processing input graphs\n " ;
343
- } else if (frames[1 ].function == " _compile" &&
344
- endsWith (frames[1 ].file , " torch_xla.py" )) {
346
+ } else if (frames[i ].function == " _compile" &&
347
+ endsWith (frames[i ].file , " torch_xla.py" )) {
345
348
ss << debug_output_prefix << " torch_xla.compile\n " ;
346
- } else if (frames[1 ].function == " _clear_pending_ops_before_compile" &&
347
- endsWith (frames[1 ].file , " torch_xla.py" )) {
349
+ } else if (frames[i ].function == " _clear_pending_ops_before_compile" &&
350
+ endsWith (frames[i ].file , " torch_xla.py" )) {
348
351
ss << debug_output_prefix
349
352
<< " torch_xla.compile clear the pending graph prior calling the "
350
353
" target function\n " ;
0 commit comments