Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- HuggingFaceM4/Idefics3-8B-Llama3
|
| 4 |
+
---
|
| 5 |
+
# FP8-Dynamic quant for Idefics2-8B-Llama3, requires about ~12 GB
|
| 6 |
+
|
| 7 |
+
## vLLM usage
|
| 8 |
+
```py
|
| 9 |
+
vllm serve leon-se/Idefics3-8B-Llama3-FP8-Dynamic --trust-remote-code
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
## Code used for quantization
|
| 13 |
+
```py
|
| 14 |
+
from transformers import AutoProcessor, AutoModelForVision2Seq
|
| 15 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 16 |
+
from llmcompressor.transformers import oneshot
|
| 17 |
+
|
| 18 |
+
model_name = "HuggingfaceM4/Idefics3-8B-Llama3"
|
| 19 |
+
|
| 20 |
+
processor = AutoProcessor.from_pretrained(model_name)
|
| 21 |
+
model = AutoModelForVision2Seq.from_pretrained(model_name, device_map="cuda", torch_dtype="auto", trust_remote_code=True)
|
| 22 |
+
|
| 23 |
+
recipe = QuantizationModifier(
|
| 24 |
+
targets="Linear",
|
| 25 |
+
scheme="FP8_DYNAMIC",
|
| 26 |
+
ignore=["re:.*lm_head", "re:model.vision_model.*", "re:model.connector.*"],
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
SAVE_DIR = model_name.split("/")[1] + "-FP8-Dynamic"
|
| 30 |
+
oneshot(model=model, recipe=recipe, output_dir=SAVE_DIR)
|
| 31 |
+
processor.save_pretrained(SAVE_DIR)
|
| 32 |
+
```
|