Debian Codegraph @

tests/deepspeed/test_alst_ulysses_sp.py

raw
1 # Copyright 2022 The HuggingFace Team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from parameterized import parameterized
16
17 from accelerate.test_utils.testing import (
18 TempDirTestCase,
19 execute_subprocess_async,
20 path_in_accelerate_package,
21 require_deepspeed,
22 require_multi_device,
23 )
24 from accelerate.utils import patch_environment
25
26
27 @require_deepspeed
28 @require_multi_device
29 class DeepSpeedALSTUlyssesSPTest(TempDirTestCase):
30 test_scripts_folder = path_in_accelerate_package("test_utils", "scripts", "external_deps")
31
32 @parameterized.expand([2, 3])
33 def test_deepspeed_alst_ulysses_sp(self, stage):
34 self.test_file_path = self.test_scripts_folder / "test_ds_alst_ulysses_sp.py"
35 world_size = 2
36 cmd = [
37 "accelerate",
38 "launch",
39 f"--num_processes={world_size}",
40 "--num_machines=1",
41 "--machine_rank=0",
42 "--mixed_precision=bf16",
43 "--use_deepspeed",
44 f"--zero_stage={stage}",
45 self.test_file_path,
46 f"--output_dir={self.tmpdir}",
47 ]
48 with patch_environment(omp_num_threads=1):
49 execute_subprocess_async(cmd)