Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lpm_kernel/L2/dpo/dpo_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions lpm_kernel/api/domains/trainprocess/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down