Skip to content

Commit

Permalink
Fix: Warn when fullfinetune without adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoCode012 committed Oct 22, 2023
1 parent 15d3a65 commit 0cef8f6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/axolotl/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ def validate_config(cfg):
"eval_steps and evaluation_strategy are not supported with val_set_size == 0"
)

if not cfg.adapter and (cfg.load_in_8bit or cfg.load_in_4bit):
raise ValueError(
"load_in_8bit and load_in_4bit are not supported without setting an adapter."
"If you want to full finetune, please turn off load_in_8bit and load_in_4bit."
)

# TODO
# MPT 7b
# https://github.com/facebookresearch/bitsandbytes/issues/25
Expand Down
43 changes: 43 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,3 +565,46 @@ def test_no_conflict_eval_strategy(self):
)

validate_config(cfg)

def test_load_in_x_bit_without_adapter(self):
cfg = DictDefault(
{
"load_in_4bit": True,
}
)

with pytest.raises(
ValueError,
match=r".*load_in_8bit and load_in_4bit are not supported without setting an adapter.*",
):
validate_config(cfg)

cfg = DictDefault(
{
"load_in_8bit": True,
}
)

with pytest.raises(
ValueError,
match=r".*load_in_8bit and load_in_4bit are not supported without setting an adapter.*",
):
validate_config(cfg)

cfg = DictDefault(
{
"load_in_4bit": True,
"adapter": "qlora",
}
)

validate_config(cfg)

cfg = DictDefault(
{
"load_in_8bit": True,
"adapter": "lora",
}
)

validate_config(cfg)

0 comments on commit 0cef8f6

Please sign in to comment.