[pytorch] Remove thread naming when torch is imported (#134066)

Fixes #133690

The naming was added in #121170 to allow performance debugging of latency critical threads. However the `pt_main_thread` name gets inherited every time a new process or thread is created from the parent one, which defeats the purpose. We need a better way to name the thread that launches kernels on accelerators but for the time being we can let users name the threads in the application code, using: `torch.multiprocessing._set_thread_name("insert_name")`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/134066
Approved by: https://github.com/soulitzer, https://github.com/d4l3k
This commit is contained in:
Valentin Andrei
2024-08-21 20:34:35 +00:00
committed by PyTorch MergeBot
parent 1491a61769
commit 865facda44

View File

@ -213,11 +213,6 @@ static PyObject* THPModule_initExtension(
std::string path = THPUtils_unpackString(shm_manager_path);
libshm_init(path.c_str());
// The main thread usually launches CPU/GPU/Accelerator kernels and therefore
// becomes latency sensitive. If the thread is named, we can debug performance
// issues easier.
c10::setThreadName("pt_main_thread");
auto module = THPObjectPtr(PyImport_ImportModule("torch"));
if (!module)
throw python_error();