Skip to navigation

aitune.torch.task.profiling.measuring_stop_strategy

View as MarkdownOpen in Claude

Measuring stop strategies for profiling.

Module Contents

Classes

NameDescription
MeasuringStopStrategyStrategy when to stop collecting measurements for given batch size.
NumStepsMeasuringStopStrategyStrategy to stop collecting measurements after a given number of steps.
StableWindowMeasuringStopStrategyStrategy to stop collecting measurements after a stable sliding window has been collected.

API

class aitune.torch.task.MeasuringStopStrategy()
Abstract

Strategy when to stop collecting measurements for given batch size.

aitune.torch.task.MeasuringStopStrategy.get_events(
abstract

Get events to use for measuring stop strategy.

aitune.torch.task.MeasuringStopStrategy.should_stop(
) -> bool
abstract

Check if the measurement should be stopped.

Parameters:

results
list[ProfilingResultEvent]

list[ ProfilingResultEvent ] — List of profiling results events for a one measurement.

Returns: bool

True if the measurement should be stopped, False otherwise.

class aitune.torch.task.NumStepsMeasuringStopStrategy(
num_steps: int = 20,
warmup_samples: int = 10
)

Bases: MeasuringStopStrategy

Strategy to stop collecting measurements after a given number of steps.

_min_samples_seen
= self.warmup_samples + self.num_steps
_samples_seen
= 0
aitune.torch.task.NumStepsMeasuringStopStrategy.get_events(

Get final measured events after should_stop() has returned True.

aitune.torch.task.NumStepsMeasuringStopStrategy.should_stop(
) -> bool

Check if the measurement should be stopped.

class aitune.torch.task.StableWindowMeasuringStopStrategy(
window_size: int = 20,
max_cv_ratio: float = 0.1,
warmup_samples: int = 10,
max_samples: int = 100
)

Bases: MeasuringStopStrategy

Strategy to stop collecting measurements after a stable sliding window has been collected.

_max_samples_seen
= self.max_samples + self.warmup_samples
_min_samples_seen
= self.window_size + self.warmup_samples
_samples_seen
= 0
_window
list[ProfilingResultEvent] = []
aitune.torch.task.StableWindowMeasuringStopStrategy.get_events(

Get events to use for measuring stop strategy.

aitune.torch.task.StableWindowMeasuringStopStrategy.should_stop(
) -> bool

Check if the measurement should be stopped.