Nanobit commited on
Commit
44c9d01
1 Parent(s): ca84cca

Fix: Warn when fullfinetune without adapter (#770)

Browse files
src/axolotl/utils/config.py CHANGED
@@ -360,6 +360,12 @@ def validate_config(cfg):
360
  "eval_table_size and eval_sample_packing are not supported together with sample_packing. Please set 'eval_sample_packing' to false."
361
  )
362
 
 
 
 
 
 
 
363
  # TODO
364
  # MPT 7b
365
  # https://github.com/facebookresearch/bitsandbytes/issues/25
 
360
  "eval_table_size and eval_sample_packing are not supported together with sample_packing. Please set 'eval_sample_packing' to false."
361
  )
362
 
363
+ if not cfg.adapter and (cfg.load_in_8bit or cfg.load_in_4bit):
364
+ raise ValueError(
365
+ "load_in_8bit and load_in_4bit are not supported without setting an adapter."
366
+ "If you want to full finetune, please turn off load_in_8bit and load_in_4bit."
367
+ )
368
+
369
  # TODO
370
  # MPT 7b
371
  # https://github.com/facebookresearch/bitsandbytes/issues/25
tests/test_validation.py CHANGED
@@ -606,3 +606,46 @@ class ValidationTest(unittest.TestCase):
606
  )
607
 
608
  validate_config(cfg)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
  )
607
 
608
  validate_config(cfg)
609
+
610
+ def test_load_in_x_bit_without_adapter(self):
611
+ cfg = DictDefault(
612
+ {
613
+ "load_in_4bit": True,
614
+ }
615
+ )
616
+
617
+ with pytest.raises(
618
+ ValueError,
619
+ match=r".*load_in_8bit and load_in_4bit are not supported without setting an adapter.*",
620
+ ):
621
+ validate_config(cfg)
622
+
623
+ cfg = DictDefault(
624
+ {
625
+ "load_in_8bit": True,
626
+ }
627
+ )
628
+
629
+ with pytest.raises(
630
+ ValueError,
631
+ match=r".*load_in_8bit and load_in_4bit are not supported without setting an adapter.*",
632
+ ):
633
+ validate_config(cfg)
634
+
635
+ cfg = DictDefault(
636
+ {
637
+ "load_in_4bit": True,
638
+ "adapter": "qlora",
639
+ }
640
+ )
641
+
642
+ validate_config(cfg)
643
+
644
+ cfg = DictDefault(
645
+ {
646
+ "load_in_8bit": True,
647
+ "adapter": "lora",
648
+ }
649
+ )
650
+
651
+ validate_config(cfg)