Manuscript Offprint

arXiv:2611.07105

NUMA-Torch: Compiler-Driven NUMA-Aware LLM Prefill on Multi-Socket CPUs

Thisara Rathnayaka Weerakoon, Ishan Dewpura, Niman Ransindu, Shavin Anjitha, Tharindu R. Patabandi, Sanath Jayasena

Thisara Rathnayaka Weerakoon®, Ishan Dewpura®, Niman Ransindu®, Shavin Anjitha®, Tharindu R. Patabandi®†, Sanath Jayasena®*

*Dept. of Computer Science & Engineering, University of Moratuwa, Sri Lanka {thisara.21, ishandewpura.21, niman.21, shavin.21, sanath}@cse.mrt.ac.lk

†Independent Researcher, San Jose, CA, USA

tharindu@protonmail.com

Abstract—For sufficiently large transformer-based Large Language Models (LLMs), whose parameters cannot be retained in on-chip caches, prefill throughput on multi-socket CPUs is often limited by sustainable DRAM bandwidth rather than peak floating-point throughput. In the standard PyTorch compilation (i.e., TorchInductor) path, model weights are allocated without considering the Non-Uniform Memory Access (NUMA) topology—specifically, the affinity between memory banks and compute cores is disregarded. This causes a substantial fraction of weight accesses to traverse the inter-socket interconnect, severely degrading the effective memory bandwidth available to each socket. We address this bottleneck through a compiler-level solution that makes TorchInductor NUMA-aware. Treating each NUMA socket as an independent tensor-parallel partition, we introduce NUMA-aware Tensor Parallelism (NUMA-TP). This approach transparently shards weights across sockets and schedules compute kernels such that thread pools and memory allocations remain strictly local to their respective sockets using CPU affinity. We evaluate the approach on GPT-2 [1] (117M, 345M, 762M) and BERT [2] (Small, Large), which exercise standard multi-head attention and MLP, as well as Gemma 3 270M [3], which combines Multi-Query Attention with a GeGLU-gated MLP. By strictly enforcing data locality, our approach successfully mitigates cross-socket traffic, achieving prefill speedups of up to 2.63× on a dual-socket Haswell platform, up to 1.87× on a dual-socket Cascade Lake platform, and up to 2.27× on a four-socket Haswell-EX platform.

Index Terms—Compilers, Data Locality, NUMA, Tensor Parallelism, Large Language Models, CPU inference

I. INTRODUCTION

Driven by the necessity of accommodating many cores, modern high-performance servers have universally adopted Non-Uniform Memory Access (NUMA) architectures [4]. There is consequently a tremendous, yet underutilized, potential to deploy Large Language Model (LLM) inference on these multi-socket CPU platforms, given their cost-effectiveness, broad availability, and the frequent absence of GPUs in

Figure

Fig. 1. Logical view of a two-socket NUMA CPU treated as a distributed system; the dashed arrow marks a high-cost remote DRAM access across the cross-socket interconnect.

deployment environments. The prefill phase of LLM inference which processes the full input prompt in one forward pass is traditionally assumed compute-bound owing to the high arithmetic intensity of dense matrix multiplications over long sequences. Yet on multi-socket CPUs under the standard TorchInductor compilation pipeline, prefill unexpectedly becomes severely DRAM-bound as NUMA-oblivious memory allocations force massive cross-socket traffic.

As illustrated in Figure 1, we view each socket of a multi-socket NUMA CPU as an independent node owning its locally attached DRAM and memory controller, together with cores that have private L1/L2 caches and share an L3. Sockets are linked by a QPI/UPI interconnect serving as the inter-rank network; accesses to another socket's memory must cross it, incurring substantially higher latency and lower bandwidth than local accesses, and are therefore treated as explicit communication in our compilation model.

In standard execution, compute threads are distributed across all cores without regard to data locality, causing roughly half of all weight accesses to incur remote DRAM latency and saturating the inter-socket link. To empirically validate this, we conducted a Roofline analysis using Intel Advisor [5] on the kernels that dominate the prefill phase of a GPT-2 345M model [1] (batch size 1, sequence length 4096) on a dual-socket Haswell platform (Figure 2). For TorchInductor-compiled unmodified Triton-CPU baseline (circles), these kernels exhibit poor data locality and sit near the main-DRAM bandwidth ceiling, confirming that the prefill operates firmly in the DRAM-bound regime. Our NUMA-Torch path (triangles)

