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

LM Head FLOPs #78

Open
Muennighoff opened this issue Sep 28, 2023 · 2 comments
Open

LM Head FLOPs #78

Muennighoff opened this issue Sep 28, 2023 · 2 comments

Comments

@Muennighoff
Copy link

Muennighoff commented Sep 28, 2023

Why are we not multiplying the LM Head flops per iteration with the checkpoint_activations_factor?

flops_per_iteration += (6 * batch_size * seq_len * num_layers * (hidden_size**2)) * (vocab_size / (num_layers * hidden_size))

Afaik the factor of 4 means 1 forward, 2 backward & 1 forward, where the last forward is needed for ckpt acts. Don't we also need all 4 for the LM Head? cc @RaymondLi0 @NouamaneTazi

@NouamaneTazi
Copy link

In selective recomputation, we only checkpoint attention, so it shouldnt affect LM Head
In full recomputation, we assume that the last hidden_states are the LM Head activs, so no need for recomputing them

hidden_states = self._checkpointed_forward(hidden_states,

@Muennighoff
Copy link
Author

In selective recomputation, we only checkpoint attention, so it shouldnt affect LM Head In full recomputation, we assume that the last hidden_states are the LM Head activs, so no need for recomputing them

hidden_states = self._checkpointed_forward(hidden_states,

I see but then don't we at least need to multiply it by 3 to account for the backward pass?

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

2 participants