run_func_test.py 18.6 KB
Newer Older
aiss's avatar
aiss committed
1
2
3
4
5
6
7
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0

# DeepSpeed Team
"""
Note: please copy webtext data to "Megatron-LM" folder, before running this script.
"""
Elton Zheng's avatar
Elton Zheng committed
8
9
10
11
12
13

import unittest
import os
import re
from .test_common import BaseTestCase

14
15
16
17
LAYERS = 2
HIDDEN_SIZE = 128
ATTN_HEADS = 8
SEQ_LEN = 64
Jeff Rasley's avatar
Jeff Rasley committed
18
MASTER_PORT = 29700
19

Elton Zheng's avatar
Elton Zheng committed
20
21
22

def grep_loss_from_file(file_name):
    loss = 0.0
Jeff Rasley's avatar
Jeff Rasley committed
23
    print(f'grepping {file_name}')
Elton Zheng's avatar
Elton Zheng committed
24
25
26
    with open(file_name, 'r') as f:
        lines = f.readlines()
        line_filter = "validation loss at the end of training for test data | LM loss:"
aiss's avatar
aiss committed
27
        match_number = re.compile(r'LM loss: ([-+]?[0-9]+\.?[0-9]*(?:[Ee][-+]?[0-9]+)?)')
Elton Zheng's avatar
Elton Zheng committed
28
29
30
31
32
33
34
35
36
37
38
39
40

        for line in lines:
            if line_filter in line:
                loss = re.findall(match_number, line)
                loss = float(loss[0])

    if loss == 0.0:
        print("no loss found in file ", file_name)

    return loss


class GPT2FuncTestCase(BaseTestCase):
aiss's avatar
aiss committed
41

Elton Zheng's avatar
Elton Zheng committed
42
43
44
45
46
47
48
49
50
51
52
53
    def __init__(self, methodName="DeepSpeed function test on GPT2 model"):
        super(GPT2FuncTestCase, self).__init__(methodName)

    def setUp(self):
        self.save_dir = os.getcwd()
        new_dir = os.path.dirname(__file__)
        if new_dir:
            os.chdir(new_dir)

    def tearDown(self):
        os.chdir(self.save_dir)

