-
Notifications
You must be signed in to change notification settings - Fork 228
Enable loading ckpt for t0 finetuning #309
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?
Changes from 1 commit
90b8f46
abdd703
0fcb19c
63daa46
89460c0
fb8ecb8
a55d2fb
2dfe5d1
ca740f1
cb0313b
b62dcaf
b15ca2d
dc8d0ab
0a32459
2699721
1e77844
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -261,11 +261,18 @@ def get_packed_attention_mask(is_causal: bool, causal_mask: torch.Tensor, decode | |||||
| - segment_ids: torch.IntTensor [batch_size, sequence_length] | ||||||
| Returns: | ||||||
| - attention_mask: torch.BoolTensor [batch_size, 1, sequence_length, sequence_length] | ||||||
|
|
||||||
| Input example for the mask examples: | ||||||
| att_mask_batch = 1 | ||||||
| seq_length = 7 | ||||||
| decoder_is_inputs = torch.tensor([[1, 1, 1, 2, 2, 2, 0]]) | ||||||
| segment_ids = torch.tensor([[1, 1, 0, 1, 1, 0, 0]]) | ||||||
| causal_mask = torch.tril(torch.ones(att_mask_batch, seq_length, seq_length)).view(att_mask_batch, 1, seq_length, seq_length) | ||||||
| """ | ||||||
|
|
||||||
| """Causal Inputs Mask: | ||||||
| mask = [[[[1, 1, 0, 0, 0, 0, 0], | ||||||
| [1, 1, 0, 0, 0, 0, 0], | ||||||
| mask = [[[[1, 1, 0, 1, 1, 0, 0], | ||||||
| [1, 1, 0, 1, 1, 0, 0], | ||||||
| [1, 1, 1, 0, 0, 0, 0], | ||||||
| [1, 1, 1, 1, 1, 0, 0], | ||||||
| [1, 1, 1, 1, 1, 0, 0], | ||||||
|
|
@@ -299,7 +306,7 @@ def get_packed_attention_mask(is_causal: bool, causal_mask: torch.Tensor, decode | |||||
| [0, 0, 0, 1, 1, 1, 0], | ||||||
| [0, 0, 0, 1, 1, 1, 0], | ||||||
| [0, 0, 0, 1, 1, 1, 0], | ||||||
| [0, 0, 0, 0, 0, 0, 0]]]] | ||||||
| [0, 0, 0, 0, 0, 0, 1]]]] | ||||||
Muennighoff marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| """ | ||||||
| segment_mask = segment_ids[:, None, :, None] == segment_ids[:, None, None, :] | ||||||
|
|
||||||
|
|
@@ -311,13 +318,22 @@ def get_packed_attention_mask(is_causal: bool, causal_mask: torch.Tensor, decode | |||||
| [0, 0, 0, 1, 1, 0, 0], | ||||||
| [0, 0, 0, 1, 1, 1, 0], | ||||||
| [0, 0, 0, 0, 0, 0, 0]]]] | ||||||
|
|
||||||
| If is_causal=True: | ||||||
| mask = [[[[1, 0, 0, 0, 0, 0, 0], | ||||||
| [1, 1, 0, 0, 0, 0, 0], | ||||||
| [1, 1, 1, 0, 0, 0, 0], | ||||||
| [0, 0, 0, 1, 0, 0, 0], | ||||||
| [0, 0, 0, 1, 1, 0, 0], | ||||||
| [0, 0, 0, 1, 1, 1, 0], | ||||||
| [0, 0, 0, 0, 0, 0, 0]]]] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hum I'm wondering if this doesn't screw something up. Essentially you're going to compute softmax on a row with only zeros ...
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last row & last col are the attention scores of the last token with respect to the last token. Since the last token is masked out in our loss_mask it doesn't matter I think.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No you compute softmax, what should be the result of the softmax of a row full of masked out values .... It feels like that would return lots of Nans.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we fill it with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can try writing a test but I would be pretty sure that the actual results are 0. (with current kernel) |
||||||
|
|
||||||
| """ | ||||||
| attention_mask = causal_inputs_mask * padding_mask * segment_mask | ||||||
|
|
||||||
| # Convert attention mask to binary: | ||||||
| attention_mask = (attention_mask < 0.5) | ||||||
| attention_mask = causal_inputs_mask * padding_mask * segment_mask | ||||||
|
|
||||||
| return attention_mask | ||||||
| # True for places we do not want to attend to | ||||||
| return ~attention_mask | ||||||
|
|
||||||
| def param_size(parameter): | ||||||
| return parameter.ds_numel if hasattr(parameter, 'ds_id') else parameter.nelement() | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.