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

more efficient use of memory buffers for LN recomputation #532

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

ngc92
Copy link
Contributor

@ngc92 ngc92 commented Jun 3, 2024

saves another ~300MiB for B=64 with the 774M model.

We just use a single buffer lnf for all layernorm computations. This works fine, except that we already were repurposing that in the backward pass :)

So in backward, we now instead reuse the last residual connection result instead (which is of the same size), which is also no longer needed after computing the gradient of lnf.

@karpathy karpathy merged commit d17893b into karpathy:master Jun 3, 2024
8 checks passed
@ngc92 ngc92 deleted the ln-buffers branch June 3, 2024 21:18
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

Successfully merging this pull request may close these issues.

2 participants