Jeff Rasley's avatar
Jeff Rasley committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    def test_mp1_gpu2_node1_fp16(self):
        test_config = {
            "mp": 1,
            "gpus": 2,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_no_zero.json",
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
72
    def test_mp1_gpu1_node1_zero1(self):
Elton Zheng's avatar
Elton Zheng committed
73
74
75
76
77
78
        test_config = {
            "mp": 1,
            "gpus": 1,
            "nodes": 1,
            "bs": 4,
            "steps": 1000,
79
80
81
82
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Elton Zheng's avatar
Elton Zheng committed
83
            "deepspeed": False,
Jeff Rasley's avatar
Jeff Rasley committed
84
            "json": "ds_config_func_bs4_zero1.json",
Elton Zheng's avatar
Elton Zheng committed
85
86
87
88
89
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
90
    def test_mp1_gpu2_node1_zero1(self):
Elton Zheng's avatar
Elton Zheng committed
91
92
93
94
95
96
        test_config = {
            "mp": 1,
            "gpus": 2,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
97
98
99
100
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Elton Zheng's avatar
Elton Zheng committed
101
            "deepspeed": False,
Jeff Rasley's avatar
Jeff Rasley committed
102
            "json": "ds_config_func_bs8_zero1.json",
Elton Zheng's avatar
Elton Zheng committed
103
104
105
106
107
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
108
    def test_mp2_gpu4_node1_zero1(self):
Elton Zheng's avatar
Elton Zheng committed
109
110
111
112
113
114
        test_config = {
            "mp": 2,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
115
116
117
118
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Elton Zheng's avatar
Elton Zheng committed
119
            "deepspeed": False,
Jeff Rasley's avatar
Jeff Rasley committed
120
121
122
123
124
125
126
127
128
129
130
131
132
            "json": "ds_config_func_bs8_zero1.json",
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp4_gpu4_node1_zero1(self):
        test_config = {
            "mp": 4,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
133
134
135
136
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Jeff Rasley's avatar
Jeff Rasley committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero1.json",
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp1_gpu1_node1_zero2(self):
        test_config = {
            "mp": 1,
            "gpus": 1,
            "nodes": 1,
            "bs": 4,
            "steps": 1000,
151
152
153
154
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Jeff Rasley's avatar
Jeff Rasley committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
            "deepspeed": False,
            "json": "ds_config_func_bs4_zero2.json",
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp1_gpu2_node1_zero2(self):
        test_config = {
            "mp": 1,
            "gpus": 2,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
169
170
171
172
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Jeff Rasley's avatar
Jeff Rasley committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2.json",
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp2_gpu4_node1_zero2(self):
        test_config = {
            "mp": 2,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
187
188
189
190
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Jeff Rasley's avatar
Jeff Rasley committed
191
192
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2.json",
Elton Zheng's avatar
Elton Zheng committed
193
194
        }

Jeff Rasley's avatar
Jeff Rasley committed
195
196
        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.01)
Elton Zheng's avatar
Elton Zheng committed
197
198
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
199
200
        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.01)
Elton Zheng's avatar
Elton Zheng committed
201
202
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
203
    def test_mp4_gpu4_node1_zero2(self):
Elton Zheng's avatar
Elton Zheng committed
204
205
206
207
208
209
        test_config = {
            "mp": 4,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
210
211
212
213
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Elton Zheng's avatar
Elton Zheng committed
214
            "deepspeed": False,
Jeff Rasley's avatar
Jeff Rasley committed
215
            "json": "ds_config_func_bs8_zero2.json",
Elton Zheng's avatar
Elton Zheng committed
216
217
        }

Jeff Rasley's avatar
Jeff Rasley committed
218
219
        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.01)
Elton Zheng's avatar
Elton Zheng committed
220
221
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.01)
        self.assertTrue(succ)

    def test_mp1_gpu1_node1_zero2_ds_offload(self):
        test_config = {
            "mp": 1,
            "gpus": 1,
            "nodes": 1,
            "bs": 4,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs4_zero2_offload.json",
            "cpu_optimizer": True,
        }
        succ = self.run_test(test_config, 0.02)
        self.assertTrue(succ)

    def test_mp1_gpu2_node1_zero2_ds_offload(self):
        test_config = {
            "mp": 1,
            "gpus": 2,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
        }
        succ = self.run_test(test_config, 0.02)
Elton Zheng's avatar
Elton Zheng committed
260
261
        self.assertTrue(succ)

262
263
264
265
266
267
268
269
270
271
272
273
    def test_mp2_gpu4_node1_zero2_gas(self):
        test_config = {
            "mp": 2,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": True,
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
274
275
            "json": "ds_config_func_bs8_zero2_gas3.json",
            "baseline": "ds_config_func_bs8_zero0_gas3.json",
276
277
278
279
280
281
282
283
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

        succ = self.run_partition_activations_test(test_config, 0.01)
        self.assertTrue(succ)

Jeff Rasley's avatar
Jeff Rasley committed
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
    def test_mp2_gpu4_node1_zero2_ds_offload(self):
        test_config = {
            "mp": 2,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
        }

        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.02)
        self.assertTrue(succ)

        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.02)
        self.assertTrue(succ)

    def test_mp4_gpu4_node1_zero2_ds_offload(self):
        test_config = {
            "mp": 4,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
        }

        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.02)
        self.assertTrue(succ)

        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.02)
        self.assertTrue(succ)

    def test_mp1_gpu1_node1_zero2_torch_offload(self):
        test_config = {
            "mp": 1,
            "gpus": 1,
            "nodes": 1,
            "bs": 4,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs4_zero2_offload.json",
            "cpu_optimizer": True,
            "test_torch_offload": True,
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp1_gpu2_node1_zero2_torch_offload(self):
        test_config = {
            "mp": 1,
            "gpus": 2,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
            "test_torch_offload": True,
        }

        succ = self.run_test(test_config, 0.01)
        self.assertTrue(succ)

    def test_mp2_gpu4_node1_zero2_torch_offload(self):
        test_config = {
            "mp": 2,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
            "test_torch_offload": True,
        }

        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.01)
        self.assertTrue(succ)

        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.01)
        self.assertTrue(succ)

    def test_mp4_gpu4_node1_zero2_torch_offload(self):
        test_config = {
            "mp": 4,
            "gpus": 4,
            "nodes": 1,
            "bs": 8,
            "steps": 1000,
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
            "deepspeed": False,
            "json": "ds_config_func_bs8_zero2_offload.json",
            "cpu_optimizer": True,
            "test_torch_offload": True,
        }

        basic_run_config = test_config
        succ = self.run_test(basic_run_config, 0.01)
        self.assertTrue(succ)

        partition_activation_config = test_config
        succ = self.run_partition_activations_test(partition_activation_config, 0.01)

