Skip to content

[ci] Install numactl in the CI images - #6405

Merged
tianyu-l merged 1 commit into
mainfrom
ci-install-numactl
Nov 26, 2026
Merged

tianyu-l merged 1 commit into
mainfrom
ci-install-numactl

Conversation

@tianyu-l

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

TrainingEngine binds each rank to its GPU's NUMA node at startup (torchtitan/training_engine.py -> maybe_apply_numa_binding in torchtitan/distributed/offloading.py). torch.numa.binding refuses to bind unless the numactl CLI is on PATH, and none of our CI images install it. So every rank of every integration test logs the same traceback twice, once at error level and once at warning level, then continues without binding.

Example (1 GPU Integration (Fake PG), llama3_fsdp+tp+cp, a passing test):

E... torch/numa/binding.py:257] Failed to apply NUMA binding for input={'device_index': 0, ...
E... torch/numa/binding.py:257]     raise RuntimeError("numactl CLI is required for NUMA binding")
W... torch/numa/binding.py:259] Continuing executing without applying NUMA binding, despite exception Traceback ...
W... torch/numa/binding.py:259] RuntimeError: numactl CLI is required for NUMA binding

The traceback shows up 164 times in one Fake PG log, 820 times in one A10G Real PG models log and 644 times in one ROCm models log. Nothing fails, but people reading failed CI logs take it for the cause (this happened on #6398).

What changed

  • .ci/docker/common/install_base.sh: add numactl to the apt packages. All three images (torchtitan-ubuntu-22.04-clang12, its :rl variant, torchtitan-rocm-ubuntu-22.04-clang12) run this script.

torch only checks that the binary exists (shutil.which("numactl")). The in-process binding torchtitan uses then calls sched_setaffinity, so the container needs no extra privileges.

Alternatives considered

  • Skip binding quietly in maybe_apply_numa_binding when numactl is missing: that would hide the same misconfiguration on real clusters, where binding matters for CPU-offloaded optimizer states (torchtitan/components/optim/CPU_OFFLOADED_MOMENTS.md). CI should run the binding path the recipes use.

Numerics

None. CPU affinity doesn't affect GPU computation, so golden losses stay the same.

Testing

.ci/docker changes the image tag (git rev-parse HEAD:.ci/docker), so this PR needs ciflow/docker to build the images before the GPU jobs can pull them. After the build, check that the GPU job logs no longer contain numactl CLI is required and show the CPU affinity for GPU N line.

TrainingEngine binds each rank to its GPU's NUMA node at startup. torch.numa
requires the numactl CLI to be on PATH, and the CI images lack it, so every
rank logs a RuntimeError traceback twice and continues without binding.
@pytorch-bot pytorch-bot Bot added ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests labels Nov 26, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 26, 2026
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 51s —— View job


Approve -- the only item is the empty human-written summary in the PR description. Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the item below before merging. This is the right fix at the right layer. The training path already calls NUMA binding, and the CI images were simply missing the binary it checks for.

What this PR does. It adds numactl to the apt packages in .ci/docker/common/install_base.sh. Every CI image is built from .ci/docker/ubuntu/Dockerfile, which runs this script, so the default, :rl, and ROCm (build.sh:29-38) variants all get it. TrainingEngine (training_engine.py:343) and the vLLM/SGLang generator wrappers call maybe_apply_numa_binding (distributed/offloading.py:13). With numactl installed, that call should bind instead of logging the traceback and falling back.

Example.

# before, every rank, twice per rank
E torch/numa/binding.py:257] RuntimeError: numactl CLI is required for NUMA binding
W torch/numa/binding.py:259] Continuing executing without applying NUMA binding ...
# after
I CPU affinity for GPU 0: <n> CPUs in <lo>-<hi>

Must fix

  1. PR description: the "Summary (human-written)" section is empty. Please fill it in before merging.
Details
  • Necessity: the logs quoted in the description show the problem on main. Making maybe_apply_numa_binding skip quietly when numactl is missing would hide the same misconfiguration on real clusters, where binding matters for CPU-offloaded moments. Fixing the environment is the smaller and more accurate fix.
  • Scope: the change is one line with no Python change. Numerics should not change, because CPU affinity doesn't touch GPU computation.
  • Once binding actually runs, CI ranks will have a narrower CPU affinity (NODE mode intersects the node's CPUs with the current affinity). On multi-NUMA runners this could slightly change CPU-side dataloader throughput. It won't affect loss.

Not verified: I could not inspect torch.numa.binding here because torch isn't installed in the review environment. That leaves two things open. First, whether binding succeeds on the CI VMs, where the GPU's numa_node in sysfs may be -1. Second, whether that case produces a different fallback warning. The post-build check in the description (the CPU affinity for GPU N line appears and numactl CLI is required is gone) will answer both.

@tianyu-l
tianyu-l requested a review from huydhn November 26, 2026 04:05
@tianyu-l
tianyu-l merged commit bb79a81 into main Nov 26, 2026
22 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rocm CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants