Skip to content

Commit 6fb6d3c

Browse files
yao-matrixydshieh
andauthored
make recurrent_gemma and voxtral cases pass on xpu (#41958)
Signed-off-by: Yao, Matrix <matrix.yao@intel.com> Co-authored-by: Yih-Dar <2521628+ydshieh@users.noreply.github.com>
1 parent 5f8d02f commit 6fb6d3c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tests/models/recurrent_gemma/test_modeling_recurrent_gemma.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,15 @@ def test_2b_sample(self):
193193
@require_bitsandbytes
194194
@require_read_token
195195
def test_model_2b_8bit(self):
196-
EXPECTED_TEXTS = ['Hello I am doing a project on the topic of "The impact of social media on the society" and I am looking', "Hi today I'm going to show you how to make a simple and easy to make a 3D"] # fmt: skip
196+
# fmt: off
197+
EXPECTED_TEXTS = Expectations(
198+
{
199+
("xpu", None): ['Hello I am doing a project on the topic of "The impact of the internet on the society" and I am stuck', "Hi today I'm going to show you how to make a simple and easy to make a 3D"],
200+
(None, None): ['Hello I am doing a project on the topic of "The impact of social media on the society" and I am looking', "Hi today I'm going to show you how to make a simple and easy to make a 3D"],
201+
}
202+
)
203+
# fmt: on
204+
EXPECTED_TEXT = EXPECTED_TEXTS.get_expectation()
197205

198206
model = AutoModelForCausalLM.from_pretrained(
199207
"gg-hf/recurrent-gemma-2b-hf",
@@ -208,7 +216,7 @@ def test_model_2b_8bit(self):
208216
output = model.generate(**inputs, max_new_tokens=20, do_sample=False)
209217
output_text = tokenizer.batch_decode(output, skip_special_tokens=True)
210218

211-
self.assertEqual(output_text, EXPECTED_TEXTS)
219+
self.assertEqual(output_text, EXPECTED_TEXT)
212220

213221
@require_read_token
214222
def test_long_context(self):

tests/models/voxtral/test_modeling_voxtral.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
is_torch_available,
2424
)
2525
from transformers.testing_utils import (
26+
Expectations,
2627
cleanup,
2728
require_torch,
2829
slow,
@@ -297,9 +298,15 @@ def test_mini_single_turn_text_and_audio(self):
297298
outputs = model.generate(**inputs, do_sample=False, max_new_tokens=500)
298299
decoded_outputs = self.processor.batch_decode(outputs, skip_special_tokens=True)
299300

300-
EXPECTED_OUTPUT = [
301-
"What can you tell me about this audio?This audio is a farewell address by President Barack Obama, delivered in Chicago. In the speech, he reflects on his eight years in office, highlighting the resilience, hope, and unity of the American people. He acknowledges the diverse perspectives and conversations he had with the public, which kept him honest and inspired. The president also emphasizes the importance of self-government and civic engagement, encouraging Americans to participate in their democracy actively. He expresses optimism about the country's future and looks forward to continuing his work as a citizen. The audio concludes with a heartfelt thank you and a blessing for the United States."
302-
]
301+
# fmt: off
302+
EXPECTED_OUTPUTS = Expectations(
303+
{
304+
(None, None): ["What can you tell me about this audio?This audio is a farewell address by President Barack Obama, delivered in Chicago. In the speech, he reflects on his eight years in office, highlighting the resilience, hope, and unity of the American people. He acknowledges the diverse perspectives and conversations he had with the public, which kept him honest and inspired. The president also emphasizes the importance of self-government and civic engagement, encouraging Americans to participate in their democracy actively. He expresses optimism about the country's future and looks forward to continuing his work as a citizen. The audio concludes with a heartfelt thank you and a blessing for the United States."],
305+
("xpu", None): ["What can you tell me about this audio?This audio is a farewell address by President Barack Obama, delivered in Chicago. In the speech, he reflects on his eight years in office, highlighting the resilience, hope, and unity of the American people. He emphasizes the importance of self-government and active citizenship, encouraging listeners to engage in their communities and participate in democracy. The president expresses his optimism about the country's future and his commitment to continuing to serve as a citizen. He concludes the speech with a heartfelt thank you and a blessing for the United States."],
306+
}
307+
)
308+
# fmt: on
309+
EXPECTED_OUTPUT = EXPECTED_OUTPUTS.get_expectation()
303310
self.assertEqual(decoded_outputs, EXPECTED_OUTPUT)
304311

305312
@slow

0 commit comments

Comments
 (0)