The deepseek-ai/DeepSeek-R1-Distill-Llama-70B model quantized to fp8.
quantization using llm_compressor
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 = "perplexity-ai/r1-1776-distill-llama-70b"
# Load the model and tokenizer with appropriate parameters
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
device_map="auto",
torch_dtype="auto",
trust_remote_code=True, # Add this to automatically trust remote code
low_cpu_mem_usage=True, # Help with memory issues during loading
offload_folder="offload" # Use disk offloading for large models
)
tokenizer = AutoTokenizer.from_pretrained(
MODEL_ID,
trust_remote_code=True # Also need this for tokenizer
)
# 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
- 14
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
Ask for provider support
Model tree for jsbaicenter/r1-1776-distill-llama-70b-FP8-Dynamic
Base model
deepseek-ai/DeepSeek-R1-Distill-Llama-70B