Elton Zheng's avatar
Elton Zheng committed
421
422
423
424
425
426
427
    def test_optimizer_scheduler(self):
        test_config = {
            "mp": 1,
            "gpus": 1,
            "nodes": 1,
            "bs": 4,
            "steps": 20,
428
429
430
431
            "layers": LAYERS,
            "hidden_size": HIDDEN_SIZE,
            "seq_length": SEQ_LEN,
            "heads": ATTN_HEADS,
Elton Zheng's avatar
Elton Zheng committed
432
433
434
435
436
437
438
439
440
441
442
443
            "deepspeed": False,
            "json": "ds_config_func_scheduler.json",
        }

        succ = self.run_test(test_config, 0.01)
        # assure no crash.
        self.assertTrue(True)

    def run_partition_activations_test(self, test_config, r_tol):
        print("\n")
        print("{0}: starting......".format(self.id()))

Jeff Rasley's avatar
Jeff Rasley committed
444
        baseline_prefix = "gpt2_func_"
Elton Zheng's avatar
Elton Zheng committed
445
446
        prefix = "gpt2_partition_activation_"

447
448
        deepspeed_config = test_config["json"]
        baseline_deepspeed_config = False
Jeff Rasley's avatar
Jeff Rasley committed
449
        cpu_optimizer_flag = self.gen_cpu_optimizer_flag(test_config, True)
450

Elton Zheng's avatar
Elton Zheng committed
451
        # baseline run...
452
453
454
455
456
457
458
459
460
        # turnoff deepspeed if baseline deepspeed config
        # is not provided
        if not "baseline" in test_config:
            test_config["deepspeed"] = False
        else:
            test_config["json"] = test_config["baseline"]
            baseline_prefix += test_config["json"][0:-5]
            baseline_deepspeed_config = True

Jeff Rasley's avatar
Jeff Rasley committed
461
        test_config["other_args"] = f"\"{cpu_optimizer_flag}\""
aiss's avatar
aiss committed
462
        base_file = self.gen_output_name(test_config, baseline_prefix, baseline_config=baseline_deepspeed_config)
Elton Zheng's avatar
Elton Zheng committed
463
464
465
466
467
468
469
470
471
472

        # skip baseline run if it exists.
        if not self.has_loss_data(base_file):
            print("{0}: baseline run.".format(self.id()))
            self.run_gpt2_test(test_config, base_file)
        else:
            print("{0}: baseline exists.".format(self.id()))

        # DeepSpeed run...
        test_config["deepspeed"] = True
Jeff Rasley's avatar
Jeff Rasley committed
473
        cpu_optimizer_flag = self.gen_cpu_optimizer_flag(test_config, False)
aiss's avatar
aiss committed
474
        test_config["other_args"] = f"\"--deepspeed-activation-checkpointing {cpu_optimizer_flag}\""
475
        test_config["json"] = deepspeed_config
Jeff Rasley's avatar
Jeff Rasley committed
476

Elton Zheng's avatar
Elton Zheng committed
477
478
479
480
481
482
483
484
485
486
487
        print("{0}: DeepSpeed run.".format(self.id()))
        test_file = self.gen_output_name(test_config, prefix)
        self.run_gpt2_test(test_config, test_file)

        return self.check_parity(base_file, test_file, r_tol)

    def run_test(self, test_config, r_tol):
        print("\n")
        print("{0}: starting......".format(self.id()))

        prefix = "gpt2_func"
488
489
490
491
        baseline_prefix = prefix

        deepspeed_config = test_config["json"]
        baseline_deepspeed_config = False
Jeff Rasley's avatar
Jeff Rasley committed
492
        cpu_optimizer_flag = self.gen_cpu_optimizer_flag(test_config, True)
493
494
495
496
497
498
499
500
501
502

        # baseline run...
        # turn off deepspeed if a baseline deepspeed config
        # is not provided
        if not "baseline" in test_config:
            test_config["deepspeed"] = False
        else:
            test_config["json"] = test_config["baseline"]
            baseline_prefix = prefix + test_config["json"][0:-5]
            baseline_deepspeed_config = True
Elton Zheng's avatar
Elton Zheng committed
503

Jeff Rasley's avatar
Jeff Rasley committed
504
505
        test_config["other_args"] = f"\"{cpu_optimizer_flag}\""

Elton Zheng's avatar
Elton Zheng committed
506
        # baseline run...
aiss's avatar
aiss committed
507
        base_file = self.gen_output_name(test_config, baseline_prefix, baseline_config=baseline_deepspeed_config)
