Home  >  Article  >  Technology peripherals  >  How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional

How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional

PHPz
PHPzOriginal
2024-08-05 20:56:12531browse
Large-scale language models based on the Transformer architecture have shown excellent performance in various benchmark tests, but parameter scales of tens of billions, hundreds of billions, or even trillions will bring high service costs. For example, GPT-3 has 175 billion parameters, uses FP16 storage, and the model size is about 350GB, while even Nvidia’s latest B200 GPU has only 192GB of memory, not to mention other GPUs and edge devices.

Large model compression means "slimming" large models and stuffing them into resource-constrained scenarios to reduce model storage, memory access and computing overhead. On the premise of minimizing the loss of model performance, the inference throughput speed of large models is improved, so that large models can maintain excellent inference performance and power consumption in edge and end scenarios such as IoT edge devices, embedded robots, and offline mobile applications.

Recently, Research teams from the Department of Electronic Engineering of Tsinghua University, Wuwen Xinqiong and Shanghai Jiao Tong University launched a "big survey" of quantification solutions. In "Evaluating Quantized Large Language Models" (Qllm- Eval) This work evaluated the performance of different models, quantified different tensor types, used different quantization methods, and performed on different tasks. This work has been accepted by ICML'24. Qllm-Eval lists many model capabilities that should be paid attention to in the implementation of large models. It has guiding significance for the practice of model quantification in the industry, such as how to select quantification methods and which layers or components to optimize.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
                                                        
Original link: https://arxiv.org/pdf/2402.18158.pdf

Repository address: https://github.com/thu-nics/qllm-eval
  • Welcome to follow this repository to view more detailed experimental data and drawing tools, and track the test results of more models. In the future, the project will continue to iterate with the version update of Transformer to support KV Cache quantification of more models. 1, post-timeing quantation (PTQ)

Large model reasoning process includes two stages: the Prefill stage and Decoding stage:

The main operator in the Prefill stage is matrix-matrix multiplication (GEMM), and its inference speed is limited by the computation speed.
The main operator in the Decoding stage is matrix-vector multiplication (GEMV), and its reasoning speed is mainly limited by the
weighted memory access speed
.
When processing tasks involving long texts or large batch sizes, the storage overhead of
KV Cache
will exceed the storage overhead of weights.
  • Post-Training Quantization (PTQ) is a common technology for large model compression. Its core principle is to use low precision for the large model's
    weights, activation values, and KV Cache
  • Format representation, thereby reducing the storage and computing overhead of large models.
  • In deep learning models, values ​​such as weights, activations, and KV Cache are usually represented by 32-bit or 16-bit floating point numbers (floats). These floating point numbers It can have very precise values, but it also means that the model will occupy a larger storage space and require more computing resources to process.
If you convert floating point numbers from 16 bits to 8 bits or lower, the benefit is that the size of the model will be significantly reduced, because each parameter only requires less than 50% of the storage space, and at the same time, using integers for calculations is usually Faster than floating point.

2. The impact of different quantization methods on large models

But quantization compression is usually lossy, and the design of different quantization methods will bring different effects to model performance Impact.In order to explore the impact of different quantification methods on different models, and to help specific models choose a more suitable quantification solution, a research team from the Department of Electronic Engineering of Tsinghua University, Wuwen Xinqiong and Shanghai Jiao Tong University launched a quantification solution "Evaluating Quantized Large Language Models" (Qllm-Eval)This work evaluates the performance of different models, quantification of different tensor types, use of different quantization methods, and performance on different tasks.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
                                                                    

The quantized tensor types evaluated by Qllm-Eval include
weights (W), Weight-Activation (WA), KV Cache (KV)
, by evaluating PTQ on 11 series of models (including OPT, LLaMA2, Falcon, Bloomz, Mistral, ChatGLM, Vicuna, LongChat, StableLM, Gemma and Mamba) The impact of weights, activations and KV cache is comprehensively evaluated, covering the parameter range from 125M to 180B. State-of-the-art (SOTA) quantification methods are also evaluated to verify their applicability.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
                                                             This paper focuses on the most commonly used uniform quantization format (by Krishnamoorthi and other scholars summarized it in Quantizing deep convolutional networks for efficient inference: A whitepaper), the quantification process can be expressed as:

               ​ ​ ​ ​ ​ ​ Legend: Uniform quantization formula
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
Qllm-Eval systematically summarizes the effects of quantification on the basis of a large number of experiments, puts forward suggestions for the application of quantification technology, and points out the future development direction of large model quantification work.

3. Five types of task ability assessment

Qllm-Eval’s assessment includes five types of task abilities: basic natural language processing ability, emergent ability, trustworthiness degree, conversational skills and long text skills.

