Constrained Dynamic Shapes: Up to 23x Prefill Throughput Gain
Constrained dynamic shapes, a key innovation for on-device LLM inference, can boost prefill throughput by over 23 times on GPUs like NVIDIA RTX 3070. This is achieved by aligning dynamic input shapes with hardware-friendly fixed-size computations, minimizing extra kernel launches and memory transfers.
The top 3
- Constrained vs. Unconstrained: The Prefill Performance Divide: By restricting LLM input shapes to hardware-friendly ranges, constrained dynamic shapes enable compilers to generate specialized, efficient kernels. This avoids the costly runtime overheads of JIT compilation or generic kernels required for fully unconstrained inputs, yielding up to 23x prefill speedups on devices like GPUs and NPUs.
- Key Compiler Optimizations for Constrained Dynamic Shapes: Constrained dynamic shapes unlock aggressive compiler optimizations, including advanced kernel fusion, static shape inference within dynamic batches, and specialized memory layouts. This allows for optimal utilization of fixed-instruction hardware like GPUs and NPUs, crucial for achieving the significant prefill throughput gains.
- Optimal LLM Scenarios for 23x Throughput Boost: The up to 23x prefill throughput gain from constrained dynamic shapes is most impactful for edge LLM inference and workloads with predictable, recurring input length patterns. This strategy transforms dynamic prefill from a deployment bottleneck into an optimizable task, significantly improving performance on GPUs and NPUs.
Sources
Open the full topic