Introduction
Large Language Models (LLMs) have revolutionized natural language processing but face significant deployment challenges due to their autoregressive nature. Generating text one token at a time makes inference memory-bound, as model weights must be repeatedly fetched from High-Bandwidth Memory (HBM). Speculative sampling mitigates this by using a smaller "draft" model to predict multiple tokens, which a larger "target" model then verifies in parallel. However, the verification step itself—involving probability ratio calculations and resampling—often becomes a secondary bottleneck on modern GPU hardware.
Proposed Methods
Researchers from TH Nürnberg and KAIST have introduced two optimization strategies to accelerate the verification phase by better utilizing GPU parallelism and memory hierarchies.
Hardware-Aware Exact Optimization
The first method focuses on a hardware-aware "tiling" approach. The researchers observed that the intermediate matrices required for draft token acceptance can be computed independently across the vocabulary. By implementing a custom GPU kernel, they "tile" the workload: data is loaded from HBM into fast, on-chip SRAM (shared memory), and the vocabulary is distributed across multiple threads for simultaneous computation.
This "exact" optimization produces mathematically identical results to standard implementations but significantly reduces latency by minimizing slow HBM accesses and maximizing thread occupancy.
Sigmoid-Based Approximation
The second method addresses the "global" bottleneck of the Softmax function. Standard sampling requires summing across the entire vocabulary to normalize probabilities, necessitating thread synchronization. The authors propose replacing Softmax with an element-wise Sigmoid function. Since Sigmoid operations are independent for each token, they can be computed entirely in parallel without inter-thread communication. While this introduces a mathematical approximation, it offers a substantial increase in hardware throughput.
Experimental Evaluation
The optimizations were tested across diverse tasks, including Automatic Speech Recognition (ASR) using the Whisper family and text summarization using Llama2, Qwen, and Gemma models.
Performance Results
The results highlight a clear trade-off between computational efficiency and model accuracy:
- Exact Optimization: Improved profiling time by 6% to 13% with zero loss in accuracy (identical Word Error Rate and ROUGE scores).
- Sigmoid Approximation: Achieved dramatic profiling time improvements ranging from 37% to 94%. In ASR tasks, this came with a minor increase in Word Error Rate (e.g., from 0.08 to 0.09 on LibriSpeech). In summarization, ROUGE-1 scores saw a slight decline, representing a viable trade-off for nearly doubling speed in some configurations.
Conclusion
By optimizing the verification step of speculative sampling for GPU architectures, this work demonstrates that significant inference speedups are possible without altering the underlying model weights. The hardware-aware tiling provides a "free" performance boost, while the Sigmoid approximation offers a tunable knob for extreme low-latency requirements. Future work will explore calibration techniques to further bridge the accuracy gap of the Sigmoid-based approach.
Summary updated