Inferensys

Glossary

Non-Uniform Memory Access (NUMA)

Non-Uniform Memory Access (NUMA) is a computer memory design for multiprocessor systems where memory access time depends on the memory location relative to the processor.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
HARDWARE ARCHITECTURE

What is Non-Uniform Memory Access (NUMA)?

Non-Uniform Memory Access (NUMA) is a multiprocessor memory architecture where access time to memory depends on its physical location relative to the requesting processor core.

In a NUMA architecture, each processor or group of cores has its own local memory bank, providing very low-latency access. Accessing memory attached to a remote processor (non-local memory) incurs significantly higher latency and lower bandwidth due to the need to traverse an interconnect fabric. This non-uniformity contrasts with Uniform Memory Access (UMA) systems, where all memory is equidistant from all processors. The primary goal is to scale memory bandwidth with processor count, avoiding the bottleneck of a single, shared memory bus.

For optimal performance, software must be NUMA-aware. This involves thread pinning to keep execution on cores near their data and memory allocation policies that place data in the local memory of the thread that will use it most. Operating systems and runtime libraries provide APIs for managing NUMA affinity. Failure to manage this can lead to severe performance degradation, as applications suffer from constant remote memory accesses. NUMA is fundamental in modern multi-socket servers and high-performance computing systems.

HARDWARE-AWARE MODEL OPTIMIZATION

Key Characteristics of NUMA Architecture

Non-Uniform Memory Access (NUMA) is a multiprocessor memory architecture where access latency depends on the memory's physical location relative to the requesting processor. Optimizing for NUMA is critical for maximizing performance on modern multi-socket servers and high-core-count CPUs.

01

Memory Hierarchy and Access Latency

In a NUMA system, each processor or group of cores (a NUMA node) has its own local memory. Accessing this local memory is fast. Accessing memory attached to a remote NUMA node (remote memory) incurs higher latency due to traversal across an interconnect (e.g., Intel's Ultra Path Interconnect, AMD's Infinity Fabric). The key performance goal is to maximize local memory accesses and minimize costly remote accesses through careful data and thread placement.

02

NUMA Affinity and Thread Pinning

NUMA affinity is the practice of binding software threads and processes to specific CPU cores and their associated memory nodes. This is achieved via OS or library calls (e.g., numactl on Linux, SetThreadAffinityMask on Windows). Thread pinning ensures a thread's memory allocations come from its local node and its execution stays on cores within that node, preventing the OS scheduler from migrating it across nodes and causing unpredictable remote memory access penalties.

03

First-Touch Policy and Data Placement

Most operating systems use a first-touch policy for memory allocation in NUMA systems. The physical memory page is allocated from the NUMA node where the thread that first writes to (touches) that page is executing. This makes initialization critical: if a master thread on Node 0 initializes all data, all memory is allocated to Node 0. Subsequent threads on Node 1 will suffer remote accesses. Proper initialization involves touching data in parallel from threads pinned to their respective nodes.

04

Interconnect Bandwidth and Contention

The NUMA interconnect is a shared resource with finite aggregate bandwidth. When many cores simultaneously access remote memory, they saturate this link, creating contention. This can degrade performance more severely than the base latency increase. Performance profiling must monitor interconnect utilization (e.g., via perf or vendor tools). Optimizations aim to reduce both the volume and the synchronization of remote accesses to avoid flooding the interconnect.

05

Relationship with Hardware Accelerators

NUMA principles extend to systems with discrete accelerators like GPUs or NPUs. Here, the accelerator's device memory is analogous to a remote NUMA node with very high access latency. Frameworks like Compute Express Link (CXL) aim to create a more NUMA-like, cache-coherent memory space between CPUs and accelerators. For optimal performance, data should reside in the executing processor's local memory, whether it's a CPU core or an accelerator's HBM.

06

Performance Analysis and Tools

