Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qlora with flan t5 issue - ValueError: Trying to set a tensor of shape torch.Size([4096, 4096]) #1567

Open
JhonDan1999 opened this issue Jun 5, 2024 · 0 comments

Comments

@JhonDan1999
Copy link

Hi,

I want to use Qlora with Flan-t5

but I got this error

ValueError: Trying to set a tensor of shape torch.Size([4096, 4096]) in "weight" (which has shape torch.Size([8388608, 1])), this look incorrect.

here is my code

model_name = "google/flan-t5-xxl"

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type='nf4',
    bnb_4bit_compute_dtype=torch.bfloat16,

    bnb_4bit_use_double_quant=True,
    llm_int8_enable_fp32_cpu_offload=True
)

model = AutoModelForSeq2SeqLM.from_pretrained( #for "google/flan-t5-xxl"
    model_name,
    quantization_config=bnb_config,
    device_map='auto',
    torch_dtype=torch.bfloat16,
)
model.config.use_cache = False
model.config.pretraining_tp = 1
model.eval()

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token

the error occur earn I call the generate here

    # Generate model output using greedy decoding
    with torch.no_grad():
        outputs = model.generate(**inputs, max_new_tokens=1, do_sample=False,top_p=None)

can you please help me with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant