Skip to content

[rl] Bind prefetch staging buffers to local NUMA node - #5103

Merged
tushar00jain merged 1 commit into
mainfrom
fs-head/tushar00jain/2
Oct 7, 2026
Merged

tushar00jain merged 1 commit into
mainfrom
fs-head/tushar00jain/2

Conversation

@tushar00jain

@tushar00jain tushar00jain commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Stack (top to bottom):


Summary

Pinned CPU prefetch buffers were allocated without NUMA affinity. UCX could therefore use NICs across both NUMA domains, adding cross-socket traffic and increasing GET latency.

A server can contain multiple CPU/memory regions called NUMA nodes. Accessing memory attached to the local NUMA node is faster than reaching memory attached to another node through the CPU interconnect.

  NUMA node 0                    NUMA node 1
  CPU cores                      CPU cores
  Memory                         Memory
  GPUs 0–1                       GPUs 2–3
  NIC ports A/B                  NIC ports C/D
         └────── CPU interconnect ──────┘

Before

  GPU rank on NUMA 0
          │
   pinned CPU buffers
     not NUMA-bound
          │
         UCX
      ┌───┴───────────────┐
      ▼                   ▼
  ibp0p0 / ibp0p1    ibp2p0 / ibp2p1
       local             cross-NUMA

This change binds each generator rank to its GPU-local NUMA node before allocating its pinned staging state dict.

After

  GPU rank on NUMA 0
          │
   bind to NUMA 0
          │
   pinned CPU buffers
          │
         UCX
          │
  ibp0p0 / ibp0p1
     local ports only

UCX validation showed every rank using only its local two-port pair. On Qwen-27B, mean steady-state GET improved from 2.77s to 2.68s, while worst GET improved from 3.89s to 2.87s.

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Oct 6, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 6, 2026
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/2 branch from 105368d to 0d5a83b Compare October 6, 2026 23:19
@tushar00jain
tushar00jain marked this pull request as ready for review October 6, 2026 23:29
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 6, 2026
self._engine_event_loop.call_soon_threadsafe(call)
return result.result()

def _setup_prefetch_staging_state_dict(self) -> dict[str, Any]:

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.

Can this be upstreamed as a torchstore method? I image the current pattern could be difficult to use correctly by other torchstore users.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This buffer is not owned by ts. Titan currently is the owner of this staging buffer - Titan or other users pass a state dict either on their CPU or GPU to get_state_dict and torchstore transfers into that.

@tushar00jain
tushar00jain requested a review from pzhan9 October 6, 2026 23:59
Comment thread torchtitan/rl/generator.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/b200 Trigger B200 CI ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl 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