Skip to content

Commit

Permalink
Dump HLO HBM usage info
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCaoG committed May 20, 2024
1 parent e0fb878 commit b4d83e4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions torch_xla/csrc/runtime/pjrt_computation_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,20 @@ std::vector<ComputationClient::ComputationPtr> PjRtComputationClient::Compile(
client_->Compile(instance.computation, compile_options).value();
}

auto memory_stats_status_or = executable->GetCompiledMemoryStats();
if (memory_stats_status_or.ok()) {
xla::CompiledMemoryStats memory_stats = memory_stats_status_or.value();
TF_VLOG(3) << "memory usage detail = " << memory_stats.DebugString();
TF_VLOG(3)
<< "total runtime device memory required to run this program = "
<< ((memory_stats.output_size_in_bytes +
memory_stats.temp_size_in_bytes) >>
20)
<< " MB";
} else {
TF_VLOG(3) << "memory usage is not availiable";
}

const auto& hlo_modules = ConsumeValue(executable->GetHloModules());
xla::HloComputation* hlo_computation = hlo_modules[0]->entry_computation();
std::shared_ptr<PjRtComputation> pjrt_computation =
Expand Down

0 comments on commit b4d83e4

Please sign in to comment.