-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Closed
Labels
module: correctness (silent)issue that returns an incorrect result silentlyissue that returns an incorrect result silentlymodule: halfRelated to float16 half-precision floatsRelated to float16 half-precision floatsmodule: macosMac OS related issuesMac OS related issuesmodule: mpsRelated to Apple Metal Performance Shaders frameworkRelated to Apple Metal Performance Shaders frameworkmodule: sdpaAll things related to torch.nn.functional.scaled_dot_product_attentiionAll things related to torch.nn.functional.scaled_dot_product_attentiiontriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Describe the bug
Almost verbatim HF example
import torch
from torch.profiler import profile, ProfilerActivity
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype="auto", trust_remote_code=True)
print(next(model.parameters()).dtype)
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
inputs = tokenizer('''def print_prime(n):
"""
Print all primes between 1 and n
"""''', return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs, max_length=32)
text = tokenizer.batch_decode(outputs)[0]
print(text)Changing data type to bf16 fixes the problem. This is tru for both CPU and MPS
Versions
CI
cc @kulinseth @DenisVieriu97 @jhavukainen @albanD @snadampal @milpuz01 @aditew01 @nikhil-arm @fadara01
Metadata
Metadata
Assignees
Labels
module: correctness (silent)issue that returns an incorrect result silentlyissue that returns an incorrect result silentlymodule: halfRelated to float16 half-precision floatsRelated to float16 half-precision floatsmodule: macosMac OS related issuesMac OS related issuesmodule: mpsRelated to Apple Metal Performance Shaders frameworkRelated to Apple Metal Performance Shaders frameworkmodule: sdpaAll things related to torch.nn.functional.scaled_dot_product_attentiionAll things related to torch.nn.functional.scaled_dot_product_attentiiontriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module