1# Copyright 2024 Huawei Technologies Co., Ltd 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# ============================================================================ 15import os 16import pytest 17from mindspore import context 18 19 20@pytest.mark.level0 21@pytest.mark.platform_arm_ascend910b_training 22@pytest.mark.env_single 23def test_lccl_allreduce(): 24 """ 25 Feature: lccl operator test. 26 Description: msrun lccl all_reduce 8P case. 27 Expectation: success 28 """ 29 os.environ['MS_ENABLE_LCCL'] = str(1) 30 context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") 31 return_code = os.system( 32 "msrun --worker_num=8 --local_worker_num=8 --join=True pytest -s test_lccl_allreduce.py") 33 assert return_code == 0 34 35 36@pytest.mark.level2 37@pytest.mark.platform_arm_ascend_training 38@pytest.mark.platform_x86_ascend_training 39@pytest.mark.env_single 40def test_lccl_allgather(): 41 """ 42 Feature: lccl operator test. 43 Description: msrun lccl all_gather 8P case. 44 Expectation: success 45 """ 46 os.environ['MS_ENABLE_LCCL'] = str(1) 47 context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") 48 return_code = os.system( 49 "msrun --worker_num=8 --local_worker_num=8 --join=True pytest -s test_lccl_allgather.py") 50 assert return_code == 0 51 52 53@pytest.mark.level2 54@pytest.mark.platform_arm_ascend_training 55@pytest.mark.platform_x86_ascend_training 56@pytest.mark.env_single 57def test_lccl_reducescatter(): 58 """ 59 Feature: lccl operator test. 60 Description: msrun lccl reduce_scatter 8P case. 61 Expectation: success 62 """ 63 os.environ['MS_ENABLE_LCCL'] = str(1) 64 context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") 65 return_code = os.system("msrun --worker_num=8 --local_worker_num=8 --join=True " 66 "pytest -s test_lccl_reduce_scatter.py") 67 assert return_code == 0 68 69 70@pytest.mark.level2 71@pytest.mark.platform_arm_ascend_training 72@pytest.mark.platform_x86_ascend_training 73@pytest.mark.env_single 74def test_lccl_broadcast(): 75 """ 76 Feature: lccl operator test. 77 Description: msrun lccl broadcast 8P case. 78 Expectation: success 79 """ 80 os.environ['MS_ENABLE_LCCL'] = str(1) 81 context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") 82 return_code = os.system( 83 "msrun --worker_num=8 --local_worker_num=8 --join=True pytest -s test_lccl_broadcast.py") 84 assert return_code == 0 85 86 87@pytest.mark.level2 88@pytest.mark.platform_arm_ascend910b_training 89@pytest.mark.env_single 90def test_lccl_matmul_allreduce(): 91 """ 92 Feature: lccl MatMulAllReduce fustion operator test. 93 Description: lccl MatMulAllReduce 8P case. 94 Expectation: success 95 """ 96 os.environ['MS_ENABLE_LCCL'] = str(1) 97 os.environ['MS_ENABLE_INTERNAL_KERNELS'] = 'on' 98 return_code = os.system( 99 "msrun --worker_num=8 --local_worker_num=8 --join=True pytest -s test_lccl_matmul_allreduce.py") 100 assert return_code == 0 101