How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="jsbaicenter/Llama-3.2-1B-Instruct-FP8")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("jsbaicenter/Llama-3.2-1B-Instruct-FP8")
model = AutoModelForCausalLM.from_pretrained("jsbaicenter/Llama-3.2-1B-Instruct-FP8")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

Llama-3.2-1B-Instruct-FP8-Dynamic

FP8 dynamic quantization pipeline for Llama-3.2-1B-Instruct using llm_compressor.


Overview

  • This repository demonstrates how to apply FP8 dynamic quantization to the Llama-3.2-1B-Instruct model.
  • The goal is to reduce memory usage and improve inference efficiency while maintaining strong performance for text generation and instruction-following tasks.

⚠️ This is a quantization pipeline, not a pre-quantized checkpoint.


Usage

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.2-1B-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)")
Downloads last month
5
Safetensors
Model size
1B params
Tensor type
BF16
·
F8_E4M3
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for jsbaicenter/Llama-3.2-1B-Instruct-FP8

Quantized
(373)
this model

Collection including jsbaicenter/Llama-3.2-1B-Instruct-FP8