|
--- |
|
base_model: |
|
- mistralai/Mistral-Small-3.1-24B-Instruct-2503 |
|
--- |
|
|
|
## Evaluation |
|
|
|
Server command: |
|
|
|
``` |
|
vllm serve nm-testing/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic |
|
``` |
|
|
|
Eval command: |
|
|
|
``` |
|
python -m eval.run eval_vllm --model_name nm-testing/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic --url http://0.0.0.0:9000 --output_dir output/ --eval_name "chartqa" |
|
Waiting for VLLM server to come online at http://0.0.0.0:9000/health ... |
|
Timeout is 120s |
|
Waiting for server (0s) ... |
|
Server is up! |
|
Loading lmms-lab/ChartQA [test]: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2500/2500 [00:11<00:00, 210.68it/s] |
|
Querying model: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2500/2500 [06:53<00:00, 6.05it/s] |
|
100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2500/2500 [00:00<00:00, 22477.08it/s] |
|
================================================================================ |
|
Metrics: |
|
{ |
|
"explicit_prompt_relaxed_correctness": 0.8136, |
|
"anywhere_in_answer_relaxed_correctness": 0.8144 |
|
} |
|
================================================================================ |
|
``` |
|
|
|
## Creation |
|
|
|
```python |
|
from transformers import AutoProcessor, AutoModelForImageTextToText |
|
|
|
from llmcompressor.modifiers.quantization import QuantizationModifier |
|
from llmcompressor.transformers import oneshot |
|
|
|
MODEL_ID = "mistralai/Mistral-Small-3.1-24B-Instruct-2503" |
|
|
|
# Load model. |
|
model = AutoModelForImageTextToText.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) |
|
processor.save_pretrained(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("==========================================") |
|
``` |