(self, train_batch_size, drop_last)
| 27 | world_size = 1 |
| 28 | |
| 29 | def test(self, train_batch_size, drop_last): |
| 30 | config_dict = {"train_batch_size": train_batch_size, "dataloader_drop_last": drop_last, "steps_per_print": 1} |
| 31 | hidden_dim = 10 |
| 32 | |
| 33 | model = SimpleModel(hidden_dim) |
| 34 | optimizer = torch.optim.AdamW(params=model.parameters()) |
| 35 | # TODO: no way to set DeepSpeedEngine.deepspeed_io params, need to use |
| 36 | # pin_memory=False for cuda device |
| 37 | train_dataset = random_dataset(total_samples=50, |
| 38 | hidden_dim=hidden_dim, |
| 39 | device=torch.device('cpu'), |
| 40 | dtype=torch.float32) |
| 41 | model, _, training_dataloader, _ = deepspeed.initialize(config=config_dict, |
| 42 | model=model, |
| 43 | training_data=train_dataset, |
| 44 | optimizer=optimizer) |
| 45 | training_dataloader.num_local_io_workers = 0 # We can't do nested mp.pool |
| 46 | for n, batch in enumerate(training_dataloader): |
| 47 | x = batch[0].to(get_accelerator().current_device_name()) |
| 48 | y = batch[1].to(get_accelerator().current_device_name()) |
| 49 | loss = model(x, y) |
| 50 | model.backward(loss) |
| 51 | model.step() |
nothing calls this directly
no test coverage detected