From b189226e8cb31361916d638c5a1e2540e3208a61 Mon Sep 17 00:00:00 2001 From: Lysandre Debut Date: Mon, 12 Jul 2021 17:51:35 +0200 Subject: [PATCH] Fix transfo xl integration test (#12652) * Cleanup test * Skip TF TransfoXL test --- tests/test_modeling_tf_transfo_xl.py | 334 +------------------------ tests/test_modeling_transfo_xl.py | 358 +-------------------------- 2 files changed, 14 insertions(+), 678 deletions(-) diff --git a/tests/test_modeling_tf_transfo_xl.py b/tests/test_modeling_tf_transfo_xl.py index a7b6fc3d9ef..da465f9d448 100644 --- a/tests/test_modeling_tf_transfo_xl.py +++ b/tests/test_modeling_tf_transfo_xl.py @@ -218,157 +218,13 @@ class TFTransfoXLModelTest(TFModelTesterMixin, unittest.TestCase): @require_tf class TFTransfoXLModelLanguageGenerationTest(unittest.TestCase): + @unittest.skip("Skip test until #12651 is resolved.") @slow def test_lm_generate_transfo_xl_wt103(self): model = TFTransfoXLLMHeadModel.from_pretrained("transfo-xl-wt103") - input_ids = tf.convert_to_tensor( - [ - [ - 33, - 1297, - 2, - 1, - 1009, - 4, - 1109, - 11739, - 4762, - 358, - 5, - 25, - 245, - 22, - 1706, - 17, - 20098, - 5, - 3215, - 21, - 37, - 1110, - 3, - 13, - 1041, - 4, - 24, - 603, - 490, - 2, - 71477, - 20098, - 104447, - 2, - 20961, - 1, - 2604, - 4, - 1, - 329, - 3, - 6224, - 831, - 16002, - 2, - 8, - 603, - 78967, - 29546, - 23, - 803, - 20, - 25, - 416, - 5, - 8, - 232, - 4, - 277, - 6, - 1855, - 4601, - 3, - 29546, - 54, - 8, - 3609, - 5, - 57211, - 49, - 4, - 1, - 277, - 18, - 8, - 1755, - 15691, - 3, - 341, - 25, - 416, - 693, - 42573, - 71, - 17, - 401, - 94, - 31, - 17919, - 2, - 29546, - 7873, - 18, - 1, - 435, - 23, - 11011, - 755, - 5, - 5167, - 3, - 7983, - 98, - 84, - 2, - 29546, - 3267, - 8, - 3609, - 4, - 1, - 4865, - 1075, - 2, - 6087, - 71, - 6, - 346, - 8, - 5854, - 3, - 29546, - 824, - 1400, - 1868, - 2, - 19, - 160, - 2, - 311, - 8, - 5496, - 2, - 20920, - 17, - 25, - 15097, - 3, - 24, - 24, - 0, - ] - ], - dtype=tf.int32, - ) + # fmt: off + input_ids = tf.convert_to_tensor([[33,1297,2,1,1009,4,1109,11739,4762,358,5,25,245,22,1706,17,20098,5,3215,21,37,1110,3,13,1041,4,24,603,490,2,71477,20098,104447,2,20961,1,2604,4,1,329,3,6224,831,16002,2,8,603,78967,29546,23,803,20,25,416,5,8,232,4,277,6,1855,4601,3,29546,54,8,3609,5,57211,49,4,1,277,18,8,1755,15691,3,341,25,416,693,42573,71,17,401,94,31,17919,2,29546,7873,18,1,435,23,11011,755,5,5167,3,7983,98,84,2,29546,3267,8,3609,4,1,4865,1075,2,6087,71,6,346,8,5854,3,29546,824,1400,1868,2,19,160,2,311,8,5496,2,20920,17,25,15097,3,24,24,0]],dtype=tf.int32) # noqa: E231 + # fmt: on # In 1991 , the remains of Russian Tsar Nicholas II and his family # ( except for Alexei and Maria ) are discovered . # The voice of Nicholas's young son , Tsarevich Alexei Nikolaevich , narrates the @@ -380,185 +236,9 @@ class TFTransfoXLModelLanguageGenerationTest(unittest.TestCase): # the Virgin Mary , prompting him to become a priest . Rasputin quickly becomes famous , # with people , even a bishop , begging for his blessing . - expected_output_ids = [ - 33, - 1297, - 2, - 1, - 1009, - 4, - 1109, - 11739, - 4762, - 358, - 5, - 25, - 245, - 22, - 1706, - 17, - 20098, - 5, - 3215, - 21, - 37, - 1110, - 3, - 13, - 1041, - 4, - 24, - 603, - 490, - 2, - 71477, - 20098, - 104447, - 2, - 20961, - 1, - 2604, - 4, - 1, - 329, - 3, - 6224, - 831, - 16002, - 2, - 8, - 603, - 78967, - 29546, - 23, - 803, - 20, - 25, - 416, - 5, - 8, - 232, - 4, - 277, - 6, - 1855, - 4601, - 3, - 29546, - 54, - 8, - 3609, - 5, - 57211, - 49, - 4, - 1, - 277, - 18, - 8, - 1755, - 15691, - 3, - 341, - 25, - 416, - 693, - 42573, - 71, - 17, - 401, - 94, - 31, - 17919, - 2, - 29546, - 7873, - 18, - 1, - 435, - 23, - 11011, - 755, - 5, - 5167, - 3, - 7983, - 98, - 84, - 2, - 29546, - 3267, - 8, - 3609, - 4, - 1, - 4865, - 1075, - 2, - 6087, - 71, - 6, - 346, - 8, - 5854, - 3, - 29546, - 824, - 1400, - 1868, - 2, - 19, - 160, - 2, - 311, - 8, - 5496, - 2, - 20920, - 17, - 25, - 15097, - 3, - 24, - 24, - 0, - 33, - 1, - 1857, - 2, - 1, - 1009, - 4, - 1109, - 11739, - 4762, - 358, - 5, - 25, - 245, - 28, - 1110, - 3, - 13, - 1041, - 4, - 24, - 603, - 490, - 2, - 71477, - 20098, - 104447, - 2, - 20961, - 1, - 2604, - 4, - 1, - 329, - 3, - 0, - ] + # fmt: off + expected_output_ids = [33,1297,2,1,1009,4,1109,11739,4762,358,5,25,245,22,1706,17,20098,5,3215,21,37,1110,3,13,1041,4,24,603,490,2,71477,20098,104447,2,20961,1,2604,4,1,329,3,6224,831,16002,2,8,603,78967,29546,23,803,20,25,416,5,8,232,4,277,6,1855,4601,3,29546,54,8,3609,5,57211,49,4,1,277,18,8,1755,15691,3,341,25,416,693,42573,71,17,401,94,31,17919,2,29546,7873,18,1,435,23,11011,755,5,5167,3,7983,98,84,2,29546,3267,8,3609,4,1,4865,1075,2,6087,71,6,346,8,5854,3,29546,824,1400,1868,2,19,160,2,311,8,5496,2,20920,17,25,15097,3,24,24,0,33,1,1857,2,1,1009,4,1109,11739,4762,358,5,25,245,28,1110,3,13,1041,4,24,603,490,2,71477,20098,104447,2,20961,1,2604,4,1,329,3,0] # noqa: E231 + # fmt: on # In 1991, the remains of Russian Tsar Nicholas II and his family ( # except for Alexei and Maria ) are discovered. The voice of young son, # Tsarevich Alexei Nikolaevich, narrates the remainder of the story. diff --git a/tests/test_modeling_transfo_xl.py b/tests/test_modeling_transfo_xl.py index f9b01e638d9..c1637d7e403 100644 --- a/tests/test_modeling_transfo_xl.py +++ b/tests/test_modeling_transfo_xl.py @@ -381,155 +381,10 @@ class TransfoXLModelLanguageGenerationTest(unittest.TestCase): def test_lm_generate_transfo_xl_wt103(self): model = TransfoXLLMHeadModel.from_pretrained("transfo-xl-wt103") model.to(torch_device) - input_ids = torch.tensor( - [ - [ - 33, - 1297, - 2, - 1, - 1009, - 4, - 1109, - 11739, - 4762, - 358, - 5, - 25, - 245, - 22, - 1706, - 17, - 20098, - 5, - 3215, - 21, - 37, - 1110, - 3, - 13, - 1041, - 4, - 24, - 603, - 490, - 2, - 71477, - 20098, - 104447, - 2, - 20961, - 1, - 2604, - 4, - 1, - 329, - 3, - 6224, - 831, - 16002, - 2, - 8, - 603, - 78967, - 29546, - 23, - 803, - 20, - 25, - 416, - 5, - 8, - 232, - 4, - 277, - 6, - 1855, - 4601, - 3, - 29546, - 54, - 8, - 3609, - 5, - 57211, - 49, - 4, - 1, - 277, - 18, - 8, - 1755, - 15691, - 3, - 341, - 25, - 416, - 693, - 42573, - 71, - 17, - 401, - 94, - 31, - 17919, - 2, - 29546, - 7873, - 18, - 1, - 435, - 23, - 11011, - 755, - 5, - 5167, - 3, - 7983, - 98, - 84, - 2, - 29546, - 3267, - 8, - 3609, - 4, - 1, - 4865, - 1075, - 2, - 6087, - 71, - 6, - 346, - 8, - 5854, - 3, - 29546, - 824, - 1400, - 1868, - 2, - 19, - 160, - 2, - 311, - 8, - 5496, - 2, - 20920, - 17, - 25, - 15097, - 3, - 24, - 24, - 0, - ] - ], - dtype=torch.long, - device=torch_device, - ) + + # fmt: off + input_ids = torch.tensor([[33,1297,2,1,1009,4,1109,11739,4762,358,5,25,245,22,1706,17,20098,5,3215,21,37,1110,3,13,1041,4,24,603,490,2,71477,20098,104447,2,20961,1,2604,4,1,329,3,6224,831,16002,2,8,603,78967,29546,23,803,20,25,416,5,8,232,4,277,6,1855,4601,3,29546,54,8,3609,5,57211,49,4,1,277,18,8,1755,15691,3,341,25,416,693,42573,71,17,401,94,31,17919,2,29546,7873,18,1,435,23,11011,755,5,5167,3,7983,98,84,2,29546,3267,8,3609,4,1,4865,1075,2,6087,71,6,346,8,5854,3,29546,824,1400,1868,2,19,160,2,311,8,5496,2,20920,17,25,15097,3,24,24,0]],dtype=torch.long,device=torch_device) # noqa: E231 + # fmt: on # In 1991 , the remains of Russian Tsar Nicholas II and his family # ( except for Alexei and Maria ) are discovered . # The voice of Nicholas's young son , Tsarevich Alexei Nikolaevich , narrates the @@ -541,208 +396,9 @@ class TransfoXLModelLanguageGenerationTest(unittest.TestCase): # the Virgin Mary , prompting him to become a priest . Rasputin quickly becomes famous , # with people , even a bishop , begging for his blessing . - expected_output_ids = [ - 33, - 1297, - 2, - 1, - 1009, - 4, - 1109, - 11739, - 4762, - 358, - 5, - 25, - 245, - 22, - 1706, - 17, - 20098, - 5, - 3215, - 21, - 37, - 1110, - 3, - 13, - 1041, - 4, - 24, - 603, - 490, - 2, - 71477, - 20098, - 104447, - 2, - 20961, - 1, - 2604, - 4, - 1, - 329, - 3, - 6224, - 831, - 16002, - 2, - 8, - 603, - 78967, - 29546, - 23, - 803, - 20, - 25, - 416, - 5, - 8, - 232, - 4, - 277, - 6, - 1855, - 4601, - 3, - 29546, - 54, - 8, - 3609, - 5, - 57211, - 49, - 4, - 1, - 277, - 18, - 8, - 1755, - 15691, - 3, - 341, - 25, - 416, - 693, - 42573, - 71, - 17, - 401, - 94, - 31, - 17919, - 2, - 29546, - 7873, - 18, - 1, - 435, - 23, - 11011, - 755, - 5, - 5167, - 3, - 7983, - 98, - 84, - 2, - 29546, - 3267, - 8, - 3609, - 4, - 1, - 4865, - 1075, - 2, - 6087, - 71, - 6, - 346, - 8, - 5854, - 3, - 29546, - 824, - 1400, - 1868, - 2, - 19, - 160, - 2, - 311, - 8, - 5496, - 2, - 20920, - 17, - 25, - 15097, - 3, - 24, - 24, - 0, - 33, - 1, - 142, - 1298, - 188, - 2, - 29546, - 113, - 8, - 3654, - 4, - 1, - 1109, - 7136, - 833, - 3, - 13, - 1645, - 4, - 29546, - 11, - 104, - 7, - 1, - 1109, - 532, - 7129, - 2, - 10, - 83507, - 2, - 1162, - 1123, - 2, - 6, - 7245, - 10, - 2, - 5, - 11, - 104, - 7, - 1, - 1109, - 532, - 7129, - 2, - 10, - 24, - 24, - 10, - 22, - 10, - 13, - 770, - 5863, - 4, - 7245, - 10, - ] + # fmt: off + expected_output_ids = [33,1297,2,1,1009,4,1109,11739,4762,358,5,25,245,22,1706,17,20098,5,3215,21,37,1110,3,13,1041,4,24,603,490,2,71477,20098,104447,2,20961,1,2604,4,1,329,3,6224,831,16002,2,8,603,78967,29546,23,803,20,25,416,5,8,232,4,277,6,1855,4601,3,29546,54,8,3609,5,57211,49,4,1,277,18,8,1755,15691,3,341,25,416,693,42573,71,17,401,94,31,17919,2,29546,7873,18,1,435,23,11011,755,5,5167,3,7983,98,84,2,29546,3267,8,3609,4,1,4865,1075,2,6087,71,6,346,8,5854,3,29546,824,1400,1868,2,19,160,2,311,8,5496,2,20920,17,25,15097,3,24,24,0,33,1,142,1298,188,2,29546,113,8,3654,4,1,1109,7136,833,3,13,1645,4,29546,11,104,7,1,1109,532,7129,2,10,83507,2,1162,1123,2,6,7245,10,2,5,11,104,7,1,1109,532,7129,2,10,24,24,10,22,10,13,770,5863,4,7245,10] # noqa: E231 + # fmt: on # In 1991, the remains of Russian Tsar Nicholas II and his family ( except for # Alexei and Maria ) are discovered. The voice of young son, Tsarevich Alexei # Nikolaevich, narrates the remainder of the story. 1883 Western Siberia, a young