Coverage for  / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / auto_parallel / sapp_nd / perf_estimation / utils_classes.py: 100%

30 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-10-25 05:45 +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"""Custom Config options""" 

16from enum import Enum, auto 

17 

18 

19class RatioType(Enum): 

20 "comm/comp" 

21 

22 COMM_ONLY = auto() 

23 COMPUTE_ONLY = auto() 

24 STATIC = auto() 

25 DYNAMIC = auto() 

26 

27 

28class PerformanceType(Enum): 

29 """What an estimate is. 

30 

31 FLOP is the live one, and a relative score: ND weighs each part's work 

32 and ranks strategies by it, and the ratios fitted on a measured round 

33 turn the parts into milliseconds, so no rate and no device peak prices 

34 a part (a host link's sustained_tflops only converts an offload copy 

35 where no ratio does). That is a decision rather than a gap: 

36 ND stays a relative scorer while it can. TIME, which would divide by a 

37 device's rates, has no production caller. 

38 """ 

39 

40 FLOP = auto() 

41 TIME = auto() # no production caller: ND is a relative scorer 

42 

43 

44class P2PCommType(Enum): 

45 """flags""" 

46 

47 NONE = auto() 

48 MANUAL = auto() 

49 

50 

51class RecType(Enum): 

52 """flags""" 

53 

54 NONE = auto() 

55 WITH = auto() 

56 COMM_ONLY = auto() 

57 COMPUTE_ONLY = auto() 

58 

59 

60class NetworkLevel(Enum): 

61 """device network""" 

62 

63 NODE = auto() 

64 CLUSTER = auto() 

65 

66 

67class CustomConfig: 

68 r"""Custom Config for Base Performance Estimator""" 

69 

70 def __init__( 

71 self, 

72 rtype=RatioType.DYNAMIC, 

73 # ttype = PerformanceType.TIME, 

74 ttype=PerformanceType.FLOP, 

75 ptype=P2PCommType.NONE, # MANUAL, 

76 retype=RecType.WITH, # recompute re-runs compute and communication 

77 ): 

78 self.rtype = rtype 

79 self.ttype = ttype 

80 self.ptype = ptype 

81 self.retype = retype 

82 

83 def __repr__(self): 

84 return ( 

85 f"CustomConfig(rtype={self.rtype}, " 

86 f"ttype={self.ttype}, " 

87 f"ptype={self.ptype}, " 

88 f"retype={self.retype})" 

89 ) 

90 

91 def __str__(self): 

92 return self.__repr__()