|
--- |
|
base_model: mistralai/Mistral-7B-v0.1 |
|
--- |
|
# Mistral-7B-v0.1-AWQ-G128-INT4-SYM-BF16 |
|
- ## Introduction |
|
This model was created by applying [Quark](https://quark.docs.amd.com/latest/index.html) with calibration samples from Pile dataset. |
|
- ## Quantization Stragegy |
|
- ***Quantized Layers***: All linear layers excluding "lm_head" |
|
- ***Weight***: INT4 symmetric per-group, group_size=128 |
|
- ***Pre-trained Model data type***: BFloat16 |
|
- ## Quick Start |
|
1. [Download and install Quark](https://quark.docs.amd.com/latest/install.html) |
|
2. Run the quantization script in the example folder using the following command line: |
|
```sh |
|
export MODEL_DIR = [local model checkpoint folder] or mistralai/Mistral-7B-v0.1 |
|
# single GPU |
|
python3 quantize_quark.py --model_dir $MODEL_DIR \ |
|
--data_type bfloat16 \ |
|
--quant_scheme w_int4_per_group_sym \ |
|
--num_calib_data 128 \ |
|
--quant_algo awq \ |
|
--dataset pileval_for_awq_benchmark \ |
|
--seq_len 512 \ |
|
--output_dir Mistral-7B-v0.1-AWQ-G128-INT4-SYM-BF16 \ |
|
--model_export quark_safetensors |
|
# cpu |
|
python3 quantize_quark.py --model_dir $MODEL_DIR \ |
|
--data_type bfloat16 \ |
|
--quant_scheme w_int4_per_group_sym \ |
|
--num_calib_data 128 \ |
|
--quant_algo awq \ |
|
--dataset pileval_for_awq_benchmark \ |
|
--seq_len 512 \ |
|
--output_dir Mistral-7B-v0.1-AWQ-G128-INT4-SYM-BF16 \ |
|
--model_export quark_safetensors \ |
|
--device cpu |
|
``` |
|
## Deployment |
|
Quark has its own export format, quark_safetensors, which is compatible with autoAWQ exports. |
|
## Evaluation |
|
Quark currently uses perplexity(PPL) as the evaluation metric for accuracy loss before and after quantization.The specific PPL algorithm can be referenced in the quantize_quark.py. |
|
The quantization evaluation results are conducted in pseudo-quantization mode, which may slightly differ from the actual quantized inference accuracy. These results are provided for reference only. |
|
#### Evaluation scores |
|
<table> |
|
<tr> |
|
<td><strong>Benchmark</strong> |
|
</td> |
|
<td><strong>Mistral-7B-v0.1(Bfloat16) </strong> |
|
</td> |
|
<td><strong>Mistral-7B-v0.1-AWQ-G128-INT4-SYM-BF16(this model)</strong> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td>Perplexity-wikitext2 |
|
</td> |
|
<td>5.2527 |
|
</td> |
|
<td>5.4250 |
|
</td> |
|
</tr> |
|
|
|
</table> |
|
|
|
#### License |
|
|
|
Modifications copyright(c) 2024 Advanced Micro Devices,Inc. All rights reserved. |
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
|
you may not use this file except in compliance with the License. |
|
You may obtain a copy of the License at |
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
|
|
|
Unless required by applicable law or agreed to in writing, software |
|
distributed under the License is distributed on an "AS IS" BASIS, |
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
See the License for the specific language governing permissions and |
|
limitations under the License. |
|
|