MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward_step

Function forward_step

sat/train_video.py:191–215  ·  view source on GitHub ↗
(data_iterator, model, args, timers, data_class=None)

Source from the content-addressed store, hash-verified

189
190
191def 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
218if __name__ == "__main__":

Callers

nothing calls this directly

Calls 8

broad_cast_batchFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
existsMethod · 0.80
saveMethod · 0.80
shared_stepMethod · 0.80
loadMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected