From 245bb1e27b4567e7520e181bf7d3b0a0f2b2ab6d Mon Sep 17 00:00:00 2001 From: KKKKKKKevin <115385420+kevin-mindverse@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:13:18 +0800 Subject: [PATCH 1/2] fix:hotfix use_previous_params problem (#320) Co-authored-by: Ye Xiangle --- lpm_kernel/api/domains/trainprocess/routes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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) From 632b98f14642ae6d38fb84a1a01756bc84c5e20a Mon Sep 17 00:00:00 2001 From: Zachary Pitroda <30330004+zpitroda@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:25:47 -0400 Subject: [PATCH 2/2] Respect cuda toggle --- lpm_kernel/L2/dpo/dpo_train.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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()