Skip to content
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

Addition of booleans is currently wrong in iree-compile #341

Merged
merged 3 commits into from
Oct 28, 2024
Merged
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
14 changes: 7 additions & 7 deletions sharktank/sharktank/layers/causal_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ def input_mask(

def decode_attention_mask(self, boolean_input_mask: torch.Tensor):
dtype = self.attention_dtype
numeric_mask = torch.zeros_like(boolean_input_mask, dtype=dtype)
numeric_mask.masked_fill_(
boolean_input_mask, self._maximally_negative_value(dtype)
)
numeric_mask = torch.where(
renxida marked this conversation as resolved.
Show resolved Hide resolved
boolean_input_mask, self._maximally_negative_value(dtype), 0
).to(dtype)
return numeric_mask.unsqueeze(1).unsqueeze(1).to(self.device)

def attention_mask(
Expand Down Expand Up @@ -127,9 +126,10 @@ def attention_mask(
dtype = self.attention_dtype
_, batch_seq_len = input_mask.shape
causal_mask = causal_context_mask[:, :, :batch_seq_len, :batch_seq_len]
boolean_mask = causal_mask + input_mask[:, None, None, :]
numeric_mask = torch.zeros_like(boolean_mask, dtype=dtype)
numeric_mask.masked_fill_(boolean_mask, self._maximally_negative_value(dtype))
boolean_mask = torch.logical_or(causal_mask, input_mask[:, None, None, :])
numeric_mask = torch.where(
boolean_mask, self._maximally_negative_value(dtype), 0
).to(dtype)
return numeric_mask.to(self.device)

def extract_tokens_from_logits(
Expand Down
Loading