You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/work/scripts/omnihub.py", line 12, in
main()
File "/work/scripts/omnihub.py", line 8, in main
o.run()
File "/work/scripts/omnihub/init.py", line 177, in run
self.func(self.extra_args, self.config)
File "/work/applications/hf-finetune/finetune.py", line 225, in run
FineTuner(*args, **kwargs).run()
File "/work/applications/hf-finetune/finetune.py", line 186, in init
self.parse_args(supported_dataclass, custom_args, config)
File "/work/applications/hf-finetune/finetune.py", line 150, in parse_args
parser = HfArgumentParser([dataclass])
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 137, in init
self._add_dataclass_arguments(dtype)
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 277, in _add_dataclass_arguments
self._parse_dataclass_field(parser, field)
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 167, in _parse_dataclass_field
raise ValueError(
ValueError: Only Union[X, NoneType] (i.e., Optional[X]) is allowed for Union because the argument parser only supports one type per argument. Problem encountered in field 'init_lora_weights'.
Expected behavior
I expect the dataclass to be created when using LoraConfig dataclass imported from peft
The text was updated successfully, but these errors were encountered:
The problem is that HfArgumentParser cannot deal with 2 different types in the type annotation (except for NoneType), but PEFT has such annotations, e.g.:
IMO, this is not something we should fix in PEFT, as having 2 different types is perfectly normal. Either HfArgumentParser needs to be updated to be able to deal with multiple types (but I don't know how hard that would be) or you cannot use HfArgumentParser for LoraConfig and need to use other means for argument parsing like argparse.ArgumentParser.
System Info
transformers
version: 4.46.3Who can help?
@SunMarc @MekkCyber
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Looks like HfArgumentParser Throws an error when loading the LoraConfig dataclass from peft that I load in from a yaml config
Some of my code:
from peft import LoraConfig, get_peft_model
from transformers import (
AutoModelForCausalLM,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
)
..
parser = HfArgumentParser([LoraConfig])
(parsed_dataclass,) = parser.parse_dict(flat_config, allow_extra_keys=True)
...
Leads to the following Traceback:
Traceback (most recent call last):
File "/work/scripts/omnihub.py", line 12, in
main()
File "/work/scripts/omnihub.py", line 8, in main
o.run()
File "/work/scripts/omnihub/init.py", line 177, in run
self.func(self.extra_args, self.config)
File "/work/applications/hf-finetune/finetune.py", line 225, in run
FineTuner(*args, **kwargs).run()
File "/work/applications/hf-finetune/finetune.py", line 186, in init
self.parse_args(supported_dataclass, custom_args, config)
File "/work/applications/hf-finetune/finetune.py", line 150, in parse_args
parser = HfArgumentParser([dataclass])
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 137, in init
self._add_dataclass_arguments(dtype)
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 277, in _add_dataclass_arguments
self._parse_dataclass_field(parser, field)
File "/opt/conda/lib/python3.10/site-packages/transformers/hf_argparser.py", line 167, in _parse_dataclass_field
raise ValueError(
ValueError: Only
Union[X, NoneType]
(i.e.,Optional[X]
) is allowed forUnion
because the argument parser only supports one type per argument. Problem encountered in field 'init_lora_weights'.Expected behavior
I expect the dataclass to be created when using LoraConfig dataclass imported from peft
The text was updated successfully, but these errors were encountered: