Error

#1
by chu88 - opened

RuntimeError: Error(s) in loading state_dict for CompressedLinear:
While copying the parameter named "weight_packed", whose dimensions in the model are torch.Size([5376, 2688]) and whose dimensions in the checkpoint are torch.Size([5376, 2688]), an exception occurred : ('Only Tensors of floating point and complex dtype can require gradients',).

IST Austria Distributed Algorithms and Systems Lab org

@chu88 are you trying to train the model?

NO, i just installed pip install git+https://github.com/huggingface/[email protected] && pip install accelerate and ran your command:

from transformers import AutoProcessor, Gemma3ForConditionalGeneration
from PIL import Image
import requests
import torch

model_id = "ISTA-DASLab/gemma-3-27b-it-GPTQ-4b-128g"

model = Gemma3ForConditionalGeneration.from_pretrained(
model_id, device_map="auto"
).eval()

processor = AutoProcessor.from_pretrained(model_id)

messages = [
{
"role": "system",
"content": [{"type": "text", "text": "You are a helpful assistant."}]
},
{
"role": "user",
"content": [
{"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
{"type": "text", "text": "Describe this image in detail."}
]
}
]

inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt"
).to(model.device, dtype=torch.bfloat16)

input_len = inputs["input_ids"].shape[-1]

with torch.inference_mode():
generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
generation = generation[0][input_len:]

decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)

IST Austria Distributed Algorithms and Systems Lab org
edited Mar 21

@chu88 which version of compressed_tensors are you using?

I used 0.9.2.

Sign up or log in to comment