Llama-4-Maverick-17B-128E-Instruct-block-FP8
Model Overview
- Model Architecture: Llama4ForConditionalGeneration
- Input: Text, Image
- Output: Text
- Model Optimizations:
- Weight quantization: FP8
- Activation quantization: FP8
- Release Date:
- Version: 1.0
- Model Developers:: Red Hat
Quantized version of meta-llama/Llama-4-Maverick-17B-128E-Instruct.
Model Optimizations
This model was obtained by quantizing the weights and activations of meta-llama/Llama-4-Maverick-17B-128E-Instruct to FP8 data type.
This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
Only the weights and activations of the linear operators within transformers blocks of the language model are quantized.
Deployment
Use with vLLM
- Initialize vLLM server:
vllm serve nm-testing/Llama-4-Maverick-17B-128E-Instruct-block-FP8 --tensor_parallel_size 8
- Send requests to the server:
from openai import OpenAI
openai_api_key = "EMPTY"
openai_api_base = "http://<your-server-host>:8000/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
model = "nm-testing/Llama-4-Maverick-17B-128E-Instruct-block-FP8"
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"},
},
{"type": "text", "text": "Describe this image."},
],
}
]
outputs = client.chat.completions.create(
model=model,
messages=messages,
)
generated_text = outputs.choices[0].message.content
print(generated_text)
Creation
This model was quantized using the llm-compressor library as shown below.
Creation details
from transformers import AutoProcessor, LlamaForCausalLM, AutoModelForImageTextToText
from llmcompressor import oneshot
from llmcompressor.modeling import replace_modules_for_calibration
from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.utils import dispatch_for_generation
MODEL_ID = "meta-llama/Llama-4-Maverick-17B-128E-Instruct"
model = AutoModelForImageTextToText.from_pretrained(MODEL_ID, dtype="auto")
processor = AutoProcessor.from_pretrained(MODEL_ID)
model = replace_modules_for_calibration(model)
ecipe = QuantizationModifier(
targets="Linear",
scheme="FP8_BLOCK",
ignore=[
"re:.*lm_head",
"re:.*self_attn",
"re:.*router",
"re:.*vision_model.*",
"re:.*multi_modal_projector.*",
"Llama4TextAttention",
],
)
oneshot(model=model, recipe=recipe)
dispatch_for_generation(model)
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-block"
model.save_pretrained(SAVE_DIR)
processor.save_pretrained(SAVE_DIR)
Evaluation
The model was evaluated on the OpenLLM leaderboard task, using lm-evaluation-harness.
vLLM was used for all evaluations.
Evaluation details
Openllm V1
lm_eval \
--model vllm \
--model_args pretrained="nm-testing/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_config
Openllm V2
lm_eval \
--model vllm \
--model_args pretrained="nm-testing/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_config
Coding Benchmarks
evalplus.evaluate --model "nm-testing/Llama-4-Maverick-17B-128E-Instruct-block-FP8" \
--dataset "humaneval" \
--backend vllm \
--tp 8 \
--greedy
evalplus.evaluate --model "nm-testing/Llama-4-Maverick-17B-128E-Instruct-block-FP8" \
--dataset "mbpp" \
--backend vllm \
--tp 8 \
--greedy
Multimodal Evaluation
lm_eval \
--model vllm-vlm \
--model_args pretrained="nm-testing/Llama-4-Maverick-17B-128E-Instruct-block-FP8",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
Accuracy
| Category |
Metric |
meta-llama/Llama-4-Maverick-17B-128E-Instruct |
nm-testing/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 |
| Coding
|
HumanEval pass@1
|
abc
|
88.40
|
xyz
|
| HumanEval+ pass@1
|
abc
|
79.30
|
xyz
|
| MBPP pass@1
|
abc
|
90.20
|
xyz
|
| MBPP+ pass@1
|
abc
|
75.10
|
xyz
|
| Multi-modal
|
MMMU (val)
|
79.08
|
78.50
|
99.26
|