Skip to content

optimize the generation of attention mask #331

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions megatron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_ltor_masks_and_position_ids(data,
attention_mask = None
if not skip_mask:
attention_mask = torch.tril(torch.ones(
(att_mask_batch, seq_length, seq_length))).view(att_mask_batch, 1, seq_length, seq_length)
(att_mask_batch, seq_length, seq_length), device=data.device)).view(att_mask_batch, 1, seq_length, seq_length)

# Loss mask.
loss_mask = torch.ones(data.size(), dtype=torch.float, device=data.device)
Expand Down Expand Up @@ -218,7 +218,6 @@ def get_ltor_masks_and_position_ids(data,
# Convert attention mask to binary:
if not skip_mask:
attention_mask = (attention_mask < 0.5)
attention_mask = attention_mask.to(data.device)

return attention_mask, loss_mask, position_ids

Expand Down