|
|
|
## Evaluation |
|
|
|
``` |
|
lm_eval --model vllm-vlm --model_args pretrained=llava-hf/llava-1.5-7b-hf --tasks mmmu_val |
|
| Groups |Version|Filter|n-shot|Metric| |Value | |Stderr| |
|
|--------------------------------|------:|------|------|------|---|-----:|---|-----:| |
|
|mmmu_val | 0|none | |acc |↑ |0.2433|± |0.0141| |
|
| - Art and Design | 0|none | |acc |↑ |0.2250|± |0.0384| |
|
| - Business | 0|none | |acc |↑ |0.2600|± |0.0358| |
|
| - Health and Medicine | 0|none | |acc |↑ |0.3067|± |0.0377| |
|
| - Humanities and Social Science| 0|none | |acc |↑ |0.2667|± |0.0403| |
|
| - Science | 0|none | |acc |↑ |0.1667|± |0.0308| |
|
| - Tech and Engineering | 0|none | |acc |↑ |0.2381|± |0.0284| |
|
|
|
|
|
lm_eval --model vllm-vlm --model_args pretrained=mgoin/llava-1.5-7b-hf-FP8-Dynamic --tasks mmmu_val |
|
| Groups |Version|Filter|n-shot|Metric| |Value | |Stderr| |
|
|--------------------------------|------:|------|------|------|---|-----:|---|-----:| |
|
|mmmu_val | 0|none | |acc |↑ |0.2433|± |0.0141| |
|
| - Art and Design | 0|none | |acc |↑ |0.2250|± |0.0384| |
|
| - Business | 0|none | |acc |↑ |0.2600|± |0.0358| |
|
| - Health and Medicine | 0|none | |acc |↑ |0.3067|± |0.0377| |
|
| - Humanities and Social Science| 0|none | |acc |↑ |0.2667|± |0.0403| |
|
| - Science | 0|none | |acc |↑ |0.1667|± |0.0308| |
|
| - Tech and Engineering | 0|none | |acc |↑ |0.2381|± |0.0284| |
|
``` |
|
|
|
## Creation |
|
https://github.com/vllm-project/llm-compressor/pull/185 |
|
|
|
```python |
|
from transformers import AutoProcessor |
|
|
|
from llmcompressor.modifiers.quantization import QuantizationModifier |
|
from llmcompressor.transformers import oneshot |
|
from llmcompressor.transformers.sparsification import create_sparse_auto_model_class |
|
|
|
MODEL_ID = "llava-hf/llava-1.5-7b-hf" |
|
|
|
# Load model. |
|
model_class = create_sparse_auto_model_class("LlavaForConditionalGeneration") |
|
model = model_class.from_pretrained(MODEL_ID, device_map="auto", torch_dtype="auto") |
|
processor = AutoProcessor.from_pretrained(MODEL_ID) |
|
|
|
# Configure the quantization algorithm and scheme. |
|
# In this case, we: |
|
# * quantize the weights to fp8 with per channel via ptq |
|
# * quantize the activations to fp8 with dynamic per token |
|
recipe = QuantizationModifier( |
|
targets="Linear", |
|
scheme="FP8_DYNAMIC", |
|
ignore=["re:.*lm_head", "re:multi_modal_projector.*", "re:vision_tower.*"], |
|
) |
|
|
|
# Apply quantization and save to disk in compressed-tensors format. |
|
SAVE_DIR = MODEL_ID.split("/")[1] + "-FP8-Dynamic" |
|
oneshot(model=model, recipe=recipe, output_dir=SAVE_DIR) |
|
|
|
# Confirm generations of the quantized model look sane. |
|
print("========== SAMPLE GENERATION ==============") |
|
input_ids = processor(text="Hello my name is", return_tensors="pt").input_ids.to("cuda") |
|
output = model.generate(input_ids, max_new_tokens=20) |
|
print(processor.decode(output[0])) |
|
print("==========================================") |
|
``` |