Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which global batch size? #3

Open
cerisara opened this issue Mar 27, 2024 · 0 comments
Open

Which global batch size? #3

cerisara opened this issue Mar 27, 2024 · 0 comments

Comments

@cerisara
Copy link
Member

cerisara commented Mar 27, 2024

Gradient accumulation is an important parameter to tune to find the best compromise between throughput and convergence speed:

  • small batch: bad throughput because of internodes latency, but "faster" SGD
  • large batch: high throughput but slower SGD

Llama2 uses 4M tokens for pretraining == 4096 x 1000
GPT3 uses 250k tokens
My script uses initially 1024x256 = 260k tokens, or 2048x256 = 500k tokens

See figure 1 from https://arxiv.org/pdf/1812.06162.pdf

See tuning playbook from Google: https://github.com/google-research/tuning_playbook
==> batch size shall be tuned wrt speed, not performance, so they recommend using the largest possible batch size on the hardware! ==> this conclusion is true for the raw batch size, but when using gradient accumulation, it's more about finding the best compromise between convergence speed and throughput.

Global batchsize may be "ramp up", from 192 to 2048 (+16 every 9_765_625 samples): https://github.com/huggingface/llm_training_handbook/tree/main/hparams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant