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

Fix BT starcoder fp16 #1255

Merged
merged 1 commit into from
Aug 4, 2023
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
6 changes: 1 addition & 5 deletions optimum/bettertransformer/models/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,7 @@ def gpt_bigcode_wrapped_scaled_dot_product(
raise_on_head_mask(head_mask)

# TODO: remove once PyTorch 2.1 is released with the scale argument to SDPA
if self.scale_attn_weights:
softmax_dtype = torch.float32 if self.attention_softmax_in_fp32 else query.dtype
if self.scale_attention_softmax_in_fp32 and query.dtype != softmax_dtype:
query = query / (self.layer_idx + 1)
else:
if not self.scale_attn_weights:
query = query / self.head_dim**0.5

# MQA models: (batch_size, query_length, num_heads * head_dim)
Expand Down
Loading