3737import yaml
3838
3939# First Party
40- from build .utils import serialize_args
4140from scripts .run_inference import TunedCausalLM
4241from tests .artifacts .language_models import MAYKEYE_TINY_LLAMA_CACHED , TINYMIXTRAL_MOE
4342from tests .artifacts .predefined_data_configs import (
@@ -875,14 +874,36 @@ def test_successful_lora_target_modules_default_from_main(monkeypatch):
875874 """
876875 with tempfile .TemporaryDirectory () as tempdir :
877876 TRAIN_KWARGS = {
878- ** MODEL_ARGS .__dict__ ,
879- ** TRAIN_ARGS .__dict__ ,
880- ** DATA_ARGS .__dict__ ,
881- ** PEFT_LORA_ARGS .__dict__ ,
882- ** {"peft_method" : "lora" , "output_dir" : tempdir },
877+ "model_name_or_path" : MODEL_ARGS .model_name_or_path ,
878+ "use_flash_attn" : MODEL_ARGS .use_flash_attn ,
879+ "torch_dtype" : MODEL_ARGS .torch_dtype ,
880+ "training_data_path" : DATA_ARGS .training_data_path ,
881+ "response_template" : DATA_ARGS .response_template ,
882+ "dataset_text_field" : DATA_ARGS .dataset_text_field ,
883+ "num_train_epochs" : TRAIN_ARGS .num_train_epochs ,
884+ "per_device_train_batch_size" : TRAIN_ARGS .per_device_train_batch_size ,
885+ "per_device_eval_batch_size" : TRAIN_ARGS .per_device_eval_batch_size ,
886+ "gradient_accumulation_steps" : TRAIN_ARGS .gradient_accumulation_steps ,
887+ "learning_rate" : TRAIN_ARGS .learning_rate ,
888+ "weight_decay" : TRAIN_ARGS .weight_decay ,
889+ "warmup_ratio" : TRAIN_ARGS .warmup_ratio ,
890+ "lr_scheduler_type" : TRAIN_ARGS .lr_scheduler_type ,
891+ "logging_steps" : TRAIN_ARGS .logging_steps ,
892+ "include_tokens_per_second" : TRAIN_ARGS .include_tokens_per_second ,
893+ "packing" : TRAIN_ARGS .packing ,
894+ "max_seq_length" : TRAIN_ARGS .max_seq_length ,
895+ "save_strategy" : TRAIN_ARGS .save_strategy ,
896+ "r" : PEFT_LORA_ARGS .r ,
897+ "lora_alpha" : PEFT_LORA_ARGS .lora_alpha ,
898+ "lora_dropout" : PEFT_LORA_ARGS .lora_dropout ,
899+ "peft_method" : "lora" ,
900+ "output_dir" : tempdir ,
883901 }
884- serialized_args = serialize_args (TRAIN_KWARGS )
885- monkeypatch .setenv ("SFT_TRAINER_CONFIG_JSON_ENV_VAR" , serialized_args )
902+ config_path = os .path .join (tempdir , "config.json" )
903+ with open (config_path , "w" , encoding = "utf-8" ) as f :
904+ json .dump (TRAIN_KWARGS , f )
905+ monkeypatch .setenv ("SFT_TRAINER_CONFIG_JSON_PATH" , config_path )
906+ monkeypatch .delenv ("SFT_TRAINER_CONFIG_JSON_ENV_VAR" , raising = False )
886907
887908 sft_trainer .main ()
888909
@@ -902,8 +923,6 @@ def test_successful_lora_target_modules_default_from_main(monkeypatch):
902923 "v_proj" ,
903924 }, "target_modules are not set to the default values."
904925
905- os .environ .pop ("SFT_TRAINER_CONFIG_JSON_ENV_VAR" , None )
906-
907926
908927def test_run_causallm_lora_add_special_tokens ():
909928 """Check if embed layer is added as modules_to_save when special tokens are added"""
0 commit comments