Elton Zheng's avatar
Elton Zheng committed
508
509
510
511
512
513
514
515
516
517

        # skip baseline run if it exists.
        if not self.has_loss_data(base_file):
            print("{0}: baseline run.".format(self.id()))
            self.run_gpt2_test(test_config, base_file)
        else:
            print("{0}: baseline exists.".format(self.id()))

        # DeepSpeed run...
        test_config["deepspeed"] = True
Jeff Rasley's avatar
Jeff Rasley committed
518
519
        cpu_optimizer_flag = self.gen_cpu_optimizer_flag(test_config, False)
        test_config["other_args"] = f"\"{cpu_optimizer_flag}\""
520

Elton Zheng's avatar
Elton Zheng committed
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
        print("{0}: DeepSpeed run.".format(self.id()))
        test_file = self.gen_output_name(test_config, prefix)
        self.run_gpt2_test(test_config, test_file)

        return self.check_parity(base_file, test_file, r_tol)

    def has_loss_data(self, file_name):
        has_loss = False
        if os.path.exists(file_name):
            loss = grep_loss_from_file(file_name)
            if loss != 0.0:
                has_loss = True

        return has_loss

    def check_parity(self, base_file, test_file, r_tol):
        base_loss = grep_loss_from_file(base_file)
        test_loss = grep_loss_from_file(test_file)

        print("baseline loss: {0}, test loss: {1}".format(base_loss, test_loss))

        if base_loss == 0.0 or test_loss == 0.0:
            return False

        if abs((base_loss - test_loss) / base_loss) > r_tol:
            return False

        return True

Jeff Rasley's avatar
Jeff Rasley committed
550
551
552
553
554
555
556
557
558
559
560
561
562
563
    def gen_cpu_optimizer_flag(self, test_config, is_baseline):
        if 'cpu_optimizer' in test_config and test_config['cpu_optimizer']:
            cpu_optimizer_flag = "--cpu-optimizer"
            if is_baseline:
                cpu_optimizer_flag += " --cpu_torch_adam"
                return cpu_optimizer_flag
            if 'test_torch_offload' in test_config and test_config['test_torch_offload']:
                cpu_optimizer_flag += " --cpu_torch_adam"
                return cpu_optimizer_flag
        else:
            cpu_optimizer_flag = ""

        return cpu_optimizer_flag

Elton Zheng's avatar
Elton Zheng committed
564
565
566

def suite():
    suite = unittest.TestSuite()
Jeff Rasley's avatar
Jeff Rasley committed
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583

    suite.addTest(GPT2FuncTestCase('test_mp1_gpu2_node1_fp16'))

    # Baseline = Megatron + Torch.Optim.Adam
    # Test = Megatron + Torch.Optim.Adam + ZeRO-Offload
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu1_node1_zero2_torch_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu2_node1_zero2_torch_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp2_gpu4_node1_zero2_torch_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp4_gpu4_node1_zero2_torch_offload'))

    # Baseline = Megatron + Torch.Optim.Adam
    # Test = Megatron + DeepSpeedAdam + ZeRO-Offload
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu1_node1_zero2_ds_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu2_node1_zero2_ds_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp2_gpu4_node1_zero2_ds_offload'))
    suite.addTest(GPT2FuncTestCase('test_mp4_gpu4_node1_zero2_ds_offload'))

Jeff Rasley's avatar
Jeff Rasley committed
584
585
586
587
588
589
590
591
592
593
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu1_node1_zero1'))
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu2_node1_zero1'))
    suite.addTest(GPT2FuncTestCase('test_mp2_gpu4_node1_zero1'))
    suite.addTest(GPT2FuncTestCase('test_mp4_gpu4_node1_zero1'))

    suite.addTest(GPT2FuncTestCase('test_mp1_gpu1_node1_zero2'))
    suite.addTest(GPT2FuncTestCase('test_mp1_gpu2_node1_zero2'))
    suite.addTest(GPT2FuncTestCase('test_mp2_gpu4_node1_zero2'))
    suite.addTest(GPT2FuncTestCase('test_mp4_gpu4_node1_zero2'))

594
595
    suite.addTest(GPT2FuncTestCase('test_mp2_gpu4_node1_zero2_gas'))

Elton Zheng's avatar
Elton Zheng committed
596
    suite.addTest(GPT2FuncTestCase('test_optimizer_scheduler'))
597

Elton Zheng's avatar
Elton Zheng committed
598
599
600
601
602
603
    return suite


if __name__ == '__main__':
    runner = unittest.TextTestRunner(failfast=True)
    runner.run(suite())