Views
No views yet
vllm serve RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8 --tensor_parallel_size 81from openai import OpenAI
2
3# Modify OpenAI's API key and API base to use vLLM's API server.
4openai_api_key = "EMPTY"
5openai_api_base = "http://<your-server-host>:8000/v1"
6
7client = OpenAI(
8 api_key=openai_api_key,
9 base_url=openai_api_base,
10)
11
12model = "RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8"
13
14messages = [
15 {
16 "role": "user",
17 "content": [
18 {
19 "type": "image_url",
20 "image_url": {"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"},
21 },
22 {"type": "text", "text": "Describe this image."},
23 ],
24 }
25]
26
27outputs = client.chat.completions.create(
28 model=model,
29 messages=messages,
30)
31
32generated_text = outputs.choices[0].message.content
33print(generated_text)1from transformers import AutoProcessor, LlamaForCausalLM, AutoModelForImageTextToText
2
3from llmcompressor import oneshot
4from llmcompressor.modeling import replace_modules_for_calibration
5from llmcompressor.modifiers.quantization import QuantizationModifier
6from llmcompressor.utils import dispatch_for_generation
7
8MODEL_ID = "meta-llama/Llama-4-Maverick-17B-128E-Instruct"
9
10# Load model.
11model = AutoModelForImageTextToText.from_pretrained(MODEL_ID, dtype="auto")
12processor = AutoProcessor.from_pretrained(MODEL_ID)
13model = replace_modules_for_calibration(model)
14
15# Configure the quantization algorithm and scheme.
16# In this case, we:
17# * quantize the weights to fp8 with per-block quantization
18# * quantize the activations to fp8 with dynamic token activations
19ecipe = QuantizationModifier(
20 targets="Linear",
21 scheme="FP8_BLOCK",
22 ignore=[
23 "re:.*lm_head",
24 "re:.*self_attn",
25 "re:.*router",
26 "re:.*vision_model.*",
27 "re:.*multi_modal_projector.*",
28 "Llama4TextAttention",
29 ],
30)
31
32# Apply quantization.
33oneshot(model=model, recipe=recipe)
34dispatch_for_generation(model)
35
36
37# Save to disk in compressed-tensors format.
38SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-block"
39model.save_pretrained(SAVE_DIR)
40processor.save_pretrained(SAVE_DIR)lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8",dtype=auto,add_bos_token=True,max_model_len=16384,tensor_parallel_size=8,gpu_memory_utilization=0.9,enable_chunked_prefill=True,trust_remote_code=True \
--tasks openllm \
--write_out \
--batch_size auto \
--show_configlm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8",dtype=auto,add_bos_token=False,max_model_len=16384,tensor_parallel_size=8,gpu_memory_utilization=0.7,disable_log_stats=True,enable_chunked_prefill=True,trust_remote_code=True \
--tasks leaderboard \
--apply_chat_template \
--fewshot_as_multiturn \
--write_out \
--batch_size auto \
--show_configevalplus.evaluate --model "RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8" \
--dataset "humaneval" \
--backend vllm \
--tp 8 \
--greedy
evalplus.evaluate --model "RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8" \
--dataset "mbpp" \
--backend vllm \
--tp 8 \
--greedylm_eval \
--model vllm-vlm \
--model_args pretrained="RedHatAI/Llama-4-Maverick-17B-128E-Instruct-FP8-block",dtype=auto,add_bos_token=False,max_model_len=1000000,tensor_parallel_size=8,gpu_memory_utilization=0.9,enable_chunked_prefill=True,trust_remote_code=True,max_images=10 \
--tasks mmlu \
--apply_chat_template \
--batch_size auto| Category | Metric | meta-llama/Llama-4-Maverick-17B-128E-Instruct | RedHatAI/Llama-4-Maverick-17B-128E-Instruct-block-FP8 | Recovery (%) |
|---|---|---|---|---|
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 73.38 | 73.38 | 100.00 |
| GSM8K (Strict-Match, 5-shot) | 93.03 | 92.72 | 99.67 | |
| HellaSwag (Acc-Norm, 10-shot) | 87.39 | 87.33 | 99.93 | |
| MMLU (Acc, 5-shot) | 86.03 | 86.15 | 100.13 | |
| TruthfulQA (MC2, 0-shot) | 62.76 | 62.90 | 100.23 | |
| Winogrande (Acc, 5-shot) | 79.56 | 79.40 | 99.80 | |
| Average Score | 80.36 | 80.31 | 99.94 | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 89.93 | 90.89 | 101.07 |
| BBH (Acc-Norm, 3-shot) | 70.53 | 71.03 | 100.71 | |
| Math-Hard (Exact-Match, 4-shot) | 64.73 | 65.26 | 100.82 | |
| GPQA (Acc-Norm, 0-shot) | 31.29 | 30.54 | 97.59 | |
| MUSR (Acc-Norm, 0-shot) | 46.56 | 46.03 | 98.86 | |
| MMLU-Pro (Acc, 5-shot) | 64.11 | 63.95 | 99.75 | |
| Average Score | 61.19 | 61.28 | 100.15 | |
| Multi-modal | MMMU (val) | 79.08 | 78.50 | 99.26 |