You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
train_batch_size + dataset + actual batch size #62
Why we should pass the training_data to the deepspeed.initialize to generate a new trainloader rather than using a normal torch trainloader ?
Can we use a custom pytorch trainloader in case we have custom dataset that returns for example inputs, outputs and mask ?
If the actual batch size that is used to be passed to the model is different than the train_batch_size in the json file, what will happen ?
Can we just define gradient_accumulation_steps and train_micro_batch_size_per_gpu
only and leave deepspeed to calculate train_batch_size automatically ?
Reacted by Dheeraj Agrawal, Zijie Tian, Xingchen Song(宋星辰) and Jiachen Zhou
Passing training_data to deepspeed.initialize is optional, and not required. Some models can benefit from deepspeed's i/o optimizations. However, using torch trainloader is fine.
In our experience, deepspeed works well with custom trainloaders and datasets. So I suspect the answer to that is yes, but please share any issues you run into.
The train_batch_size in json file is used to perform gradient accumulation and compute progress statistics, so a mismatch could result in incorrect training and confusing statistics.
@tjruwase could you clarify - how does the parallelization work with a custom dataloader? Do you need to make sure the dataloader uses the local rank as input to load a separate portion of the dataset manually?
This is correct, it is the responsibility of the custom loader to load the appropriate dataset portion based on local rank (or whatever else the client finds appropriate) into GPU memory. DeepSpeed does not impose any restrictions on the custom dataloader, and does not perform any sanity checks.
Yes, batch_size should be equal to train_micro_batch_size_per_gpu, which is batch size for a single step on one gpu.
Assuming DatasetGenerator is returning the correct batch for each gpu, then this would be correct since the .to() is simply moving the data bits into gpu memory.
@tjruwase assuming I'm using some customer data loader as @agemagician above but in a multi-node, multi-gpu settings, how would I go about and send tensors to the right GPU? Do I still do tensor.to(engine.local_rank) or global_rank please? Thanks.
Activity
tjruwase commentedon Feb 11, 2020
Passing training_data to deepspeed.initialize is optional, and not required. Some models can benefit from deepspeed's i/o optimizations. However, using torch trainloader is fine.
In our experience, deepspeed works well with custom trainloaders and datasets. So I suspect the answer to that is yes, but please share any issues you run into.
The train_batch_size in json file is used to perform gradient accumulation and compute progress statistics, so a mismatch could result in incorrect training and confusing statistics.
Yes, this is supported.
msdejong commentedon Feb 11, 2020
@tjruwase could you clarify - how does the parallelization work with a custom dataloader? Do you need to make sure the dataloader uses the local rank as input to load a separate portion of the dataset manually?
tjruwase commentedon Feb 11, 2020
This is correct, it is the responsibility of the custom loader to load the appropriate dataset portion based on local rank (or whatever else the client finds appropriate) into GPU memory. DeepSpeed does not impose any restrictions on the custom dataloader, and does not perform any sanity checks.
Hope that clears things up.
agemagician commentedon Feb 11, 2020
@tjruwase Thanks for the clarification.
Just one more question.
Assuming I have a custom data generator like that:
Does this mean:
tjruwase commentedon Feb 11, 2020
Yes, batch_size should be equal to train_micro_batch_size_per_gpu, which is batch size for a single step on one gpu.
Assuming DatasetGenerator is returning the correct batch for each gpu, then this would be correct since the .to() is simply moving the data bits into gpu memory.
agemagician commentedon Feb 11, 2020
@tjruwase Thanks a lot that answers all my questions for now :)
updating deepspeed config for Sparse Transformer (deepspeedai#62)
PLD Client (deepspeedai#61) (deepspeedai#62)
update submodule sycl_kernels for new compiler 0630 fix (deepspeedai#62)
tnq177 commentedon Sep 21, 2022
@tjruwase assuming I'm using some customer data loader as @agemagician above but in a multi-node, multi-gpu settings, how would I go about and send tensors to the right GPU? Do I still do
tensor.to(engine.local_rank)orglobal_rankplease? Thanks.tjruwase commentedon Sep 21, 2022
@tnq177, I believe you want
local_rankas crossing node boundaries requires communication collectives, likebroadcast.Removed megatron-lm from requirements (deepspeedai#62)
fix(fp_quantizer): fix UB and negative shift warnings in fp_quantize_…
fix(fp_quantizer): fix UB and negative shift warnings in fp_quantize_…
fix(fp_quantizer): fix UB and negative shift warnings in fp_quantize_…
fix(fp_quantizer): fix UB and negative shift warnings in fp_quantize_…