DeepSpeed
Зеркало из https://github.com/microsoft/DeepSpeed
1# Copyright (c) Microsoft Corporation.
2# SPDX-License-Identifier: Apache-2.0
3
4# DeepSpeed Team
5
6from deepspeed.runtime.config_utils import DeepSpeedConfigModel
7
8#########################################
9# Timers
10#########################################
11# Timers. By default, timers are enabled.
12# Users can configure in ds_config.json as below example:
13TIMERS_FORMAT = '''
14Timers should be enabled as:
15"timers": {
16"throughput": {
17"enabled": true,
18"synchronized": true
19}
20}
21'''
22
23TIMERS = "timers"
24TIMERS_THROUGHPUT = "throughput"
25
26
27def get_timers_config(param_dict):
28if param_dict and TIMERS in param_dict and TIMERS_THROUGHPUT in param_dict[TIMERS]:
29timers_config_dict = param_dict[TIMERS][TIMERS_THROUGHPUT]
30else:
31timers_config_dict = {}
32return DeepSpeedThroughputTimerConfig(**timers_config_dict)
33
34
35class DeepSpeedThroughputTimerConfig(DeepSpeedConfigModel):
36""" Configure throughput timers """
37
38enabled: bool = True
39""" Turn on/off throughput timers """
40
41synchronized: bool = True
42""" Whether to synchronize a device when measuring the time.
43Synchronizing a device is required to produce the most accurate timer measurements.
44However, this comes at the expense of performance degradation. The CPU timer provides
45sufficient accuracy in many cases.
46"""
47