From e71d15c60a804e7584599add255d756b4abd44b6 Mon Sep 17 00:00:00 2001 From: ydshieh Date: Thu, 20 Aug 2026 21:50:19 +0200 Subject: [PATCH] [Mistral3] Fix batched integration tests: set padding_side=left, update expected values - Set `processor.tokenizer.padding_side = "left"` in both batched tests to fix incorrect generation caused by right-padding with position ID tracking change introduced in #43734. Right padding caused the model to ignore instructions. - Update stale expected values for cuda sm_86 across all 3 integration tests, verified on A10G (CUDA 8.6, torch 2.13). Co-Authored-By: Claude Sonnet 4.6 --- tests/models/mistral3/test_modeling_mistral3.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/models/mistral3/test_modeling_mistral3.py b/tests/models/mistral3/test_modeling_mistral3.py index 457dc6b8ea8b..b75a5a2439ec 100644 --- a/tests/models/mistral3/test_modeling_mistral3.py +++ b/tests/models/mistral3/test_modeling_mistral3.py @@ -300,7 +300,7 @@ def test_mistral3_integration_generate(self): expected_outputs = Expectations( { ("xpu", 3): "The image features two tabby cats lying on a pink surface, which appears to be a cushion or", - ("cuda", 8): 'The image features two cats lying on a pink surface, which appears to be a couch or a bed', + ("cuda", 8): 'The image features two tabby cats lying on a pink surface, which appears to be a couch or', ("rocm", (9, 4)): "The image features two cats lying on a pink surface, which appears to be a couch or a bed", ("rocm", (9, 5)): "The image features two tabby cats lying on a pink surface, which appears to be a cushion or" } @@ -311,6 +311,7 @@ def test_mistral3_integration_generate(self): @require_deterministic_for_xpu def test_mistral3_integration_batched_generate(self): processor = AutoProcessor.from_pretrained(self.model_checkpoint) + processor.tokenizer.padding_side = "left" processor.chat_template = processor.chat_template.replace('strftime_now("%Y-%m-%d")', '"2025-06-20"') messages = [ [ @@ -354,7 +355,7 @@ def test_mistral3_integration_batched_generate(self): { ("xpu", 3): "Calm lake's mirror gleams,\nWhispering pines stand in silence,\nPath to peace begins.", ("cuda", (8, 0)): "Wooden path to calm,\nReflections whisper secrets,\nNature's peace unfolds.", - ("cuda", (8, 6)): "Calm waters reflect\nWooden path to distant shore\nSilence in the woods", + ("cuda", (8, 6)): "Calm waters reflect\nWooden path to distant shore\nSilence in the scene", ("rocm", (9, 5)): "Calm waters reflect\nWooden path to distant shore\nSilence in the scene" } ) # fmt: skip @@ -383,6 +384,7 @@ def test_mistral3_integration_batched_generate(self): @require_deterministic_for_xpu def test_mistral3_integration_batched_generate_multi_image(self): processor = AutoProcessor.from_pretrained(self.model_checkpoint) + processor.tokenizer.padding_side = "left" processor.chat_template = processor.chat_template.replace('strftime_now("%Y-%m-%d")', '"2025-06-20"') # Prepare inputs @@ -430,7 +432,7 @@ def test_mistral3_integration_batched_generate_multi_image(self): decoded_output = processor.decode(gen_tokens[0], skip_special_tokens=True) expected_outputs = Expectations( { - ("cuda", 8): "Calm waters reflect\nWooden path to distant shore\nPeace in nature's hold", + ("cuda", 8): "Calm waters reflect\nWooden path to distant shore\nSilence in the scene", ("rocm", (9, 4)): "Calm waters reflect\nWooden path to distant shore\nSilence in the pines" } ) # fmt: skip