-
Notifications
You must be signed in to change notification settings - Fork 301
Fixed the llama model #769
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
Changes from 1 commit
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 |
---|---|---|
|
@@ -197,15 +197,17 @@ def forward(self, idx: Tensor, input_pos: Optional[Tensor] = None) -> Tensor: | |
|
||
if input_pos is None: | ||
mask = None | ||
input_pos = torch.arange(0, idx.shape[1], device=idx.device) | ||
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. Thank you for your reply. It makes sense to separate the logic for creating 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've also tested the inference case where 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.
This is what I mentioned earlier. I think right now there is no code that uses inference w/o Can you update the PR description to describe the problem this PR fixes clearer? i.e. when 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. Got it, thanks for the clarification! I updated the PR description, UTs and docstring. Please review it again. |
||
freqs_cis = self.freqs_cis[:idx.shape[1]] | ||
elif not self.linear_causal_mask: | ||
mask = self.causal_mask[None, None, input_pos] | ||
elif len(input_pos)>1 and self.linear_causal_mask: # prefill for linear causal mask | ||
mask = torch.tril(torch.ones(len(input_pos), self.max_seq_length, dtype=torch.bool, device=input_pos.device)).unsqueeze(0).unsqueeze(0) | ||
else: # decode_one_token for linear causal mask | ||
self.causal_mask[0,0,0,input_pos] = 1 | ||
mask = self.causal_mask | ||
freqs_cis = self.freqs_cis[input_pos] | ||
else: | ||
if not self.linear_causal_mask: | ||
mask = self.causal_mask[None, None, input_pos] | ||
elif len(input_pos)>1 and self.linear_causal_mask: # prefill for linear causal mask | ||
mask = torch.tril(torch.ones(len(input_pos), self.max_seq_length, dtype=torch.bool, device=input_pos.device)).unsqueeze(0).unsqueeze(0) | ||
else: # decode_one_token for linear causal mask | ||
self.causal_mask[0,0,0,input_pos] = 1 | ||
mask = self.causal_mask | ||
freqs_cis = self.freqs_cis[input_pos] | ||
|
||
x = self.tok_embeddings(idx) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.