Views
No views yet
1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "RedHatAI/Ministral-3-14B-Instruct-2512-NVFP4"
5number_gpus = 1
6sampling_params = SamplingParams(temperature=0.15, top_p=1.0, top_k=20, min_p=0, max_tokens=65536)
7
8messages = [
9 {"role": "user", "content": prompt}
10]
11
12tokenizer = AutoTokenizer.from_pretrained(model_id)
13
14messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
15
16prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
17
18llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
19
20outputs = llm.generate(prompts, sampling_params)
21
22generated_text = outputs[0].outputs[0].text
23print(generated_text)1from datasets import load_dataset
2from transformers import Mistral3ForConditionalGeneration, MistralCommonBackend
3from llmcompressor import oneshot
4from llmcompressor.modifiers.quantization import QuantizationModifier
5from llmcompressor.utils import dispatch_for_generation
6
7MODEL_ID = "mistralai/Ministral-3-14B-Instruct-2512-BF16"
8
9model = Mistral3ForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto")
10tokenizer = MistralCommonBackend.from_pretrained(MODEL_ID)
11
12recipe = QuantizationModifier(
13 targets="Linear",
14 scheme="NVFP4",
15 weight_observer="mse",
16 ignore= ['re:.*lm_head', 're:.*vision_tower.*', 're:.*multi_modal_projector.*', 're:.*self_attn'],
17)
18
19# Apply quantization.
20oneshot(model=model, recipe=recipe)
21
22# Confirm generations of the quantized model look sane.
23print("========== SAMPLE GENERATION ==============")
24dispatch_for_generation(model)
25input_ids = tokenizer("Hello my name is", return_tensors="pt").input_ids.to(
26 model.device
27)
28output = model.generate(input_ids, max_new_tokens=20)
29print(tokenizer.decode(output[0]))
30print("==========================================")
31
32
33# Save to disk in compressed-tensors format.
34SAVE_DIR = MODEL_ID.split("/")[1] + "-NVFP4"
35model.save_pretrained(SAVE_DIR, save_compressed = True)
36tokenizer.save_pretrained(SAVE_DIR)lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Ministral-3-14B-Instruct-2512-NVFP4",dtype=auto,gpu_memory_utilization=0.7,max_model_len=262144,enable_chunk_prefill=True,tensor_parallel_size=1 \
--tasks ifeval,mmmu_val \
--apply_chat_template\
--fewshot_as_multiturn \
--batch_size auto1model_parameters:
2 provider: "hosted_vllm"
3 model_name: "hosted_vllm/RedHatAI/Ministral-3-14B-Instruct-2512-NVFP4"
4 base_url: "http://0.0.0.0:8000/v1"
5 api_key: ""
6 timeout: 1200
7 concurrent_requests: 16
8 generation_parameters:
9 temperature: 0.15
10 max_new_tokens: 65536
11 top_p: 0.95
12 seed: 0lighteval endpoint litellm litellm_config.yaml "aime25"lighteval endpoint litellm litellm_config.yaml "math_500"lighteval endpoint litellm litellm_config.yaml "gpqa:diamond"| Category | Benchmark | Ministral-3-14B-Instruct-2512-BF16 | Ministral-3-14B-Instruct-2512-NVFP4 (this model) | Recovery |
|---|---|---|---|---|
| Vision | MMMU | 55.33 | 52.37 | 94.65% |
| OpenLLM v2 | IFEval | 77.34 | 63.55 | 82.17% |
| Reasoning (generation) | AIME 2025 | 36.67 | 32.5 | 88.63% |
| GPQA diamond | 58.59 | 60.94 | 104.02% | |
| Math-lvl-5 | 88.6 | 85.80 | 93.84% | |
| Average | 61.29 | 59.75 | 97.49% |