Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion xllm/xllm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ namespace py = pybind11;
#endif

#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <memory>
#include <random>

Expand Down Expand Up @@ -302,6 +305,18 @@ void init_npu_python_runtime() {
PyEval_SaveThread();
}
}

[[noreturn]] void exit_npu_process(int exit_code) {
VerboseTraceLogger::get_instance().shutdown();
LOG(INFO) << "NPU process shutdown complete; bypassing process-static "
"destructors, exit_code="
<< exit_code;
google::FlushLogFiles(google::INFO);
std::cout.flush();
std::cerr.flush();
std::fflush(nullptr);
std::_Exit(exit_code);
}
} // namespace
#endif

Expand Down Expand Up @@ -605,5 +620,10 @@ int main(int argc, char** argv) {
init_npu_python_runtime();
#endif

return run();
const int exit_code = run();
#if defined(USE_NPU)
exit_npu_process(exit_code);
#else
return exit_code;
#endif
}
Loading