Giter VIP home page Giter VIP logo

Comments (4)

samyam avatar samyam commented on May 8, 2024 1

You can train a larger batch size in two ways:

  1. Use gradient accumulation. If you want to train a batch size of 32 but can only fit batch size of 4, you can use a micro_batch_per_gpu of size 4 and gradient_accumulation_step of 8. Was the original code using gradient accumulation? Are the batch sizes consistent between deepscale config file and the data loader you are using?

  2. Use activation check-pointing/re-materialization/re-computation. I assume this is what you mean by gradient check-pointing. With this you should be able to run a significantly larger batch size for the model you are describing.

What is the sequence length you are using, and what are your hidden dimensions?

Please take a look at the line 390-398 in the following file for example of activation checkpointing.

https://github.com/microsoft/DeepSpeedExamples/blob/07d1ce0d26044602a7b8bb289e590a980f14aded/Megatron-LM/mpu/transformer.py

image

from deepspeed.

agemagician avatar agemagician commented on May 8, 2024

Thanks @samyam for the feedback.

In the original code, I was using both gradient accumulation and activation check-pointing/re-materialization/re-computation.
The total batch size was: 32 batch size * 8 gradient accumulation * 6 GPUs
Input length: 1024
embedding dimensions: 768
hidden dimensions: 3072
Vocab: 22

The gradient accumulation is not an issue between my code and deepspeed code.
The batch size is consistent between my custom data loader and deepspeed config file.

The problem is in the activation check-pointing/re-materialization/re-computation. I assumed if I disabled it and activate deepspeed, I can get the same results. Apparently, this is not the case.

I will re-integrate gradient checkpoint and see if there is a benefit of using deepspeed in this case or not.

from deepspeed.

samyam avatar samyam commented on May 8, 2024

Yes, DeepSpeed does not do activation check-pointing automatically. You have to add that in the model. Please keep us posted on if this solves your issue

from deepspeed.

ShadenSmith avatar ShadenSmith commented on May 8, 2024

Closing the issue. Please let us know if there are further questions or issues!

from deepspeed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.