From e012936d75b19179f08ec54c01c2775dcb9f506d Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Mon, 15 Dec 2025 18:46:21 -0500 Subject: [PATCH] nits --- cli/commands/train.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/cli/commands/train.py b/cli/commands/train.py index efc034d6ea..ec9b36588d 100644 --- a/cli/commands/train.py +++ b/cli/commands/train.py @@ -59,24 +59,9 @@ def train( ) raise typer.Exit(code=2) - from pathlib import Path as PathlibPath - from backend.trainer import UnslothTrainer - from backend.model_config import ModelConfig - - trainer = UnslothTrainer() - # Check if the model path is a LoRA adapter (has adapter_config.json) - model_path = PathlibPath(cfg.model) if cfg.model else None + model_path = Path(cfg.model) if cfg.model else None model_is_lora = model_path and model_path.is_dir() and (model_path / "adapter_config.json").exists() - - model_config = ModelConfig.from_ui_selection( - dropdown_value=cfg.model, search_value=None, hf_token=hf_token, is_lora=model_is_lora - ) - if not model_config: - typer.echo("Could not resolve model config", err=True) - raise typer.Exit(code=1) - - is_vision = model_config.is_vision use_lora = cfg.training.training_type.lower() == "lora" if model_is_lora and not use_lora: @@ -87,6 +72,20 @@ def train( ) raise typer.Exit(code=2) + from backend.trainer import UnslothTrainer + from backend.model_config import ModelConfig + + trainer = UnslothTrainer() + + model_config = ModelConfig.from_ui_selection( + dropdown_value=cfg.model, search_value=None, hf_token=hf_token, is_lora=model_is_lora + ) + if not model_config: + typer.echo("Could not resolve model config", err=True) + raise typer.Exit(code=1) + + is_vision = model_config.is_vision + if not trainer.load_model( model_name=model_config.identifier, max_seq_length=cfg.training.max_seq_length,