Downloads · 30 days
19
12% of all-time downloads
jsbaicenter/Meta-Llama-3-8B-Instruct-FP8
Meta-Llama-3-8B-Instruct-FP8 is a text generation model from jsbaicenter. Use it when you need the model to write or continue text. The card lists the license as llama3.
This project demonstrates how to apply FP8 dynamic quantization to Llama-3.1-8B-Instruct using llmcompressor. It provides a pipeline to reduce memory usage and improve inference efficiency while maintaining strong per…
Downloads · 30 days
19
12% of all-time downloads
All-time downloads
154
Public
Parameters
8B
9.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors9.1 GB · 100%
How the weights are stored.
F8_E4M37B · 87%
From the Hugging Face model README
This project demonstrates how to apply FP8 dynamic quantization to Llama-3.1-8B-Instruct using llm_compressor.
It provides a pipeline to reduce memory usage and improve inference efficiency while maintaining strong performance.
from transformers import AutoTokenizer, AutoModelForCausalLM
from llmcompressor.transformers import oneshot
from llmcompressor.modifiers.quantization import QuantizationModifier
# Define the model ID for the model you want to quantize
MODEL_ID = "meta-llama/Llama-3.1-8B-Instruct"
# Load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID, device_map="auto", torch_dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
# Configure the quantization recipe
recipe = QuantizationModifier(targets="Linear", scheme="FP8_DYNAMIC", ignore=["lm_head"])
# Apply the quantization algorithm
oneshot(model=model, recipe=recipe)
# Define the directory to save the quantized model
SAVE_DIR = MODEL_ID.split("/")[1] + "-FP8-Dynamic"
# Save the quantized model and tokenizer
model.save_pretrained(SAVE_DIR)
tokenizer.save_pretrained(SAVE_DIR)
print(f"Quantized model saved to (SAVE_DIR)")