IterationTimer#
- class IterationTimer(warmup_iter=1)[source]#
Bases:
HookBaseMeasure data/batch latency and append timing and ETA to iteration logs.
Times each training iteration and feeds the results into
trainer.storageand the per-iteration log string. Inbefore_stepit recordsdata_time(time spent waiting for the batch); inafter_stepit recordsbatch_time(full iteration), decrements the remaining- iteration counter, and appendsData,Batch, andRemain(ETA, computed from the running average batch time) tocomm_info["iter_info"]. The remaining-iteration budget is initialized inbefore_trainand the per-iteration timer is reset inbefore_epoch. Registered asIterationTimer.- Parameters:
warmup_iter (int) – Number of initial iterations whose timing is reset (excluded from the running averages) so startup/compile overhead does not skew ETA. Defaults to
1.
Example
Add to
cfg.hooks; it times each iteration and feeds the timing intotrainer.storageand the per-step log line:hooks = [dict(type="IterationTimer", warmup_iter=2)] # → puts scalars "data_time" (before_step) and "batch_time" (after_step) # into trainer.storage and appends "Data … Batch … Remain HH:MM:SS" # (ETA) to comm_info["iter_info"]; the first 2 iters reset the averages