-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Why avoid gradient accumulation? #69
Comments
A lot of architecture have BN layers which don't work properly unless actually backprogated through, I think. |
Interesting? What is BN? Bias?
When you say "a lot of", does that include Llama 2 and 3 type models?
Basically you're saying that accumulating the gradients isn't enough, some
important info is thrown away once you move to the next forward pass?
…On Tue, Jun 11, 2024 at 4:44 PM Dimitris Mantas ***@***.***> wrote:
A lot of architecture have BN layers which don't work properly unless
actually backprogated through, I think.
—
Reply to this email directly, view it on GitHub
<#69 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASVG6CXHG4UBKV6Z5HC4L2DZG5OSVAVCNFSM6AAAAABIRBGLXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRGU3TIMBWGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Batch normalization. Essentially, BN blocks keep track of the running batch mean and standard deviation and use them to normalize their inputs. These parameters are non-trainable and are updated with each minibatch the blocks receive. However, because the total number of batches per epoch is not the same as that of backpropagations when using gradient accumulation, BN blocks now compute "incorrect" statistics. This problem is further magnified by their other parameters still being updated according to accumulated batches. Basically, batches and their descriptive statistics become “unsynchronized”. BN blocks are very popular in computer vision tasks, and unfortunately, I’m not too familiar with much else. However, I believe that transformer blocks use typically use layer normalization blocks which do not depend on batch size, so you should be safe. |
By the way, large batch sizes are just as "dangerous" as small ones due to potential overmoothing of the gradient landscape. It's kind of a "pick your poison" situation. |
Thanks yeah agreed on the problems at big batches.
And yeah that makes sense re ga and batch norm. Llama 2 and 3 are layer
norm so should be fine but good to know for multi model models - I need to
check if clip has batch norm.
…On Tue 11 Jun 2024 at 18:31, Dimitris Mantas ***@***.***> wrote:
By the way, large batch sizes are just as "dangerous" as small ones due to
potential overmoothing of the gradient landscape. It's kind of a "pick your
poison" situation.
—
Reply to this email directly, view it on GitHub
<#69 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASVG6CUBGN5YHYUUFXQHODDZG53CZAVCNFSM6AAAAABIRBGLXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRG4YDQNZSGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There is this quote:
For large GPUs and multi-GPU setups, I can see this making sense, as you can run batches of 32 and don't need accumulation.
Am I mistaken or missing something?
But, on smaller GPUs, grad accum can be important because it provides averaging in the virtual batches that stabilises the training.
The text was updated successfully, but these errors were encountered: