-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Auto_Parallel] Update auto parallel ci and support new hybrid cases (#…
- Loading branch information
1 parent
be823ca
commit 815b656
Showing
12 changed files
with
326 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is generated by ${PADDLE_ROOT}/tools/gen_ut_cmakelists.py. | ||
# Please don't modify this file manually. | ||
# If you need to change unittests in this file, please modify testslist.csv in the current directory | ||
# and then run the command `python3 ${PADDLE_ROOT}/tools/gen_ut_cmakelists.py -f ${CURRENT_DIRECTORY}/testslist.csv` | ||
set(LOCAL_ALL_ARCH ON) | ||
set(LOCAL_ALL_PLAT ON) | ||
if((WITH_GPU) AND (LINUX)) | ||
py_test_modules( | ||
test_semi_auto_parallel_hybrid_strategy MODULES | ||
test_semi_auto_parallel_hybrid_strategy ENVS | ||
"http_proxy=;https_proxy=;PYTHONPATH=../..:${PADDLE_BINARY_DIR}/python") | ||
set_tests_properties(test_semi_auto_parallel_hybrid_strategy | ||
PROPERTIES TIMEOUT "120" LABELS "RUN_TYPE=HYBRID") | ||
endif() |
63 changes: 63 additions & 0 deletions
63
test/auto_parallel/hybrid_strategy/semi_auto_parallel_simple_net_dp_mp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
from auto_parallel.semi_auto_parallel_simple_net import ( | ||
DemoNet, | ||
TestSimpleNetForSemiAutoParallel, | ||
) | ||
|
||
import paddle | ||
import paddle.distributed as dist | ||
|
||
|
||
class TestSimpleNetHybridStrategyForSemiAutoParallel( | ||
TestSimpleNetForSemiAutoParallel | ||
): | ||
def __init__(self): | ||
self._dtype = os.getenv("dtype") | ||
self._backend = os.getenv("backend") | ||
self._seed = eval(os.getenv("seed")) | ||
self._mesh = dist.ProcessMesh([[0, 1], [2, 3]], dim_names=["x", "y"]) | ||
|
||
paddle.set_device(self._backend) | ||
|
||
self.set_random_seed(self._seed) | ||
self.init_single_card_net_result() | ||
|
||
def test_dp_mp_demo_net(self): | ||
self.set_random_seed(self._seed) | ||
model = dist.shard_layer( | ||
DemoNet("dp_mp_hybrid_strategy"), self._mesh, self.shard_fn | ||
) | ||
|
||
( | ||
self.dp_mp_loss, | ||
self.dp_mp_parameters, | ||
) = self.run_dynamic(model, shard_input=True) | ||
|
||
self.check_tensor_eq(self.dp_mp_loss, self.base_loss) | ||
for param, param_base in zip( | ||
self.dp_mp_parameters, self.base_parameters | ||
): | ||
self.check_tensor_eq(param, param_base) | ||
self.check_tensor_eq(param.grad, param_base.grad) | ||
|
||
def run_test_case(self): | ||
self.test_dp_mp_demo_net() | ||
|
||
|
||
if __name__ == '__main__': | ||
TestSimpleNetHybridStrategyForSemiAutoParallel().run_test_case() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name,os,arch,timeout,run_type,launcher,num_port,run_serial,envs,conditions | ||
test_semi_auto_parallel_hybrid_strategy,LINUX,GPU,120,HYBRID,test_runner.py,,,http_proxy=;https_proxy=;PYTHONPATH=../.., |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.