Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
aea7b23b
Unverified
Commit
aea7b23b
authored
May 18, 2023
by
Joao Gante
Committed by
GitHub
May 18, 2023
Browse files
Generate: skip left-padding tests on old models (#23437)
parent
a8732e09
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
65 additions
and
3 deletions
+65
-3
tests/generation/test_utils.py
tests/generation/test_utils.py
+1
-3
tests/models/bart/test_modeling_bart.py
tests/models/bart/test_modeling_bart.py
+4
-0
tests/models/bigbird_pegasus/test_modeling_bigbird_pegasus.py
...s/models/bigbird_pegasus/test_modeling_bigbird_pegasus.py
+4
-0
tests/models/blenderbot/test_modeling_blenderbot.py
tests/models/blenderbot/test_modeling_blenderbot.py
+4
-0
tests/models/blenderbot_small/test_modeling_blenderbot_small.py
...models/blenderbot_small/test_modeling_blenderbot_small.py
+4
-0
tests/models/ctrl/test_modeling_ctrl.py
tests/models/ctrl/test_modeling_ctrl.py
+4
-0
tests/models/imagegpt/test_modeling_imagegpt.py
tests/models/imagegpt/test_modeling_imagegpt.py
+4
-0
tests/models/marian/test_modeling_marian.py
tests/models/marian/test_modeling_marian.py
+4
-0
tests/models/mbart/test_modeling_mbart.py
tests/models/mbart/test_modeling_mbart.py
+4
-0
tests/models/mvp/test_modeling_mvp.py
tests/models/mvp/test_modeling_mvp.py
+4
-0
tests/models/pegasus/test_modeling_pegasus.py
tests/models/pegasus/test_modeling_pegasus.py
+4
-0
tests/models/plbart/test_modeling_plbart.py
tests/models/plbart/test_modeling_plbart.py
+4
-0
tests/models/prophetnet/test_modeling_prophetnet.py
tests/models/prophetnet/test_modeling_prophetnet.py
+4
-0
tests/models/reformer/test_modeling_reformer.py
tests/models/reformer/test_modeling_reformer.py
+8
-0
tests/models/transfo_xl/test_modeling_transfo_xl.py
tests/models/transfo_xl/test_modeling_transfo_xl.py
+4
-0
tests/models/trocr/test_modeling_trocr.py
tests/models/trocr/test_modeling_trocr.py
+4
-0
No files found.
tests/generation/test_utils.py
View file @
aea7b23b
...
...
@@ -1597,9 +1597,7 @@ class GenerationTesterMixin:
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.
...
...
tests/models/bart/test_modeling_bart.py
View file @
aea7b23b
...
...
@@ -1516,3 +1516,7 @@ class BartStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin, un
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
tests/models/bigbird_pegasus/test_modeling_bigbird_pegasus.py
View file @
aea7b23b
...
...
@@ -811,3 +811,7 @@ class BigBirdPegasusStandaloneDecoderModelTest(ModelTesterMixin, GenerationTeste
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
tests/models/blenderbot/test_modeling_blenderbot.py
View file @
aea7b23b
...
...
@@ -561,3 +561,7 @@ class BlenderbotStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMix
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
tests/models/blenderbot_small/test_modeling_blenderbot_small.py
View file @
aea7b23b
...
...
@@ -566,3 +566,7 @@ class BlenderbotSmallStandaloneDecoderModelTest(ModelTesterMixin, GenerationTest
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
tests/models/ctrl/test_modeling_ctrl.py
View file @
aea7b23b
...
...
@@ -249,6 +249,10 @@ class CTRLModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
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
):
...
...
tests/models/imagegpt/test_modeling_imagegpt.py
View file @
aea7b23b
...
...
@@ -520,6 +520,10 @@ class ImageGPTModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterM
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
():
...
...
tests/models/marian/test_modeling_marian.py
View file @
aea7b23b
...
...
@@ -862,3 +862,7 @@ class MarianStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin,
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
tests/models/mbart/test_modeling_mbart.py
View file @
aea7b23b
...
...
@@ -692,3 +692,7 @@ class MBartStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin, u
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
tests/models/mvp/test_modeling_mvp.py
View file @
aea7b23b
...
...
@@ -818,3 +818,7 @@ class MvpStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin, uni
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
tests/models/pegasus/test_modeling_pegasus.py
View file @
aea7b23b
...
...
@@ -573,3 +573,7 @@ class PegasusStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin,
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
tests/models/plbart/test_modeling_plbart.py
View file @
aea7b23b
...
...
@@ -658,3 +658,7 @@ class PLBartStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin,
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
tests/models/prophetnet/test_modeling_prophetnet.py
View file @
aea7b23b
...
...
@@ -1146,6 +1146,10 @@ class ProphetNetStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMix
# 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
):
...
...
tests/models/reformer/test_modeling_reformer.py
View file @
aea7b23b
...
...
@@ -682,6 +682,10 @@ class ReformerLocalAttnModelTest(ReformerTesterMixin, GenerationTesterMixin, Mod
[
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
(
...
...
@@ -839,6 +843,10 @@ class ReformerLSHAttnModelTest(
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
...
...
tests/models/transfo_xl/test_modeling_transfo_xl.py
View file @
aea7b23b
...
...
@@ -486,6 +486,10 @@ class TransfoXLModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTester
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
):
...
...
tests/models/trocr/test_modeling_trocr.py
View file @
aea7b23b
...
...
@@ -192,3 +192,7 @@ class TrOCRStandaloneDecoderModelTest(ModelTesterMixin, GenerationTesterMixin, P
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment