


New quantization method based on reordering RPTQ: realizing 3-bit quantization of large language models
Large language models (LLMs) perform well on a variety of tasks, but present deployment challenges due to their sheer model size.
In this paper, researchers from Houmo Intelligence, Tencent AI Lab, Huazhong University of Science and Technology, Peking University, and Illinois Institute of Technology found that the main challenge in quantifying large language models comes from Different activation ranges between channels, not just an outlier issue.
The author proposes a novel reranking-based quantization method RPTQ, which solves the problem of quantifying large language model activations. RPTQ reduces the impact of channel-wide differences by rearranging the channels in activation and then clustering them for quantification.
Additionally, the authors reduce storage and computational overhead by avoiding explicit reordering. This work is the first to push activation quantization of LLM models to 3 bits. The 3-bit quantization of activation values can also be used together with the 3-bit quantization of weights, which greatly reduces the overhead of large speech models.
##Paper address: https://arxiv.org/abs/2304.01089
Open source address: https://github.com/hahnyuan/RPTQ4LLM
Large-scale language models (LLMs) are widely used in various have demonstrated excellent performance in this task, but their deployment faces challenges due to their huge model size. For example, a 66B model contains 66 billion parameters and requires a lot of memory to store. In addition, as the sequence length and batch size increase, the memory consumption problem becomes more serious, because activation also consumes a large amount of memory, such as the key and value cache (Key/Value Cache) in Self-attention. However, a single GPU or server does not have enough memory capacity to store such a large number of model weights and intermediate activations. Therefore, LLM needs to be split into multiple chunks and stored in different devices. Since weights and activations are stored on different devices, data needs to be transferred between these devices during computation, resulting in significant bandwidth and energy consumption.
To overcome the model scaling challenges of LLMs, model quantification has emerged as a promising approach. This technique involves quantizing the weights and activations of LLMs using low-bit integers, thereby significantly reducing the cost of storing and running these models. Specifically, quantization helps reduce the memory requirements for holding tensors and accelerates computationally intensive operations such as matrix multiplications and linear layers. By quantizing weights and activations, storage and communication overhead are reduced, and efficiency and inference speed are improved.
Figure 1 Numerical distribution of different channels. Each point represents a (maximum, minimum) value in an activation channel.
Recently, GPTQ successfully quantized the weights of LLMs into 4 bit or 3 bit using PTQ. However, quantifying activation in LLMs remains a challenging task.
Two observations can be made from Figure 1:
1) Some channels have significant outliers with their maximum or minimum The value is hundreds of times larger than other channels. Previous studies have also discovered this problem and proposed special treatments for outliers.
2) Different channels have significant differences in numerical ranges. Using the same quantization parameters to quantize different channels can lead to significant quantization errors. Even if two channels have the same absolute value of outliers, they can have large variations in numerical range.
Per-tensor quantization techniques that quantize the entire tensor using the same quantization parameters may be less efficient. The reason is that setting the quantization range to cover a large range of values may result in large quantization errors for channels with smaller values, while setting it to cover a small range of values may result in significant truncation of outliers and result in Significant quantization error. For example, one channel might have a value range of -100 to -50, while another channel might have a value range of 80 to 100. Trying to cover their range by quantizing the range from - 100 to 100 will result in significant quantization errors for both channels. This is a challenge that has not been effectively addressed in previous research.
Figure 2 Comparison of different methods to solve the activation quantization problem.
To solve the problem of channel differences in activation, the authors propose a novel reordering-based post-training quantization method RPTQ.
As shown in Figure 2, this method clusters channels with similar numerical ranges together and then quantizes the values in each cluster using the same quantization parameters. To implement the reranking-based quantification method, the authors first used a calibration dataset as inference input, from which the maximum and minimum values of each activation channel were derived.
Next, they used the KMeans algorithm to divide different channels into g clusters, based on the points formed by the maximum and minimum values of each channel. Once clusters are established, they perform channel reordering to place channels from the same cluster in close proximity. This way channels with similar maxima and minima are grouped together and share a common set of quantization parameters. After the reordering process, the authors quantified activation within each cluster. This method calculates the quantization parameters (scaling factor s and zero point z) separately for each cluster, ensuring that these parameters are specific to the corresponding channel.
Ultimately, this method ensures that the quantization of each cluster is optimized, reducing quantization errors.
Figure 3: Failure diagram of the inference process of a quantized Transformer layer with rearranged weights and activations. Rearrangement indices are represented by the symbols R1 to R5.
Explicit rearrangement is a run-time operation of rearranging active channels, which requires physically moving data from different channels from one memory location to another, so For large models with a large number of channels, the rearrangement process can be very time-consuming. Additionally, storing source and target activation tensors increases memory overhead. Therefore, the authors propose strategies to avoid explicit reordering, thereby reducing computational overhead and improving inference efficiency.
As shown in Figure 3, the authors reorder the weights of the linear layers so that they produce activations directly in the sorted order. Additionally, the authors modified LayerNorm's method to directly produce reordered activations, eliminating the need for explicit channel adjustments during inference.
The authors evaluated the performance of OPT under three different bit-width configurations: W4A16, W4A8, and W4A4. In addition, the author also developed a new quantification scheme, W4A4KV, W4A3KV and W3A3KV, which only quantifies the main memory consumption - key cache and value cache (Key/Value Cache). Based on the table, the following observations can be made: In general, as the activation quantization bitwidth decreases, the performance of the model decreases. But in most cases, this degradation is not significant. For some tasks, performance dropped by less than 1% or even improved.
The memory overhead of LLM comes from three aspects: First, the storage of weights in device memory can be significantly reduced through quantization. Second, temporary activations generated during network execution require device memory to be allocated. These temporary activations can be released after use and therefore do not significantly impact overall memory usage. Finally, the Key/Value Cache is necessary to predict subsequent words. When the batch size and sequence length are large, the key and value cache takes up most of the memory.
The table shows the memory usage under different settings. It can be found that lower bit activation can significantly reduce memory usage, especially when the batch size and sequence length are large. situation. Specifically, when the batch size is 64 and the sequence length is 8192, the W4A4 configuration under OPT-66b saves more than 900GB of memory compared to the W4A16 configuration. Therefore, employing RPTQ to quantify activations can greatly reduce memory pressure in long text tasks or high-volume scenarios.
The above is the detailed content of New quantization method based on reordering RPTQ: realizing 3-bit quantization of large language models. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Imagine an artificial intelligence model that not only has the ability to surpass traditional computing, but also achieves more efficient performance at a lower cost. This is not science fiction, DeepSeek-V2[1], the world’s most powerful open source MoE model is here. DeepSeek-V2 is a powerful mixture of experts (MoE) language model with the characteristics of economical training and efficient inference. It consists of 236B parameters, 21B of which are used to activate each marker. Compared with DeepSeek67B, DeepSeek-V2 has stronger performance, while saving 42.5% of training costs, reducing KV cache by 93.3%, and increasing the maximum generation throughput to 5.76 times. DeepSeek is a company exploring general artificial intelligence

