Logs the training throughput and utilization. +-------------------------------------+-----------------------------------------------------------+ | Key | Logged data | +=====================================+==
| 151 | |
| 152 | |
| 153 | class SpeedMonitorBase: |
| 154 | """Logs the training throughput and utilization. |
| 155 | |
| 156 | +-------------------------------------+-----------------------------------------------------------+ |
| 157 | | Key | Logged data | |
| 158 | +=====================================+===========================================================+ |
| 159 | | | Rolling average (over `window_size` most recent | |
| 160 | | `throughput/batches_per_sec` | batches) of the number of batches processed per second | |
| 161 | | | | |
| 162 | +-------------------------------------+-----------------------------------------------------------+ |
| 163 | | | Rolling average (over `window_size` most recent | |
| 164 | | `throughput/samples_per_sec` | batches) of the number of samples processed per second | |
| 165 | | | | |
| 166 | +-------------------------------------+-----------------------------------------------------------+ |
| 167 | | | Rolling average (over `window_size` most recent | |
| 168 | | `throughput/tokens_per_sec` | batches) of the number of tokens processed per second. | |
| 169 | | | This may include padding depending on dataset | |
| 170 | +-------------------------------------+-----------------------------------------------------------+ |
| 171 | | | Estimates flops by `flops_per_batch * batches_per_sec` | |
| 172 | | `throughput/flops_per_sec` | | |
| 173 | | | | |
| 174 | +-------------------------------------+-----------------------------------------------------------+ |
| 175 | | `throughput/device/batches_per_sec` | `throughput/batches_per_sec` divided by world size | |
| 176 | +-------------------------------------+-----------------------------------------------------------+ |
| 177 | | `throughput/device/samples_per_sec` | `throughput/samples_per_sec` divided by world size | |
| 178 | +-------------------------------------+-----------------------------------------------------------+ |
| 179 | | | `throughput/tokens_per_sec` divided by world size. This | |
| 180 | | `throughput/device/tokens_per_sec` | may include pad tokens depending on dataset | |
| 181 | | | | |
| 182 | +-------------------------------------+-----------------------------------------------------------+ |
| 183 | | | `throughput/flops_per_sec` divided by world size. Only | |
| 184 | | `throughput/device/flops_per_sec` | logged when model has attribute `flops_per_batch` | |
| 185 | | | | |
| 186 | +-------------------------------------+-----------------------------------------------------------+ |
| 187 | | | `throughput/device/flops_per_sec` divided by world size. | |
| 188 | | `throughput/device/mfu` | | |
| 189 | | | | |
| 190 | +-------------------------------------+-----------------------------------------------------------+ |
| 191 | | `time/train` | Total elapsed training time | |
| 192 | +-------------------------------------+-----------------------------------------------------------+ |
| 193 | | `time/val` | Total elapsed validation time | |
| 194 | +-------------------------------------+-----------------------------------------------------------+ |
| 195 | | `time/total` | Total elapsed time (time/train + time/val) | |
| 196 | +-------------------------------------+-----------------------------------------------------------+ |
| 197 | |
| 198 | Notes: |
| 199 | - The implementation assumes that devices are homogeneous as it normalizes by the world size. |
| 200 | - Tokens/sec, flops/sec and MFU do not account for padding tokens if present. We suggest using samples/sec or |
| 201 | batches/sec to measure throughput under this circumstance. |
| 202 | - Be careful when comparing MFU numbers across projects, as this will highly depend on the ``flops_per_batch``. |
| 203 | There is no widespread, realistic, and reliable implementation to compute them. |
| 204 | We suggest using our ``measure_flops`` function, but many other works will use ``estimated_flops`` which |
| 205 | will almost always be an overestimate when compared to the true value. |
| 206 | |
| 207 | Args: |
| 208 | window_size (int, optional): Number of batches to use for a rolling average of throughput. |
| 209 | Defaults to 100. |
| 210 | time_unit (str, optional): Time unit to use for `time` logging. Can be one of |