Coverage for hyper_parallel / platform / mindspore / platform_graph.py: 63%

27 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-01 07:33 +0800

1# Copyright 2025 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# ============================================================================ 

15"""MindSpore platform api for grap mode""" 

16from hyper_parallel.platform.mindspore.platform import MindSporePlatform 

17from mindspore import ops 

18 

19class MindSporeGraphPlatform(MindSporePlatform): 

20 """MindSpore platform api""" 

21 

22 @staticmethod 

23 def all_gather_into_tensor(data, group_info, async_op=False): 

24 output = ops.AllGather(group=group_info.group_name)(data) 

25 return output, None 

26 

27 @staticmethod 

28 def all_reduce(data, group_info, async_op=False): 

29 output = ops.AllReduce(group=group_info.group_name)(data) 

30 return output, None 

31 

32 @staticmethod 

33 def reduce_scatter_tensor(data, group_info, async_op=False): 

34 output = ops.ReduceScatter(group=group_info.group_name)(data) 

35 return output, None 

36 

37 @staticmethod 

38 def ckpt_wrapper(module, checkpoint_fn=None, **checkpoint_fn_kwargs): 

39 raise NotImplementedError("ckpt_wrapper is not supported on MindSpore Graph platform") 

40 

41 @property 

42 def noop_context_fn(self): 

43 raise NotImplementedError("noop_context_fn is not supported on MindSpore Graph platform") 

44 

45 @staticmethod 

46 def create_selective_checkpoint_contexts(policy_fn_or_list, allow_cache_entry_mutation=False): 

47 raise NotImplementedError("create_selective_checkpoint_contexts is not supported on MindSpore Graph platform") 

48 

49 @staticmethod 

50 def async_save_on_cpu(policy_fn=None): 

51 raise NotImplementedError("async_save_on_cpu is not supported on MindSpore Graph platform")