Analyzing NUMA performance requires specific tools:

  • numactl / numastat: Linux utilities to control policy and view memory allocation statistics per node.
  • likwid-perfctr: Provides detailed performance counter monitoring per NUMA node.
  • Vendor Profilers: Intel VTune Profiler and AMD uProf have dedicated NUMA analysis views.
  • Key Metrics: Local/remote memory access ratios, interconnect bandwidth utilization, and remote cache hit rates. The goal is to identify which processes or data structures are causing excessive remote accesses.
HARDWARE-AWARE MODEL OPTIMIZATION

How NUMA Works and the Role of NUMA Affinity

Non-Uniform Memory Access (NUMA) is a critical memory architecture in modern multi-socket servers that directly impacts the performance of high-throughput AI workloads by introducing variable memory access latencies.

Non-Uniform Memory Access (NUMA) is a multiprocessor memory architecture where a processor's access time to memory depends on its physical location. In a NUMA node, a group of CPU cores shares fast, local memory. Accessing memory attached to a remote NUMA node incurs significantly higher latency and lower bandwidth. This non-uniformity makes data and thread placement—NUMA affinity—a primary performance determinant for memory-intensive applications like large model inference.

NUMA affinity is the practice of explicitly binding software processes or threads to specific CPU cores and their associated local memory nodes. This minimizes costly remote memory accesses. In AI systems, optimizing for NUMA involves partitioning model weights, pinning dataloader workers, and configuring inter-process communication to respect node boundaries. Failure to manage affinity can lead to severe, unpredictable performance degradation as memory traffic saturates the interconnect between nodes.

MEMORY ARCHITECTURE

NUMA vs. UMA: A Comparison

A comparison of Non-Uniform Memory Access (NUMA) and Uniform Memory Access (UMA) architectures, detailing their core design principles, performance characteristics, and suitability for different multiprocessing workloads.

Architectural FeatureNon-Uniform Memory Access (NUMA)Uniform Memory Access (UMA)

Core Design Principle

Memory is physically partitioned and attached to specific processor nodes (CPU sockets).

All memory is centralized and equidistant from all processors via a shared bus or crossbar.

Memory Access Latency

Non-uniform. Access to local memory is fast; access to remote memory (on another node) is slower.

Uniform. All memory accesses have statistically identical latency, regardless of the requesting CPU.

Scalability

High. Scales efficiently to systems with many CPU sockets (e.g., 4, 8, 16+) by adding memory with each node.

Limited. Becomes a bottleneck as more CPUs contend for the shared memory bus, limiting practical socket count.

Typical Hardware

Modern multi-socket servers, high-end workstations, and large-scale systems.

Traditional symmetric multiprocessing (SMP) systems, single-socket PCs, and some older multi-socket servers.

Programming & OS Complexity

High. Requires OS and application awareness (NUMA affinity) for optimal performance via careful thread and data placement.

Low. The OS and applications view a single, flat memory space; no special placement logic is required.

Cost & Design

Higher cost and complexity due to distributed memory controllers and interconnects (e.g., AMD Infinity Fabric, Intel Ultra Path Interconnect).

Lower cost and simpler design with centralized memory controllers.

Optimal Workload Type

Workloads with strong data locality, where threads can be pinned to a node and work primarily on local data (e.g., large in-memory databases, scientific simulations).

Workloads with inherently shared, frequently accessed data or smaller-scale multiprocessing where simplicity is key.

Memory Bandwidth

Aggregate bandwidth scales with the number of nodes, as each has its own memory channels.

Total bandwidth is limited by the shared bus or central memory controller, creating a potential bottleneck.

HARDWARE-AWARE OPTIMIZATION

Implications for AI and Machine Learning Workloads

Non-Uniform Memory Access (NUMA) architectures present unique performance challenges and optimization opportunities for AI/ML systems. Understanding NUMA locality is critical for minimizing latency and maximizing throughput in multi-socket servers running large-scale training or high-throughput inference.

01

Latency Impact on Distributed Training