AI is indeed changing mathematics. Recently, Tao Zhexuan, who has been paying close attention to this issue, forwarded the latest issue of "Bulletin of the American Mathematical Society" (Bulletin of the American Mathematical Society). Focusing on the topic "Will machines change mathematics?", many mathematicians expressed their opinions. The whole process was full of sparks, hardcore and exciting. The author has a strong lineup, including Fields Medal winner Akshay Venkatesh, Chinese mathematician Zheng Lejun, NYU computer scientist Ernest Davis and many other well-known scholars in the industry. The world of AI has changed dramatically. You know, many of these articles were submitted a year ago.

Boston Dynamics Atlas officially enters the era of electric robots! Yesterday, the hydraulic Atlas just "tearfully" withdrew from the stage of history. Today, Boston Dynamics announced that the electric Atlas is on the job. It seems that in the field of commercial humanoid robots, Boston Dynamics is determined to compete with Tesla. After the new video was released, it had already been viewed by more than one million people in just ten hours. The old people leave and new roles appear. This is a historical necessity. There is no doubt that this year is the explosive year of humanoid robots. Netizens commented: The advancement of robots has made this year's opening ceremony look like a human, and the degree of freedom is far greater than that of humans. But is this really not a horror movie? At the beginning of the video, Atlas is lying calmly on the ground, seemingly on his back. What follows is jaw-dropping

Earlier this month, researchers from MIT and other institutions proposed a very promising alternative to MLP - KAN. KAN outperforms MLP in terms of accuracy and interpretability. And it can outperform MLP running with a larger number of parameters with a very small number of parameters. For example, the authors stated that they used KAN to reproduce DeepMind's results with a smaller network and a higher degree of automation. Specifically, DeepMind's MLP has about 300,000 parameters, while KAN only has about 200 parameters. KAN has a strong mathematical foundation like MLP. MLP is based on the universal approximation theorem, while KAN is based on the Kolmogorov-Arnold representation theorem. As shown in the figure below, KAN has

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

Target detection is a relatively mature problem in autonomous driving systems, among which pedestrian detection is one of the earliest algorithms to be deployed. Very comprehensive research has been carried out in most papers. However, distance perception using fisheye cameras for surround view is relatively less studied. Due to large radial distortion, standard bounding box representation is difficult to implement in fisheye cameras. To alleviate the above description, we explore extended bounding box, ellipse, and general polygon designs into polar/angular representations and define an instance segmentation mIOU metric to analyze these representations. The proposed model fisheyeDetNet with polygonal shape outperforms other models and simultaneously achieves 49.5% mAP on the Valeo fisheye camera dataset for autonomous driving

FP8 and lower floating point quantification precision are no longer the "patent" of H100! Lao Huang wanted everyone to use INT8/INT4, and the Microsoft DeepSpeed team started running FP6 on A100 without official support from NVIDIA. Test results show that the new method TC-FPx's FP6 quantization on A100 is close to or occasionally faster than INT4, and has higher accuracy than the latter. On top of this, there is also end-to-end large model support, which has been open sourced and integrated into deep learning inference frameworks such as DeepSpeed. This result also has an immediate effect on accelerating large models - under this framework, using a single card to run Llama, the throughput is 2.65 times higher than that of dual cards. one
