Common API
Framework indepedent definitions and enumerations.
model_navigator.api.config.SizedIterable
model_navigator.api.config.SizedDataLoader = Union[SizedIterable, Sequence]
module-attribute
model_navigator.api.config.Format
model_navigator.api.config.CustomConfig
Base class used for custom configs. Input for Model Navigator optimize
method.
defaults()
from_dict(config_dict)
classmethod
model_navigator.api.config.CustomConfigForFormat
Bases: DataObject
, CustomConfig
Abstract base class used for custom configs representing particular format.
format: Format
property
abstractmethod
Format represented by CustomConfig.
model_navigator.api.config.Sample = Dict[str, numpy.ndarray]
module-attribute
model_navigator.api.config.VerifyFunction = Callable[[Iterable[Sample], Iterable[Sample]], bool]
module-attribute
model_navigator.api.ProfilerConfig
dataclass
Bases: DataObject
Profiler configuration.
For each batch size profiler will run measurments in windows. Depending on the measurement mode, each window will have fixed time length (MeasurementMode.TIME_WINDOWS) or fixed number of requests (MeasurementMode.COUNT_WINDOWS). Batch sizes are profiled in the ascending order.
Profiler will run multiple trials and will stop when the measurements
are stable (within stability_percentage
from the mean) within three consecutive windows.
If the measurements are not stable after max_trials
trials, the profiler will stop with an error.
Profiler will also stop profiling when the throughput does not increase at least by throughput_cutoff_threshold
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_profiling |
bool
|
If True, run profiling, otherwise skip profiling. |
True
|
batch_sizes |
Optional[List[Union[int, None]]]
|
List of batch sizes to profile. None means that the model does not support batching. |
None
|
measurement_mode |
MeasurementMode
|
Measurement mode. |
MeasurementMode.COUNT_WINDOWS
|
measurement_interval |
Optional[float]
|
Measurement interval in milliseconds. Used only in MeasurementMode.TIME_WINDOWS mode. |
5000
|
measurement_request_count |
Optional[int]
|
Number of requests to measure in each window. Used only in MeasurementMode.COUNT_WINDOWS mode. |
50
|
stability_percentage |
float
|
Allowed percentage of variation from the mean in three consecutive windows. |
10.0
|
max_trials |
int
|
Maximum number of window trials. |
10
|
throughput_cutoff_threshold |
float
|
Minimum throughput increase to continue profiling. |
DEFAULT_PROFILING_THROUGHPUT_CUTOFF_THRESHOLD
|
from_dict(profiler_config_dict)
classmethod
Instantiate ProfilerConfig class from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profiler_config_dict |
Mapping
|
Data dictionary. |
required |
Returns:
Type | Description |
---|---|
ProfilerConfig
|
ProfilerConfig |
Source code in model_navigator/api/config.py
model_navigator.api.MeasurementMode
Bases: Enum
Measurement mode.
TIME_WINDOWS
mode run measurement windows with fixed time length.
COUNT_WINDOWS
mode run measurement windows with fixed number of requests.