Skip to content

Commit

Permalink
Generate: skip left-padding tests on old models (huggingface#23437)
Browse files Browse the repository at this point in the history
  • Loading branch information
gante authored and sheonhan committed Jun 1, 2023
1 parent dec7284 commit dd9fa7f
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tests/generation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,7 @@ def test_generate_with_head_masking(self):
attn_weights = out[attn_name] if attn_name == attention_names[0] else out[attn_name][-1]
self.assertEqual(sum([w.sum().item() for w in attn_weights]), 0.0)

# TODO (joao): this test is actually not slow :) However, it is not passing in some models (e.g. GPTNeoX) and the
# fix for some models is quite lengthy. Being slow means it doesn't block our push CI while we fix it.
@slow
@slow # TODO (Joao): fix GPTBigCode
def test_left_padding_compatibility(self):
# The check done in this test is fairly difficult -- depending on the model architecture, passing the right
# position index for the position embeddings can still result in a different output, due to numerical masking.
Expand Down
4 changes: 4 additions & 0 deletions tests/models/bart/test_modeling_bart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,3 +1516,7 @@ def test_retain_grad_hidden_states_attentions(self):

def test_save_load_fast_init_from_base(self):
pass

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/bigbird_pegasus/test_modeling_bigbird_pegasus.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/blenderbot/test_modeling_blenderbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/ctrl/test_modeling_ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def test_model_from_pretrained(self):
model = CTRLModel.from_pretrained(model_name)
self.assertIsNotNone(model)

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


@require_torch
class CTRLModelLanguageGenerationTest(unittest.TestCase):
Expand Down
4 changes: 4 additions & 0 deletions tests/models/imagegpt/test_modeling_imagegpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ def _create_and_check_torchscript(self, config, inputs_dict):

self.assertTrue(models_equal)

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


# We will verify our results on an image of cute cats
def prepare_img():
Expand Down
4 changes: 4 additions & 0 deletions tests/models/marian/test_modeling_marian.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,3 +862,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/mbart/test_modeling_mbart.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/mvp/test_modeling_mvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/pegasus/test_modeling_pegasus.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/plbart/test_modeling_plbart.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,3 +658,7 @@ def test_decoder_model_attn_mask_past(self):
def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass
4 changes: 4 additions & 0 deletions tests/models/prophetnet/test_modeling_prophetnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,10 @@ def test_retain_grad_hidden_states_attentions(self):
# decoder cannot keep gradients
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


@require_torch
class ProphetNetStandaloneEncoderModelTest(ModelTesterMixin, unittest.TestCase):
Expand Down
8 changes: 8 additions & 0 deletions tests/models/reformer/test_modeling_reformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@ def _check_hidden_states_for_generate(
[expected_shape] * len(iter_hidden_states),
)

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


@require_torch
class ReformerLSHAttnModelTest(
Expand Down Expand Up @@ -839,6 +843,10 @@ def test_problem_types(self):
def test_past_key_values_format(self):
pass

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


@require_torch
@require_sentencepiece
Expand Down
4 changes: 4 additions & 0 deletions tests/models/transfo_xl/test_modeling_transfo_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ def _mock_init_weights(self, module):
weight = getattr(module, param)
weight.data.fill_(3)

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass


@require_torch
class TransfoXLModelLanguageGenerationTest(unittest.TestCase):
Expand Down
4 changes: 4 additions & 0 deletions tests/models/trocr/test_modeling_trocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,7 @@ def test_decoder_model_past(self):
# decoder cannot keep gradients
def test_retain_grad_hidden_states_attentions(self):
return

@unittest.skip("The model doesn't support left padding") # and it's not used enough to be worth fixing :)
def test_left_padding_compatibility(self):
pass

0 comments on commit dd9fa7f

Please sign in to comment.