Update all metrics in `self.state` by iterating through special positional arguments & kwargs.
(
self, *, global_step: Optional[int] = None, lr: Optional[float] = None, update_step_time: bool = False, **kwargs
)
| 150 | return f"=>> [Global Step] {self.global_step:06d} =>> LR :: {lr:.6f} -- Loss :: {loss:.4f}" |
| 151 | |
| 152 | def commit( |
| 153 | self, *, global_step: Optional[int] = None, lr: Optional[float] = None, update_step_time: bool = False, **kwargs |
| 154 | ) -> None: |
| 155 | """Update all metrics in `self.state` by iterating through special positional arguments & kwargs.""" |
| 156 | if global_step is not None: |
| 157 | self.global_step = global_step |
| 158 | |
| 159 | # For all other variables --> only track on rank zero! |
| 160 | if not overwatch.is_rank_zero(): |
| 161 | return |
| 162 | |
| 163 | # Special Positional Arguments |
| 164 | if lr is not None: |
| 165 | self.state["lr"].append(lr) |
| 166 | |
| 167 | if update_step_time: |
| 168 | self.state["step_time"].append(time.time() - self.step_start_time) |
| 169 | self.step_start_time = time.time() |
| 170 | |
| 171 | # Generic Keyword Arguments |
| 172 | for key, value in kwargs.items(): |
| 173 | if key == "loss": |
| 174 | loss_val = value.detach() |
| 175 | self.state["loss_raw"].append(loss_val) |
| 176 | self.state["loss"].append(loss_val) |
| 177 | else: |
| 178 | self.state[key].append(value.detach()) |
| 179 | |
| 180 | @overwatch.rank_zero_only |
| 181 | def push(self) -> str: |
no test coverage detected