diff --git a/backend/models/__init__.py b/backend/models/__init__.py deleted file mode 100644 index 07836f2168..0000000000 --- a/backend/models/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -Pydantic models for API request/response schemas -""" -from .training import ( - TrainingStartRequest, - TrainingStartResponse, - TrainingStatusResponse, - TrainingMetricsResponse, - TrainingProgressResponse, -) -from .models import ( - ModelSearchRequest, - ModelSearchResponse, - ModelListResponse, - ModelConfigResponse, - LoRAScanResponse, - LoRAInfo, - ModelInfo, -) - -__all__ = [ - # Training schemas - "TrainingStartRequest", - "TrainingStartResponse", - "TrainingStatusResponse", - "TrainingMetricsResponse", - "TrainingProgressResponse", - # Model management schemas - "ModelSearchRequest", - "ModelSearchResponse", - "ModelListResponse", - "ModelConfigResponse", - "LoRAScanResponse", - "LoRAInfo", - "ModelInfo", -] - diff --git a/backend/models/models.py b/backend/models/models.py deleted file mode 100644 index 9561bf3288..0000000000 --- a/backend/models/models.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -Pydantic schemas for Model Management API -""" -from pydantic import BaseModel, Field -from typing import Optional, List, Dict, Any - - -class ModelSearchRequest(BaseModel): - """Request schema for searching HuggingFace models""" - query: str = Field(..., description="Search query") - hf_token: Optional[str] = Field(None, description="HuggingFace token for authenticated searches") - - -class ModelInfo(BaseModel): - """Model information""" - id: str = Field(..., description="Model identifier") - name: Optional[str] = Field(None, description="Display name") - description: Optional[str] = Field(None, description="Model description") - size: Optional[str] = Field(None, description="Model size") - is_vision: bool = Field(False, description="Whether model is a vision model") - is_lora: bool = Field(False, description="Whether model is a LoRA adapter") - - -class ModelSearchResponse(BaseModel): - """Response schema for model search""" - models: List[ModelInfo] = Field(default_factory=list, description="List of matching models") - total: int = Field(0, description="Total number of results") - - -class ModelListResponse(BaseModel): - """Response schema for listing available models""" - models: List[ModelInfo] = Field(default_factory=list, description="List of available models") - default_models: List[str] = Field(default_factory=list, description="List of default model IDs") - - -class ModelConfigResponse(BaseModel): - """Response schema for model configuration""" - model_name: str = Field(..., description="Model identifier") - config: Dict[str, Any] = Field(..., description="Model configuration dictionary") - is_vision: bool = Field(False, description="Whether model is a vision model") - is_lora: bool = Field(False, description="Whether model is a LoRA adapter") - base_model: Optional[str] = Field(None, description="Base model if this is a LoRA adapter") - - -class LoRAInfo(BaseModel): - """LoRA adapter information""" - display_name: str = Field(..., description="Display name for the LoRA") - adapter_path: str = Field(..., description="Path to the LoRA adapter") - base_model: Optional[str] = Field(None, description="Base model identifier") - - -class LoRAScanResponse(BaseModel): - """Response schema for scanning trained LoRA adapters""" - loras: List[LoRAInfo] = Field(default_factory=list, description="List of found LoRA adapters") - outputs_dir: str = Field(..., description="Directory that was scanned") - diff --git a/backend/models/training.py b/backend/models/training.py deleted file mode 100644 index 9105eaa7d3..0000000000 --- a/backend/models/training.py +++ /dev/null @@ -1,96 +0,0 @@ -""" -Pydantic schemas for Training API -""" -from pydantic import BaseModel, Field -from typing import Optional, List - - -class TrainingStartRequest(BaseModel): - """Request schema for starting training""" - # Model parameters - model_name: str = Field(..., description="Model identifier (e.g., 'unsloth/llama-3-8b-bnb-4bit')") - training_type: str = Field(..., description="Training type: 'LoRA/QLoRA' or 'Full Finetuning'") - hf_token: Optional[str] = Field(None, description="HuggingFace token") - load_in_4bit: bool = Field(True, description="Load model in 4-bit quantization") - max_seq_length: int = Field(2048, description="Maximum sequence length") - - # Dataset parameters - hf_dataset: Optional[str] = Field(None, description="HuggingFace dataset identifier") - local_datasets: List[str] = Field(default_factory=list, description="List of local dataset paths") - format_type: str = Field(..., description="Dataset format type") - - # Training parameters - num_epochs: int = Field(1, description="Number of training epochs") - learning_rate: str = Field("2e-4", description="Learning rate") - batch_size: int = Field(1, description="Batch size") - gradient_accumulation_steps: int = Field(1, description="Gradient accumulation steps") - warmup_steps: Optional[int] = Field(None, description="Warmup steps") - warmup_ratio: Optional[float] = Field(None, description="Warmup ratio") - max_steps: Optional[int] = Field(None, description="Maximum training steps") - save_steps: int = Field(100, description="Steps between checkpoints") - weight_decay: float = Field(0.01, description="Weight decay") - random_seed: int = Field(42, description="Random seed") - packing: bool = Field(False, description="Enable sequence packing") - optim: str = Field("adamw_8bit", description="Optimizer") - lr_scheduler_type: str = Field("linear", description="Learning rate scheduler type") - - # LoRA parameters - use_lora: bool = Field(True, description="Use LoRA (derived from training_type)") - lora_r: int = Field(16, description="LoRA rank") - lora_alpha: int = Field(16, description="LoRA alpha") - lora_dropout: float = Field(0.0, description="LoRA dropout") - target_modules: List[str] = Field(default_factory=list, description="Target modules for LoRA") - gradient_checkpointing: str = Field("", description="Gradient checkpointing setting") - use_rslora: bool = Field(False, description="Use RSLoRA") - use_loftq: bool = Field(False, description="Use LoftQ") - train_on_completions: bool = Field(False, description="Train on completions only") - - # Vision-specific LoRA parameters - finetune_vision_layers: bool = Field(False, description="Finetune vision layers") - finetune_language_layers: bool = Field(False, description="Finetune language layers") - finetune_attention_modules: bool = Field(False, description="Finetune attention modules") - finetune_mlp_modules: bool = Field(False, description="Finetune MLP modules") - - # Logging parameters - enable_wandb: bool = Field(False, description="Enable Weights & Biases logging") - wandb_token: Optional[str] = Field(None, description="W&B token") - wandb_project: Optional[str] = Field(None, description="W&B project name") - enable_tensorboard: bool = Field(False, description="Enable TensorBoard logging") - tensorboard_dir: Optional[str] = Field(None, description="TensorBoard directory") - - -class TrainingStartResponse(BaseModel): - """Response schema for training start""" - status: str = Field(..., description="Status: 'started' or 'error'") - job_id: Optional[str] = Field(None, description="Training job ID") - message: str = Field(..., description="Status message") - error: Optional[str] = Field(None, description="Error message if status is 'error'") - - -class TrainingStatusResponse(BaseModel): - """Response schema for training status""" - status: str = Field(..., description="Status: 'idle', 'preparing', 'training', 'stopping', 'error'") - is_active: bool = Field(..., description="Whether training is currently active (actual training running)") - message: str = Field(..., description="Status message") - current_step: Optional[int] = Field(None, description="Current training step") - total_steps: Optional[int] = Field(None, description="Total training steps") - - -class TrainingMetricsResponse(BaseModel): - """Response schema for training metrics""" - loss_history: List[float] = Field(default_factory=list, description="Loss values") - lr_history: List[float] = Field(default_factory=list, description="Learning rate values") - step_history: List[int] = Field(default_factory=list, description="Step numbers") - current_loss: Optional[float] = Field(None, description="Current loss value") - current_lr: Optional[float] = Field(None, description="Current learning rate") - current_step: Optional[int] = Field(None, description="Current step") - - -class TrainingProgressResponse(BaseModel): - """Response schema for training progress updates""" - step: int = Field(..., description="Current step") - loss: float = Field(..., description="Current loss") - learning_rate: float = Field(..., description="Current learning rate") - status_message: str = Field(..., description="Status message") - progress_percent: Optional[float] = Field(None, description="Progress percentage") - diff --git a/backend/utils/.gitkeep b/backend/utils/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/backend/assets/datasets/alpaca_unsloth.json b/studio/backend/assets/datasets/alpaca_unsloth.json similarity index 100% rename from backend/assets/datasets/alpaca_unsloth.json rename to studio/backend/assets/datasets/alpaca_unsloth.json diff --git a/backend/auth/.gitkeep b/studio/backend/auth/.gitkeep similarity index 100% rename from backend/auth/.gitkeep rename to studio/backend/auth/.gitkeep diff --git a/backend/auth/__init__.py b/studio/backend/auth/__init__.py similarity index 100% rename from backend/auth/__init__.py rename to studio/backend/auth/__init__.py diff --git a/backend/backend/__init__.py b/studio/backend/backend/__init__.py similarity index 100% rename from backend/backend/__init__.py rename to studio/backend/backend/__init__.py diff --git a/backend/backend/export.py b/studio/backend/backend/export.py similarity index 100% rename from backend/backend/export.py rename to studio/backend/backend/export.py diff --git a/backend/backend/inference.py b/studio/backend/backend/inference.py similarity index 100% rename from backend/backend/inference.py rename to studio/backend/backend/inference.py diff --git a/backend/backend/model_config.py b/studio/backend/backend/model_config.py similarity index 100% rename from backend/backend/model_config.py rename to studio/backend/backend/model_config.py diff --git a/backend/backend/path_utils.py b/studio/backend/backend/path_utils.py similarity index 100% rename from backend/backend/path_utils.py rename to studio/backend/backend/path_utils.py diff --git a/backend/backend/trainer.py b/studio/backend/backend/trainer.py similarity index 100% rename from backend/backend/trainer.py rename to studio/backend/backend/trainer.py diff --git a/backend/backend/training.py b/studio/backend/backend/training.py similarity index 100% rename from backend/backend/training.py rename to studio/backend/backend/training.py diff --git a/backend/core/__init__.py b/studio/backend/core/__init__.py similarity index 100% rename from backend/core/__init__.py rename to studio/backend/core/__init__.py diff --git a/backend/core/export/__init__.py b/studio/backend/core/export/__init__.py similarity index 100% rename from backend/core/export/__init__.py rename to studio/backend/core/export/__init__.py diff --git a/backend/core/export/export.py b/studio/backend/core/export/export.py similarity index 100% rename from backend/core/export/export.py rename to studio/backend/core/export/export.py diff --git a/backend/core/inference/__init__.py b/studio/backend/core/inference/__init__.py similarity index 100% rename from backend/core/inference/__init__.py rename to studio/backend/core/inference/__init__.py diff --git a/backend/core/inference/inference.py b/studio/backend/core/inference/inference.py similarity index 100% rename from backend/core/inference/inference.py rename to studio/backend/core/inference/inference.py diff --git a/backend/core/training/__init__.py b/studio/backend/core/training/__init__.py similarity index 100% rename from backend/core/training/__init__.py rename to studio/backend/core/training/__init__.py diff --git a/backend/core/training/trainer.py b/studio/backend/core/training/trainer.py similarity index 100% rename from backend/core/training/trainer.py rename to studio/backend/core/training/trainer.py diff --git a/backend/core/training/training.py b/studio/backend/core/training/training.py similarity index 100% rename from backend/core/training/training.py rename to studio/backend/core/training/training.py diff --git a/backend/loggers/.gitkeep b/studio/backend/loggers/.gitkeep similarity index 100% rename from backend/loggers/.gitkeep rename to studio/backend/loggers/.gitkeep diff --git a/backend/loggers/__init__.py b/studio/backend/loggers/__init__.py similarity index 100% rename from backend/loggers/__init__.py rename to studio/backend/loggers/__init__.py diff --git a/backend/main.py b/studio/backend/main.py similarity index 100% rename from backend/main.py rename to studio/backend/main.py diff --git a/backend/requirements.txt b/studio/backend/requirements.txt similarity index 100% rename from backend/requirements.txt rename to studio/backend/requirements.txt diff --git a/backend/models/.gitkeep b/studio/backend/routes/.gitkeep similarity index 100% rename from backend/models/.gitkeep rename to studio/backend/routes/.gitkeep diff --git a/backend/routes/__init__.py b/studio/backend/routes/__init__.py similarity index 100% rename from backend/routes/__init__.py rename to studio/backend/routes/__init__.py diff --git a/backend/routes/inference.py b/studio/backend/routes/inference.py similarity index 100% rename from backend/routes/inference.py rename to studio/backend/routes/inference.py diff --git a/backend/routes/models.py b/studio/backend/routes/models.py similarity index 100% rename from backend/routes/models.py rename to studio/backend/routes/models.py diff --git a/backend/routes/training.py b/studio/backend/routes/training.py similarity index 100% rename from backend/routes/training.py rename to studio/backend/routes/training.py diff --git a/backend/run.py b/studio/backend/run.py similarity index 100% rename from backend/run.py rename to studio/backend/run.py diff --git a/backend/routes/.gitkeep b/studio/backend/state/.gitkeep similarity index 100% rename from backend/routes/.gitkeep rename to studio/backend/state/.gitkeep diff --git a/backend/state/__init__.py b/studio/backend/state/__init__.py similarity index 100% rename from backend/state/__init__.py rename to studio/backend/state/__init__.py diff --git a/backend/state/.gitkeep b/studio/backend/utils/.gitkeep similarity index 100% rename from backend/state/.gitkeep rename to studio/backend/utils/.gitkeep diff --git a/backend/utils/datasets/dataset_utils.py b/studio/backend/utils/datasets/dataset_utils.py similarity index 100% rename from backend/utils/datasets/dataset_utils.py rename to studio/backend/utils/datasets/dataset_utils.py diff --git a/backend/utils/paths/__init__.py b/studio/backend/utils/paths/__init__.py similarity index 100% rename from backend/utils/paths/__init__.py rename to studio/backend/utils/paths/__init__.py diff --git a/backend/utils/paths/path_utils.py b/studio/backend/utils/paths/path_utils.py similarity index 100% rename from backend/utils/paths/path_utils.py rename to studio/backend/utils/paths/path_utils.py diff --git a/backend/utils/utils.py b/studio/backend/utils/utils.py similarity index 100% rename from backend/utils/utils.py rename to studio/backend/utils/utils.py