From 620a4964fc0ff6eb44563651f0f42f404e7bbe7c Mon Sep 17 00:00:00 2001 From: marscrazy Date: Fri, 10 Jun 2022 05:45:44 +0000 Subject: [PATCH 1/3] add tests Signed-off-by: marscrazy --- flagai/model/glm_model.py | 1 - tests/{bak_test_autoloader.py => test_autoloader.py} | 2 +- tests/{bak_test_bert.py => test_bert.py} | 0 tests/{bak_test_glm_large_ch.py => test_glm_large_ch.py} | 0 tests/{bak_test_glm_seq2seq.py => test_glm_seq2seq.py} | 2 +- tests/{bak_test_glm_superglue.py => test_glm_superglue.py} | 2 +- tests/{bak_test_gpt2_ch.py => test_gpt2_ch.py} | 0 tests/{bak_test_t5_ch.py => test_t5_ch.py} | 0 tests/test_tokenizer.py | 2 +- 9 files changed, 4 insertions(+), 5 deletions(-) rename tests/{bak_test_autoloader.py => test_autoloader.py} (98%) rename tests/{bak_test_bert.py => test_bert.py} (100%) rename tests/{bak_test_glm_large_ch.py => test_glm_large_ch.py} (100%) rename tests/{bak_test_glm_seq2seq.py => test_glm_seq2seq.py} (98%) rename tests/{bak_test_glm_superglue.py => test_glm_superglue.py} (98%) rename tests/{bak_test_gpt2_ch.py => test_gpt2_ch.py} (100%) rename tests/{bak_test_t5_ch.py => test_t5_ch.py} (100%) diff --git a/flagai/model/glm_model.py b/flagai/model/glm_model.py index a0263a79..2511109f 100644 --- a/flagai/model/glm_model.py +++ b/flagai/model/glm_model.py @@ -755,7 +755,6 @@ def forward(self, position_ids, attention_mask, prompt_pos=prompt_pos, - labels=kwargs['labels'], mems=kwargs['mems']) outputs, mems = model_out['logits'], model_out['hidden_states'] diff --git a/tests/bak_test_autoloader.py b/tests/test_autoloader.py similarity index 98% rename from tests/bak_test_autoloader.py rename to tests/test_autoloader.py index f178711f..51748e24 100644 --- a/tests/bak_test_autoloader.py +++ b/tests/test_autoloader.py @@ -93,7 +93,7 @@ def test_T5_base_ch(self): def test_CPM_large_ch(self): for t_name in self.task_name: - m_name = 'CPM-large-ch' + m_name = 'CPM-large-ch-generation' loader = AutoLoader(task_name=t_name, model_name=m_name, class_num=3, diff --git a/tests/bak_test_bert.py b/tests/test_bert.py similarity index 100% rename from tests/bak_test_bert.py rename to tests/test_bert.py diff --git a/tests/bak_test_glm_large_ch.py b/tests/test_glm_large_ch.py similarity index 100% rename from tests/bak_test_glm_large_ch.py rename to tests/test_glm_large_ch.py diff --git a/tests/bak_test_glm_seq2seq.py b/tests/test_glm_seq2seq.py similarity index 98% rename from tests/bak_test_glm_seq2seq.py rename to tests/test_glm_seq2seq.py index 305fcd3e..0fb0b154 100644 --- a/tests/bak_test_glm_seq2seq.py +++ b/tests/test_glm_seq2seq.py @@ -24,7 +24,7 @@ def test_init_trainer_pytorch(self): eval_interval=100, log_interval=50, experiment_name='glm_large', - pytorch_device='cpu', + pytorch_device='cuda', load_dir=None, lr=1e-4) print("downloading...") diff --git a/tests/bak_test_glm_superglue.py b/tests/test_glm_superglue.py similarity index 98% rename from tests/bak_test_glm_superglue.py rename to tests/test_glm_superglue.py index 06642cc2..5c35d2c2 100644 --- a/tests/bak_test_glm_superglue.py +++ b/tests/test_glm_superglue.py @@ -25,7 +25,7 @@ def test_init_trainer_pytorch(self): eval_interval=100, log_interval=50, experiment_name='glm_large', - pytorch_device='cpu', + pytorch_device='cuda', load_dir=None, lr=1e-4, save_epoch=10) diff --git a/tests/bak_test_gpt2_ch.py b/tests/test_gpt2_ch.py similarity index 100% rename from tests/bak_test_gpt2_ch.py rename to tests/test_gpt2_ch.py diff --git a/tests/bak_test_t5_ch.py b/tests/test_t5_ch.py similarity index 100% rename from tests/bak_test_t5_ch.py rename to tests/test_t5_ch.py diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index 6b7c83a6..d2f1e81f 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -84,7 +84,7 @@ def suite(): suite.addTest(TokenizerTestCase('test_tokenizer_t5')) suite.addTest(TokenizerTestCase('test_tokenizer_roberta')) suite.addTest(TokenizerTestCase('test_tokenizer_bert')) - suite.addTest(TokenizerTestCase('test_tokenizer_cpm1')) + # suite.addTest(TokenizerTestCase('test_tokenizer_cpm1')) return suite From 129a35e37fb51e6746d7f13539bcb9677322e8e0 Mon Sep 17 00:00:00 2001 From: marscrazy Date: Fri, 10 Jun 2022 05:59:14 +0000 Subject: [PATCH 2/3] add all Signed-off-by: marscrazy --- tests/test_glm_seq2seq.py | 2 +- tests/test_glm_superglue.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_glm_seq2seq.py b/tests/test_glm_seq2seq.py index 0fb0b154..0d008304 100644 --- a/tests/test_glm_seq2seq.py +++ b/tests/test_glm_seq2seq.py @@ -24,8 +24,8 @@ def test_init_trainer_pytorch(self): eval_interval=100, log_interval=50, experiment_name='glm_large', + fp16=True, pytorch_device='cuda', - load_dir=None, lr=1e-4) print("downloading...") diff --git a/tests/test_glm_superglue.py b/tests/test_glm_superglue.py index 5c35d2c2..0735db09 100644 --- a/tests/test_glm_superglue.py +++ b/tests/test_glm_superglue.py @@ -27,6 +27,7 @@ def test_init_trainer_pytorch(self): experiment_name='glm_large', pytorch_device='cuda', load_dir=None, + fp16=True, lr=1e-4, save_epoch=10) print("downloading...") From b08e913291b06edc794ef6ce2b5565a4a1ee4106 Mon Sep 17 00:00:00 2001 From: marscrazy Date: Fri, 10 Jun 2022 08:05:48 +0000 Subject: [PATCH 3/3] fix bug in evaluate Signed-off-by: marscrazy --- flagai/trainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flagai/trainer.py b/flagai/trainer.py index ea3e28c8..a72bc3db 100644 --- a/flagai/trainer.py +++ b/flagai/trainer.py @@ -707,8 +707,8 @@ def evaluate(self, step_output = forward_step_func(data_iterator, model, mems=mems) - lm_loss, mems = step_output['loss'], step_output[ - 'hidden_states'] + lm_loss= step_output['loss'] + # mems = step_output['hidden_states'] '''when contiguous memory optimizations are enabled, the buffers allocated by the optimizations are deallocated during backward pass in the absence of backward pass the buffers should be reset after each