LLMs are central to modern natural language processing, delivering exceptional performance in various tasks. However, their substantial computational and memory requirements present challenges, especially for devices with limited DRAM capacity. This paper tackles the challenge of efficiently running LLMs that exceed the available DRAM capacity by storing the model parameters in flash memory, but bringing them on demand to DRAM. Our method involves constructing an inference cost model that takes into account the characteristics of flash memory, guiding us to optimize in two critical areas: reducing the volume of data transferred from flash and reading data in larger, more contiguous chunks. Within this hardware-informed framework, we introduce two principal techniques. First, "windowing" strategically reduces data transfer by reusing previously activated neurons, and second, "row-column bundling", tailored to the sequential data access strengths of flash memory, increases the size of data chunks read from flash memory. These methods collectively enable running models up to twice the size of the available DRAM, with a 4-5x and 20-25x increase in inference speed compared to naive loading approaches in CPU and GPU, respectively. Our integration of sparsity awareness, context-adaptive loading, and a hardware-oriented design paves the way for effective inference of LLMs on devices with limited memory.
Introduces a method to enable LLM inference on devices with limited DRAM by using flash memory.
Describes techniques to reduce data transfer and align with optimal flash memory operations.
Introduces 'windowing' and 'row-column bundling' for efficient memory use.
Demonstrates up to double LLM size operation relative to available DRAM and substantial inference speed gains.
Highlights the importance of hardware-aware algorithm development for machine learning.
Advancements in natural language processing have been propelled by the development of LLMs, which are highly sophisticated models capable of understanding and generating human-like text. Notable examples of these models include GPT-3, OPT, and PaLM. LLMs are incredibly parameter-dense, often having a size that challenges the storage and computational capabilities of many devices, particularly those with constrained DRAM capacity. This paper introduces an innovative method that enables LLM inference on such devices by leveraging flash memory, which is typically higher in capacity compared to DRAM, without the need to load the whole model into DRAM at once.
The core of the challenge boils down to the discrepancy between the high capacity of flash memory and the faster speeds of DRAM. Traditionally, running an LLM requires loading the entire model into the quick-access DRAM. This is not feasible for very large models on hardware with limited DRAM capacity. The authors' method circumvents this limitation by directly reading only the necessary model parameters from flash memory during inference. This technique is based on two key principles: reducing the volume of data transfer from flash and reading data in more substantial and sequential blocks, aligning with how flash memory performs best.
The authors further describe a "windowing" technique, which involves only loading parameters related to the most recent tokens, thereby reusing previously activated data and reducing the number of I/O requests to flash memory. Moreover, they introduce "row-column bundling," a method that combines associated matrix rows and columns for larger contiguous data reads. These strategies, coupled with a focus on sparsity within model layers, significantly reduce the amount of data needing to be loaded from flash memory. The approach is designed to selectively load only the non-zero and more likely to be non-zero parameters, therefore minimizing the amount of necessary memory traffic.
Implementing these techniques, the study shows that it is possible to run LLMs that are up to double the size of the available DRAM with substantial speed gains. In particular, the researchers achieved an inference speed increase of 4 to 5 times on CPU and 20 to 25 times on GPU relative to more naive loading strategies. These results offer a substantial contribution to the field of AI by enabling more efficient utilization of LLMs on a variety of devices, thus widening the scope of potential applications. The study stands as an example of the significance of considering hardware limitations in the design of machine learning algorithms, particularly those that are resource-intensive.
The work accomplished in this paper paves the way for numerous new possibilities where LLMs can be utilized effectively on devices previously deemed unsuitable due to memory constraints. This not only democratizes access to state-of-the-art AI capabilities but also invites further research dedicated to optimizing the performance of such models, ensuring their widespread adoption across various platforms. The intersection of hardware-aware algorithm development and machine learning, as showcased in this study, is likely to remain a crucial area of focus as the models continue to grow in scale and potential.