When using DeepSpeed why do I need to pass dataloaders to the `accelerator.prepare`?
If we don’t pass dataloaders toaccelerator.prepare, we get an error from thisline:You must specify a training or evaluation dataloader inaccelerate.prepare()when using DeepSpeed.Based on my limited understanding from reading the code, it looks like the dataloader is needed to figure out the batch size per device. I didn’t see any other direct relation of DeepSpeed w.r.t. to preparing the dataloader.In my case, I don’t want accelerate to prepare the dataloader for me as I am handing distributed process and per worker sharding myself. Would it be reasonable to adjust prepare to accept an optional batch size argument directly so as not to enforce the passing of the dataloader to prepare or maybe I am missing a deeper detail in the code/logic?
2022-09-02T13:58:10Z
Hello@aps, yes, you are correct. The logic behind the current setup is that the conventional training would involve preparing dataloaders and we fill relevant DeepSpeed config params from it. As for the use case you have described, the current workaround would be to pass a dummy dataloader withbatch_sizefilled in which should mimic just passing thebatch_sizearg directly topreparecall.A cleaner approach would be to skip this part iftrain_micro_batch_size_per_gpuis provided inconfig_filewhen usingDEEPSPEED_CONFIG_FILEsupport. Let me know if that would solve the issue. If so, please raise a feature Request on repo.
2022-09-03T06:49:52Z
PR/deepspeed enhancements and fixes by pacman100 · Pull Request #676 · huggingface/accelerate (github.com)skips this dataloader requirement whentrain_micro_batch_size_per_gpuis specified in the deepspeed config file when using config_file support.