Inferensys

Glossary

NUMA Alignment

The practice of binding a workload's CPU and memory resources to the same Non-Uniform Memory Access node to minimize memory access latency, a critical optimization for GPU-attached host processes.
Performance engineer optimizing AI latency on laptop, latency charts visible, technical optimization session.
MEMORY AFFINITY OPTIMIZATION

What is NUMA Alignment?

NUMA Alignment is a system optimization technique that binds a workload's CPU threads and memory allocations to the same physical Non-Uniform Memory Access node, minimizing remote memory access latency for latency-sensitive processes like GPU-attached host services.

NUMA Alignment is the practice of co-locating a process's compute threads and its allocated memory within a single Non-Uniform Memory Access (NUMA) node. In multi-socket server architectures, each CPU socket has its own local memory controller and directly attached DRAM. Accessing memory attached to a remote socket incurs significantly higher latency and reduced bandwidth compared to local access. Alignment enforces a strict affinity policy, preventing the operating system scheduler from migrating threads or memory pages across the NUMA interconnect.

This optimization is critical for GPU-attached host processes, such as NVIDIA's GPU Direct memory pinning agents or data loading pipelines. If a CPU core on socket 0 is managing a GPU on the PCIe bus attached to socket 0, but its working memory is allocated on socket 1, every data transfer traverses the inter-socket UPI or Infinity Fabric link. This introduces jitter and bottlenecks the GPU's data ingestion rate, starving the accelerator. Proper alignment ensures the entire data path—from storage to CPU memory to GPU—remains localized.

MEMORY ARCHITECTURE OPTIMIZATION

Key Characteristics of NUMA Alignment

NUMA alignment is a critical performance optimization for GPU-attached host processes. By binding CPU threads and their memory allocations to the same NUMA node, systems eliminate cross-node memory access penalties that can devastate throughput in latency-sensitive AI workloads.

01

The Remote Access Penalty

In a Non-Uniform Memory Access architecture, each CPU socket owns local memory banks. Accessing local memory occurs at full speed, but accessing remote memory attached to another socket incurs a significant latency penalty—often 50-100% slower. For GPU-attached processes like data loaders or inference preprocessors, a thread running on socket 0 but accessing memory allocated on socket 1 forces every read across the inter-socket interconnect (UPI/Infinity Fabric) , creating a bottleneck that starves the GPU of data.

50-100%
Remote Access Latency Penalty
03

GPU-NUMA Topology Discovery

Determining which NUMA node a GPU is attached to requires querying the system's PCIe topology. The command nvidia-smi topo -m displays the affinity matrix between GPUs, NICs, and NUMA nodes. A GPU connected via the CPU's integrated PCIe controller will show PIX (PCIe internal) affinity to its local NUMA node. Misalignment occurs when a workload's CPU threads are scheduled on a different NUMA node than the GPU's attached node, forcing all GPU Direct RDMA transfers and command submissions to traverse the inter-socket link.

PIX
Optimal GPU-NUMA Affinity
04

Automatic NUMA Balancing Pitfalls

Linux kernels with automatic NUMA balancing enabled attempt to migrate pages closer to accessing threads. However, for GPU workloads, this can be actively harmful:

  • The kernel may migrate memory pages to a remote node based on transient access patterns
  • GPU-driven DMA transfers are invisible to the CPU's page access tracking
  • Balancing scans consume CPU cycles and memory bandwidth

Best practice is to disable automatic NUMA balancing (echo 0 > /proc/sys/kernel/numa_balancing) on GPU compute nodes and rely on explicit numactl binding.

05

Multi-GPU Alignment Strategy

In multi-GPU systems, each GPU should be paired with a dedicated CPU process bound to its local NUMA node. Common patterns include:

  • One process per GPU: Launch N processes, each bound with numactl --cpunodebind=X --membind=X where X matches the GPU's NUMA node
  • Thread affinity within a process: Use pthread_setaffinity_np() or taskset to pin specific threads to cores on the correct node
  • CUDA IPC and NUMA: When using CUDA Inter-Process Communication for multi-GPU sharing, ensure the producer and consumer processes reside on the same NUMA node to avoid inter-socket IPC overhead
06

Memory Allocation Policy Enforcement

Beyond numactl, applications can enforce alignment programmatically:

  • libnuma API: Provides numa_alloc_onnode() and numa_run_on_node() for fine-grained control
  • CUDA managed memory: cudaMallocManaged() with cudaMemAdviseSetPreferredLocation can hint the GPU's local NUMA node
  • Huge pages: Combining NUMA binding with 1GB huge pages (hugetlbfs) ensures large contiguous memory regions stay local, reducing TLB misses during high-throughput GPU data transfers

Failure to align huge pages results in the same remote access penalty amplified across larger memory regions.

NUMA ALIGNMENT

Frequently Asked Questions

Clear, technical answers to the most common questions about Non-Uniform Memory Access optimization for GPU-accelerated workloads.

NUMA alignment is the practice of binding a workload's CPU threads and memory allocations to the same physical Non-Uniform Memory Access node to minimize cross-node memory access latency. In a multi-socket server, each CPU socket has its own local memory controller and directly attached DRAM, forming a NUMA node. When a process running on CPU core 0 accesses memory allocated on the DIMMs attached to CPU socket 1, the data must traverse the inter-socket interconnect (e.g., Intel UPI or AMD Infinity Fabric), incurring 1.5x to 2x higher latency and reduced bandwidth compared to local access. NUMA alignment works by using operating system APIs like numactl or libnuma to explicitly pin processes to specific cores and allocate memory from the local node, ensuring the CPU-to-memory path remains on-die. For GPU-attached host processes, this is critical because the CPU must efficiently stage data and issue commands to the GPU over PCIe, and any NUMA-induced latency jitter directly degrades inference and training throughput.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.