(data_iterator, model, args, timers, data_class=None)
| 189 | |
| 190 | |
| 191 | def forward_step(data_iterator, model, args, timers, data_class=None): |
| 192 | if mpu.get_model_parallel_rank() == 0: |
| 193 | timers("data loader").start() |
| 194 | batch = next(data_iterator) |
| 195 | timers("data loader").stop() |
| 196 | for key in batch: |
| 197 | if isinstance(batch[key], torch.Tensor): |
| 198 | batch[key] = batch[key].cuda() |
| 199 | |
| 200 | if torch.distributed.get_rank() == 0: |
| 201 | if not os.path.exists(os.path.join(args.save, "training_config.yaml")): |
| 202 | configs = [OmegaConf.load(cfg) for cfg in args.base] |
| 203 | config = OmegaConf.merge(*configs) |
| 204 | os.makedirs(args.save, exist_ok=True) |
| 205 | OmegaConf.save(config=config, f=os.path.join(args.save, "training_config.yaml")) |
| 206 | else: |
| 207 | batch = {"mp4": None, "fps": None, "num_frames": None, "txt": None} |
| 208 | |
| 209 | batch["global_step"] = args.iteration |
| 210 | |
| 211 | broad_cast_batch(batch) |
| 212 | |
| 213 | loss, loss_dict = model.shared_step(batch) |
| 214 | |
| 215 | return loss, loss_dict |
| 216 | |
| 217 | |
| 218 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected