support for DoRA w/ PEFT (#1363)
Browse files
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
--extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
|
2 |
packaging==23.2
|
3 |
-
peft
|
4 |
-
transformers
|
5 |
tokenizers==0.15.0
|
6 |
bitsandbytes>=0.41.1
|
7 |
accelerate==0.26.1
|
|
|
1 |
--extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
|
2 |
packaging==23.2
|
3 |
+
peft==0.9.0
|
4 |
+
transformers==4.38.2
|
5 |
tokenizers==0.15.0
|
6 |
bitsandbytes>=0.41.1
|
7 |
accelerate==0.26.1
|
src/axolotl/utils/config/models/input/v0_4_1/__init__.py
CHANGED
@@ -178,6 +178,7 @@ class LoraConfig(BaseModel):
|
|
178 |
lora_dropout: Optional[float] = None
|
179 |
peft_layers_to_transform: Optional[List[int]] = None
|
180 |
peft: Optional[PeftConfig] = None
|
|
|
181 |
|
182 |
lora_on_cpu: Optional[bool] = None
|
183 |
gptq: Optional[bool] = None
|
@@ -233,6 +234,17 @@ class LoraConfig(BaseModel):
|
|
233 |
raise ValueError("Require cfg.load_in_4bit to be True for qlora")
|
234 |
return self
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
class ReLoRAConfig(BaseModel):
|
238 |
"""ReLoRA configuration subset"""
|
|
|
178 |
lora_dropout: Optional[float] = None
|
179 |
peft_layers_to_transform: Optional[List[int]] = None
|
180 |
peft: Optional[PeftConfig] = None
|
181 |
+
peft_use_dora: Optional[bool] = None
|
182 |
|
183 |
lora_on_cpu: Optional[bool] = None
|
184 |
gptq: Optional[bool] = None
|
|
|
234 |
raise ValueError("Require cfg.load_in_4bit to be True for qlora")
|
235 |
return self
|
236 |
|
237 |
+
@model_validator(mode="before")
|
238 |
+
@classmethod
|
239 |
+
def validate_quantized_dora(cls, data):
|
240 |
+
if data.get("peft_use_dora") and (
|
241 |
+
data.get("load_in_8bit") or data.get("load_in_4bit")
|
242 |
+
):
|
243 |
+
raise ValueError(
|
244 |
+
"`peft_use_dora` is not currently compatible with quantized weights."
|
245 |
+
)
|
246 |
+
return data
|
247 |
+
|
248 |
|
249 |
class ReLoRAConfig(BaseModel):
|
250 |
"""ReLoRA configuration subset"""
|
src/axolotl/utils/models.py
CHANGED
@@ -830,6 +830,8 @@ def load_lora(model, cfg, inference=False, config_only=False):
|
|
830 |
if loftq_bits:
|
831 |
lora_config_kwargs["loftq_config"] = LoftQConfig(loftq_bits=loftq_bits)
|
832 |
lora_config_kwargs["init_lora_weights"] = "loftq"
|
|
|
|
|
833 |
|
834 |
lora_config = LoraConfig(
|
835 |
r=cfg.lora_r,
|
|
|
830 |
if loftq_bits:
|
831 |
lora_config_kwargs["loftq_config"] = LoftQConfig(loftq_bits=loftq_bits)
|
832 |
lora_config_kwargs["init_lora_weights"] = "loftq"
|
833 |
+
if cfg.peft_use_dora:
|
834 |
+
lora_config_kwargs["use_dora"] = cfg.peft_use_dora
|
835 |
|
836 |
lora_config = LoraConfig(
|
837 |
r=cfg.lora_r,
|