diff --git a/lpm_kernel/L2/dpo/dpo_train.py b/lpm_kernel/L2/dpo/dpo_train.py index fb5d0bc1..86826989 100644 --- a/lpm_kernel/L2/dpo/dpo_train.py +++ b/lpm_kernel/L2/dpo/dpo_train.py @@ -42,13 +42,18 @@ def training_data_processor(args, SYS = "You are a helpful assistant.\n\n"): return training_data def train(args): + # Read CUDA toggle from training params + training_params = TrainingParamsManager.get_latest_training_params() + use_cuda = training_params.get('use_cuda', False) + device = torch.device('cuda' if use_cuda and torch.cuda.is_available() else 'cpu') + tokenizer = AutoTokenizer.from_pretrained(args.base_model_path, padding_side="left") model = AutoModelForCausalLM.from_pretrained( - args.base_model_path, - trust_remote_code=True, - ignore_mismatched_sizes=True, - torch_dtype=torch.float32, # CPU doesn't support bfloat16 -) + args.base_model_path, + trust_remote_code=True, + ignore_mismatched_sizes=True, + torch_dtype="auto", + ).to(device) time_str = get_east_eight_time_formatted() # merged_model = model.merge_and_unload() diff --git a/lpm_kernel/api/domains/trainprocess/routes.py b/lpm_kernel/api/domains/trainprocess/routes.py index af6425e4..c8a12f2e 100644 --- a/lpm_kernel/api/domains/trainprocess/routes.py +++ b/lpm_kernel/api/domains/trainprocess/routes.py @@ -288,7 +288,6 @@ def retrain(): data_synthesis_mode: Mode for data synthesis (optional) use_cuda: Whether to use CUDA for training (optional) is_cot: Whether to use Chain of Thought (optional) - use_previous_params: Whether to use previous training parameters (optional, default True) Returns: Response: JSON response @@ -318,7 +317,7 @@ def retrain(): is_cot = data.get("is_cot", None) # Log the received parameters - logger.info(f"Retrain parameters: model_name={model_name}, learning_rate={learning_rate}, number_of_epochs={number_of_epochs}, concurrency_threads={concurrency_threads}, data_synthesis_mode={data_synthesis_mode}, use_cuda={use_cuda}, is_cot={is_cot}, use_previous_params={use_previous_params}") + logger.info(f"Retrain parameters: model_name={model_name}, learning_rate={learning_rate}, number_of_epochs={number_of_epochs}, concurrency_threads={concurrency_threads}, data_synthesis_mode={data_synthesis_mode}, use_cuda={use_cuda}, is_cot={is_cot}") # Create training service instance train_service = TrainProcessService(current_model_name=model_name)