Profiler (original) (raw)

Edit this page

Toggle table of contents sidebar

class composer.profiler.Profiler(schedule, trace_handlers, sys_prof_cpu=True, sys_prof_memory=False, sys_prof_disk=False, sys_prof_net=False, sys_prof_stats_thread_interval_seconds=0.5, torch_prof_folder='{run_name}/torch_traces', torch_prof_filename='rank{rank}.{batch}.pt.trace.json', torch_prof_remote_file_name='{run_name}/torch_traces/rank{rank}.{batch}.pt.trace.json', torch_prof_memory_filename=None, torch_prof_memory_remote_file_name='{run_name}/torch_memory_traces/rank{rank}.{batch}.pt.memory_trace.html', torch_prof_overwrite=False, torch_prof_use_gzip=False, torch_prof_record_shapes=False, torch_prof_profile_memory=True, torch_prof_with_stack=False, torch_prof_with_flops=True, torch_prof_num_traces_to_keep=- 1)[source]#

Composer Profiler.

See the Profiling Guide for additional information.

Parameters

bind_to_state(state)[source]#

Bind the profiler to the state.

Note

The Trainer automatically invokes this method.

Parameters

state (State) – The training state.

marker(name, actions=(<ProfilerAction.WARMUP: 'warmup'>, <ProfilerAction.ACTIVE: 'active'>, <ProfilerAction.ACTIVE_AND_SAVE: 'active_and_save'>), record_instant_on_start=False, record_instant_on_finish=False, categories=())[source]#

Create and get an instance of a Marker.

If a Marker with the specified name does not already exist, it will be created. Otherwise, the existing instance will be returned.

Note

Profiler.marker() should be used to construct markers. Marker should not be instantiated directly by the user.

For example:

marker = profiler.marker("foo") marker <composer.profiler.marker.Marker object at ...>

Please see Marker.start() and Marker.finish() for usage on creating markers to measure duration events,Marker.instant() for usage on creating markers to mark instant events and Marker.counter() for usage on creating markers for counting.

Parameters

Returns

Marker – Marker instance.

record_chrome_json_trace_file(filepath)[source]#

Record trace events in Chrome JSON format in the trace handlers.

See this documentfor more information about Chrome JSON format.

Note

For custom profiling, it is recommended to use marker() instead of manually creating a Chrome JSON trace file. By default, the Composer Profiler will automatically saving Marker events in Chrome JSON format.

This method exists for external profilers that natively record events in Chrome JSON format (such as theTorchProfiler). These profilers can use this method to route their profiling traces to the Composer profiler trace_handlers so events from both the Composer Profiler and external profilers are recorded in the same trace file.

property trace_handlers#

Profiler trace handlers.