From 19085c28dae05ff88027b85cb465b252d934cdcb Mon Sep 17 00:00:00 2001 From: Afanti Date: Tue, 25 Mar 2025 17:49:24 +0800 Subject: [PATCH] fix typos in the tests directory (#36932) * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: fix typos in test codes * chore: format codes --- tests/models/chameleon/test_modeling_chameleon.py | 2 +- tests/models/dab_detr/test_modeling_dab_detr.py | 6 +++--- .../granitemoeshared/test_modeling_granitemoeshared.py | 4 +++- tests/models/idefics/test_modeling_idefics.py | 4 ++-- tests/models/idefics/test_modeling_tf_idefics.py | 4 ++-- tests/models/mimi/test_modeling_mimi.py | 4 ++-- tests/models/rt_detr/test_modeling_rt_detr.py | 8 ++++---- tests/models/shieldgemma2/test_processing_shieldgemma2.py | 2 +- tests/models/video_llava/test_modeling_video_llava.py | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/models/chameleon/test_modeling_chameleon.py b/tests/models/chameleon/test_modeling_chameleon.py index ae06de34ab..e13e918ba0 100644 --- a/tests/models/chameleon/test_modeling_chameleon.py +++ b/tests/models/chameleon/test_modeling_chameleon.py @@ -130,7 +130,7 @@ class ChameleonModelTester: def get_config(self): # create dummy vocab map for image2bpe mapping if it needs remapping - # we assume that vocab size is big enough to accoun for image tokens somewhere in the beginning + # we assume that vocab size is big enough to account for image tokens somewhere in the beginning # same way as in real ckpt, when img tokens are in first half of embeds # we will need "vq_num_embeds" amount of tokens diff --git a/tests/models/dab_detr/test_modeling_dab_detr.py b/tests/models/dab_detr/test_modeling_dab_detr.py index 584bd1882a..572efc5de5 100644 --- a/tests/models/dab_detr/test_modeling_dab_detr.py +++ b/tests/models/dab_detr/test_modeling_dab_detr.py @@ -699,10 +699,10 @@ class DabDetrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) self.model_tester.num_labels, ) self.assertEqual(outputs.logits.shape, expected_shape) - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.model.backbone.conv_encoder.intermediate_channel_sizes), 3) else: - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.backbone.conv_encoder.intermediate_channel_sizes), 3) self.assertTrue(outputs) @@ -726,7 +726,7 @@ class DabDetrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) abs(param.data.max().item()), msg=f"Parameter {name} of model {model_class} seems not properly initialized", ) - # Modifed from RT-DETR + # Modified from RT-DETR elif "class_embed" in name and "bias" in name: bias_tensor = torch.full_like(param.data, bias_value) torch.testing.assert_close( diff --git a/tests/models/granitemoeshared/test_modeling_granitemoeshared.py b/tests/models/granitemoeshared/test_modeling_granitemoeshared.py index 97658549f5..28787870d8 100644 --- a/tests/models/granitemoeshared/test_modeling_granitemoeshared.py +++ b/tests/models/granitemoeshared/test_modeling_granitemoeshared.py @@ -358,7 +358,9 @@ class GraniteMoeSharedModelTest(ModelTesterMixin, GenerationTesterMixin, unittes long_input_length = int(config.max_position_embeddings * 1.5) # Inputs - x = torch.randn(1, dtype=torch.float32, device=torch_device) # used exlusively to get the dtype and the device + x = torch.randn( + 1, dtype=torch.float32, device=torch_device + ) # used exclusively to get the dtype and the device position_ids_short = torch.arange(short_input_length, dtype=torch.long, device=torch_device) position_ids_short = position_ids_short.unsqueeze(0) position_ids_long = torch.arange(long_input_length, dtype=torch.long, device=torch_device) diff --git a/tests/models/idefics/test_modeling_idefics.py b/tests/models/idefics/test_modeling_idefics.py index d09b5f7850..2b591aa04f 100644 --- a/tests/models/idefics/test_modeling_idefics.py +++ b/tests/models/idefics/test_modeling_idefics.py @@ -521,7 +521,7 @@ class IdeficsModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) with torch.no_grad(): outputs = model(**self._prepare_for_class(inputs_dict, model_class)) attentions = outputs.attentions - # IDEFICS does not support outputting attention score becuase it uses SDPA under the hood + # IDEFICS does not support outputting attention score because it uses SDPA under the hood self.assertTrue(attentions[0] is None) out_len = len(outputs) @@ -539,7 +539,7 @@ class IdeficsModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) self_attentions = outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions self.assertEqual(len(self_attentions), self.model_tester.num_hidden_layers) - # IDEFICS does not support outputting attention score becuase it uses SDPA under the hood + # IDEFICS does not support outputting attention score because it uses SDPA under the hood self.assertTrue(self_attentions[0] is None) def test_hidden_states_output(self): diff --git a/tests/models/idefics/test_modeling_tf_idefics.py b/tests/models/idefics/test_modeling_tf_idefics.py index bbb997aa6f..3d2ba3f78c 100644 --- a/tests/models/idefics/test_modeling_tf_idefics.py +++ b/tests/models/idefics/test_modeling_tf_idefics.py @@ -372,7 +372,7 @@ class TFIdeficsModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestC model = model_class(config) outputs = model(**self._prepare_for_class(inputs_dict, model_class)) attentions = outputs.attentions - # IDEFICS does not support outputting attention score becuase it uses SDPA under the hood + # IDEFICS does not support outputting attention score because it uses SDPA under the hood self.assertTrue(attentions[0] is None) out_len = len(outputs) @@ -386,7 +386,7 @@ class TFIdeficsModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestC self_attentions = outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions self.assertEqual(len(self_attentions), self.model_tester.num_hidden_layers) - # IDEFICS does not support outputting attention score becuase it uses SDPA under the hood + # IDEFICS does not support outputting attention score because it uses SDPA under the hood self.assertTrue(self_attentions[0] is None) def test_hidden_states_output(self): diff --git a/tests/models/mimi/test_modeling_mimi.py b/tests/models/mimi/test_modeling_mimi.py index 43219155c1..bf9155bf70 100644 --- a/tests/models/mimi/test_modeling_mimi.py +++ b/tests/models/mimi/test_modeling_mimi.py @@ -485,7 +485,7 @@ class MimiIntegrationTest(unittest.TestCase): for num_codebooks, expected_rmse in expected_rmse.items(): with torch.no_grad(): - # use max bandwith for best possible reconstruction + # use max bandwidth for best possible reconstruction encoder_outputs = model.encode(inputs["input_values"], num_quantizers=int(num_codebooks)) audio_codes = encoder_outputs[0] @@ -537,7 +537,7 @@ class MimiIntegrationTest(unittest.TestCase): model = MimiModel.from_pretrained(model_id, use_cache=use_cache).to(torch_device) for num_codebooks, expected_rmse in expected_rmses.items(): with torch.no_grad(): - # use max bandwith for best possible reconstruction + # use max bandwidth for best possible reconstruction encoder_outputs = model.encode(inputs["input_values"], num_quantizers=int(num_codebooks)) audio_code_sums = encoder_outputs[0].sum().cpu().item() diff --git a/tests/models/rt_detr/test_modeling_rt_detr.py b/tests/models/rt_detr/test_modeling_rt_detr.py index ab465065f1..5dedeaceae 100644 --- a/tests/models/rt_detr/test_modeling_rt_detr.py +++ b/tests/models/rt_detr/test_modeling_rt_detr.py @@ -547,10 +547,10 @@ class RTDetrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): self.model_tester.num_labels, ) self.assertEqual(outputs.logits.shape, expected_shape) - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.model.backbone.intermediate_channel_sizes), 3) else: - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.backbone.intermediate_channel_sizes), 3) self.assertTrue(outputs) @@ -579,10 +579,10 @@ class RTDetrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): self.model_tester.num_labels, ) self.assertEqual(outputs.logits.shape, expected_shape) - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.model.backbone.intermediate_channel_sizes), 3) else: - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.backbone.intermediate_channel_sizes), 3) self.assertTrue(outputs) diff --git a/tests/models/shieldgemma2/test_processing_shieldgemma2.py b/tests/models/shieldgemma2/test_processing_shieldgemma2.py index 31ae324870..d38c0f29c6 100644 --- a/tests/models/shieldgemma2/test_processing_shieldgemma2.py +++ b/tests/models/shieldgemma2/test_processing_shieldgemma2.py @@ -140,7 +140,7 @@ class ShieldGemma2ProcessorTest(ProcessorTesterMixin, unittest.TestCase): if processor.chat_template is None: self.skipTest("Processor has no chat template") - # Test policies adapated from https://ailuminate.mlcommons.org/benchmarks/ hazard categories + # Test policies adapted from https://ailuminate.mlcommons.org/benchmarks/ hazard categories custom_policies = { "cbrne": "Test policy related to indiscriminate weapons.", "ip": "Test policy related to intellectual property.", diff --git a/tests/models/video_llava/test_modeling_video_llava.py b/tests/models/video_llava/test_modeling_video_llava.py index d46b1ae111..208c793a9b 100644 --- a/tests/models/video_llava/test_modeling_video_llava.py +++ b/tests/models/video_llava/test_modeling_video_llava.py @@ -391,7 +391,7 @@ class VideoLlavaForConditionalGenerationModelTest(ModelTesterMixin, GenerationTe config, input_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: model = model_class(config).to(torch_device) - _ = model(**input_dict) # successfull forward with no modifications + _ = model(**input_dict) # successful forward with no modifications # remove one image but leave the image token in text input_dict["pixel_values_images"] = input_dict["pixel_values_images"][-1:, ...]