Skip to content

Commit f6ebf4d

Browse files
authored
modify test problem (#2662)
1 parent d21da81 commit f6ebf4d

File tree

4 files changed

+11
-296
lines changed

4 files changed

+11
-296
lines changed

tests/data/test_data_collator.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
from paddleformers.data import default_data_collator
2424

25-
from ..testing_utils import skip_for_none_ce_case
26-
2725

2826
class DataCollatorIntegrationTest(unittest.TestCase):
2927
def setUp(self):
@@ -90,13 +88,3 @@ def test_default_with_no_labels(self):
9088
batch = default_data_collator(features)
9189
self.assertTrue("labels" not in batch)
9290
self.assertEqual(batch["inputs"].shape, [8, 6])
93-
94-
@skip_for_none_ce_case
95-
def test_data_collator_for_language_modeling(self):
96-
no_pad_features = [{"input_ids": list(range(10))}, {"input_ids": list(range(10))}]
97-
pad_features = [{"input_ids": list(range(5))}, {"input_ids": list(range(10))}]
98-
self._test_no_pad_and_pad(no_pad_features, pad_features)
99-
100-
no_pad_features = [list(range(10)), list(range(10))]
101-
pad_features = [list(range(5)), list(range(10))]
102-
self._test_no_pad_and_pad(no_pad_features, pad_features)

tests/generation/test_streamers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ def test_text_streamer_decode_kwargs(self):
7777
# Tests that we can pass `decode_kwargs` to the streamer to control how the tokens are decoded. Must be tested
7878
# with actual models -- the dummy models' tokenizers are not aligned with their models, and
7979
# `skip_special_tokens=True` has no effect on them
80-
tokenizer = AutoTokenizer.from_pretrained("PaddleNLP/bloom-560m")
81-
model = AutoModelForCausalLM.from_pretrained("PaddleNLP/bloom-560m")
80+
tokenizer = AutoTokenizer.from_pretrained("Paddleformers/tiny-random-qwen3")
81+
model = AutoModelForCausalLM.from_pretrained("Paddleformers/tiny-random-qwen3", convert_from_hf=True)
8282
model.config.eos_token_id = -1
83+
model.config.bos_token_id = 1
8384

8485
input_ids = paddle.ones([1, 5], dtype="int64") * model.config.bos_token_id
8586
attention_mask = paddle.ones_like(input_ids, dtype="bool")

tests/trainer/test_unified_checkpoint.py

Lines changed: 0 additions & 274 deletions
Original file line numberDiff line numberDiff line change
@@ -233,219 +233,6 @@ def testTP2Sharding4(self):
233233
np.testing.assert_allclose(res[0], res[1], self.rtol)
234234

235235

236-
@pytest.mark.xdist_group(name="UC")
237-
class TestUnifiedCheckpointFull(TestUnifiedCheckpointBase):
238-
@skip_for_none_ce_case
239-
@require_paddle_at_least_8_gpu
240-
def testTP8(self):
241-
remove_logs()
242-
remove_ckpt(pretrain_arguments["output_dir"])
243-
244-
train_args = self.configs["TP8"]
245-
self.runfirst(train_args)
246-
self.rerun(train_args)
247-
248-
if self.need_allclose:
249-
res = check_acc()
250-
assert len(res) == 2
251-
np.testing.assert_allclose(res[0], res[1], self.rtol)
252-
253-
@skip_for_none_ce_case
254-
@require_paddle_at_least_8_gpu
255-
def testTP4DP2(self):
256-
remove_logs()
257-
remove_ckpt(pretrain_arguments["output_dir"])
258-
259-
train_args = self.configs["TP4DP2"]
260-
self.runfirst(train_args)
261-
self.rerun(train_args)
262-
263-
if self.need_allclose:
264-
res = check_acc()
265-
assert len(res) == 2
266-
np.testing.assert_allclose(res[0], res[1], self.rtol)
267-
268-
@skip_for_none_ce_case
269-
@require_paddle_at_least_8_gpu
270-
def testTP4Sharding2(self):
271-
remove_logs()
272-
remove_ckpt(pretrain_arguments["output_dir"])
273-
274-
train_args = self.configs["TP4Sharding2"]
275-
self.runfirst(train_args)
276-
self.rerun(train_args)
277-
278-
if self.need_allclose:
279-
res = check_acc()
280-
assert len(res) == 2
281-
np.testing.assert_allclose(res[0], res[1], self.rtol)
282-
283-
@skip_for_none_ce_case
284-
@require_paddle_at_least_8_gpu
285-
def testTP2PP4(self):
286-
remove_logs()
287-
remove_ckpt(pretrain_arguments["output_dir"])
288-
289-
train_args = self.configs["TP2PP4"]
290-
self.runfirst(train_args)
291-
self.rerun(train_args)
292-
293-
if self.need_allclose:
294-
res = check_acc()
295-
assert len(res) == 2
296-
np.testing.assert_allclose(res[0], res[1], self.rtol)
297-
298-
@skip_for_none_ce_case
299-
@require_paddle_at_least_8_gpu
300-
def testPP8(self):
301-
remove_logs()
302-
remove_ckpt(pretrain_arguments["output_dir"])
303-
304-
train_args = self.configs["PP8"]
305-
self.runfirst(train_args)
306-
self.rerun(train_args)
307-
308-
if self.need_allclose:
309-
res = check_acc()
310-
assert len(res) == 2
311-
np.testing.assert_allclose(res[0], res[1], self.rtol)
312-
313-
@skip_for_none_ce_case
314-
@require_paddle_at_least_8_gpu
315-
def testPP4DP2(self):
316-
remove_logs()
317-
remove_ckpt(pretrain_arguments["output_dir"])
318-
319-
train_args = self.configs["PP4DP2"]
320-
self.runfirst(train_args)
321-
self.rerun(train_args)
322-
323-
if self.need_allclose:
324-
res = check_acc()
325-
assert len(res) == 2
326-
np.testing.assert_allclose(res[0], res[1], self.rtol)
327-
328-
@skip_for_none_ce_case
329-
@require_paddle_at_least_8_gpu
330-
def testPP4Sharding2(self):
331-
remove_logs()
332-
remove_ckpt(pretrain_arguments["output_dir"])
333-
334-
train_args = self.configs["PP4Sharding2"]
335-
self.runfirst(train_args)
336-
self.rerun(train_args)
337-
338-
if self.need_allclose:
339-
res = check_acc()
340-
assert len(res) == 2
341-
np.testing.assert_allclose(res[0], res[1], self.rtol)
342-
343-
@skip_for_none_ce_case
344-
@require_paddle_at_least_8_gpu
345-
def testSharding8S1(self):
346-
remove_logs()
347-
remove_ckpt(pretrain_arguments["output_dir"])
348-
349-
train_args = self.configs["Sharding8S1"]
350-
self.runfirst(train_args)
351-
self.rerun(train_args)
352-
353-
if self.need_allclose:
354-
res = check_acc()
355-
assert len(res) == 2
356-
np.testing.assert_allclose(res[0], res[1], self.rtol)
357-
358-
@skip_for_none_ce_case
359-
@require_paddle_at_least_8_gpu
360-
def testSharding8S2(self):
361-
remove_logs()
362-
remove_ckpt(pretrain_arguments["output_dir"])
363-
364-
train_args = self.configs["Sharding8S2"]
365-
self.runfirst(train_args)
366-
self.rerun(train_args)
367-
368-
if self.need_allclose:
369-
res = check_acc()
370-
assert len(res) == 2
371-
np.testing.assert_allclose(res[0], res[1], self.rtol)
372-
373-
@skip_for_none_ce_case
374-
@require_paddle_at_least_8_gpu
375-
def testSharding4S1DP2(self):
376-
remove_logs()
377-
remove_ckpt(pretrain_arguments["output_dir"])
378-
379-
train_args = self.configs["Sharding4S1DP2"]
380-
self.runfirst(train_args)
381-
self.rerun(train_args)
382-
383-
if self.need_allclose:
384-
res = check_acc()
385-
assert len(res) == 2
386-
np.testing.assert_allclose(res[0], res[1], self.rtol)
387-
388-
@skip_for_none_ce_case
389-
@require_paddle_at_least_8_gpu
390-
def testSharding4S2DP2(self):
391-
remove_logs()
392-
remove_ckpt(pretrain_arguments["output_dir"])
393-
394-
train_args = self.configs["Sharding4S2DP2"]
395-
self.runfirst(train_args)
396-
self.rerun(train_args)
397-
398-
if self.need_allclose:
399-
res = check_acc()
400-
assert len(res) == 2
401-
np.testing.assert_allclose(res[0], res[1], self.rtol)
402-
403-
@skip_for_none_ce_case
404-
@require_paddle_at_least_8_gpu
405-
def testSharding2S1DP4(self):
406-
remove_logs()
407-
remove_ckpt(pretrain_arguments["output_dir"])
408-
409-
train_args = self.configs["Sharding2S1DP4"]
410-
self.runfirst(train_args)
411-
self.rerun(train_args)
412-
413-
if self.need_allclose:
414-
res = check_acc()
415-
assert len(res) == 2
416-
np.testing.assert_allclose(res[0], res[1], self.rtol)
417-
418-
@skip_for_none_ce_case
419-
@require_paddle_at_least_8_gpu
420-
def testSharding2S2DP4(self):
421-
remove_logs()
422-
remove_ckpt(pretrain_arguments["output_dir"])
423-
424-
train_args = self.configs["Sharding2S2DP4"]
425-
self.runfirst(train_args)
426-
self.rerun(train_args)
427-
428-
if self.need_allclose:
429-
res = check_acc()
430-
assert len(res) == 2
431-
np.testing.assert_allclose(res[0], res[1], self.rtol)
432-
433-
@skip_for_none_ce_case
434-
@require_paddle_at_least_8_gpu
435-
def testDP8(self):
436-
remove_logs()
437-
remove_ckpt(pretrain_arguments["output_dir"])
438-
439-
train_args = self.configs["DP8"]
440-
self.runfirst(train_args)
441-
self.rerun(train_args)
442-
443-
if self.need_allclose:
444-
res = check_acc()
445-
assert len(res) == 2
446-
np.testing.assert_allclose(res[0], res[1], self.rtol)
447-
448-
449236
@pytest.mark.skipif(True, reason="Skip for None CE")
450237
class TestUnifiedCheckpointOnN2C4(TestUnifiedCheckpointBase):
451238
def setUp(self):
@@ -460,28 +247,6 @@ def rerun(self, train_args):
460247
self.run_n2c4(self.run_pretrain_file, **train_args)
461248

462249

463-
# Test Unified Checkpoint Hybrid Parallel Strategy Convert on N1C8
464-
@pytest.mark.skipif(True, reason="Skip for failed")
465-
class TestUnifiedCheckpointOnN1C8Dynamic(TestUnifiedCheckpointFull):
466-
def setUp(self):
467-
super().setUp()
468-
self.need_allclose = False
469-
self.rtol = 1e-4
470-
self.k = MAX_CONVERT_CONFIGS # max: 16, min: 1
471-
472-
def runfirst(self, train_args):
473-
self.run_n1c8(self.run_pretrain_file, **train_args)
474-
475-
def rerun(self, train_args):
476-
configs = random_sample(self.configs.keys(), k=self.k)
477-
for config_name in configs:
478-
print(f"Rerun using {config_name}")
479-
config = self.configs[config_name]
480-
self.run_n1c8(self.run_pretrain_file, **config)
481-
res = check_acc()
482-
np.testing.assert_allclose(res[0], res[-1], rtol=self.rtol)
483-
484-
485250
# Test Unified Checkpoint Hybrid Parallel Strategy Convert on N2C4
486251
@pytest.mark.skipif(True, reason="Skip for failed")
487252
class TestUnifiedCheckpointOnN2C4Dynamic(TestUnifiedCheckpointBase):
@@ -1132,42 +897,3 @@ def rerun(self, train_args):
1132897
self.run_n1c8(self.run_pretrain_file, **config)
1133898
res = check_acc()
1134899
np.testing.assert_allclose(res[0], res[-1], rtol=self.rtol)
1135-
1136-
1137-
@pytest.mark.skipif(True, reason="Skip for None CE")
1138-
class TestUnifiedCheckpointOnN1C8SaveLoadSpeed(TestUnifiedCheckpointFull):
1139-
def setUp(self):
1140-
super().setUp()
1141-
for config_key in self.configs:
1142-
self.configs[config_key]["skip_profile_timer"] = 0
1143-
self.configs[config_key]["unified_checkpoint"] = 1
1144-
self.configs[config_key]["save_steps"] = 6
1145-
self.configs[config_key]["unified_checkpoint_config"] = "skip_save_model_weight master_weight_compatible"
1146-
1147-
self.need_allclose = False
1148-
self.rtol = 1e-7
1149-
1150-
def runfirst(self, train_args):
1151-
self.run_n1c8(self.run_pretrain_file, log_dir="log_uc", **train_args)
1152-
1153-
def rerun(self, train_args):
1154-
self.run_n1c8(self.run_pretrain_file, log_dir="log_uc", **train_args)
1155-
1156-
1157-
@pytest.mark.skipif(True, reason="Skip for None CE")
1158-
class TestPaddleCheckpointOnN1C8SaveLoadSpeed(TestUnifiedCheckpointFull):
1159-
def setUp(self):
1160-
super().setUp()
1161-
for config_key in self.configs:
1162-
self.configs[config_key]["skip_profile_timer"] = 0
1163-
self.configs[config_key]["unified_checkpoint"] = 0
1164-
self.configs[config_key]["save_steps"] = 6
1165-
1166-
self.need_allclose = False
1167-
self.rtol = 1e-7
1168-
1169-
def runfirst(self, train_args):
1170-
self.run_n1c8(self.run_pretrain_file, log_dir="log_pd", **train_args)
1171-
1172-
def rerun(self, train_args):
1173-
self.run_n1c8(self.run_pretrain_file, log_dir="log_pd", **train_args)

tests/transformers/llama/test_modeling.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ def test_inference_no_attention(self):
356356
with paddle.no_grad():
357357
output = model(input_ids, attention_mask=attention_mask)[0]
358358

359-
expected_shape = [1, 11, 768]
359+
expected_shape = [1, 11, 16]
360360
self.assertEqual(output.shape, expected_shape)
361361

362362
expected_slice = paddle.to_tensor(
363363
[
364364
[
365-
[0.20443289, 0.18662477, -0.75216216],
366-
[0.37699354, -0.38747141, -1.21889985],
367-
[0.31100151, -0.40143669, -0.64101797],
365+
[-1.41304350, 0.50553894, 1.06899679],
366+
[-0.22070873, -0.05084248, -0.92472076],
367+
[-0.45478714, -1.70910871, 0.60857075],
368368
]
369369
]
370370
)
@@ -379,14 +379,14 @@ def test_inference_with_attention(self):
379379
with paddle.no_grad():
380380
output = model(input_ids, attention_mask=attention_mask)[0]
381381

382-
expected_shape = [1, 11, 768]
382+
expected_shape = [1, 11, 16]
383383
self.assertEqual(output.shape, expected_shape)
384384
expected_slice = paddle.to_tensor(
385385
[
386386
[
387-
[0.20443289, 0.18662477, -0.75216216],
388-
[0.37699354, -0.38747141, -1.21889985],
389-
[0.31100151, -0.40143669, -0.64101797],
387+
[-1.41304350, 0.50553894, 1.06899679],
388+
[-0.22070873, -0.05084248, -0.92472076],
389+
[-0.45478714, -1.70910871, 0.60857075],
390390
]
391391
]
392392
)

0 commit comments

Comments
 (0)