© 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. Accepted for publication in the 2026 IEEE 33rd International Conference on High Performance Computing, Data, and Analytics (HiPC), Bengaluru, India, December 16–19, 2026. This is the authors' accepted version; the final published version will appear in IEEE Xplore.

Figure

Fig. 2. Roofline analysis on dual-socket Haswell: baseline Triton CPU kernels (circles) versus the NUMA-Torch path (triangles) for the dominant GPT-2 345M prefill kernels (batch size 1, sequence length 4096). Arrows indicate the per-kernel trajectory from baseline to NUMA-Torch.

improves core-to-memory affinity and, as the trajectory arrows indicate, shifts the kernels toward the higher-bandwidth L3 and L2 cache tiers, increasing overall throughput (GFLOPS).

Despite this architectural reality, existing CPU optimization efforts frequently overlook the NUMA penalty, focusing on intra-core compute optimizations. Addressing this NUMA-induced DRAM bandwidth wall must instead be the primary objective, and the most direct solution is strict enforcement of data locality: explicitly placing weights in socket-local DRAM via NUMA-aware memory allocation, and binding computations to the corresponding cores via NUMA-aware thread scheduling.

While mainstream frameworks for CPU inference, such as llama.cpp [6], deliver high baseline performance, they are not explicitly optimized for NUMA data locality. Recent work such as ArcLight [7] addresses this memory bottleneck through cross-NUMA tensor parallelism. However, because ArcLight is a custom inference engine written entirely in C++, it relies heavily on manual engineering and requires the model code to be meticulously rewritten to support different LLM architectures. In this work, we focus on lifting cross-NUMA Tensor Parallelism into PyTorch 2.0's compiler ecosystem [8] to provide a PyTorch-native implementation. By extending the standard TorchInductor pipeline, our transformations remain entirely transparent to the user, requiring zero modifications to the model code, optimizer, or the inference loop.

We present the first compiler-based, PyTorch-native implementation of NUMA-aware tensor parallelism targeting multi-socket CPUs. We make the following contributions:

  1. A compiler-driven solution to the NUMA DRAM bottleneck that leverages post-grad FX graph transformations to partition operations across sockets, minimizing manual engineering overhead.
  2. An extended Triton-CPU backend [9], [10] that emits per-socket buffer allocations and dispatches kernels via a persistent, NUMA-aware thread pool.
  3. An evaluation of the compiler approach across standard models (GPT-2 [1], BERT [2]) and modern LLMs with complex attention and MLP variants (Gemma 3 [3]),

Figure

Fig. 3. Overview of NUMA-Torch: NUMA-Torch extends TorchInductor and Triton-CPU compilation stacks with NUMA-aware tensor parallel graph transformations, per-socket buffer placement, and a NUMA-aware runtime that dispatches kernels to socket-pinned worker groups. The NUMA partitioning schema (folded-corner note) is not a pipeline stage: it is per-block metadata emitted by the NUMA passes at FX-graph level and consumed by the wrapper code generator when materializing socket-local buffers (dashed arrows).

showing up to 2.63× prefill speedup on dual-socket platforms, comparing against process-level NUMA policies (numactl), and assessing scalability from dual-socket to four-socket platforms.

This work targets the prefill phase at fixed shapes. Throughout, “end-to-end prefill” denotes a single prefill forward pass at a fixed shape, not end-to-end serving: we measure prefill in isolation, so decode, continuous batching, KV-cache placement, and serving-level metrics are outside the evaluation.

Figure 3 illustrates the overall design of our approach, which we refer to as NUMA-Torch. NUMA-Torch is built on top of TorchInductor and Triton-CPU, extending the compiler pipeline with NUMA-aware graph transformations, socket-local buffer management, and affinity-aware kernel dispatch. Section II describes each component of this pipeline in detail.

Section III provides a comprehensive evaluation of NUMA-Torch, Section IV discusses related literature, and we present concluding remarks in Section V.

References (33)