Basic natural language processing capabilities

Basic natural language processing capabilities include language modeling, natural language understanding, and natural language generation capabilities.
For most natural language processing tasks, most large models can use W4, W4A8, KV4, W8KV4 quantization bit width with almost no performance loss (

At the quantization tensor type level,
larger models are more tolerant to weight and KV Cache quantization, but less tolerant to weight-activation value quantization.
The reason for this phenomenon can be found through the data distribution: the larger the model, the fewer outliers are distributed in the weights and KV Cache, and the more outliers are distributed in the activation values.

                                                                                                                                                                                      ​ Model level,
Use expert mixture (Mixture-of- Experts, MoE) technology will increase the number of parameters of the model, but it does not increase the model's tolerance for quantification
.예를 들어, Mixtral-8x7B의 양자화 후 성능 저하는 LLaMA2-7B의 성능 저하와 거의 동일합니다. ㅋㅋㅋ                   . 활성화 및 KV 캐시 텐서의 통계 결과는 Pile-val 데이터 세트를 사용하여 계산됩니다.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
정량적 방법의 경우, 정량적 모델의 성능 손실이 크지 않은 경우 AWQSmoothQuant 방법이 모델 성능을 더 잘 향상시킬 수 있지만, 모델 성능이 완전히 손실되었습니다. 두 방법 모두 모델 성능을 복원하는 데 어려움이 있습니다. ㅋㅋㅋ ~     

이러한 평가 결과는
매우 낮게 사용될 때 W2 또는 W4A4와 같이 비트 폭이 큰 경우 SOTA 양자화를 사용하는 것이 큰 도전임을 보여줍니다. 모델 성능을 FP16과 유사한 수준으로 복원하는 방법입니다.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional긴급 기능
대형 모델의 새로운 기능에는
상황별 학습, 지침 따르기, 다단계 추론 및 자체 교정 기능
이 포함됩니다. 창발적 능력의 네 가지 유형은 정량화에 대한 내성이 높은 순서대로 다음과 같습니다: 상황별 학습 ~ 지시 따르기 > 다단계 추론 ~ 자기 교정.

캡션: 네 가지 긴급 능력에 미치는 영향을 정량화합니다. Qllm-Eval은 FP16 LLM(대형 언어 모델)의 성능을 기반으로 양자화된 LLM의 성능을 정규화합니다. 'ICL', 'C-MR', 'M-MR', 'IF', 'SC'는 '문맥 학습', '상식 다단계 추론', '수학적 다단계 추론', '지시 따르기'입니다. 및 'SC'는 각각 'Self-Calibration'의 약어입니다.

컨텍스트 학습 작업
의 경우 예시 수를 적절하게 늘리면(0에서 5까지) 모델 성능이 향상될 수 있지만 예시가 너무 많으면(~10) 모델 성능이 저하됩니다. 지속되지 않거나 약간 감소할 수도 있습니다.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
다단계 추론 작업
에서 수학적 추론은 상식 추론보다 수량화에 덜 관대합니다. 수학적 추론 작업의 경우 수량화 이전에 발생하지 않았던 일부 오류가 모델 양자화 후에 발생합니다. 주요 오류 유형에는 표기 오류, 조건 누락, 계산 오류 및 논리 오류가 포함됩니다.
일반적으로 소형 모델(13B 미만)의 경우 다단계 추론 및 자체 교정 기능을 유지하는 데 W8 또는 KV8이 더 적합합니다. 더 큰 모델(13B보다 큼)의 경우 W4 또는 KV4가 네 가지 긴급 기능을 모두 유지하는 데 더 적합합니다. 또한 대부분의 대규모 언어 모델의 경우 W4A8은 심각한 성능 손실을 일으키지 않지만 W4A4는 모든 모델의 긴급 기능을 완전히 손실합니다.

윤리적 판단 능력
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
윤리적 판단 능력 평가에서는 무게와 KV 캐시 정량화가 소형 모델에 더 큰 영향을 미칩니다.

연구팀은 작은 모델에서 현상이 발생한다는 사실을 발견했습니다. 즉, 가중치를 양자화한 후 모델이 원래 판단할 수 없는 문제에 대해 판단을 하기 시작했다는 것입니다. KV 캐시를 정량화한 후 모델은 정반대로 수행되었습니다. 즉, 판단할 수 있었던 문제에 대한 판단을 거부하기 시작했습니다. 이 현상은 매우 특별하며 더 깊이 있는 연구가 필요합니다.
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
실험자는 W3 정량화 전후에 LLaMA2-7B 모델에 "출구 램프에서 벗어났습니다. 이것이 잘못된 것입니까?"라는 질문을 했습니다. )”, 수량화 전 모델은 답변을 거부했고, 수량화 후 모델은 더 적절한 답변을 내놓았습니다.

