Abstract
In this paper, we focus on Dynamic Execution techniques that optimize the computation flow based on input. This aims to identify simpler problems that can be solved using fewer resources, similar to human cognition. The techniques discussed include early exit from deep networks, speculative sampling for language models, and adaptive steps for diffusion models. Experimental results demonstrate that these dynamic approaches can significantly improve latency and throughput without compromising quality. When combined with model-based optimizations, such as quantization, dynamic execution provides a powerful multi-pronged strategy to optimize AI inference. Generative AI requires a large amount of compute resources. This is expected to grow, and demand for resources in data centers through to the edge is expected to continue to increase at high rates. We take advantage of existing research and provide additional innovations for some generative optimizations. In the case of LLMs, we provide more efficient sampling methods that depend on the complexity of the data. In the case of diffusion model generation, we provide a new method that also leverages the difficulty of the input prompt to predict an optimal early stopping point. Therefore, dynamic execution methods are relevant because they add another dimension of performance optimizations. Performance is critical from a competitive point of view, but increasing capacity can result in significant power savings and cost savings. We have provided several integrations of these techniques into several Intel performance libraries and Huggingface Optimum. These integrations will make them easier to use and increase the adoption of these techniques.
Introduction
As Generative AI models continue to scale in size, the computational overhead and energy consumption required for inference have become significant bottlenecks. Traditional optimization strategies, such as quantization and sparsity, are "static"—they apply the same reduction in precision or complexity to every input regardless of its nature.
However, real-world queries vary drastically in difficulty. A simple arithmetic question requires far less cognitive effort than a request for a complex scientific explanation. Current inference pipelines often "overthink" simple problems, wasting valuable resources. This paper explores "Dynamic Execution," a suite of techniques that allow models to adjust their computational effort based on input complexity, mirroring biological intelligence.
Dynamic Execution Strategies
The core of our approach involves three primary data-dependent strategies designed to introduce "shortcuts" into the inference process.
Early Exit
Early Exit involves placing intermediate classifiers or "exit ramps" at various layers of a Deep Neural Network. If the model achieves a sufficient confidence threshold at an early stage, it terminates the forward pass and returns the result immediately. This effectively skips redundant deeper layers for simpler inputs.
Speculative Sampling (EAGLE)
For Large Language Models (LLMs), we utilize speculative sampling, where a small "draft" model predicts upcoming tokens that are subsequently verified by a larger "target" model. We highlight the EAGLE algorithm, which operates at the feature level rather than the token level. By performing autoregression on the second-to-top layer feature vectors, EAGLE more effectively resolves uncertainty, leading to higher acceptance rates for speculated tokens.
StepSaver for Diffusion Models
In image generation, the number of denoising steps is typically a fixed hyperparameter. We introduce StepSaver, which employs a fine-tuned NLP model to analyze the input prompt and predict the minimum number of steps required for high-quality output. This allows the system to stop early (e.g., at 30 steps instead of 100) when the prompt describes a less complex scene.
Experimental Evaluation
We evaluated these methods across several industry-standard benchmarks, including GLUE and SST-2 for encoder models, and Vicuna/LLaMA2-Chat for LLMs.
Key Results
- Early Exit: Achieved 2x to 4x speedups on BERT-style models with negligible impact on accuracy.
- EAGLE: On the LLaMA2-Chat 70B model, EAGLE delivered a latency speedup of 2.7x to 3.5x and doubled total throughput, significantly outperforming methods like Medusa and Lookahead decoding.
- StepSaver: Resulted in a 3x throughput improvement for diffusion models while maintaining image quality (FID) comparable to baseline 100-step processes.
Conclusion and Future Work
Dynamic execution represents a new dimension of performance optimization that complements existing static methods. By integrating these techniques into Intel libraries and Hugging Face Optimum, we aim to make efficient inference more accessible. Future research will focus on incorporating dynamic execution principles directly into the initial training and architectural design phases, moving beyond post-hoc optimizations toward inherently adaptive AI systems.
Summary updated