Downloads · 30 days
8
38% of all-time downloads
Tfloow/Llama-3.2-1B-Instruct-adpq-4bit-sim
Llama-3.2-1B-Instruct-adpq-4bit-sim is a machine learning model from Tfloow. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This work is part of a master thesis. The library used for quantization is available at auto-adpq.
Downloads · 30 days
8
38% of all-time downloads
All-time downloads
21
Public
Parameters
1.2B
2.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.5 GB · 100%
From the Hugging Face model README
This work is part of a master thesis. The library used for quantization is available at auto-adpq.
pip install auto-adpq
This is a compressed version of meta-llama/Llama-3.2-1B-Instruct created using 4-bit quantization.
This model was quantized to reduce VRAM usage and increase inference speed while maintaining majority of the original model's performance.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Tfloow/Llama-3.2-1B-Instruct-adpq-4bit-sim"
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
inputs = tokenizer("Hello, world!", return_tensors="pt").to("cuda")
output = model.generate(**inputs, max_new_tokens=20)
print(tokenizer.decode(output[0]))
import torch
from transformers import AutoModelForCausalLM
from auto_adpq import Auto_AdpQ, AutoAdpQConfig
model_name = "meta-llama/Llama-3.2-1B-Instruct"
# Setup Auto-AdpQ configuration
adpq_config = AutoAdpQConfig(
group_size=group_size,
n_iters=250, # Throw UserWarning if too low
alpha=0.05, # The higher, the better the PPL loss but higher overhead
device="cpu",
q_bit=4,
data_packing=False,
symmetrical_quantization=True,
)
user = "Tfloow"
adpq_model_name = f"{user}/{model_name.split('/')[-1]}-adpq-4bit-sim"
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
# virtual quantization
quantized = Auto_AdpQ.apply_quantization(model, adpq_config, multi_threaded=16)
model.push_to_hub(adpq_model_name)