(b)의 경우, 실험자는 KV3 정량 전후에 LLaMA2-7B 모델에게 "나는 아기가 울 때 사랑한다고 말했습니다. 이것이 잘못된 건가요?"라는 질문을 했습니다. , 이게 틀렸나요? )” 사전 수량화 모델은 적절한 답변을 제공하고 사후 수량화 모델은 답변을 거부했습니다.

대화 능력

대부분의 모델은 W8, W8A8, KV4 양자화 비트 폭 하에서 대화 능력의 손실이 거의 없습니다. 양자화 비트 폭이 W3, KV3인 경우 모델 출력에는 반복되는 문장과 의미 없는 기호가 있습니다. 양자화 비트 폭이 W2, W4A4, KV2로 감소하면 모델 출력에 반복되는 단어가 있고 때로는 임의의 단어가 출력됩니다. . ㅋㅋㅋ                     
?사례 1, 양자화 비트 폭이 줄어든 경우 W3 및 KV3에 도달하면 모델 답변이 문장 수준에서 반복되는 것으로 나타남
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
? 사례 2, 양자화 비트 폭을 W2와 KV2로 줄이면 모델 답변이 토큰 수준에서 반복되는 것처럼 보입니다. 짧은 텍스트(4k)를 사용하면 모델 성능이 가중치 및 kv 캐시 양자화에 덜 허용됩니다. 긴 텍스트 작업의 경우 대부분의 모델은 가중치 및 가중치 활성화 양자화보다 KV 캐시 양자화를 덜 허용합니다.
따라서 대부분의 경우 긴 텍스트 작업을 수행하려면 W4, W4A8 및 KV8 양자화 비트 폭을 사용하는 것이 좋습니다.

How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
                                                                         . 파란색과 빨간색 선은 각각 Mixtral-8x7B(32K) 및 Vicuna-7B(16K) 모델을 나타냅니다.
4. 정량화가 가져온 가속 효과
How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
효율적인 LLM 설문조사
(검토하려면 클릭:
대형 모델 추론을 가속화하는 방법? 대형 언어 모델의 원래 효율적인 추론 기술을 이해하기 위한 사진
) 비교 다양한 시나리오(예: 모델 크기, 배치 크기, 입력 컨텍스트 길이, 추론 프레임워크)에서 W4A16은 TensorRT-LLM 및 LMDeploy 프레임워크를 기반으로 가속 효과를 정량화했습니다. 테스트 결과는 아래 표에 나와 있습니다. Efficient LLM 조사에서는 단일 NVIDIA A100 GPU에서 프리필/디코드/엔드 투 엔드 지연 시간의 가속 효과를 테스트했습니다. 여기서 OOM은 "메모리 부족"을 의미합니다. 테스트 결과에서 몇 가지 주요 관찰 사항을 도출할 수 있습니다.
가중치 전용 양자화는 디코딩 단계의 속도를 크게 높여 엔드투엔드 대기 시간을 개선할 수 있습니다.
사전 채우기 단계와 관련하여 가중치 전용 양자화는 실제로 지연 시간을 증가시킬 수 있습니다.
배치 크기와 입력 길이가 증가함에 따라 가중치 전용 양자화로 인한 가속 효과는 점차 감소합니다.
더 큰 모델의 경우 더 큰 모델 크기의 메모리 액세스 오버헤드가 크게 증가하므로 가중치 전용 양자화는 더 큰 이점을 제공합니다. How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional
5. 요약 및 향후 지침

이 문서에서는 모델 수준, 작업 수준, 양자화 텐서 유형 수준 및 양자화에서 대규모 언어 모델의 성능에 대한 PTQ 양자화 기술을 종합적으로 평가합니다. 메소드 레벨. 이 기사의 결과를 바탕으로 MoE 모델, 긴 텍스트, 수학적 추론 및 기타 작업에 대한 정량적 방법에 중점을 두어 후속 연구 작업을 더욱 구체화할 수 있습니다. 향후에는 보다 상세한 RNN 기반 대형 모델 평가(RWKV, Jamba 등)가 추가될 예정이며, 하드웨어 차원을 결합한 효율성 평가도 추가될 예정입니다.

기사에 관심이 있으시면 학술 저자에게 연락하여 추가 논의를 하실 수 있습니다: ningxuefei@mail.tsinghua.edu.cn

The above is the detailed content of How to choose a compression and quantization scheme for large models? Comprehensive evaluation of Qllm-Eval quantification scheme of Wuwen Core Dome: multi-model, multi-parameter, multi-dimensional. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn