已合并
hccl Aicpu展开算子在python解析时被归为hccl问题 #70
wangzixuan创建于 2月9日
hccl Aicpu展开算子在python解析时被归为hccl问题 #70
已合并
共 11 个文件变更+24-22
| @@ -472,7 +472,8 @@ class Constant: | |||
| 472 | DATA_PROCESS_AI_CPU = "AICPU" | 472 | DATA_PROCESS_AI_CPU = "AICPU" |
| 473 | TASK_TYPE_WRITE_BACK = "WRITE_BACK" | 473 | TASK_TYPE_WRITE_BACK = "WRITE_BACK" |
| 474 | TASK_TYPE_INVALID = "INVALID" | 474 | TASK_TYPE_INVALID = "INVALID" |
| 475 | - TASK_TYPE_HCCL = "COMMUNICATION" | 475 | + TASK_TYPE_HCCL = "HCCL" |
| 476 | + TASK_TYPE_COMMUNICATION = "COMMUNICATION" | ||
| 476 | TASK_TYPE_HCCL_AI_CPU = "HCCL_AI_CPU" | 477 | TASK_TYPE_HCCL_AI_CPU = "HCCL_AI_CPU" |
| 477 | TASK_TYPE_DSA = "DSA_SQE" | 478 | TASK_TYPE_DSA = "DSA_SQE" |
| 478 | TASK_TYPE_DVPP = "DVPP" | 479 | TASK_TYPE_DVPP = "DVPP" |
| @@ -106,7 +106,7 @@ class PmuCalculator(ICalculator): | |||
| 106 | 106 | ||
| 107 | def _format_ge_data(self: any, ge_data: list) -> None: | 107 | def _format_ge_data(self: any, ge_data: list) -> None: |
| 108 | for data in ge_data: | 108 | for data in ge_data: |
| 109 | - if data.task_type not in (Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_AIV, Constant.TASK_TYPE_HCCL, | 109 | + if data.task_type not in (Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_AIV, Constant.TASK_TYPE_COMMUNICATION, |
| 110 | Constant.TASK_TYPE_MIX_AIC, Constant.TASK_TYPE_MIX_AIV): | 110 | Constant.TASK_TYPE_MIX_AIC, Constant.TASK_TYPE_MIX_AIV): |
| 111 | continue | 111 | continue |
| 112 | _key = self.STREAM_TASK_KEY_FMT.format(data.task_id, data.stream_id) | 112 | _key = self.STREAM_TASK_KEY_FMT.format(data.task_id, data.stream_id) |
| @@ -542,13 +542,13 @@ class TaskGear(CANNGear): | |||
| 542 | return False | 542 | return False |
| 543 | 543 | ||
| 544 | def get_truth_task_type_for_kernel_hccl_task(self, add_dto): | 544 | def get_truth_task_type_for_kernel_hccl_task(self, add_dto): |
| 545 | - task_type = Constant.TASK_TYPE_HCCL | 545 | + task_type = Constant.TASK_TYPE_COMMUNICATION |
| 546 | if add_dto.task_type == self.KERNEL_AICPU: | 546 | if add_dto.task_type == self.KERNEL_AICPU: |
| 547 | # helper场景: HCCL算子运行在AI_CPU上 | 547 | # helper场景: HCCL算子运行在AI_CPU上 |
| 548 | task_type = Constant.TASK_TYPE_HCCL_AI_CPU | 548 | task_type = Constant.TASK_TYPE_HCCL_AI_CPU |
| 549 | if add_dto.task_type == self.KERNEL_AICORE: | 549 | if add_dto.task_type == self.KERNEL_AICORE: |
| 550 | # Reduce tbe | 550 | # Reduce tbe |
| 551 | - task_type = Constant.TASK_TYPE_HCCL | 551 | + task_type = Constant.TASK_TYPE_COMMUNICATION |
| 552 | return task_type | 552 | return task_type |
| 553 | 553 | ||
| 554 | def add_kernel_task(self, call_stack: dict, add_dto: TaskTrackDto, is_level0: bool): | 554 | def add_kernel_task(self, call_stack: dict, add_dto: TaskTrackDto, is_level0: bool): |
| @@ -635,7 +635,8 @@ class TaskGear(CANNGear): | |||
| 635 | # notice: reduce TBE op | 635 | # notice: reduce TBE op |
| 636 | op_name = hccl_dto.item_id | 636 | op_name = hccl_dto.item_id |
| 637 | task_type = self.get_truth_task_type_for_kernel_hccl_task(add_dto) | 637 | task_type = self.get_truth_task_type_for_kernel_hccl_task(add_dto) |
| 638 | - elif task_type == Constant.TASK_TYPE_HCCL and add_dto.task_type == self.KERNEL_AICPU: | 638 | + elif (task_type in (Constant.TASK_TYPE_COMMUNICATION, Constant.TASK_TYPE_HCCL) and |
| 639 | + add_dto.task_type == self.KERNEL_AICPU): | ||
| 639 | # helper场景, HCCL算子运行在AI_CPU上, 但没有HCCL层api | 640 | # helper场景, HCCL算子运行在AI_CPU上, 但没有HCCL层api |
| 640 | task_type = Constant.TASK_TYPE_AI_CPU | 641 | task_type = Constant.TASK_TYPE_AI_CPU |
| 641 | for cxt_id in cxt_ids: | 642 | for cxt_id in cxt_ids: |
| @@ -170,7 +170,7 @@ class MergeOpCounterCalculator(MsMultiProcess): | |||
| 170 | 170 | ||
| 171 | def _get_ge_data(self: any, ge_curs: any) -> list: | 171 | def _get_ge_data(self: any, ge_curs: any) -> list: |
| 172 | device_id = InfoConfReader().get_device_id() | 172 | device_id = InfoConfReader().get_device_id() |
| 173 | - hccl_task_type = Constant.TASK_TYPE_HCCL | 173 | + hccl_task_type = Constant.TASK_TYPE_COMMUNICATION |
| 174 | hccl_ai_cpu = Constant.TASK_TYPE_HCCL_AI_CPU | 174 | hccl_ai_cpu = Constant.TASK_TYPE_HCCL_AI_CPU |
| 175 | ge_data = [] | 175 | ge_data = [] |
| 176 | iter_list = MsprofIteration(self.project_path).get_index_id_list_with_index_and_model(self.iter_range) | 176 | iter_list = MsprofIteration(self.project_path).get_index_id_list_with_index_and_model(self.iter_range) |
| @@ -56,7 +56,7 @@ class OpCounterOpSceneCalculator(MsMultiProcess): | |||
| 56 | "task_id, stream_id, batch_id,context_id from {0} where device_id={1} " \ | 56 | "task_id, stream_id, batch_id,context_id from {0} where device_id={1} " \ |
| 57 | "and task_type != '{2}' and task_type != '{3}'" \ | 57 | "and task_type != '{2}' and task_type != '{3}'" \ |
| 58 | .format(DBNameConstant.TABLE_GE_TASK, device_id, | 58 | .format(DBNameConstant.TABLE_GE_TASK, device_id, |
| 59 | - Constant.TASK_TYPE_HCCL, Constant.TASK_TYPE_HCCL_AI_CPU) | 59 | + Constant.TASK_TYPE_COMMUNICATION, Constant.TASK_TYPE_HCCL_AI_CPU) |
| 60 | return ge_sql | 60 | return ge_sql |
| 61 | 61 | ||
| 62 | 62 | ||
| @@ -209,7 +209,7 @@ class KfcCalculator(ICalculator, MsMultiProcess): | |||
| 209 | def get_host_task_info(self: any, kfc_op_data) -> dict: | 209 | def get_host_task_info(self: any, kfc_op_data) -> dict: |
| 210 | with GeInfoViewModel(self._project_path, [DBNameConstant.TABLE_GE_TASK]) as model: | 210 | with GeInfoViewModel(self._project_path, [DBNameConstant.TABLE_GE_TASK]) as model: |
| 211 | ge_data = model.get_ge_info_by_device_id(DBNameConstant.TABLE_GE_TASK, InfoConfReader().get_device_id(), | 211 | ge_data = model.get_ge_info_by_device_id(DBNameConstant.TABLE_GE_TASK, InfoConfReader().get_device_id(), |
| 212 | - (Constant.TASK_TYPE_HCCL, Constant.TASK_TYPE_HCCL_AI_CPU)) | 212 | + (Constant.TASK_TYPE_COMMUNICATION, Constant.TASK_TYPE_HCCL_AI_CPU)) |
| 213 | node_info = {} | 213 | node_info = {} |
| 214 | for data in ge_data: | 214 | for data in ge_data: |
| 215 | if data.stream_id not in kfc_op_data: | 215 | if data.stream_id not in kfc_op_data: |
| @@ -589,7 +589,7 @@ class FftsPmuCalculator(PmuCalculator, MsMultiProcess): | |||
| 589 | 589 | ||
| 590 | def _format_ge_data(self: any, ge_data: list) -> None: | 590 | def _format_ge_data(self: any, ge_data: list) -> None: |
| 591 | for data in ge_data: | 591 | for data in ge_data: |
| 592 | - if data.task_type not in [Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_AIV, Constant.TASK_TYPE_HCCL, | 592 | + if data.task_type not in [Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_AIV, Constant.TASK_TYPE_COMMUNICATION, |
| 593 | Constant.TASK_TYPE_MIX_AIC, Constant.TASK_TYPE_MIX_AIV]: | 593 | Constant.TASK_TYPE_MIX_AIC, Constant.TASK_TYPE_MIX_AIV]: |
| 594 | continue | 594 | continue |
| 595 | _key = self.STREAM_TASK_CONTEXT_KEY_FMT.format(data.stream_id, data.task_id, data.context_id) | 595 | _key = self.STREAM_TASK_CONTEXT_KEY_FMT.format(data.stream_id, data.task_id, data.context_id) |
| @@ -82,7 +82,7 @@ class GeInfoModel(BaseModel): | |||
| 82 | "from {0} where index_id != 0 and (task_type = '{1}' or task_type = '{2}') " \ | 82 | "from {0} where index_id != 0 and (task_type = '{1}' or task_type = '{2}') " \ |
| 83 | "group by model_id, index_id, stream_id) as min_time_table " \ | 83 | "group by model_id, index_id, stream_id) as min_time_table " \ |
| 84 | "on {0}.timestamp = min_time_table.timestamp".format( | 84 | "on {0}.timestamp = min_time_table.timestamp".format( |
| 85 | - DBNameConstant.TABLE_GE_TASK, Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_HCCL) | 85 | + DBNameConstant.TABLE_GE_TASK, Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_COMMUNICATION) |
| 86 | ge_data = DBManager.fetch_all_data(self.cur, ge_sql) | 86 | ge_data = DBManager.fetch_all_data(self.cur, ge_sql) |
| 87 | 87 | ||
| 88 | if Utils.is_single_op_scene(self.result_dir): | 88 | if Utils.is_single_op_scene(self.result_dir): |
| @@ -138,20 +138,20 @@ class GeInfoModel(BaseModel): | |||
| 138 | sql = "select model_id, GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ | 138 | sql = "select model_id, GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ |
| 139 | "where index_id=0 and (task_type = '{1}' or task_type = '{2}') " \ | 139 | "where index_id=0 and (task_type = '{1}' or task_type = '{2}') " \ |
| 140 | "group by model_id".format(DBNameConstant.TABLE_GE_TASK, | 140 | "group by model_id".format(DBNameConstant.TABLE_GE_TASK, |
| 141 | - Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_HCCL) | 141 | + Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_COMMUNICATION) |
| 142 | else: | 142 | else: |
| 143 | sql = "select model_id||'-'||index_id, " \ | 143 | sql = "select model_id||'-'||index_id, " \ |
| 144 | "GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ | 144 | "GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ |
| 145 | "where index_id<>0 and (task_type = '{1}' or task_type = '{2}') " \ | 145 | "where index_id<>0 and (task_type = '{1}' or task_type = '{2}') " \ |
| 146 | "group by model_id||'-'||index_id".format(DBNameConstant.TABLE_GE_TASK, | 146 | "group by model_id||'-'||index_id".format(DBNameConstant.TABLE_GE_TASK, |
| 147 | - Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_HCCL) | 147 | + Constant.TASK_TYPE_AI_CORE, Constant.TASK_TYPE_COMMUNICATION) |
| 148 | if ProfilingScene().is_step_export(): | 148 | if ProfilingScene().is_step_export(): |
| 149 | if is_static_shape == Constant.GE_STATIC_SHAPE: | 149 | if is_static_shape == Constant.GE_STATIC_SHAPE: |
| 150 | sql = "select {model_id}, GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ | 150 | sql = "select {model_id}, GROUP_CONCAT(stream_id||'-'||task_id||'-'||batch_id) from {0} " \ |
| 151 | "where index_id=0 and (task_type = '{1}' or task_type = '{2}') " \ | 151 | "where index_id=0 and (task_type = '{1}' or task_type = '{2}') " \ |
| 152 | "group by {model_id}".format(DBNameConstant.TABLE_GE_TASK, | 152 | "group by {model_id}".format(DBNameConstant.TABLE_GE_TASK, |
| 153 | Constant.TASK_TYPE_AI_CORE, | 153 | Constant.TASK_TYPE_AI_CORE, |
| 154 | - Constant.TASK_TYPE_HCCL, | 154 | + Constant.TASK_TYPE_COMMUNICATION, |
| 155 | model_id=NumberConstant.INVALID_MODEL_ID) | 155 | model_id=NumberConstant.INVALID_MODEL_ID) |
| 156 | else: | 156 | else: |
| 157 | sql = "select {model_id}||'-'||index_id, " \ | 157 | sql = "select {model_id}||'-'||index_id, " \ |
| @@ -159,7 +159,7 @@ class GeInfoModel(BaseModel): | |||
| 159 | "where index_id<>0 and (task_type = '{1}' or task_type = '{2}') " \ | 159 | "where index_id<>0 and (task_type = '{1}' or task_type = '{2}') " \ |
| 160 | "group by {model_id}||'-'||index_id".format(DBNameConstant.TABLE_GE_TASK, | 160 | "group by {model_id}||'-'||index_id".format(DBNameConstant.TABLE_GE_TASK, |
| 161 | Constant.TASK_TYPE_AI_CORE, | 161 | Constant.TASK_TYPE_AI_CORE, |
| 162 | - Constant.TASK_TYPE_HCCL, | 162 | + Constant.TASK_TYPE_COMMUNICATION, |
| 163 | model_id=NumberConstant.INVALID_MODEL_ID) | 163 | model_id=NumberConstant.INVALID_MODEL_ID) |
| 164 | task_data = DBManager.fetch_all_data(self.cur, sql) | 164 | task_data = DBManager.fetch_all_data(self.cur, sql) |
| 165 | task_data_dict = {} | 165 | task_data_dict = {} |
| @@ -192,7 +192,7 @@ class TsTrackViewModel(ViewModel): | |||
| 192 | "ON t1.model_id=t2.model_id AND (t1.index_id=t2.index_id OR t2.index_id=0 ) " \ | 192 | "ON t1.model_id=t2.model_id AND (t1.index_id=t2.index_id OR t2.index_id=0 ) " \ |
| 193 | "AND t1.stream_id = t2.stream_id AND t1.task_id = t2.task_id AND " \ | 193 | "AND t1.stream_id = t2.stream_id AND t1.task_id = t2.task_id AND " \ |
| 194 | "t2.device_id = {3} ORDER BY t1.timestamp".format( | 194 | "t2.device_id = {3} ORDER BY t1.timestamp".format( |
| 195 | - DBNameConstant.TABLE_STEP_TRACE, DBNameConstant.TABLE_GE_TASK, Constant.TASK_TYPE_HCCL, device_id) | 195 | + DBNameConstant.TABLE_STEP_TRACE, DBNameConstant.TABLE_GE_TASK, Constant.TASK_TYPE_COMMUNICATION, device_id) |
| 196 | return DBManager.fetch_all_data(self.cur, sql, dto_class=StepTraceGeDto) | 196 | return DBManager.fetch_all_data(self.cur, sql, dto_class=StepTraceGeDto) |
| 197 | 197 | ||
| 198 | def get_ai_cpu_data(self) -> list: | 198 | def get_ai_cpu_data(self) -> list: |
| @@ -100,7 +100,7 @@ class CriticalPathParser(MetaParser): | |||
| 100 | op_dict = { | 100 | op_dict = { |
| 101 | Constant.TASK_TYPE_AI_CORE: [], | 101 | Constant.TASK_TYPE_AI_CORE: [], |
| 102 | Constant.TASK_TYPE_AI_CPU: [], | 102 | Constant.TASK_TYPE_AI_CPU: [], |
| 103 | - Constant.TASK_TYPE_HCCL: [] | 103 | + Constant.TASK_TYPE_COMMUNICATION: [] |
| 104 | } | 104 | } |
| 105 | for event in critical_path: | 105 | for event in critical_path: |
| 106 | op_task_type = event.get(CriticalPathParser.TASK_TYPE) | 106 | op_task_type = event.get(CriticalPathParser.TASK_TYPE) |
| @@ -112,7 +112,7 @@ class CriticalPathParser(MetaParser): | |||
| 112 | sorted_op_list, op_num, op_time = cls.parse_op_list(op_dict.get(op_type), top_type) | 112 | sorted_op_list, op_num, op_time = cls.parse_op_list(op_dict.get(op_type), top_type) |
| 113 | 113 | ||
| 114 | # Filter out Receive and Send operators | 114 | # Filter out Receive and Send operators |
| 115 | - if op_type == Constant.TASK_TYPE_HCCL: | 115 | + if op_type == Constant.TASK_TYPE_COMMUNICATION: |
| 116 | topk_op = [op for i, op in zip(range(top_k), filter(cls.filter_method, sorted_op_list))] | 116 | topk_op = [op for i, op in zip(range(top_k), filter(cls.filter_method, sorted_op_list))] |
| 117 | else: | 117 | else: |
| 118 | topk_op = sorted_op_list[0:top_k] | 118 | topk_op = sorted_op_list[0:top_k] |
| @@ -198,7 +198,7 @@ class CriticalPathParser(MetaParser): | |||
| 198 | """"get execution type of event in critical path """ | 198 | """"get execution type of event in critical path """ |
| 199 | execution_type_analysis_result = [] | 199 | execution_type_analysis_result = [] |
| 200 | for event in critical_path: | 200 | for event in critical_path: |
| 201 | - if event.get(CriticalPathParser.TASK_TYPE) != Constant.TASK_TYPE_HCCL: | 201 | + if event.get(CriticalPathParser.TASK_TYPE) != Constant.TASK_TYPE_COMMUNICATION: |
| 202 | continue | 202 | continue |
| 203 | intersection_event_list = self.get_time_intersection_event(event) | 203 | intersection_event_list = self.get_time_intersection_event(event) |
| 204 | serial_time, parallel_time = self.get_event_serial_parallel_time(event, intersection_event_list) | 204 | serial_time, parallel_time = self.get_event_serial_parallel_time(event, intersection_event_list) |
| @@ -230,7 +230,7 @@ class CriticalPathParser(MetaParser): | |||
| 230 | for hccl_op, hccl_events in self.hccl_op_events.items(): | 230 | for hccl_op, hccl_events in self.hccl_op_events.items(): |
| 231 | hccl_op_dict = { | 231 | hccl_op_dict = { |
| 232 | CriticalPathParser.NAME: hccl_op, | 232 | CriticalPathParser.NAME: hccl_op, |
| 233 | - CriticalPathParser.TASK_TYPE: Constant.TASK_TYPE_HCCL, | 233 | + CriticalPathParser.TASK_TYPE: Constant.TASK_TYPE_COMMUNICATION, |
| 234 | CriticalPathParser.TID: hccl_events[0].stream_id, | 234 | CriticalPathParser.TID: hccl_events[0].stream_id, |
| 235 | CriticalPathParser.TS: hccl_events[0].first_timestamp, | 235 | CriticalPathParser.TS: hccl_events[0].first_timestamp, |
| 236 | CriticalPathParser.ES: max([event.timestamp + event.duration for event in hccl_events]) | 236 | CriticalPathParser.ES: max([event.timestamp + event.duration for event in hccl_events]) |
| @@ -249,7 +249,7 @@ class CriticalPathParser(MetaParser): | |||
| 249 | critical_path_event = self.get_critical_path() | 249 | critical_path_event = self.get_critical_path() |
| 250 | event_execution_type_analysis_data = self.event_execution_type_analysis(critical_path_event) | 250 | event_execution_type_analysis_data = self.event_execution_type_analysis(critical_path_event) |
| 251 | op_type_analysis = self.event_type_analysis(event_execution_type_analysis_data) | 251 | op_type_analysis = self.event_type_analysis(event_execution_type_analysis_data) |
| 252 | - hccl_result = op_type_analysis.get(Constant.TASK_TYPE_HCCL) | 252 | + hccl_result = op_type_analysis.get(Constant.TASK_TYPE_COMMUNICATION) |
| 253 | logging.info("With critical path analysis, total ops num: %d, hccl ops num: %d ", | 253 | logging.info("With critical path analysis, total ops num: %d, hccl ops num: %d ", |
| 254 | len(critical_path_event), hccl_result.get('op_num')) | 254 | len(critical_path_event), hccl_result.get('op_num')) |
| 255 | 255 | ||
| @@ -110,7 +110,7 @@ class AiCoreOpReport: | |||
| 110 | union_data.append(datum + (Constant.NA,) * ai_core_data_len) | 110 | union_data.append(datum + (Constant.NA,) * ai_core_data_len) |
| 111 | continue | 111 | continue |
| 112 | ai_core_datum = ai_core_queue.popleft() | 112 | ai_core_datum = ai_core_queue.popleft() |
| 113 | - if datum[task_type_idx] == Constant.TASK_TYPE_HCCL and not \ | 113 | + if datum[task_type_idx] == Constant.TASK_TYPE_COMMUNICATION and not \ |
| 114 | datum[op_name_idx].endswith(StrConstant.AIV_KERNEL): | 114 | datum[op_name_idx].endswith(StrConstant.AIV_KERNEL): |
| 115 | # 去除运行在AI_CORE的HCCL小算子 | 115 | # 去除运行在AI_CORE的HCCL小算子 |
| 116 | logging.info("Found ai core hccl small op of stream %d, task %d", datum[2], datum[1]) | 116 | logging.info("Found ai core hccl small op of stream %d, task %d", datum[2], datum[1]) |
| @@ -129,7 +129,7 @@ class AiCoreOpReport: | |||
| 129 | # 全导和按step导,task type的索引是6; 按子图导,task type的索引是7 | 129 | # 全导和按step导,task type的索引是6; 按子图导,task type的索引是7 |
| 130 | task_type_idx, op_name_idx = (7, 4) if ProfilingScene().is_graph_export() else (6, 3) | 130 | task_type_idx, op_name_idx = (7, 4) if ProfilingScene().is_graph_export() else (6, 3) |
| 131 | for datum in data: | 131 | for datum in data: |
| 132 | - if datum[task_type_idx] in (Constant.TASK_TYPE_HCCL_AI_CPU, Constant.TASK_TYPE_HCCL) and not \ | 132 | + if datum[task_type_idx] in (Constant.TASK_TYPE_HCCL_AI_CPU, Constant.TASK_TYPE_COMMUNICATION) and not \ |
| 133 | datum[op_name_idx].endswith(StrConstant.AIV_KERNEL): | 133 | datum[op_name_idx].endswith(StrConstant.AIV_KERNEL): |
| 134 | logging.info("Found hccl small op of stream %d, task %d", datum[2], datum[1]) | 134 | logging.info("Found hccl small op of stream %d, task %d", datum[2], datum[1]) |
| 135 | continue | 135 | continue |