pytorch/test/profiler
Shivam Raikundalia f295eff512 [Profiler] Hide Kineto Step Tracker Behind Env Var (#144494)
Summary:
To support iteration-based on-demand we have step tracker hooks for both the scheduler and for the optimizer to control Kineto's backend FSM. We already hide the optimizer step tracker behind and ENV_VAR to prevent any extra overhead from the frontend profiler down to the kineto backend, but we don't do any such thing for the profiler step tracker. It also seems to cause errors occasionally in the FSM having both auto-trace and on-demand occurring at the same time.

To remedy this issue, lets put in a patch to guard the step incrementer for the frontend step function. This will bypass all of the on-demand logic which shouldn't occur in auto-trace

Test Plan:
Ran
`buck run mode/dev-nosan kineto/libkineto/fb/integration_tests:pytorch_resnet_integration_test -- --enable_profiling --trace_handler=auto_trace --with_stack` and added prints in on-demand functions (performLoopStep and collectTrace) and saw that neither were called even though they were called on main.

Also got following healthy traces:

Auto-Trace (schedule-based):
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree/traces/dynocli/devvm2185.cco0.facebook.com/rank-0.Jan_09_12_43_37.1122140.pt.trace.json.gz&bucket=gpu_traces

Timing Based On-demand:
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree/traces/dynocli/0/1736456722/localhost/libkineto_activities_1286261.json.gz&bucket=gpu_traces

Iteration Based On-demand:
https://www.internalfb.com/intern/perfdoctor/trace_view?filepath=tree/traces/dynocli/0/1736456889/localhost/libkineto_activities_1304781.json.gz&bucket=gpu_traces

Differential Revision: D67990080

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144494
Approved by: https://github.com/ngimel
2025-01-10 07:00:56 +00:00
..
profiler_utils_mock_events.json
test_cpp_thread.cpp
test_cpp_thread.py [profiler][UT] instantiate profiler UTs for devices and enable UTs for xpu profiler (#134316) 2024-11-05 05:46:13 +00:00
test_cpp_thread_lib.pyi
test_execution_trace.py [4/N] Apply py39 ruff and pyupgrade fixes (#143257) 2025-01-04 10:47:51 +00:00
test_kineto.py
test_memory_profiler.py [4/N] Apply py39 ruff and pyupgrade fixes (#143257) 2025-01-04 10:47:51 +00:00
test_profiler.py [Profiler] Hide Kineto Step Tracker Behind Env Var (#144494) 2025-01-10 07:00:56 +00:00
test_profiler_tree.py [ci, 3.13] disable segfaulting dynamo-wrapped profiler test (#141951) 2024-12-05 00:33:26 +00:00
test_record_function.py [4/N] Apply py39 ruff and pyupgrade fixes (#143257) 2025-01-04 10:47:51 +00:00
test_torch_tidy.py [4/N] Apply py39 ruff and pyupgrade fixes (#143257) 2025-01-04 10:47:51 +00:00