Abstract
We introduce QUICK, a group of novel optimized CUDA kernels for the efficient inference of quantized Large Language Models (LLMs). QUICK addresses the shared memory bank-conflict problem of state-of-the-art mixed precision matrix multiplication kernels. Our method interleaves the quantized weight matrices of LLMs offline to skip the shared memory write-back after the dequantization. We demonstrate up to 1.91x speedup over existing kernels of AutoAWQ on larger batches and up to 1.94x throughput gain on representative LLM models on various NVIDIA GPU devices.
Introduction
As Large Language Models (LLMs) scale to hundreds of billions of parameters, weight-only quantization (e.g., 4-bit weights with 16-bit activations) has become essential for fitting these models into GPU memory. However, modern GPU Tensor Cores do not natively support these mixed-precision operations.
In standard kernels, the GPU must fetch 4-bit weights, dequantize them to 16-bit in registers, and then write them back to shared memory so they can be re-loaded using the ldmatrix instruction in the specific pattern required by Tensor Cores. This "write-back" step creates a significant bottleneck due to shared memory bank conflicts, where multiple threads attempt to access the same memory bank simultaneously, forcing serialization and wasting cycles.
Methodology: The QUICK Approach
QUICK (Quantization-aware Interleaving and Conflict-free Kernel) shifts the complexity of data rearrangement from the inference "hot path" to an offline preprocessing step.
Offline Weight Interleaving
Instead of rearranging data on the fly, QUICK reorders the quantized weight matrix offline. It anticipates the exact data pattern required by the mma (matrix multiply-accumulate) instruction. By "pre-shuffling" weights in global memory, the kernel can load them directly into registers, bypassing the shared memory write-back and the subsequent ldmatrix call entirely.
Dequantization-Aware Reordering
The weights are interleaved to match the specific access pattern of the dequantization kernel. This ensures that weights are ready for computation immediately after being expanded to 16-bit, maintaining high throughput.
Tile Size Optimization
Eliminating the need to store weight matrices in shared memory frees up significant on-chip resources. QUICK utilizes this saved memory to increase the GEMM tile size, reducing the frequency of DRAM accesses and improving overall GPU occupancy.
Evaluation and Results
The researchers evaluated QUICK using representative models like Mistral-7B, Vicuna-13B, and LLaMA-2-13B/33B across various NVIDIA hardware (RTX 4090, A6000, L40, and A100).
Memory Overhead Reduction
The primary performance gain comes from eliminating the write-back and shared load overhead. As shown in the comparison with AutoAWQ, QUICK significantly reduces the total memory operation time.
Performance Gains
- Kernel Speedup: QUICK achieved a 1.33x to 1.91x speedup over AutoAWQ kernels for matrix multiplications at larger batch sizes (e.g., BS=256).
- End-to-End Throughput: In real-world generation tasks, QUICK delivered up to a 1.94x throughput gain compared to AutoAWQ.
- vLLM Integration: When integrated into the vLLM framework, QUICK showed a 27-29% improvement over standard AWQ and a 33% gain over full-precision (FP16) models.
Conclusion
QUICK demonstrates that optimizing memory access patterns is as crucial as raw computational power for modern AI workloads. By leveraging the static nature of LLM weights to pre-calculate hardware-optimal layouts, QUICK effectively bypasses shared memory bottlenecks, unlocking significant performance gains for quantized model inference. While it remains slightly less efficient than pure FP16 at extremely large batch sizes (>512), it provides a superior solution for the most common inference scenarios.
Summary updated