deepspeedai / deepspeedai/DeepSpeed
[REQUEST] dynamic batch size with gradient accumulate
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Is your feature request related to a problem? Please describe.
my truly minimal use case request: I have 2 datasets with resolutions 256 and 512, I want to build 2 dataloaders, one dataloader load
256x256 images with batch size 8, one load 512x512 images batch size 2.
it comes to a conflict with the note in the documentation:
Note: train_batch_size must be equal to train_micro_batch_size_per_gpu * gradient_accumulation_steps * number of GPUs. For simplicity, you can choose to only specify two of the three parameters, the last one will be inferred automatically by DeepSpeed.
so how to decide the train_micro_batch_size_per_gpu?
that is comes to a grounding problem: how deepspeed process gradient accumulation?
- judge the forward access of the model, no matter the batch size is what, the gradient accumulation is logical right
- judge the instance number, namely the number of data instances go through the model, such as if instances reaches to 32 to perform optimization, so for 512x512 and 256X256 data, the forward times will be different, and cause a logical promblem with mixed batch size training.
Describe the solution you'd like
- describe how deepspeed process gradient accumulation in the document
- it is better to judge the forward access of the model to perform gradient accumulation
- unlock the limitation of train_batch_size must be equal to train_micro_batch_size_per_gpu * gradient_accumulation_steps * number of GPUs
thank you for your great work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start with the documented train_batch_size, train_micro_batch_size_per_gpu, and gradient_accumulation_steps relationship, then trace how gradient accumulation is defined for mixed-resolution dataloaders. Done would require an agreed behavior and documentation or implementation that addresses variable batch sizes across the requested loaders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100