From efa1209a92a1ab19c297e2f38836dde2acb7b67e Mon Sep 17 00:00:00 2001 From: Wing Lian Date: Wed, 30 Oct 2024 15:40:27 -0400 Subject: [PATCH] add smoke test training --- src/axolotl/core/trainer_builder.py | 1 + tests/e2e/test_optimizers.py | 41 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/axolotl/core/trainer_builder.py b/src/axolotl/core/trainer_builder.py index 7537f80fe2..265cfeb8c0 100755 --- a/src/axolotl/core/trainer_builder.py +++ b/src/axolotl/core/trainer_builder.py @@ -1638,6 +1638,7 @@ def build(self, total_num_steps): trainer_kwargs["max_length"] = self.cfg.sequence_len if self.cfg.optimizer in [ + # pylint: disable=duplicate-code "optimi_adamw", "ao_adamw_4bit", "ao_adamw_8bit", diff --git a/tests/e2e/test_optimizers.py b/tests/e2e/test_optimizers.py index 119dd3d7cf..24985dde0f 100644 --- a/tests/e2e/test_optimizers.py +++ b/tests/e2e/test_optimizers.py @@ -65,3 +65,44 @@ def test_optimi_adamw(self, temp_dir): train(cfg=cfg, cli_args=cli_args, dataset_meta=dataset_meta) assert (Path(temp_dir) / "adapter_model.bin").exists() + + @with_temp_dir + def test_soap(self, temp_dir): + # pylint: disable=duplicate-code + cfg = DictDefault( + { + "base_model": "HuggingFaceTB/SmolLM-135M", + "sequence_len": 1024, + "load_in_8bit": True, + "adapter": "lora", + "lora_r": 8, + "lora_alpha": 16, + "lora_dropout": 0.05, + "lora_target_linear": True, + "val_set_size": 0.1, + "special_tokens": { + "pad_token": "<|endoftext|>", + }, + "datasets": [ + { + "path": "vicgalle/alpaca-gpt4", + "type": "alpaca", + }, + ], + "num_epochs": 1, + "micro_batch_size": 8, + "gradient_accumulation_steps": 1, + "output_dir": temp_dir, + "learning_rate": 0.00001, + "optimizer": "soap", + "optim_soap_beta1": 0.95, + "optim_soap_beta2": 0.95, + "lr_scheduler": "cosine", + } + ) + normalize_config(cfg) + cli_args = TrainerCliArgs() + dataset_meta = load_datasets(cfg=cfg, cli_args=cli_args) + + train(cfg=cfg, cli_args=cli_args, dataset_meta=dataset_meta) + assert (Path(temp_dir) / "adapter_model.bin").exists()