-
Notifications
You must be signed in to change notification settings - Fork 33
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
Loss disagreement between TP=1 and TP=2 #631
base: main
Are you sure you want to change the base?
Conversation
❌ 31 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
# embedding_activation_buffer=self.embedding_activation_buffer, | ||
# grad_output_buffer=self.grad_output_buffer, | ||
# ) | ||
self.output_layer = torch.nn.Linear(config.hidden_size, self.vocab_size, bias=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably has bugs with bias
getting out of sync between TP ranks during training FYI. See https://jirasw.nvidia.com/browse/BIONEMO-668 and https://jirasw.nvidia.com/browse/BIONEMO-666 and https://nvidia.slack.com/archives/C074Z808N05/p1737508003987919 and https://nvidia.slack.com/archives/C0434FDLPQV/p1733963545314469
Also if your concern is when you do TP=2 that the logit dim is 1/2 that may be because columnparallellinear splits along the logit vocab dimension, and ideally vocab parallel cross entropy knows how to reduce across this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Only temporarily placed torch.nn.Linear
to debug. Will revert back to ColumnParallelLinear
after so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am less concerned about "1/2 logits dim" (128 dim) but more concerned about torch.nn.Linear
giving 256 dim on TP=2. 128 dim should be the correct dim (33 + padding).
Description
Loss values from
unreduced_token_loss_fn
disagree even though thelogits
are the same when TP=1 and TP=2. Interestingly, this introduces a nearly-constant offset in training curve and does not impactgrad_norm
. The offset slowly shrinks over 100 training steps.Suspected root cause:
vocab_parallel_cross_entropy
takes into account oflogits
at the padded vocab dimensions while it should have ignored them. As training progresses, more probabilities are then assigned to "real vocabs" so the padding vacabs slowly becomes less relevant, leading to the closing gap between TP=1 and TP=2 loss curves.logits
dimensions also expanded from 128 to 256 when replacingColumnParallelLinear
withtorch.nn.Linear
although the reason is still unclear. Ifvocab_parallel_cross_entropy
takes into account of the padding vocab dimensions, this can potentially explain the constant offset observed.On a related issue,
unreduced_token_loss_fn
introduces inplace operation on the token logits.https://github.com/NVIDIA/bionemo-framework/blob/sichu/loss-curve-tp-shift/sub-packages/bionemo-llm/tests/bionemo/llm/model/test_loss.py#L158
See Slack channel here.
Type of changes
Usage
Pre-submit Checklist