composer.profiler.profiler#

Composer Profiler.

Classes

Profiler

Composer Profiler.

class composer.profiler.profiler.Profiler(state, schedule, trace_handlers)[source]#

Composer Profiler.

See the Profiling Guide for additional information.

Note

The Trainer creates an instance of this Profiler class when prof_trace_handlers and prof_schedule are provided. When using the Composer Trainer, one does not need to directly create an instance of this Profiler class.

Parameters
  • state (State) โ€“ The training state.

  • schedule ((State) -> ProfilerAction) โ€“

    The profiling scheduling function.

    It takes the training state and returns a ProfilerAction.

  • trace_handlers (TraceHandler | Sequence[TraceHandler]) โ€“ Trace handlers which record and save profiling data to traces.

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
  • name (str) โ€“ The name for the Marker.

  • actions (Sequence[ProfilerAction], optional) โ€“ ProfilerAction states to record on. Defaults to (WARMUP, ACTIVE, ACTIVE_AND_SAVE).

  • record_instant_on_start (bool, optional) โ€“ Whether to record an instant event whenever the marker is started. Defaults to False.

  • record_instant_on_finish (bool, optional) โ€“ Whether to record an instant event whenever the marker is finished. Defaults to False.

  • categories (Union[List[str], Tuple[str, ...]], optional) โ€“ Categories for this marker. Defaults to None.

Returns

Marker โ€“ Marker instance.

record_chrome_json_trace_file(filepath)[source]#

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

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 the TorchProfiler). 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.