You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PERF] Each DEVICE_THREAD_POOL CPU worker gets its own full-size OpenMP team: ~2.5k OS threads on a 320-CPU host #4356
Severity: medium. Status: confirmed by repro. Related to item 2 of #4351, which records the test-side symptom.
Where
gptqmodel/__init__.py:391-405 (_default_cpu_workers) and the pool build (~430).
No worker calls torch.set_num_threads; cap_torch_threads is opt-in.
Description
libgomp gives each pthread that enters a parallel region its own team of torch.get_num_threads() threads. That is 205 by default on this host.
With 12 CPU workers, the thread count goes from 68 to 2538 (DPWorker-cpu#0..11 × 205).
The comment at line 401, "cap CPU workers to avoid OpenMP team explosion", caps the number of workers but not the team size.
The free-threading cap (≤8 workers) is also skipped here, because importing triton re-enables the GIL, so has_gil_disabled() is False. This part is partly environmental.
Inside a full pytest session (OMP_NUM_THREADS=8), the same mechanism gives 157 threads. That fails tests/test_thread_caps.py::test_process_thread_count_does_not_scale_with_cpu_count (157 > 80), which passes when run alone. Twenty of those threads are lingering device-smi-metrics threads.
Repro
Large-core host, OMP_NUM_THREADS not set:
importos, torchfromgptqmodelimportDEVICE_THREAD_POOLdefw(): a=torch.randn(512, 512); (a @ a).sum().item()
[f.result() forfin [DEVICE_THREAD_POOL.submit(torch.device("cpu"), w) for_inrange(64)]]
print(len(os.listdir("/proc/self/task"))) # 2538 here
Expected: roughly the number of workers plus one OpenMP pool, e.g. by calling torch.set_num_threads(max(1, total // workers)) in each CPU worker's init.
Found during an AI-assisted review (Claude Code, round 11) of 842d666; repros were run at that commit on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
ZX-ModelCloud commentedon Nov 16, 2026
Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.
fix(threadx): give every device-pool worker its own intra-op team (Mo…