Repository navigation
Conversation
mlazos
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
fegin,
sanketpurandare,
tianyu-l,
wconstab,
wwwjn,
xmfan and
yiming0416
as code owners
June 4, 2026 03:51
tianyu-l
reviewed
Jun 4, 2026
anijain2305
added a commit
that referenced
this pull request
Nov 9, 2026
…tions Bind each training process to the NUMA node of its GPU right after set_device in TrainingEngine, before anything allocates pinned host memory, so first touch places that memory on the GPU-local node. Why core: core now has pinned-memory users whose bandwidth depends on NUMA placement -- FSDP2 CPU offload shards (CPUOffloadPolicy pins by default), EMA host copies, pinned batches, and the upcoming eager activation offloading. On GB300 (2 Grace CPUs, 2 GPUs each), a 1 GiB pinned copy from GPU0 measures: pinned memory on D2H H2D local node 193 GB/s 211 GB/s remote node 97 GB/s 100 GB/s Without binding, which node a rank's pinned memory lands on depends on where the scheduler ran the allocating thread, so a rank can silently get half the bandwidth. This also moves the existing calls into the engine. GraphTrainingEngine and the RL Trainer bound only after the model was built and sharded, i.e. after FSDP CPU offload had already pinned its shards. The vLLM generator keeps its own call (separate process, no TrainingEngine). This revives #3519, which was redirected to graph_trainer (#3489) until core had a use for it.
anijain2305
added a commit
that referenced
this pull request
Nov 9, 2026
…tions Bind each training process to the NUMA node of its GPU right after set_device in TrainingEngine, before anything allocates pinned host memory, so first touch places that memory on the GPU-local node. Why core: core now has pinned-memory users whose bandwidth depends on NUMA placement -- FSDP2 CPU offload shards (CPUOffloadPolicy pins by default), EMA host copies, pinned batches, and the upcoming eager activation offloading. On GB300 (2 Grace CPUs, 2 GPUs each), a 1 GiB pinned copy from GPU0 measures: pinned memory on D2H H2D local node 193 GB/s 211 GB/s remote node 97 GB/s 100 GB/s Without binding, which node a rank's pinned memory lands on depends on where the scheduler ran the allocating thread, so a rank can silently get half the bandwidth. This also moves the existing calls into the engine. GraphTrainingEngine and the RL Trainer bound only after the model was built and sharded, i.e. after FSDP CPU offload had already pinned its shards. The vLLM generator keeps its own call (separate process, no TrainingEngine). The helper now logs the resulting affinity instead of claiming success unconditionally, and has a TODO for its private torch.numa dependency. AffinityMode.NODE intersects the node's CPUs with the current affinity, so it never widens a narrower launcher binding (torchrun --numa-binding=core-complex, SLURM --cpu-bind=cores); if the launcher bound to another node, torch.numa warns and leaves the affinity alone. Test plan: llama3 8B, FSDP over 4 GB300 GPUs, seq 8192, 2 x 8192 tokens per rank, 30 steps, runs interleaved on a shared host; tps over steps 6-30 (main = 98a8ce0): run mean tps median tps stdev median MFU main #1 22,022 22,055 721 51.09% this PR #1 22,182 22,146 745 51.30% this PR #2 22,179 22,167 750 51.35% main #2 22,024 21,949 735 50.85% Throughput is unchanged (+0.7%, within noise); the Grain loader's prefetch threads run in-process and are rebound with it. This revives #3519, which was redirected to graph_trainer (#3489) until core had a use for it.
anijain2305
added a commit
that referenced
this pull request
Nov 10, 2026
<!--
Reviewers need to be convinced, not just informed. Delete sections you
don't need.
Agents: follow .claude/skills/pr-description/SKILL.md. Never fill in the
Summary.
-->
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
this approach, and what you checked yourself. -->
This revives #3519, which was redirected to graph_trainer (#3489) until
core had a use for it.
Bind each training process to the NUMA node of its GPU right after
set_device in TrainingEngine, before anything allocates pinned host
memory, so first touch places that memory on the GPU-local node.
Why core: On GB300 (2 Grace CPUs, 2 GPUs each), a 1 GiB pinned copy from
GPU0 measures:
pinned memory on D2H H2D
local node 193 GB/s 211 GB/s
remote node 97 GB/s 100 GB/s
Without binding, which node a rank's pinned memory lands on depends on
where the scheduler ran the allocating thread, so a rank can silently
get half the bandwidth.
We are working on activation offloading, and this will ensure that there
is appropriate core affinity.
This also moves the existing calls into the engine. GraphTrainingEngine
and the RL Trainer bound only after the model was built and sharded,
i.e. after FSDP CPU offload had already pinned its shards. The vLLM
generator keeps its own call (separate process, no TrainingEngine).
## Testing
<!-- What you ran, and the regression each new test catches. -->
CI
rakkit
pushed a commit
to rakkit/torchtitan
that referenced
this pull request
Nov 25, 2026
<!--
Reviewers need to be convinced, not just informed. Delete sections you
don't need.
Agents: follow .claude/skills/pr-description/SKILL.md. Never fill in the
Summary.
-->
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
this approach, and what you checked yourself. -->
This revives pytorch#3519, which was redirected to graph_trainer (pytorch#3489) until
core had a use for it.
Bind each training process to the NUMA node of its GPU right after
set_device in TrainingEngine, before anything allocates pinned host
memory, so first touch places that memory on the GPU-local node.
Why core: On GB300 (2 Grace CPUs, 2 GPUs each), a 1 GiB pinned copy from
GPU0 measures:
pinned memory on D2H H2D
local node 193 GB/s 211 GB/s
remote node 97 GB/s 100 GB/s
Without binding, which node a rank's pinned memory lands on depends on
where the scheduler ran the allocating thread, so a rank can silently
get half the bandwidth.
We are working on activation offloading, and this will ensure that there
is appropriate core affinity.
This also moves the existing calls into the engine. GraphTrainingEngine
and the RL Trainer bound only after the model was built and sharded,
i.e. after FSDP CPU offload had already pinned its shards. The vLLM
generator keeps its own call (separate process, no TrainingEngine).
## Testing
<!-- What you ran, and the regression each new test catches. -->
CI
(cherry picked from commit dae9de6)
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.
Stack from ghstack (oldest at bottom):
Pin each worker to the NUMA node of its GPU at Trainer init via
torch.numa.binding. On multi-NUMA machines (e.g. GB200 NVLink-C2C)
this ensures pinned-memory allocations land locally, yielding ~330 GB/s
D2H bandwidth vs ~115 GB/s cross-NUMA (~3x improvement).
Falls back gracefully on non-CUDA hardware or when numactl is unavailable.