diff --git a/profiler/advisor/advisor_backend/cluster_advice/cluster_advice_base.py b/profiler/advisor/advisor_backend/cluster_advice/cluster_advice_base.py index 60e5a75482a5b183612fbae08f4e28e2fa088501..34624e2c3444838775c6504f044a2263afc2de15 100644 --- a/profiler/advisor/advisor_backend/cluster_advice/cluster_advice_base.py +++ b/profiler/advisor/advisor_backend/cluster_advice/cluster_advice_base.py @@ -23,6 +23,7 @@ from profiler.prof_common.constant import Constant logger = Logger() + class ClusterAdviceBase(AdviceBase): def __init__(self, collection_path: str): super().__init__(collection_path) diff --git a/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py b/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py index 47fd73d0ab2ac9e76947f7c472dc606105dc80c4..e371df1abd1463185b5330bed027b1f75fbe7ebd 100644 --- a/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py +++ b/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py @@ -124,6 +124,7 @@ class PipelineTraceViewer: return data + class ClusterPipelineAdvice(ClusterAdviceBase): BUBBLE = "Bubble" STAGE = "Stage" @@ -140,21 +141,6 @@ class ClusterPipelineAdvice(ClusterAdviceBase): self.cur_advices = "" - @staticmethod - def _align_trace_bound(results: List) -> None: - """ - align all rank trace bound for better visualization - """ - start_list, end_list = [], [] - for res in results: - start_list.append(res[0].start) - end_list.append(res[-1].end) - - # update all rank trace bound - for res in results: - res[0].start = min(start_list) - res[-1].end = max(end_list) - @staticmethod def load_trace_view_data(json_path) -> Optional[FineTraceViewData]: """ @@ -444,3 +430,18 @@ class ClusterPipelineAdvice(ClusterAdviceBase): pipeline_que.popleft() else: bp_bound_que.popleft() + + @staticmethod + def _align_trace_bound(results: List) -> None: + """ + align all rank trace bound for better visualization + """ + start_list, end_list = [], [] + for res in results: + start_list.append(res[0].start) + end_list.append(res[-1].end) + + # update all rank trace bound + for res in results: + res[0].start = min(start_list) + res[-1].end = max(end_list) diff --git a/profiler/advisor/advisor_backend/common_func_advisor/trace_view_json.py b/profiler/advisor/advisor_backend/common_func_advisor/trace_view_json.py index a6337cd5798e6367e0e61e241ab54fa89ee28b60..8c529ae6e1257416e97a0c6103432b98b3a8ace2 100644 --- a/profiler/advisor/advisor_backend/common_func_advisor/trace_view_json.py +++ b/profiler/advisor/advisor_backend/common_func_advisor/trace_view_json.py @@ -28,6 +28,7 @@ from profiler.advisor.advisor_backend.logger import Logger logger = Logger() + @dataclass class TraceObj: ph: str = "" @@ -39,7 +40,7 @@ class TraceObj: id: int = 0 ts: str = "" dur: float = 0.0 - args: dict = field(default='unknown') + args: dict = field(default_factory=lambda: {}) @abstractmethod def hash(self): diff --git a/profiler/advisor/advisor_backend/compute_advice/compute_advice_base.py b/profiler/advisor/advisor_backend/compute_advice/compute_advice_base.py index cca97c1e77739c08d11dbaa9e03494936d16b382..f3db56f369eb2f082c1ee8730e7d95831cfd2035 100644 --- a/profiler/advisor/advisor_backend/compute_advice/compute_advice_base.py +++ b/profiler/advisor/advisor_backend/compute_advice/compute_advice_base.py @@ -16,10 +16,13 @@ from abc import abstractmethod from collections import defaultdict import os +import logging from advice_base import AdviceBase from profiler.prof_common.file_manager import FileManager +logger = logging.getLogger() + class ComputeAdviceBase(AdviceBase): ASCEND_PT = 'ascend_pt' @@ -40,22 +43,22 @@ class ComputeAdviceBase(AdviceBase): check whether input path is valid """ if not os.path.exists(self.collection_path): - print("[ERROR] Path: {} is not exist.".format(self.collection_path)) + logger.error("Path: {} is not exist.".format(self.collection_path)) return False if os.path.isdir(self.collection_path) and \ (self.collection_path.endswith("ascend_pt") or self.collection_path.endswith("ascend_ms")): self.kernel_details_path = os.path.join(self.collection_path, "ASCEND_PROFILER_OUTPUT", "kernel_details.csv") if not os.path.exists(self.kernel_details_path): - print("[ERROR] kernel_details.csv is not exist in the Path: {}.".format( + logger.error("kernel_details.csv is not exist in the Path: {}.".format( os.path.join(self.collection_path, "ASCEND_PROFILER_OUTPUT"))) return False elif os.path.isfile(self.collection_path) and os.path.basename(self.collection_path) == "kernel_details.csv": self.kernel_details_path = self.collection_path else: - print("[ERROR] Please input ascend_pt or kernel_details.csv") + logger.error("Please input ascend_pt or kernel_details.csv") return False - print("[INFO] Start to analyse the target file: {}".format(self.kernel_details_path)) + logger.error("Start to analyse the target file: {}".format(self.kernel_details_path)) self.preparse() return True @@ -103,4 +106,4 @@ class ComputeAdviceBase(AdviceBase): def preparse(self): if self.has_preparse: - return + return \ No newline at end of file diff --git a/profiler/advisor/advisor_backend/compute_advice/npu_fused/json_analyzer.py b/profiler/advisor/advisor_backend/compute_advice/npu_fused/json_analyzer.py index fd2a72ffa39bfde1b3e59450c6d76f51d98110d9..da86dd421e5ad9a2f17440a316244a9d532eea8e 100644 --- a/profiler/advisor/advisor_backend/compute_advice/npu_fused/json_analyzer.py +++ b/profiler/advisor/advisor_backend/compute_advice/npu_fused/json_analyzer.py @@ -17,6 +17,10 @@ import pandas as pd from common_func_advisor.trace_view_json import TraceViewJson +from profiler.advisor.advisor_backend.logger import Logger + +logger = Logger() + class JSONAnalyzer(object): def __init__(self, path): @@ -28,18 +32,18 @@ class JSONAnalyzer(object): for i, row in data.iterrows(): if ts_col not in data.columns.tolist(): - print("[ERROR] No {} col found in data columns.".format(ts_col)) + logger.error("No {} col found in data columns.".format(ts_col)) return callstacks timestamp = row[ts_col] flow_event = trace_json.get_torch_2_npu_flow_event(timestamp) if not flow_event.valid(): - print("[ERROR] Get flow event failed for pattern {}.".format(row['pattern'])) + logger.error("Get flow event failed for pattern {}.".format(row['pattern'])) callstacks.loc[i] = "" continue flow_event_s_key = flow_event.s_point_ts python_dur_events = trace_json.get_python_dur_events_contain_ts(flow_event_s_key) if not python_dur_events: - print("[ERROR] No python dur event found for pattern {}.".format(row['pattern'])) + logger.error("No python dur event found for pattern {}.".format(row['pattern'])) callstacks.loc[i] = "" continue # 保持新老版本callstack兼容性 @@ -52,4 +56,4 @@ class JSONAnalyzer(object): callstack = [event.name for event in python_dur_events if event.cat == "python_function"] callstack_str = "\n".join(callstack) callstacks.loc[i] = callstack_str - return callstacks + return callstacks \ No newline at end of file diff --git a/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py b/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py index 7bcbed5a75807b57a55787c743cfaaff55a68589..a2c806ef48490c33e19d1bec0c102beba1dea8b1 100644 --- a/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py +++ b/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py @@ -14,11 +14,14 @@ # limitations under the License. import functools from typing import Dict +import logging from common_func_advisor.constant import Constant from common_func_advisor.constant import CoreType from common_func_advisor.constant import PerfColor +logger = logging.getLogger() + class OpPerfFactory: @classmethod @@ -129,7 +132,7 @@ class OpPerf: shapes = self.shape_to_tuple(shapes_str) dtypes = self.dtype_to_tuple(dtypes_str) if len(shapes) > len(dtypes): - print(f"[ERROR] The size of shape is greater than that of dtypes.") + logger.error("The size of shape is greater than that of dtypes.") return 0 if len(shapes) < len(dtypes): shapes = list(shapes) @@ -144,7 +147,7 @@ class OpPerf: def get_calc_size(self): # input and output bytes (MB) if not self.input_shapes or not self.output_shapes: - print("[ERROR] There is no tensor data, do not assess vector op performance.") + logger.error("There is no tensor data, do not assess vector op performance.") return 0 intput_size = self.get_size(self.input_shapes, self.input_data_types) output_size = self.get_size(self.output_shapes, self.output_data_types) @@ -153,7 +156,7 @@ class OpPerf: def get_throughput(self): # throughput(GB/s) if not self.task_duration or abs(self.task_duration) < 1e-6: - print("[ERROR] There is no task_duration, do not assess vector op performance.") + logger.error("There is no task_duration, do not assess vector op performance.") return 0 return self.row[Constant.TITLE.SIZE] / Constant.BYTE_UNIT_TRANS / self.task_duration * Constant.UNIT_TRANS * Constant.UNIT_TRANS @@ -186,7 +189,7 @@ class CubeOpPerf(OpPerf): def get_perf_color(self) -> PerfColor: aic_mac_ratio = self.get_mac_ratio() if not aic_mac_ratio: - print("[WARNING] There is no aic_mac_ratio, do not assess cube op performance.") + logger.warning("There is no aic_mac_ratio, do not assess cube op performance.") return PerfColor.WHITE elif aic_mac_ratio < 0.6: return PerfColor.RED diff --git a/profiler/advisor/advisor_backend/compute_advice/npu_fused_advice.py b/profiler/advisor/advisor_backend/compute_advice/npu_fused_advice.py index fd5610bbbbb98d15fbab22bb646b2dd7de36ac3d..c0254c7d85f0e88e752eab4961b9dd049c7d4c42 100644 --- a/profiler/advisor/advisor_backend/compute_advice/npu_fused_advice.py +++ b/profiler/advisor/advisor_backend/compute_advice/npu_fused_advice.py @@ -17,11 +17,16 @@ import os from abc import ABC import pandas as pd +import logging from compute_advice.compute_advice_base import ComputeAdviceBase from compute_advice.npu_fused.csv_analyzer import CSVAnalyzer from compute_advice.npu_fused.json_analyzer import JSONAnalyzer +from profiler.advisor.advisor_backend.logger import Logger + +logger = Logger() + class NpuFusedAdvice(ComputeAdviceBase, ABC): @@ -46,7 +51,7 @@ class NpuFusedAdvice(ComputeAdviceBase, ABC): all_pattern_data = all_pattern_data.sort_values(by='duration sum(us)', ascending=False) filter_data = all_pattern_data.get(all_pattern_data.get("duration sum(us)", 0) > 0) if not self.has_callstack(): - print("[Warning] No call stack info found, advice will be incomplete") + logger.warning("call stack info found, advice will be incomplete") self.cur_data = filter_data else: json_analyzer = JSONAnalyzer(self.trace_view_path) diff --git a/profiler/advisor/advisor_backend/compute_advice/npu_slow_advice.py b/profiler/advisor/advisor_backend/compute_advice/npu_slow_advice.py index 48522cf55a4cfb3f89083c3ac69ec7b22b295195..4479c1d1b0a29aa8a49cbf5dac1b9079beec94d8 100644 --- a/profiler/advisor/advisor_backend/compute_advice/npu_slow_advice.py +++ b/profiler/advisor/advisor_backend/compute_advice/npu_slow_advice.py @@ -25,6 +25,10 @@ from common_func_advisor.constant import Constant from common_func_advisor.constant import PerfColor from advisor_backend.common_func_advisor.trace_view_json import TraceViewJson +from profiler.advisor.advisor_backend.logger import Logger + +logger = Logger() + class NpuSlowAdvice(ComputeAdviceBase, ABC): OP_PERF_SHEET = "op_perf" @@ -64,7 +68,7 @@ class NpuSlowAdvice(ComputeAdviceBase, ABC): def get_call_stack(self, data: pd.DataFrame, index_id: int, ts_col: str) -> str: if not self.has_callstack(): - print("There is no call stack info, please set 'with_stack=True'") + logger.warning("There is no call stack info, please set 'with_stack=True'") return "" trace_json = TraceViewJson(self.trace_view_path) return trace_json.get_call_stack(data, index_id, ts_col) diff --git a/profiler/advisor/advisor_backend/logger.py b/profiler/advisor/advisor_backend/logger.py index 3b72d157a28a0a2953cf99bb90d0d31539ce2be9..bfb4faf25e1d40cc2fda69d03de1c048353a571a 100644 --- a/profiler/advisor/advisor_backend/logger.py +++ b/profiler/advisor/advisor_backend/logger.py @@ -15,6 +15,7 @@ import logging + class Logger: def __init__(self): if not hasattr(self, 'logger'): diff --git a/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py b/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py index effa9099e2bffbd3e36858218b6271ba3fab851e..94ea33ae78bf5f94202a67a4bdacaf2c24e71746 100644 --- a/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py +++ b/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py @@ -13,9 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import os +import logging from advisor_backend.advice_base import AdviceBase +from profiler.advisor.advisor_backend.logger import Logger from profiler.advisor.display.prompt.base_prompt import BasePrompt from profiler.prof_common.constant import Constant @@ -23,6 +25,8 @@ from compare_interface.comparison_interface import ComparisonInterface from profiler.prof_common.additional_args_manager import AdditionalArgsManager +logger = Logger() + class OverallSummaryAdvice(AdviceBase): @@ -56,7 +60,7 @@ class OverallSummaryAdvice(AdviceBase): try: duration = float(split_data[0]) except ValueError: - print(f"[WARNING] Invalid time value: {time_value}.") + logger.warning(f"Invalid time value: {time_value}.") return duration, num @staticmethod @@ -77,7 +81,7 @@ class OverallSummaryAdvice(AdviceBase): if os.path.exists(self.base_collection_path): self._has_base_collection = True else: - print(f"[WARNING] Invalid path which not exists: {self.base_collection_path}.") + logger.warning(f"Invalid path which not exists: {self.base_collection_path}.") return os.path.exists(self.collection_path) def process(self): diff --git a/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py b/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py index 9e868784c7962f79e6f398160fedd3e36decebf2..03359f80fa72de7c67fb346cde1df40a38c6b75a 100644 --- a/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py +++ b/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py @@ -19,6 +19,7 @@ from timeline_advice.timeline_advice_base import TimelineAdviceBase logger = logging.getLogger() + class OpScheduleAdvice(TimelineAdviceBase): def __init__(self, collection_path: str): super().__init__(collection_path) diff --git a/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py b/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py index 0bcf9a8f68787fc42d1ed5f9e34eafd42e5cbb21..f5f95986d3906cabcc54b806dab04ca3b2a4ea77 100644 --- a/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py +++ b/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py @@ -25,6 +25,7 @@ from profiler.prof_common.file_manager import FileManager logger = logging.getLogger() logger.setLevel(logging.INFO) + class TimelineAdviceBase(AdviceBase): class PreParseType: OPTIMIZER = 0 @@ -53,7 +54,7 @@ class TimelineAdviceBase(AdviceBase): check whether input path is valid """ if not os.path.exists(self.collection_path): - logger.error("Path: %s is not exist.",str(self.collection_path)) + logger.error("Path: %s is not exist.", str(self.collection_path)) return False if os.path.isdir(self.collection_path) and \ (self.collection_path.endswith("ascend_pt") or self.collection_path.endswith("ascend_ms")): diff --git a/profiler/advisor/analyzer/base_analyzer.py b/profiler/advisor/analyzer/base_analyzer.py index 17fa7fd3fad9b6f6837c1fe701882c0f060edc3f..a0cec581d578edc5a7d030135602b839011719fc 100644 --- a/profiler/advisor/analyzer/base_analyzer.py +++ b/profiler/advisor/analyzer/base_analyzer.py @@ -102,7 +102,7 @@ class BaseAnalyzer(VersionControl, metaclass=ABCMeta): pass @abstractmethod - def get_priority(self, max_mem_op_dur): + def get_priority(self): pass def identify_profiling_type(self, profiling_type_list): diff --git a/profiler/advisor/analyzer/cluster/Communication_retransmission_analyzer.py b/profiler/advisor/analyzer/cluster/communication_retransmission_analyzer.py similarity index 93% rename from profiler/advisor/analyzer/cluster/Communication_retransmission_analyzer.py rename to profiler/advisor/analyzer/cluster/communication_retransmission_analyzer.py index 3683ef1b44f8b6c571dd4d8fdce0d39882d342af..c324b4cfdbf543fa2bce3785615c004d7cc6ceaf 100644 --- a/profiler/advisor/analyzer/cluster/Communication_retransmission_analyzer.py +++ b/profiler/advisor/analyzer/cluster/communication_retransmission_analyzer.py @@ -14,13 +14,14 @@ # limitations under the License. import logging +from profiler.advisor.advisor_backend.logger import Logger from profiler.advisor.analyzer.base_analyzer import BaseAnalyzer from profiler.advisor.result.result import OptimizeResult -from profiler.advisor.analyzer.cluster.Communication_retransmission_checker import CommunicationRetransmissionChecker +from profiler.advisor.analyzer.cluster.communication_retransmission_checker import CommunicationRetransmissionChecker from profiler.advisor.display.html.render import HTMLRender from profiler.advisor.dataset.cluster.cluster_dataset import ClusterCommunicationDataset -logger = logging.getLogger() +logger = Logger() class RDMARetransmissionAnalyzer(BaseAnalyzer): diff --git a/profiler/advisor/analyzer/cluster/Communication_retransmission_checker.py b/profiler/advisor/analyzer/cluster/communication_retransmission_checker.py similarity index 100% rename from profiler/advisor/analyzer/cluster/Communication_retransmission_checker.py rename to profiler/advisor/analyzer/cluster/communication_retransmission_checker.py diff --git a/profiler/advisor/analyzer/computation/aicpu/aicpu_checker.py b/profiler/advisor/analyzer/computation/aicpu/aicpu_checker.py index 83f3b6acc68fa5ab10693f2136368a1a433066d0..e7d87e1fd9748f60bd173fb40168a9323afd6e6a 100644 --- a/profiler/advisor/analyzer/computation/aicpu/aicpu_checker.py +++ b/profiler/advisor/analyzer/computation/aicpu/aicpu_checker.py @@ -26,6 +26,7 @@ from profiler.prof_common.additional_args_manager import AdditionalArgsManager from profiler.prof_common.file_manager import FileManager from profiler.prof_common.constant import Constant + class AicpuChecker(OperatorChecker): _CHECKER = "aicpu operator" _MIN_TASK_DURATION = 20 diff --git a/profiler/advisor/analyzer/computation/op_compile/dynamic_shape_checker.py b/profiler/advisor/analyzer/computation/op_compile/dynamic_shape_checker.py index 8481821332ba3014fcd460f6abec7d057de16cb3..1396b81505d16ee180d4a0085694a5873a4f8337 100644 --- a/profiler/advisor/analyzer/computation/op_compile/dynamic_shape_checker.py +++ b/profiler/advisor/analyzer/computation/op_compile/dynamic_shape_checker.py @@ -39,7 +39,7 @@ class DynamicShapeChecker(OperatorChecker): self._PROBLEM = self.prompt_class.PROBLEM self._description = self.prompt_class.DESCRIPTION self.enable_compiled_suggestion = self.prompt_class.ENABLE_COMPILED_SUGGESTION - self._SUGGESTION = [self.prompt_class.ENABLE_COMPILED_SUGGESTION] + self._suggestion = [self.prompt_class.ENABLE_COMPILED_SUGGESTION] self.release_suggestion = self.prompt_class.RELEASE_SUGGESTION def check(self, profiling_data) -> bool: @@ -54,7 +54,7 @@ class DynamicShapeChecker(OperatorChecker): optimization_item = OptimizeItem( self._PROBLEM, self._description, - self._SUGGESTION + self._suggestion ) statistics_item = StatisticsItem("", "", 1) return OptimizeRecord(optimization_item, statistics_item) diff --git a/profiler/advisor/analyzer/computation/operator_checker.py b/profiler/advisor/analyzer/computation/operator_checker.py index 445f09cff15291c0823b184b94e1418ee69c5268..6ff724e1ecb11389b87a3abcb35b21944962963b 100644 --- a/profiler/advisor/analyzer/computation/operator_checker.py +++ b/profiler/advisor/analyzer/computation/operator_checker.py @@ -42,7 +42,7 @@ class OperatorChecker(VersionControl): _description = str() STACK_INFO_ITEMS = "" _ITEMS: List[str] = [] - _SUGGESTION: List[str] = [] + _suggestion: List[str] = [] SKIP_CHECK_MSG = "Skip %s checker because of not containing %s" _tune_op_info_list: List[OpInfo] = [] @@ -130,7 +130,7 @@ class OperatorChecker(VersionControl): optimization_item = OptimizeItem( self._PROBLEM, self._get_description(self._description, self.get_op_type_list(self._op_list)[:self._MAX_TUNE_OP_NUM]), - self._SUGGESTION + self._suggestion ) return OptimizeRecord(optimization_item, statistics_item) @@ -317,9 +317,9 @@ class OperatorChecker(VersionControl): def format_suggestion_content(self, profiling_data: ProfilingDataset) -> None: if profiling_data.prof_type == EnumParamsParser().profiling_type.ascend_pytorch_profiler: - self._SUGGESTION.append(self.pytorch_op_tune_suggestion) + self._suggestion.append(self.pytorch_op_tune_suggestion) elif profiling_data.prof_type == EnumParamsParser.profiling_type.mslite: - self._SUGGESTION.append(self.mslite_op_tune_suggestion) + self._suggestion.append(self.mslite_op_tune_suggestion) def _check_data(self, profiling_data): return True diff --git a/profiler/advisor/analyzer/computation/profiling_analyzer.py b/profiler/advisor/analyzer/computation/profiling_analyzer.py index 97154bb9f7bfc11d8299b65bdd6ce050745ba41c..b818026fd352727688fababd803e775e1ae1ed86 100644 --- a/profiler/advisor/analyzer/computation/profiling_analyzer.py +++ b/profiler/advisor/analyzer/computation/profiling_analyzer.py @@ -78,7 +78,7 @@ class ProfilingAnalyzer(BaseAnalyzer, ABC): return self.result - def get_priority(self,max_mem_op_dur): + def get_priority(self): if "aicpu" not in max_mem_op_dur.__class__.__name__.lower(): return PriorityBackgroundColor.low diff --git a/profiler/advisor/analyzer/memory/memory_analyzer.py b/profiler/advisor/analyzer/memory/memory_analyzer.py index 939e2de90c634ee6cca584dca345111dce26bb7b..78f1d2a1d77d2783603f1ccc22cbc1a929bcb7db 100644 --- a/profiler/advisor/analyzer/memory/memory_analyzer.py +++ b/profiler/advisor/analyzer/memory/memory_analyzer.py @@ -39,10 +39,11 @@ class MemoryAnalyzer(BaseAnalyzer): memory_checker = MemoryOpsChecker() memory_checker.check_memory_ops(self.dataset) memory_checker.make_record(self.result) - memory_checker.make_render(self.html_render, priority=self.get_priority(memory_checker.max_mem_op_dur), rank=kwargs.get("rank")) + memory_checker.make_render(self.html_render, + priority=self.get_priority(memory_checker.max_mem_op_dur), rank=kwargs.get("rank")) return self.result - def get_priority(self, max_mem_op_dur): + def get_priority(self): step_duration = getattr(self.dataset, "step_duration", None) if step_duration is None: return PriorityBackgroundColor.high diff --git a/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py b/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py index 2d3a601ac533b48c15fd44504cf56265a42335a7..ad963e343ed5cb4d78521414f6b15a5a985791da 100644 --- a/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py +++ b/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py @@ -43,5 +43,5 @@ class SynchronizeStreamAnalyzer(BaseAnalyzer): rank=kwargs.get("rank")) return self.result - def get_priority(self, synchronize_stream_checker): + def get_priority(self, synchronize_stream_checker = None): return synchronize_stream_checker.priority diff --git a/profiler/advisor/common/profiling/ge_info.py b/profiler/advisor/common/profiling/ge_info.py index 91642f967970fdf27f76754ee4bbd7f4ab4fcc50..9446427f45298d4db97aaa5046b93f397dc4109e 100644 --- a/profiler/advisor/common/profiling/ge_info.py +++ b/profiler/advisor/common/profiling/ge_info.py @@ -43,7 +43,7 @@ class GeInfo(ProfilingParser): super().__init__(path) self.op_state_info_list = None - def parse_from_file(self, file: str): + def parse_from_file(self, file: str = ""): """ ge info """ diff --git a/profiler/advisor/common/profiling/op_summary.py b/profiler/advisor/common/profiling/op_summary.py index c042509df96c0c8feacb39a56e6f73358cd5d8a9..cc7f58b0bf7b0f5986eb9b5a46097da35b8f3f76 100644 --- a/profiler/advisor/common/profiling/op_summary.py +++ b/profiler/advisor/common/profiling/op_summary.py @@ -43,7 +43,7 @@ class OpSummary(ProfilingParser): self._total_task_wait_time = 0.0 self._raw_data: List[List[str]] = [] - def parse_from_file(self, file: str): + def parse_from_file(self, file: str = ""): if not self._parse_csv(file): return False title_dict = dict(enumerate(self._raw_data[0])) diff --git a/profiler/advisor/dataset/profiling/profiling_dataset.py b/profiler/advisor/dataset/profiling/profiling_dataset.py index cd1d953aa0fd355328bc823e4a064d012a06e3f3..ad16e518e85ab006e9a28eaaf7e093eb484c22b8 100644 --- a/profiler/advisor/dataset/profiling/profiling_dataset.py +++ b/profiler/advisor/dataset/profiling/profiling_dataset.py @@ -37,7 +37,8 @@ class ProfilingDataset(Dataset): def __init__(self, collection_path, data: dict, **kwargs) -> None: self.cann_version = kwargs.get(Constant.CANN_VERSION, EnumParamsParser().get_default(Constant.CANN_VERSION)) - self.prof_type = kwargs.get(Constant.PROFILING_TYPE_UNDER_LINE, EnumParamsParser().get_default(Constant.PROFILING_TYPE_UNDER_LINE)) + self.prof_type = kwargs.get(Constant.PROFILING_TYPE_UNDER_LINE, + EnumParamsParser().get_default(Constant.PROFILING_TYPE_UNDER_LINE)) self.patterns = self.parse_pattern() self.current_version_pattern = self.get_current_version_pattern() self._info = None diff --git a/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py b/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py index d868acbf59e3a0aec6af99c8cbafcd55d834b8db..5d6711294371055de56f316bf4430344e7632d1f 100644 --- a/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py +++ b/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py @@ -40,7 +40,7 @@ class StepCollector(BaseOpCollector): super().__init__() self.require_filter_by_step = False - def add_op(self, event): + def add_op(self, event = None): if event.name.startswith(self.KEY_WORD): self.op_list.append(event) diff --git a/profiler/advisor/display/prompt/base_prompt.py b/profiler/advisor/display/prompt/base_prompt.py index 2dcacc381e01bd9e84568f77d12b7083170e8d61..2a538f3dbbd7188d551ebd7f04d430792e8deff5 100644 --- a/profiler/advisor/display/prompt/base_prompt.py +++ b/profiler/advisor/display/prompt/base_prompt.py @@ -16,6 +16,7 @@ import importlib from profiler.prof_common.additional_args_manager import AdditionalArgsManager + def split_camel_case(word): result = [] current_word = [] diff --git a/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py b/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py index b350f603f115eb9dad32c49b2d1659ec367df6fe..36e6f5e528ddad9f1130094f8c87ed25efacb870 100644 --- a/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py +++ b/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py @@ -17,8 +17,8 @@ class DynamicShapePrompt(object): RANK_ID = "RANK {} " PROBLEM = "Dynamic Shape Operator" DESCRIPTION = "Found all operators are dynamic shape" - ENABLE_COMPILED_SUGGESTION = "1. Please try to set environment by execute `export HOST_CACHE_CAPACITY=20`.\n." \ - "2. Please place the following code at the entrance of the python script to disable jit compile.\n " \ - "Code: `torch_npu.npu.set_compile_mode(jit_compile=False) \n " \ - "torch_npu.npu.config.allow_internal_format = False`.\n" + ENABLE_COMPILED_SUGGESTION = """1. Please try to set environment by execute `export HOST_CACHE_CAPACITY=20`.\n. + 2. Please place the following code at the entrance of the python script to disable jit compile.\n + Code: `torch_npu.npu.set_compile_mode(jit_compile=False) + torch_npu.npu.config.allow_internal_format = False`.\n""" RELEASE_SUGGESTION = "for details please refer to link : LINK"