In multi-socket NUMA systems, inter-socket memory access can be 2-3x slower than local memory access. For distributed training frameworks like PyTorch DDP or TensorFlow MirroredStrategy, improper process affinity can cause severe bottlenecks.

  • DataLoader processes pinned to the wrong NUMA node incur high latency fetching training batches.
  • Gradient synchronization across sockets becomes a major throughput limiter.
  • Optimal strategy: Bind each training process to a specific socket and allocate its working memory locally using numactl or framework-specific APIs.
02

Inference Throughput & Batch Scheduling

High-throughput inference servers (e.g., TensorRT, Triton) must manage request batching across NUMA nodes to avoid cross-socket memory transfers.

  • Batch composition should group requests being processed on the same socket.
  • Model weights should be replicated in each socket's local memory to prevent remote fetches during forward passes.
  • Static binding of inference threads to cores prevents expensive migrations that break memory locality.
03

Large Model Memory Footprint Management

Models exceeding a single socket's memory capacity (e.g., LLMs with >80B parameters) force cross-NUMA memory allocation. This creates a permanent performance penalty.

  • Techniques like NUMA-aware model parallelism split layers across sockets, keeping weight gradients local.
  • ZeRO-Offload and similar CPU-offload strategies must partition optimizer states according to NUMA topology.
  • Transparent Huge Pages (THP) can worsen remote access latency; use explicit 1GB pages allocated locally per node.
04

GPU Acceleration & NUMA Affinity

GPUs and NPUs connected via PCIe to a specific CPU socket have optimal bandwidth to that socket's local memory. GPU-Direct RDMA performance depends on NUMA alignment.

  • CUDA device affinity APIs (cudaSetDeviceFlags) should bind GPU contexts to the local NUMA node.
  • Data staging buffers for GPU transfers must be allocated in local CPU memory to avoid extra hops.
  • Multi-GPU systems often map GPUs to different sockets; peer-to-peer transfers require careful NUMA-aware placement.
05

Framework & Runtime Optimizations

Modern ML frameworks provide NUMA controls, but often require explicit configuration.

  • PyTorch: Set torch.set_num_threads() per process and use numactl wrapper scripts. The torch.nn.parallel.DistributedDataParallel benefits from torch.multiprocessing with correct spawn context.
  • TensorFlow: Use tf.config.threading APIs and the NUMA_BINDING environment variable for thread placement.
  • OpenMP: The OMP_PLACES and OMP_PROC_BIND environment variables are critical for math library kernels (e.g., oneDNN, cuBLAS).
06

Containerization & Orchestration Considerations

Orchestrators like Kubernetes must be configured to respect NUMA topology for AI workloads.

  • Kubernetes Topology Manager policy should be set to restricted or single-numa-node for guaranteed locality.
  • CPU Manager policies align with exclusive CPU allocation for pods.
  • Device Plugins (e.g., for GPUs) should expose NUMA node affinity in their resource advertisements.
  • Docker supports --cpuset-cpus and --cpuset-mems flags to pin containers to specific sockets and memory nodes.
HARDWARE-AWARE OPTIMIZATION

Frequently Asked Questions

Non-Uniform Memory Access (NUMA) is a critical memory architecture for modern multi-socket servers and high-core-count CPUs. Understanding NUMA is essential for optimizing the performance of data-intensive workloads, including large-scale machine learning training and inference, by minimizing costly remote memory accesses.

Non-Uniform Memory Access (NUMA) is a computer memory design for multiprocessor systems where memory access time depends on the physical location of the memory relative to the requesting processor core. In a NUMA system, each processor or group of cores (a NUMA node) has its own local memory bank. Accessing this local memory is fast, while accessing memory attached to another processor (remote memory) is slower due to the need to traverse an interconnect (like AMD's Infinity Fabric or Intel's Ultra Path Interconnect). The operating system and applications must be aware of this topology to place threads and data intelligently, a practice known as setting NUMA affinity, to avoid performance degradation from excessive remote accesses.

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.