-
Notifications
You must be signed in to change notification settings - Fork 346
[RFC] Pass the original input to all PP stages #1130
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
base: main
Are you sure you want to change the base?
Conversation
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.
on PP side looks good. Does the current llama3 and 4 not support document masking? How come model changes are needed?
@H-Huang llama3 doesn't have this. And document masking + PP is one missing feature for llama4. |
We need the original tokens to generate the document masks/block causal masks. Since TorchTitan currently let all ranks perform data loading, there will be no performance regressions.
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.
Left some nit comments.
CI is broken by compile + SAC. Please make sure this change works before merge.
If pipeline parallelism is enabled, this will be the input token indices | ||
for the ranks on the first pipeline stage. This will be the activation of the | ||
previous pipeline stage if the current rank is not on the first stage. | ||
input_batch (torch.Tensor): The input batch read from the dataloader. |
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.
please add a comment that -- this field is needed for non-first PP stages to obtain proper document masks
@@ -351,7 +355,7 @@ def train_step(self, input_dict: dict[str, torch.Tensor], labels: torch.Tensor): | |||
# Non-PP forward / backward | |||
with self.train_context(optional_context_parallel_ctx): | |||
assert len(model_parts) == 1 | |||
pred = model_parts[0](inputs) | |||
pred = model_parts[0](inputs, input_batch=inputs) |
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.
non PP branch looks a bit strange -- I slightly prefer the alternative way of making input_batch
optional, and let init_attention_mask
use tokens
if input_batch is None
. The idea is that non PP users see less universal usage of input_batch
We need the original tokens to generate the document masks/block causal masks. Since TorchTitan currently let all ranks perform data loading, there will be no performance regressions.
This is required to support document masking attention with PP.