fixes / cleanup
This commit is contained in:
parent
cf966fe98e
commit
7828f77175
3 changed files with 6 additions and 25 deletions
24
cli.py
24
cli.py
|
|
@ -1,4 +1,3 @@
|
|||
import logging
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
|
@ -15,15 +14,6 @@ app = typer.Typer(
|
|||
)
|
||||
|
||||
|
||||
def configure_logging(verbose: bool):
|
||||
level = logging.DEBUG if verbose else logging.INFO
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s",
|
||||
datefmt="%H:%M:%S",
|
||||
)
|
||||
|
||||
|
||||
@app.command()
|
||||
@add_options_from_config(Config)
|
||||
def train(
|
||||
|
|
@ -41,12 +31,9 @@ def train(
|
|||
"--dry-run",
|
||||
help="Show resolved config and exit without training.",
|
||||
),
|
||||
verbose: bool = typer.Option(False, "--verbose/--quiet"),
|
||||
config_overrides: dict = None, # Injected by decorator
|
||||
config_overrides: dict = None, # Injected by add_options_from_config decorator
|
||||
):
|
||||
"""
|
||||
Launch training using the existing Unsloth training backend.
|
||||
"""
|
||||
"""Launch training using the existing Unsloth training backend."""
|
||||
try:
|
||||
cfg = load_config(config)
|
||||
except FileNotFoundError as e:
|
||||
|
|
@ -79,7 +66,6 @@ def train(
|
|||
from backend.trainer import UnslothTrainer
|
||||
from backend.model_config import ModelConfig
|
||||
|
||||
configure_logging(verbose)
|
||||
trainer = UnslothTrainer()
|
||||
|
||||
model_config = ModelConfig.from_ui_selection(
|
||||
|
|
@ -155,16 +141,12 @@ def inference(
|
|||
),
|
||||
max_seq_length: int = typer.Option(2048, "--max-seq-length"),
|
||||
load_in_4bit: bool = typer.Option(True, "--load-in-4bit/--no-load-in-4bit"),
|
||||
verbose: bool = typer.Option(False, "--verbose/--quiet"),
|
||||
):
|
||||
"""
|
||||
Run a single inference using the specified model.
|
||||
"""
|
||||
"""Run a single inference using the specified model."""
|
||||
# Lazy imports to avoid triggering Unsloth patches on --help
|
||||
from backend.model_config import ModelConfig
|
||||
from backend.inference import get_inference_backend
|
||||
|
||||
configure_logging(verbose)
|
||||
inference_backend = get_inference_backend()
|
||||
model_config = ModelConfig.from_ui_selection(
|
||||
dropdown_value=model, search_value=None, hf_token=hf_token, is_lora=False
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class Config(BaseModel):
|
|||
"""Return kwargs for trainer.prepare_model_for_training()."""
|
||||
# Determine target modules based on model type
|
||||
if use_lora and is_vision:
|
||||
target_modules = ["all-linear"] if self.lora.vision_all_linear else []
|
||||
target_modules = "all-linear" if self.lora.vision_all_linear else []
|
||||
else:
|
||||
target_modules = [m.strip() for m in self.lora.target_modules.split(",") if m.strip()]
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,8 @@ def _get_python_type(annotation: Any) -> type:
|
|||
|
||||
def _collect_config_fields(config_class: type[BaseModel]) -> list[tuple[str, Any]]:
|
||||
"""
|
||||
Collect all fields from a config class, flattening nested models.
|
||||
Returns list of (name, field_info) tuples.
|
||||
Raises ValueError on duplicate field names.
|
||||
Collect all fields from a config class, flattening nested models. Returns list of
|
||||
(name, field_info) tuples. Raises ValueError on duplicate field names.
|
||||
"""
|
||||
fields = []
|
||||
seen_names: set[str] = set()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue