Repository navigation
Conversation
torchrun exports OMP_NUM_THREADS=1 for every process when --nproc_per_node > 1, unless the variable is already set. The CPU optimizer's OpenMP loop then runs on a single thread, and nothing says so. The deepspeed launcher only sets the thread count with --bind_cores_to_rank. DeepSpeedCPUAdam now logs one warning per process when OMP_NUM_THREADS is 1 and the rank has at least two cores (CPU affinity divided by LOCAL_WORLD_SIZE). The ZeRO-Offload tutorial gets a note for torchrun users. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
torchrun sets
OMP_NUM_THREADS=1for every process when--nproc_per_nodeis larger than 1, unless the variable is already set.DeepSpeedCPUAdamthen steps on a single OpenMP thread, and nothing in the log says so. The deepspeed launcher sets the thread count only with--bind_cores_to_rank, which is the path the ZeRO-Offload tutorial documents. Users who launch with torchrun or accelerate get no hint.Measured effect
Setup: ZeRO-1 with
offload_optimizer: cpu, Qwen3-4B in bf16, fp32 gradient accumulation, one GH200 on a 72-core host.OMP_NUM_THREADSThat is 7× faster. In a 2-GPU torchrun job on L40S with the default setting, the same step took 6.2 s.
Change
single_thread_warning()indeepspeed/ops/adam/cpu_adam.pyreturns a message whenOMP_NUM_THREADSis"1"and the rank has at least two cores (CPU affinity divided byLOCAL_WORLD_SIZE).DeepSpeedCPUAdam.__init__logs it once per process, for the first optimizer instance.It only warns and does not change the thread count:
OMP_NUM_THREADS=1may be intentional;Tests
tests/unit/ops/adam/test_cpu_adam_threads.pyis CPU only and does not build the op. It checks four cases:yapf, flake8, codespell and the license check pass.