llmcompressor.metrics.utils.frequency_manager
FrequencyManager
Class for managing the frequency of logging and model updates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_frequency | LogStepType | The frequency to log at | None |
mode | LoggingModeType | The logging mode to use, either "on_change" or "exact", "on_change" will log when the model has been updated since the last log, "exact" will log at the given frequency regardless of model updates | DEFAULT_LOGGING_MODE |
frequency_type | FrequencyType | The frequency type to use, either "epoch", "step", or "batch" controls what the frequency manager is tracking, e.g. if the frequency type is "epoch", then the frequency manager will track the number of epochs that have passed since the last log, if the frequency type is "step", then the frequency manager will track the number of optimizer steps | DEFAULT_FREQUENCY_TYPE |
Source code in src/llmcompressor/metrics/utils/frequency_manager.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
is_epoch_frequency_manager
property
Returns:
Type | Description |
---|---|
bool | True if the frequency manager is tracking epochs, False otherwise |
is_optim_frequency_manager
property
Returns:
Type | Description |
---|---|
bool | True if the frequency manager is tracking optimizer steps, False otherwise |
log_frequency
property
writable
Returns:
Type | Description |
---|---|
LogStepType | The log frequency |
log_ready(current_log_step, check_model_update=False)
Check if the frequency manager is ready to log Conditions for readiness: - log frequency is not None - current log step is None - current log step greater than or equal to the last log step plus the log frequency - if check_model_update is True, or self._check_model_update is True, then the last model update step must be greater than or equal to the last log step, and the current log step must be greater than or equal to the last model update step plus the log frequency
Parameters:
Name | Type | Description | Default |
---|---|---|---|
current_log_step | LogStepType | The current log step | required |
check_model_update | bool | If True, will check if the model has been updated since the last log step and if _log_frequency steps have passed since the last model update; Defaults to False. | False |
Returns:
Type | Description |
---|---|
True if the frequency manager is ready to log, False otherwise |
Source code in src/llmcompressor/metrics/utils/frequency_manager.py
log_written(step=None)
Sets the last log step to the given step
:post-cond: The last log step is set to the given step
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step | LogStepType | The step to set the last log step to | None |
Source code in src/llmcompressor/metrics/utils/frequency_manager.py
model_updated(step=None)
Sets the last model update to the given step
:post-cond: The last model update step is set to the given step
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step | LogStepType | The step to set the last model update to | None |
Source code in src/llmcompressor/metrics/utils/frequency_manager.py
log_ready(current_log_step, last_log_step, log_frequency, last_model_update_step=None, check_model_update=False)
Check if we are ready to log again based on the given parameters (Stateless version of FrequencyManager().log_ready)
Conditions for readiness: - log frequency is not None - current log step is None - current log step greater than or equal to the last log step plus the log frequency - if check_model_update is True, then the last model update step must be greater than or equal to the last log step, and the current log step must be greater than or equal to the last model update step plus the log frequency
Parameters:
Name | Type | Description | Default |
---|---|---|---|
current_log_step | Optional[LogStepType] | The current log step | required |
last_log_step | Optional[LogStepType] | The last step at which logging occurred | required |
log_frequency | Optional[LogStepType] | The frequency to log at | required |
last_model_update_step | Optional[LogStepType] | The last step at which the model was updated | None |
check_model_update | bool | If True, will check if the model has been updated since the last log step and if log_frequency steps have passed since the last model update; Defaults to False. | False |
Returns:
Type | Description |
---|---|
True if logging cadence has been reached again False otherwise |