Views
No views yet
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|1from transformers import AutoProcessor
2
3from llmcompressor.modifiers.quantization import QuantizationModifier
4from llmcompressor.transformers import oneshot
5from llmcompressor.transformers.sparsification import create_sparse_auto_model_class
6
7MODEL_ID = "llava-hf/llava-1.5-7b-hf"
8
9# Load model.
10model_class = create_sparse_auto_model_class("LlavaForConditionalGeneration")
11model = model_class.from_pretrained(MODEL_ID, device_map="auto", torch_dtype="auto")
12processor = AutoProcessor.from_pretrained(MODEL_ID)
13
14# Configure the quantization algorithm and scheme.
15# In this case, we:
16# * quantize the weights to fp8 with per channel via ptq
17# * quantize the activations to fp8 with dynamic per token
18recipe = QuantizationModifier(
19 targets="Linear",
20 scheme="FP8_DYNAMIC",
21 ignore=["re:.*lm_head", "re:multi_modal_projector.*", "re:vision_tower.*"],
22)
23
24# Apply quantization and save to disk in compressed-tensors format.
25SAVE_DIR = MODEL_ID.split("/")[1] + "-FP8-Dynamic"
26oneshot(model=model, recipe=recipe, output_dir=SAVE_DIR)
27
28# Confirm generations of the quantized model look sane.
29print("========== SAMPLE GENERATION ==============")
30input_ids = processor(text="Hello my name is", return_tensors="pt").input_ids.to("cuda")
31output = model.generate(input_ids, max_new_tokens=20)
32print(processor.decode(output[0]))
33print("==========================================")