File size: 2,456 Bytes
17c6d62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<!--Copyright 2024 The HuggingFace Team. 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.
β οΈ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
# EETQ [[eetq]]
[EETQ](https://github.com/NetEase-FuXi/EETQ) λΌμ΄λΈλ¬λ¦¬λ NVIDIA GPUμ λν΄ int8 μ±λλ³(per-channel) κ°μ€μΉ μ μ© μμν(weight-only quantization)μ μ§μν©λλ€. κ³ μ±λ₯ GEMM λ° GEMV 컀λμ FasterTransformer λ° TensorRT-LLMμμ κ°μ Έμμ΅λλ€. κ΅μ (calibration) λ°μ΄ν°μ
μ΄ νμ μμΌλ©°, λͺ¨λΈμ μ¬μ μ μμνν νμλ μμ΅λλ€. λν, μ±λλ³ μμν(per-channel quantization) λλΆμ μ νλ μ νκ° λ―Έλ―Έν©λλ€.
[λ¦΄λ¦¬μ€ νμ΄μ§](https://github.com/NetEase-FuXi/EETQ/releases)μμ eetqλ₯Ό μ€μΉνλμ§ νμΈνμΈμ.
```
pip install --no-cache-dir https://github.com/NetEase-FuXi/EETQ/releases/download/v1.0.0/EETQ-1.0.0+cu121+torch2.1.2-cp310-cp310-linux_x86_64.whl
```
λλ μμ€ μ½λ https://github.com/NetEase-FuXi/EETQ μμ μ€μΉν μ μμ΅λλ€. EETQλ CUDA κΈ°λ₯μ΄ 8.9 μ΄νμ΄κ³ 7.0 μ΄μμ΄μ΄μΌ ν©λλ€.
```
git clone https://github.com/NetEase-FuXi/EETQ.git
cd EETQ/
git submodule update --init --recursive
pip install .
```
λΉμμν λͺ¨λΈμ "from_pretrained"λ₯Ό ν΅ν΄ μμνν μ μμ΅λλ€.
```py
from transformers import AutoModelForCausalLM, EetqConfig
path = "/path/to/model".
quantization_config = EetqConfig("int8")
model = AutoModelForCausalLM.from_pretrained(path, device_map="auto", quantization_config=quantization_config)
```
μμνλ λͺ¨λΈμ "save_pretrained"λ₯Ό ν΅ν΄ μ μ₯ν μ μμΌλ©°, "from_pretrained"λ₯Ό ν΅ν΄ λ€μ μ¬μ©ν μ μμ΅λλ€.
```py
quant_path = "/path/to/save/quantized/model"
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map="auto")
``` |