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

DS-Chat BLOOM: Fix Attention mask #4338

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions deepspeed/ops/transformer/inference/ds_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ def compute_attention(self, qkv_out, input_mask, layer_past, alibi):

offset = dist.get_rank() * self.num_attention_heads_per_partition if dist.is_initialized() else 0
target_dtype = torch.float16 if self.config.dtype == torch.int8 else self.config.dtype

# When using the hybrid engine with BLOOM, input_mask needs to be converted from torch.bool -> torch.int64
if input_mask.dtype == torch.bool:
input_mask = input_mask.long()

attention_probs = self.softmax_func(attn_scores=attention_scores,
attn_mask=((1 - input_mask).to(target_dtype) * minus_inf),
alibi=alibi,
Expand Down