!68238 huitui profiler steptrace multisubgraph

Merge pull request !68238 from Henry Shi/huitui_profiler
This commit is contained in:
i-robot 2024-04-13 02:33:40 +00:00 committed by Gitee
commit d894457674
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 3 additions and 58 deletions

View File

@ -149,50 +149,6 @@ void DebugActor::DebugForGraph(const KernelGraphPtr &graph, const DeviceContext
#endif
}
/*
* Feature group: ascend step start timestamp
* Target device group: Ascend.
* Description: Add step start timestamp when profiler is started.
*/
void DebugActor::AscendStepStart(const std::vector<KernelGraphPtr> &graphs,
std::vector<DeviceContext *> device_contexts) {
auto profiler = profiler::Profiler::GetInstance(kAscendDevice);
if (profiler == nullptr || !profiler->IsInitialized() || graphs.empty()) {
return;
}
if (profiler->GetEnableFlag() && !graphs[0]->IsDatasetGraph()) {
profile_started_ = false;
for (size_t i = 0; i < graphs.size(); ++i) {
MS_EXCEPTION_IF_NULL(graphs[i]);
MS_EXCEPTION_IF_NULL(device_contexts[i]);
if (device_contexts[i]->GetDeviceType() == device::DeviceType::kAscend && !profile_started_) {
device_ctx_ = device_contexts[i];
device_ctx_->device_res_manager_->BindDeviceToCurrentThread(false);
MS_LOG(INFO) << "Dot step start timestamp.";
profiler->StepStart(current_step++, device_contexts[i]->device_res_manager_->GetStream());
profile_started_ = true;
}
}
}
}
/*
* Feature group: ascend step end timestamp
* Target device group: Ascend.
* Description: Add step end timestamp when profiler is end.
*/
void DebugActor::AscendStepEnd() {
auto profiler = profiler::Profiler::GetInstance(kAscendDevice);
if (profile_started_ && profiler != nullptr && profiler->GetEnableFlag()) {
MS_EXCEPTION_IF_NULL(device_ctx_);
device_ctx_->device_res_manager_->BindDeviceToCurrentThread(false);
device_ctx_->device_res_manager_->SyncAllStreams();
MS_LOG(INFO) << "Dot step end timestamp.";
profiler->StepStop();
profile_started_ = false;
}
}
/*
* Feature group: Dump, Online debugger.
* Target device group: Ascend, GPU.
@ -218,7 +174,7 @@ void DebugActor::DebugOnStepBegin(const std::vector<KernelGraphPtr> &graphs,
}
}
if (backend == "ge") {
AscendStepStart(graphs, device_contexts);
MS_LOG(INFO) << "On GE backend, debug_actor is not supported except for acl dump.";
return;
}
MS_EXCEPTION_IF_NULL(op_context);
@ -278,8 +234,7 @@ void DebugActor::DebugOnStepEnd(OpContext<DeviceTensor> *const op_context, const
dump_flag = false;
}
if (backend == "ge") {
AscendStepEnd();
MS_LOG(INFO) << "On GE backend, debug_actor is not supported.";
MS_LOG(INFO) << "On GE backend, debug_actor is not supported except for acl dump.";
return;
}
MS_EXCEPTION_IF_NULL(op_context);

View File

@ -495,8 +495,7 @@ void GraphScheduler::BuildAndScheduleGlobalActor() {
#ifdef ENABLE_DEBUGGER
auto debugger = Debugger::GetInstance();
MS_EXCEPTION_IF_NULL(debugger);
auto profiler = profiler::Profiler::GetInstance(kAscendDevice);
if ((profiler != nullptr && profiler->IsInitialized()) || debugger->DebuggerBackendEnabled()) {
if (debugger->DebuggerBackendEnabled()) {
debugger_actor_need = true;
}
#endif

View File

@ -185,7 +185,6 @@ class TestProfiler:
def test_ascend_profiler(self):
self._train_with_profiler(device_target="Ascend", profile_memory=True)
self._check_d_profiling_file()
self._check_d_profiling_step_trace_on_multisubgraph()
self._check_host_profiling_file()
@pytest.mark.level1
@ -267,14 +266,6 @@ class TestProfiler:
for file in d_profiler_files:
assert os.path.isfile(file)
def _check_d_profiling_step_trace_on_multisubgraph(self):
step_trace_file = self.profiler_path + f'step_trace_raw_{self.rank_id}_detail_time.csv'
assert os.path.isfile(step_trace_file)
with open(step_trace_file, 'r') as csvfile:
reader = csv.DictReader(csvfile)
row_count = sum(1 for _ in reader)
assert row_count == 11
def _check_cpu_profiling_file(self):
op_detail_file = self.profiler_path + f'cpu_op_detail_info_{self.device_id}.csv'
op_type_file = self.profiler_path + f'cpu_op_type_info_{self.device_id}.csv'