Why LLMs Struggle: Hardware Prefers Fixed Inputs

Modern hardware, particularly GPUs and NPUs, is optimized for fixed-size vector and tensor instructions to achieve peak performance. This creates a fundamental mismatch with Large Language Models, which inherently process user prompts of unpredictable, dynamic lengths, leading to significant inefficiencies during the initial 'prefill' inference stage. [1]

The top 3

  1. GPUs' Fixed-Width Design: The Core Bottleneck: Modern GPUs and NPUs employ fixed-width SIMD vector and tensor instruction sets, meaning optimal performance is achieved only when LLM input shapes precisely align, preventing memory fragmentation and maximizing compute unit utilization.
  2. Deep Learning's Fixed-Input Legacy: From CNNs to LLMs: Early deep learning, particularly computer vision with Convolutional Neural Networks (CNNs), standardized on fixed-size inputs like images, driving hardware and software optimization towards static tensor shapes—a paradigm now challenged by LLMs' variable prompt lengths.
  3. Dynamic Shapes' Performance Cost: Up to 23x Throughput Loss: Without dynamic shape optimization, LLM inference on GPUs can experience dramatically reduced throughput; for instance, applying constrained dynamic shapes has been shown to boost prefill throughput by over 23 times compared to unoptimized baselines on hardware like NVIDIA RTX 3070.

Sources

Open the full topic