artidoro / qlora

QLoRA: Efficient Finetuning of Quantized LLMs
https://arxiv.org/abs/2305.14314
MIT License
9.72k stars 798 forks source link

Getting error dataclasses.FrozenInstanceError: cannot assign to field generation_config when executing any of the scripts in the scripts folder with default parameters. #253

Open vasuems opened 11 months ago

vasuems commented 11 months ago

When I am trying to execute the script finetune_llama2_guanaco_7b.sh, I am getting error dataclasses.FrozenInstanceError: cannot assign to field generation_config.

The stack trace is below:

qlora.py", line 841, in train() qlora.py", line 694, in train training_args.generation_config = transformers.GenerationConfig(**vars(generation_args)) File "qlora/.venv/lib/python3.10/site-packages/transformers/training_args.py", line 1714, in setattr raise FrozenInstanceError(f"cannot assign to field {name}") dataclasses.FrozenInstanceError: cannot assign to field generatio

How the issue can be resolved?

stefan-it commented 10 months ago

Hey @vasuems I got the same error message in another library.

The training args are now fully immutable in Transformers 4.32 (see https://github.com/huggingface/transformers/pull/25435).

So a fix for this repo could be:

# Instead of:
#training_args.generation_config = transformers.GenerationConfig(**vars(generation_args))

import dataclasses

training_args = dataclasses.replace(training_args, generation_config = transformers.GenerationConfig(**vars(generation_args)))

But untested!

ThereforeGames commented 10 months ago

@stefan-it Your fix seems to work on my device. Thank you!