[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
27ec6e5af2
commit
f5b3a673ee
104 changed files with 1528 additions and 1315 deletions
|
|
@ -82,7 +82,6 @@ def start(port: int = 8888):
|
|||
from colab import start
|
||||
start()
|
||||
"""
|
||||
import sys
|
||||
|
||||
logger.info("🦥 Starting Unsloth Studio...")
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import structlog
|
||||
import loggers
|
||||
import logging
|
||||
import re
|
||||
import shutil
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
import os
|
||||
import structlog
|
||||
import subprocess
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ Export backend - handles model exporting in various formats
|
|||
|
||||
import glob
|
||||
import json
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import shutil
|
||||
|
|
@ -23,7 +22,7 @@ from utils.hardware import clear_gpu_cache
|
|||
|
||||
from utils.models import is_vision_model, get_base_model_from_lora
|
||||
from utils.models.model_config import detect_audio_type
|
||||
from utils.paths import ensure_dir, outputs_root, resolve_export_dir, resolve_output_dir
|
||||
from utils.paths import ensure_dir, outputs_root, resolve_export_dir
|
||||
from core.inference import get_inference_backend
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
|
|||
|
|
@ -15,13 +15,11 @@ Pattern follows core/inference/orchestrator.py.
|
|||
"""
|
||||
|
||||
import atexit
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import multiprocessing as mp
|
||||
import queue
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Optional, Tuple
|
||||
from utils.paths import outputs_root
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Pattern follows core/inference/worker.py and core/training/worker.py.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Supports: SNAC (Orpheus), CSM (Sesame), BiCodec (Spark), DAC (OuteTTS)
|
|||
import io
|
||||
import re
|
||||
import wave
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
from typing import Optional, Tuple
|
||||
|
||||
|
|
|
|||
|
|
@ -7,21 +7,16 @@ Core inference backend - streamlined
|
|||
|
||||
from unsloth import FastLanguageModel, FastVisionModel
|
||||
from unsloth.chat_templates import get_chat_template
|
||||
from transformers import TextStreamer
|
||||
from peft import PeftModel, PeftModelForCausalLM
|
||||
|
||||
import json
|
||||
import sys
|
||||
import torch
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union, Generator, Tuple
|
||||
from utils.models import ModelConfig, get_base_model_from_lora
|
||||
from utils.paths import is_model_cached
|
||||
from utils.models import ModelConfig
|
||||
from utils.utils import format_error_message
|
||||
from utils.hardware import get_device, clear_gpu_cache, log_gpu_memory
|
||||
from core.inference.audio_codecs import AudioCodecManager
|
||||
from io import StringIO
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
|
||||
|
|
@ -902,7 +897,6 @@ class InferenceBackend:
|
|||
try:
|
||||
from utils.datasets import (
|
||||
MODEL_TO_TEMPLATE_MAPPER,
|
||||
get_tokenizer_chat_template,
|
||||
)
|
||||
|
||||
model_name_lower = self.active_model_name.lower()
|
||||
|
|
@ -1143,7 +1137,6 @@ class InferenceBackend:
|
|||
Uses processor.apply_chat_template with audio embedded in messages (Gemma 3n pattern).
|
||||
"""
|
||||
import threading
|
||||
import numpy as np
|
||||
|
||||
model_info = self.models[self.active_model_name]
|
||||
model = model_info["model"]
|
||||
|
|
@ -1736,7 +1729,7 @@ class InferenceBackend:
|
|||
formatted_prompt = tokenizer.apply_chat_template(
|
||||
chat_messages, tokenize = False, add_generation_prompt = True
|
||||
)
|
||||
logger.info(f"Successfully applied tokenizer's native chat template")
|
||||
logger.info("Successfully applied tokenizer's native chat template")
|
||||
return formatted_prompt
|
||||
except Exception as e:
|
||||
error_msg = str(e).lower()
|
||||
|
|
@ -1745,7 +1738,7 @@ class InferenceBackend:
|
|||
or "no template argument" in error_msg
|
||||
):
|
||||
logger.info(
|
||||
f"Base model detected - no built-in chat template available, using fallback formatting"
|
||||
"Base model detected - no built-in chat template available, using fallback formatting"
|
||||
)
|
||||
else:
|
||||
logger.warning(f"Failed to apply tokenizer chat template: {e}")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import atexit
|
|||
import contextlib
|
||||
import json
|
||||
import struct
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import shutil
|
||||
import socket
|
||||
|
|
@ -2034,7 +2033,7 @@ class LlamaCppBackend:
|
|||
|
||||
except httpx.ConnectError:
|
||||
raise RuntimeError("Lost connection to llama-server")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
if cancel_event is not None and cancel_event.is_set():
|
||||
return
|
||||
raise
|
||||
|
|
@ -2629,7 +2628,7 @@ class LlamaCppBackend:
|
|||
|
||||
except httpx.ConnectError:
|
||||
raise RuntimeError("Lost connection to llama-server")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
if cancel_event is not None and cancel_event.is_set():
|
||||
return
|
||||
raise
|
||||
|
|
@ -2792,7 +2791,7 @@ class LlamaCppBackend:
|
|||
|
||||
except httpx.ConnectError:
|
||||
raise RuntimeError("Lost connection to llama-server")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
if cancel_event is not None and cancel_event.is_set():
|
||||
return
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Pattern follows core/training/training.py.
|
|||
|
||||
import atexit
|
||||
import base64
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import multiprocessing as mp
|
||||
import queue
|
||||
|
|
@ -25,7 +24,6 @@ import threading
|
|||
import time
|
||||
import uuid
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, Generator, Optional, Tuple, Union
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Pattern follows core/training/worker.py.
|
|||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import queue as _queue
|
||||
|
|
|
|||
|
|
@ -33,22 +33,19 @@ if sys.platform in ("win32", "darwin"):
|
|||
sys.path.insert(0, _compile_cache)
|
||||
|
||||
import torch
|
||||
from utils.hardware import clear_gpu_cache, safe_num_proc, dataset_map_num_proc
|
||||
from utils.hardware import clear_gpu_cache, dataset_map_num_proc
|
||||
|
||||
torch._dynamo.config.recompile_limit = 64
|
||||
from unsloth import FastLanguageModel, FastVisionModel, is_bfloat16_supported
|
||||
from unsloth.chat_templates import get_chat_template
|
||||
|
||||
import json
|
||||
import threading
|
||||
import math
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Optional, Callable
|
||||
from dataclasses import dataclass
|
||||
import pandas as pd
|
||||
from datasets import Dataset, load_dataset
|
||||
|
||||
from utils.models import is_vision_model, detect_audio_type
|
||||
|
|
@ -814,7 +811,7 @@ class UnslothTrainer:
|
|||
# second attempt because the failed first call's partial
|
||||
# imports clean up the stale state as a side effect.
|
||||
self._source_code_retried = True
|
||||
logger.info(f"\n'could not get source code' — retrying once...\n")
|
||||
logger.info("\n'could not get source code' — retrying once...\n")
|
||||
return self.load_model(
|
||||
model_name = model_name,
|
||||
max_seq_length = max_seq_length,
|
||||
|
|
@ -1016,7 +1013,7 @@ class UnslothTrainer:
|
|||
# Phase 2: Whisper uses FastModel.get_peft_model with task_type=None
|
||||
from unsloth import FastModel
|
||||
|
||||
logger.info(f"Audio model (whisper) LoRA configuration:")
|
||||
logger.info("Audio model (whisper) LoRA configuration:")
|
||||
logger.info(f" - Target modules: {target_modules}\n")
|
||||
|
||||
self.model = FastModel.get_peft_model(
|
||||
|
|
@ -1057,7 +1054,7 @@ class UnslothTrainer:
|
|||
|
||||
elif self.is_vlm:
|
||||
# Vision model LoRA
|
||||
logger.info(f"Vision model LoRA configuration:")
|
||||
logger.info("Vision model LoRA configuration:")
|
||||
logger.info(f" - Finetune vision layers: {finetune_vision_layers}")
|
||||
logger.info(f" - Finetune language layers: {finetune_language_layers}")
|
||||
logger.info(
|
||||
|
|
@ -1085,7 +1082,7 @@ class UnslothTrainer:
|
|||
)
|
||||
else:
|
||||
# Text model LoRA
|
||||
logger.info(f"Text model LoRA configuration:")
|
||||
logger.info("Text model LoRA configuration:")
|
||||
logger.info(f" - Target modules: {target_modules}\n")
|
||||
|
||||
self.model = FastLanguageModel.get_peft_model(
|
||||
|
|
@ -1114,7 +1111,6 @@ class UnslothTrainer:
|
|||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
error_details = (
|
||||
f"{type(e).__name__}: {str(e)}"
|
||||
|
|
@ -1140,7 +1136,6 @@ class UnslothTrainer:
|
|||
and strip non-TransformersKwargs params that Unsloth/PEFT inject.
|
||||
"""
|
||||
import types
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
from transformers.models.csm.modeling_csm import (
|
||||
CsmForConditionalGeneration,
|
||||
|
|
@ -1707,7 +1702,6 @@ class UnslothTrainer:
|
|||
"""
|
||||
import sys
|
||||
import torch
|
||||
import numpy as np
|
||||
import torchaudio.transforms as T
|
||||
|
||||
import subprocess
|
||||
|
|
@ -2550,7 +2544,7 @@ class UnslothTrainer:
|
|||
custom_format_mapping = custom_format_mapping,
|
||||
)
|
||||
eval_dataset = eval_info["dataset"]
|
||||
logger.info(f"Eval dataset formatted successfully\n")
|
||||
logger.info("Eval dataset formatted successfully\n")
|
||||
elif eval_enabled and not has_separate_eval_source:
|
||||
# No separate eval source — split the already-formatted dataset
|
||||
formatted_dataset = dataset_info["dataset"]
|
||||
|
|
@ -3049,7 +3043,7 @@ class UnslothTrainer:
|
|||
else:
|
||||
# Default to warmup_steps if neither provided
|
||||
config_args["warmup_steps"] = 5
|
||||
logger.info(f"Using default warmup_steps: 5\n")
|
||||
logger.info("Using default warmup_steps: 5\n")
|
||||
|
||||
# Add save_steps if specified
|
||||
save_steps_val = training_args.get("save_steps", 0)
|
||||
|
|
@ -3191,7 +3185,7 @@ class UnslothTrainer:
|
|||
self.tokenizer, "tokenizer"
|
||||
):
|
||||
logger.info(
|
||||
f" ⚠️ Unwrapping Processor → raw tokenizer for text-only SFTTrainer"
|
||||
" ⚠️ Unwrapping Processor → raw tokenizer for text-only SFTTrainer"
|
||||
)
|
||||
sft_tokenizer = self.tokenizer.tokenizer
|
||||
|
||||
|
|
@ -3499,7 +3493,6 @@ def _ensure_deepseek_ocr_installed():
|
|||
sys.path.insert(0, parent_dir)
|
||||
|
||||
# Try importing again
|
||||
from deepseek_ocr.modeling_deepseekocr import format_messages
|
||||
|
||||
logger.info("DeepSeek OCR module installed successfully")
|
||||
logger.info("DeepSeek OCR module installed successfully!\n")
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@ import math
|
|||
import multiprocessing as mp
|
||||
import queue
|
||||
import threading
|
||||
import time
|
||||
import structlog
|
||||
from datetime import datetime, timezone
|
||||
from loggers import get_logger
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, Tuple, Any
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ Pattern follows core/data_recipe/jobs/worker.py.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import platform
|
||||
|
|
@ -460,7 +459,6 @@ def run_training_process(
|
|||
ensure_dir,
|
||||
resolve_output_dir,
|
||||
resolve_tensorboard_dir,
|
||||
datasets_root,
|
||||
)
|
||||
|
||||
import transformers
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ if os.getenv("ENVIRONMENT_TYPE", "production") == "production":
|
|||
from fastapi import Depends, FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import FileResponse, HTMLResponse, Response
|
||||
from fastapi.responses import FileResponse, Response
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ async def get_system_info():
|
|||
import platform
|
||||
import subprocess
|
||||
import psutil
|
||||
from utils.hardware import get_device, get_gpu_memory_info, DeviceType
|
||||
from utils.hardware import get_gpu_memory_info
|
||||
|
||||
# GPU Info — query nvidia-smi for physical GPUs, filtered by
|
||||
# CUDA_VISIBLE_DEVICES when set (the frontend uses this for GGUF
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Pydantic schemas for Export API.
|
|||
"""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional, Literal, Dict, Any
|
||||
from typing import Optional, Literal, Dict, Any
|
||||
|
||||
|
||||
class LoadCheckpointRequest(BaseModel):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from auth import storage, hashing
|
|||
from auth.authentication import (
|
||||
create_access_token,
|
||||
create_refresh_token,
|
||||
get_current_subject,
|
||||
get_current_subject_allow_password_change,
|
||||
refresh_access_token,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import sys
|
|||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
# Add backend directory to path
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ Export API routes: checkpoint discovery and model export operations.
|
|||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
import structlog
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from loggers import get_logger
|
||||
|
||||
# Add backend directory to path
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from fastapi import APIRouter, Depends, HTTPException, Request
|
|||
from fastapi.responses import StreamingResponse, JSONResponse
|
||||
from typing import Optional
|
||||
import json
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import asyncio
|
||||
import threading
|
||||
|
|
@ -82,8 +81,6 @@ from models.inference import (
|
|||
)
|
||||
from auth.authentication import get_current_subject
|
||||
|
||||
import io
|
||||
import wave
|
||||
import base64
|
||||
import numpy as np
|
||||
|
||||
|
|
@ -328,14 +325,14 @@ async def load_model(
|
|||
training_method = adapter_cfg.get("unsloth_training_method")
|
||||
if training_method == "lora" and load_in_4bit:
|
||||
logger.info(
|
||||
f"adapter_config.json says unsloth_training_method='lora' — "
|
||||
f"setting load_in_4bit=False to match 16-bit training"
|
||||
"adapter_config.json says unsloth_training_method='lora' — "
|
||||
"setting load_in_4bit=False to match 16-bit training"
|
||||
)
|
||||
load_in_4bit = False
|
||||
elif training_method == "qlora" and not load_in_4bit:
|
||||
logger.info(
|
||||
f"adapter_config.json says unsloth_training_method='qlora' — "
|
||||
f"setting load_in_4bit=True to match QLoRA training"
|
||||
"adapter_config.json says unsloth_training_method='qlora' — "
|
||||
"setting load_in_4bit=True to match QLoRA training"
|
||||
)
|
||||
load_in_4bit = True
|
||||
elif training_method:
|
||||
|
|
@ -752,7 +749,6 @@ async def generate_audio(
|
|||
|
||||
def _decode_audio_base64(b64: str) -> np.ndarray:
|
||||
"""Decode base64 audio (any format) → float32 numpy array at 16kHz."""
|
||||
import torch
|
||||
import torchaudio
|
||||
import tempfile
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import sys
|
|||
from pathlib import Path
|
||||
from fastapi import APIRouter, Body, Depends, HTTPException, Query
|
||||
from typing import List, Optional
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
import re as _re
|
||||
|
|
@ -775,7 +774,6 @@ async def get_gguf_variants(
|
|||
# case-insensitive match.
|
||||
cached_bytes_by_quant: dict[str, int] = {}
|
||||
try:
|
||||
import re as _re
|
||||
from huggingface_hub import constants as hf_constants
|
||||
|
||||
# Sanitize repo_id: must be "owner/name" with safe chars only
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ import sys
|
|||
from pathlib import Path
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
from fastapi.responses import StreamingResponse
|
||||
from typing import Dict, Optional, Any
|
||||
import structlog
|
||||
from typing import Optional, Any
|
||||
from loggers import get_logger
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
"""Tests for transformers version detection with local checkpoint fallbacks."""
|
||||
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Run with:
|
|||
python -m pytest tests/test_utils.py -v
|
||||
"""
|
||||
|
||||
import platform
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
|
|
@ -295,8 +294,6 @@ class TestLogGpuMemory:
|
|||
"utilization_pct": 12.5,
|
||||
"free_gb": 14.0,
|
||||
}
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
|
@ -312,8 +309,6 @@ class TestLogGpuMemory:
|
|||
|
||||
def test_logs_cpu_fallback_when_no_gpu(self, caplog):
|
||||
fake_info = {"available": False, "backend": "cpu"}
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ by spawned subprocesses.
|
|||
"""
|
||||
|
||||
import shutil
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@ This module contains functions for applying chat templates to datasets
|
|||
and generating dataset info summaries.
|
||||
"""
|
||||
|
||||
from .format_detection import detect_dataset_format, detect_multimodal_dataset, detect_custom_format_heuristic
|
||||
from .format_detection import detect_custom_format_heuristic
|
||||
from .model_mappings import MODEL_TO_TEMPLATE_MAPPER
|
||||
from loggers import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
|
||||
|
||||
DEFAULT_ALPACA_TEMPLATE = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
||||
|
||||
### Instruction:
|
||||
|
|
@ -63,18 +62,21 @@ def get_tokenizer_chat_template(tokenizer, model_name):
|
|||
)
|
||||
except Exception as e:
|
||||
logger.info(f"⚠️ Failed to apply Unsloth template '{matched_template}': {e}")
|
||||
logger.info(f" Falling back to tokenizer's default chat template")
|
||||
logger.info(" Falling back to tokenizer's default chat template")
|
||||
else:
|
||||
# Check if tokenizer actually has a chat_template set
|
||||
has_chat_template = (
|
||||
hasattr(tokenizer, 'chat_template')
|
||||
and tokenizer.chat_template is not None
|
||||
hasattr(tokenizer, "chat_template") and tokenizer.chat_template is not None
|
||||
)
|
||||
if has_chat_template:
|
||||
logger.info(f"📝 Using tokenizer's own chat template (no Unsloth template match)")
|
||||
logger.info(
|
||||
"📝 Using tokenizer's own chat template (no Unsloth template match)"
|
||||
)
|
||||
else:
|
||||
# Base model with no chat template — apply default ChatML
|
||||
logger.info(f"📝 No chat template found — applying default ChatML template (base model)")
|
||||
logger.info(
|
||||
"📝 No chat template found — applying default ChatML template (base model)"
|
||||
)
|
||||
try:
|
||||
tokenizer = get_chat_template(
|
||||
tokenizer,
|
||||
|
|
@ -82,7 +84,7 @@ def get_tokenizer_chat_template(tokenizer, model_name):
|
|||
)
|
||||
except Exception as e:
|
||||
logger.info(f"⚠️ Failed to apply default ChatML template: {e}")
|
||||
logger.info(f" Falling back to tokenizer as-is")
|
||||
logger.info(" Falling back to tokenizer as-is")
|
||||
|
||||
return tokenizer
|
||||
|
||||
|
|
@ -99,7 +101,7 @@ def get_dataset_info_summary(dataset_info):
|
|||
"sharegpt": "ShareGPT format (needs standardization)",
|
||||
"chatml_messages": "ChatML format (messages column) - OpenAI compatible",
|
||||
"chatml_conversations": "ChatML format (conversations column) - HuggingFace standard",
|
||||
"unknown": "Unknown format"
|
||||
"unknown": "Unknown format",
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -110,7 +112,8 @@ def get_dataset_info_summary(dataset_info):
|
|||
"chat_column": dataset_info["chat_column"],
|
||||
"is_standardized": dataset_info["is_standardized"],
|
||||
"warnings": dataset_info.get("warnings", []),
|
||||
"ready_for_training": dataset_info["is_standardized"] and final_format != "unknown"
|
||||
"ready_for_training": dataset_info["is_standardized"]
|
||||
and final_format != "unknown",
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -154,7 +157,7 @@ def apply_chat_template_to_dataset(
|
|||
# Get EOS token if needed
|
||||
eos_token = ""
|
||||
if add_eos_token:
|
||||
if hasattr(tokenizer, 'eos_token') and tokenizer.eos_token:
|
||||
if hasattr(tokenizer, "eos_token") and tokenizer.eos_token:
|
||||
eos_token = tokenizer.eos_token
|
||||
else:
|
||||
warnings.append("add_eos_token=True but tokenizer has no eos_token")
|
||||
|
|
@ -167,14 +170,16 @@ def apply_chat_template_to_dataset(
|
|||
if not dataset_info.get("auto_detection_attempted", False):
|
||||
custom_format_mapping = detect_custom_format_heuristic(dataset)
|
||||
if custom_format_mapping:
|
||||
warnings.append(f"Auto-detected column mapping: {custom_format_mapping}")
|
||||
warnings.append(
|
||||
f"Auto-detected column mapping: {custom_format_mapping}"
|
||||
)
|
||||
else:
|
||||
errors.append("Could not auto-detect format mapping")
|
||||
return {
|
||||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
else:
|
||||
# Already failed once in format_dataset, don't retry
|
||||
|
|
@ -186,7 +191,7 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
if custom_format_mapping:
|
||||
|
|
@ -209,7 +214,7 @@ def apply_chat_template_to_dataset(
|
|||
|
||||
for i in range(num_examples):
|
||||
convo = []
|
||||
role_order = ['system', 'user', 'assistant']
|
||||
role_order = ["system", "user", "assistant"]
|
||||
|
||||
for target_role in role_order:
|
||||
for col_name, role in custom_format_mapping.items():
|
||||
|
|
@ -218,11 +223,18 @@ def apply_chat_template_to_dataset(
|
|||
|
||||
if is_user_provided:
|
||||
# User explicitly mapped - include even if empty
|
||||
convo.append({"role": role, "content": str(content) if content else ""})
|
||||
convo.append(
|
||||
{
|
||||
"role": role,
|
||||
"content": str(content) if content else "",
|
||||
}
|
||||
)
|
||||
else:
|
||||
# Auto-detected - skip empty
|
||||
if content and str(content).strip():
|
||||
convo.append({"role": role, "content": str(content)})
|
||||
convo.append(
|
||||
{"role": role, "content": str(content)}
|
||||
)
|
||||
|
||||
conversations.append(convo)
|
||||
|
||||
|
|
@ -232,31 +244,35 @@ def apply_chat_template_to_dataset(
|
|||
return result
|
||||
|
||||
try:
|
||||
dataset = dataset.map(_apply_custom_mapping, batched = True, batch_size = batch_size)
|
||||
dataset = dataset.map(
|
||||
_apply_custom_mapping, batched = True, batch_size = batch_size
|
||||
)
|
||||
# Update to use conversations format
|
||||
final_format = "chatml_conversations"
|
||||
chat_column = "conversations"
|
||||
is_standardized = True
|
||||
warnings.append("Successfully converted to ChatML format via custom mapping")
|
||||
warnings.append(
|
||||
"Successfully converted to ChatML format via custom mapping"
|
||||
)
|
||||
except Exception as e:
|
||||
errors.append(f"Custom format mapping failed: {e}")
|
||||
return {
|
||||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
# ALPACA FORMAT
|
||||
if final_format == "alpaca":
|
||||
|
||||
# Set alpaca chat template on tokenizer for saving (if not already set)
|
||||
# This ensures the template is saved with the model for inference
|
||||
if not (hasattr(tokenizer, 'chat_template') and tokenizer.chat_template):
|
||||
if not (hasattr(tokenizer, "chat_template") and tokenizer.chat_template):
|
||||
try:
|
||||
from unsloth.chat_templates import get_chat_template
|
||||
|
||||
tokenizer = get_chat_template(tokenizer, chat_template = "alpaca")
|
||||
logger.info(f"📝 Set alpaca chat template on tokenizer for model saving")
|
||||
logger.info("📝 Set alpaca chat template on tokenizer for model saving")
|
||||
except Exception as e:
|
||||
logger.info(f"⚠️ Could not set alpaca template on tokenizer: {e}")
|
||||
|
||||
|
|
@ -266,12 +282,16 @@ def apply_chat_template_to_dataset(
|
|||
for i in range(len(examples["instruction"])):
|
||||
fields = {
|
||||
"instruction": examples["instruction"][i],
|
||||
"input": examples.get("input", [""] * len(examples["instruction"]))[i],
|
||||
"output": examples["output"][i]
|
||||
"input": examples.get("input", [""] * len(examples["instruction"]))[
|
||||
i
|
||||
],
|
||||
"output": examples["output"][i],
|
||||
}
|
||||
|
||||
try:
|
||||
text = DEFAULT_ALPACA_TEMPLATE.format(fields["instruction"], fields["input"], fields["output"])
|
||||
text = DEFAULT_ALPACA_TEMPLATE.format(
|
||||
fields["instruction"], fields["input"], fields["output"]
|
||||
)
|
||||
text += eos_token
|
||||
texts.append(text)
|
||||
except KeyError as e:
|
||||
|
|
@ -284,24 +304,26 @@ def apply_chat_template_to_dataset(
|
|||
|
||||
try:
|
||||
dataset_map_kwargs = {
|
||||
'batched': True,
|
||||
'batch_size': batch_size,
|
||||
"batched": True,
|
||||
"batch_size": batch_size,
|
||||
}
|
||||
|
||||
try:
|
||||
from torch.utils.data import IterableDataset
|
||||
|
||||
_is_torch_iterable = isinstance(dataset, IterableDataset)
|
||||
except ImportError:
|
||||
_is_torch_iterable = False
|
||||
|
||||
if not _is_torch_iterable:
|
||||
from utils.hardware import dataset_map_num_proc
|
||||
|
||||
if num_proc is None or type(num_proc) is not int:
|
||||
num_proc = dataset_map_num_proc()
|
||||
else:
|
||||
num_proc = dataset_map_num_proc(num_proc)
|
||||
dataset_map_kwargs['num_proc'] = num_proc
|
||||
dataset_map_kwargs['desc'] = "Applying template to Alpaca format"
|
||||
dataset_map_kwargs["num_proc"] = num_proc
|
||||
dataset_map_kwargs["desc"] = "Applying template to Alpaca format"
|
||||
|
||||
formatted_dataset = dataset.map(formatted_fn, **dataset_map_kwargs)
|
||||
|
||||
|
|
@ -309,7 +331,7 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": formatted_dataset,
|
||||
"success": True,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
except Exception as e:
|
||||
errors.append(f"Failed to format Alpaca dataset: {e}")
|
||||
|
|
@ -317,12 +339,11 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
# CHATML FORMATS
|
||||
elif final_format in ["chatml_messages", "chatml_conversations"]:
|
||||
|
||||
if not is_standardized:
|
||||
warnings.append("Dataset may not be fully standardized")
|
||||
|
||||
|
|
@ -337,13 +358,11 @@ def apply_chat_template_to_dataset(
|
|||
for convo in convos:
|
||||
try:
|
||||
text = tokenizer.apply_chat_template(
|
||||
convo,
|
||||
tokenize = False,
|
||||
add_generation_prompt = False
|
||||
convo, tokenize = False, add_generation_prompt = False
|
||||
)
|
||||
|
||||
if remove_bos_prefix:
|
||||
text = text.removeprefix('<bos>')
|
||||
text = text.removeprefix("<bos>")
|
||||
text += eos_token
|
||||
|
||||
texts.append(text)
|
||||
|
|
@ -357,23 +376,25 @@ def apply_chat_template_to_dataset(
|
|||
try:
|
||||
try:
|
||||
from torch.utils.data import IterableDataset
|
||||
|
||||
_is_torch_iterable = isinstance(dataset, IterableDataset)
|
||||
except ImportError:
|
||||
_is_torch_iterable = False
|
||||
|
||||
dataset_map_kwargs = {
|
||||
'batched': True,
|
||||
'batch_size': batch_size,
|
||||
"batched": True,
|
||||
"batch_size": batch_size,
|
||||
}
|
||||
|
||||
if not _is_torch_iterable:
|
||||
from utils.hardware import dataset_map_num_proc
|
||||
|
||||
if num_proc is None or type(num_proc) is not int:
|
||||
num_proc = dataset_map_num_proc()
|
||||
else:
|
||||
num_proc = dataset_map_num_proc(num_proc)
|
||||
dataset_map_kwargs['num_proc'] = num_proc
|
||||
dataset_map_kwargs['desc'] = f"Applying chat template to {final_format}"
|
||||
dataset_map_kwargs["num_proc"] = num_proc
|
||||
dataset_map_kwargs["desc"] = f"Applying chat template to {final_format}"
|
||||
|
||||
# Monitor tqdm progress from dataset.map() and relay to callback
|
||||
_tqdm_monitor_stop = None
|
||||
|
|
@ -411,7 +432,7 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": formatted_dataset,
|
||||
"success": True,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
except Exception as e:
|
||||
errors.append(f"Failed to format ChatML dataset: {e}")
|
||||
|
|
@ -419,7 +440,7 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
# UNKNOWN FORMAT
|
||||
|
|
@ -432,5 +453,5 @@ def apply_chat_template_to_dataset(
|
|||
"dataset": dataset,
|
||||
"success": False,
|
||||
"warnings": warnings,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ particularly for VLM/OCR processing.
|
|||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, List, Optional, Union
|
||||
from typing import Any, List
|
||||
from loggers import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
@ -75,7 +75,6 @@ class DeepSeekOCRDataCollator:
|
|||
Returns:
|
||||
dict with input_ids, attention_mask, labels, pixel_values, etc.
|
||||
"""
|
||||
from PIL import Image
|
||||
|
||||
# Extract messages and images
|
||||
all_messages = []
|
||||
|
|
|
|||
|
|
@ -38,12 +38,7 @@ from .format_conversion import (
|
|||
from .chat_templates import (
|
||||
apply_chat_template_to_dataset,
|
||||
get_dataset_info_summary,
|
||||
get_tokenizer_chat_template,
|
||||
DEFAULT_ALPACA_TEMPLATE,
|
||||
)
|
||||
from .vlm_processing import generate_smart_vlm_instruction
|
||||
from .data_collators import DeepSeekOCRDataCollator, VLMDataCollator
|
||||
from .model_mappings import TEMPLATE_TO_MODEL_MAPPER
|
||||
from loggers import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
@ -701,7 +696,7 @@ def format_dataset(
|
|||
}
|
||||
|
||||
else:
|
||||
warnings.append(f"Cannot convert unknown format to Alpaca")
|
||||
warnings.append("Cannot convert unknown format to Alpaca")
|
||||
return {
|
||||
"dataset": dataset,
|
||||
"detected_format": "unknown",
|
||||
|
|
@ -766,7 +761,7 @@ def format_dataset(
|
|||
}
|
||||
|
||||
else:
|
||||
warnings.append(f"Unknown format, attempting standardization")
|
||||
warnings.append("Unknown format, attempting standardization")
|
||||
if detected["chat_column"]:
|
||||
try:
|
||||
standardized = standardize_chat_format(
|
||||
|
|
@ -914,7 +909,7 @@ def format_and_template_dataset(
|
|||
f"falling back to auto-detection"
|
||||
)
|
||||
logger.info(
|
||||
f"⚠️ User VLM mapping failed, falling back to auto-detection..."
|
||||
"⚠️ User VLM mapping failed, falling back to auto-detection..."
|
||||
)
|
||||
custom_format_mapping = None # clear so auto-detection runs below
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ def standardize_chat_format(
|
|||
"""
|
||||
import collections
|
||||
import itertools
|
||||
from datasets import IterableDataset
|
||||
|
||||
# Check if vision tokenizer is used
|
||||
is_vlm = False
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ def detect_custom_format_heuristic(dataset):
|
|||
if prefix in ["generation", "pass", "inference"]:
|
||||
return True
|
||||
|
||||
if len(col_lower) <= 2 and not col_lower in ["qa", "q", "a"]:
|
||||
if len(col_lower) <= 2 and col_lower not in ["qa", "q", "a"]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import os
|
|||
import re
|
||||
import textwrap
|
||||
import time
|
||||
from itertools import islice
|
||||
from typing import Any, Optional
|
||||
|
||||
from loggers import get_logger
|
||||
|
|
@ -105,7 +104,7 @@ def precache_helper_gguf():
|
|||
finally:
|
||||
try:
|
||||
enable_progress_bars()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Usage:
|
|||
"""
|
||||
|
||||
import platform
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
from enum import Enum
|
||||
from typing import Optional, Dict, Any
|
||||
|
|
@ -183,7 +182,6 @@ def get_gpu_memory_info() -> Dict[str, Any]:
|
|||
# ---- MLX path (Apple Silicon) ----
|
||||
if device == DeviceType.MLX:
|
||||
try:
|
||||
import mlx.core as mx
|
||||
import psutil
|
||||
|
||||
# MLX uses unified memory — report system memory as the pool
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from pathlib import Path
|
|||
from typing import Dict, Any, Optional
|
||||
import json
|
||||
import yaml
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
from utils.models.model_config import load_model_defaults
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ Checkpoint scanning utilities for discovering training runs and their checkpoint
|
|||
"""
|
||||
|
||||
import json
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Tuple
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from utils.paths import (
|
|||
resolve_export_dir,
|
||||
)
|
||||
from utils.utils import without_hf_auth
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import subprocess
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ Path utilities for model and dataset handling
|
|||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ Strategy:
|
|||
|
||||
import importlib
|
||||
import json
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ Shared backend utilities
|
|||
"""
|
||||
|
||||
import os
|
||||
import structlog
|
||||
from loggers import get_logger
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ def pip_install(
|
|||
)
|
||||
if result.returncode == 0:
|
||||
return
|
||||
print(_red(f" uv failed, falling back to pip..."))
|
||||
print(_red(" uv failed, falling back to pip..."))
|
||||
if result.stdout:
|
||||
print(result.stdout.decode(errors = "replace"))
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
INSTALL_SH = REPO_ROOT / "install.sh"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
# Add the studio directory so we can import install_python_stack
|
||||
STUDIO_DIR = Path(__file__).resolve().parents[2] / "studio"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Covers:
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import ast
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from unsloth import FastLanguageModel
|
||||
from unsloth.chat_templates import get_chat_template
|
||||
from trl import SFTTrainer, SFTConfig
|
||||
from trl import SFTTrainer
|
||||
from transformers import DataCollatorForSeq2Seq, TrainingArguments
|
||||
from datasets import load_dataset
|
||||
import torch
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import sys
|
|||
from pathlib import Path
|
||||
import multiprocessing as mp
|
||||
import gc
|
||||
from multiprocessing import Queue
|
||||
|
||||
REPO_ROOT = Path(__file__).parents[3]
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
from unsloth import FastLanguageModel
|
||||
from transformers import AutoModelForCausalLM
|
||||
from peft import PeftModel
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import warnings
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from unsloth import FastLanguageModel, FastModel
|
||||
from transformers import AutoModelForCausalLM, WhisperForConditionalGeneration
|
||||
from peft import PeftModel
|
||||
from unsloth import FastModel
|
||||
from transformers import WhisperForConditionalGeneration
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import warnings
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ train_dataset = dataset.select(range(2000))
|
|||
# To select the next 200 examples for evaluation
|
||||
eval_dataset = dataset.select(range(2000, 2200))
|
||||
|
||||
print(f"✅ Dataset loaded successfully!")
|
||||
print("✅ Dataset loaded successfully!")
|
||||
print(f" 📈 Training samples: {len(train_dataset)}")
|
||||
print(f" 📊 Evaluation samples: {len(eval_dataset)}")
|
||||
|
||||
|
|
@ -110,10 +110,10 @@ try:
|
|||
loftq_config = None, # And LoftQ
|
||||
)
|
||||
print("✅ LoRA configuration applied successfully!")
|
||||
print(f" 🎯 LoRA rank (r): 16")
|
||||
print(f" 📊 LoRA alpha: 32")
|
||||
print(f" 🔍 Vision layers: Enabled")
|
||||
print(f" 💬 Language layers: Enabled")
|
||||
print(" 🎯 LoRA rank (r): 16")
|
||||
print(" 📊 LoRA alpha: 32")
|
||||
print(" 🔍 Vision layers: Enabled")
|
||||
print(" 💬 Language layers: Enabled")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to apply LoRA configuration: {e}")
|
||||
raise
|
||||
|
|
@ -165,10 +165,10 @@ try:
|
|||
),
|
||||
)
|
||||
print("✅ Trainer setup completed!")
|
||||
print(f" 📦 Batch size: 2")
|
||||
print(f" 🔄 Gradient accumulation steps: 4")
|
||||
print(f" 📈 Max training steps: 10")
|
||||
print(f" 🎯 Learning rate: 2e-4")
|
||||
print(" 📦 Batch size: 2")
|
||||
print(" 🔄 Gradient accumulation steps: 4")
|
||||
print(" 📈 Max training steps: 10")
|
||||
print(" 🎯 Learning rate: 2e-4")
|
||||
print(f" 💾 Precision: {'BF16' if is_bf16_supported() else 'FP16'}")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to setup trainer: {e}")
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ train_dataset = dataset.select(range(2000))
|
|||
# To select the next 200 examples for evaluation
|
||||
eval_dataset = dataset.select(range(2000, 2200))
|
||||
|
||||
print(f"✅ Dataset loaded successfully!")
|
||||
print("✅ Dataset loaded successfully!")
|
||||
print(f" 📈 Training samples: {len(train_dataset)}")
|
||||
print(f" 📊 Evaluation samples: {len(eval_dataset)}")
|
||||
|
||||
|
|
@ -111,10 +111,10 @@ try:
|
|||
loftq_config = None, # And LoftQ
|
||||
)
|
||||
print("✅ LoRA configuration applied successfully!")
|
||||
print(f" 🎯 LoRA rank (r): 16")
|
||||
print(f" 📊 LoRA alpha: 32")
|
||||
print(f" 🔍 Vision layers: Enabled")
|
||||
print(f" 💬 Language layers: Enabled")
|
||||
print(" 🎯 LoRA rank (r): 16")
|
||||
print(" 📊 LoRA alpha: 32")
|
||||
print(" 🔍 Vision layers: Enabled")
|
||||
print(" 💬 Language layers: Enabled")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to apply LoRA configuration: {e}")
|
||||
raise
|
||||
|
|
@ -166,10 +166,10 @@ try:
|
|||
),
|
||||
)
|
||||
print("✅ Trainer setup completed!")
|
||||
print(f" 📦 Batch size: 2")
|
||||
print(f" 🔄 Gradient accumulation steps: 4")
|
||||
print(f" 📈 Max training steps: 10")
|
||||
print(f" 🎯 Learning rate: 2e-4")
|
||||
print(" 📦 Batch size: 2")
|
||||
print(" 🔄 Gradient accumulation steps: 4")
|
||||
print(" 📈 Max training steps: 10")
|
||||
print(" 🎯 Learning rate: 2e-4")
|
||||
print(f" 💾 Precision: {'BF16' if is_bf16_supported() else 'FP16'}")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to setup trainer: {e}")
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
from unsloth import FastVisionModel
|
||||
|
||||
import torch
|
||||
from qwen_vl_utils import process_vision_info
|
||||
import os
|
||||
from datasets import load_dataset
|
||||
from trl import SFTTrainer, SFTConfig
|
||||
|
||||
|
|
@ -20,7 +17,6 @@ from tests.utils.ocr_eval import OCRModelEvaluator
|
|||
|
||||
|
||||
## Dataset Preparation
|
||||
from datasets import load_dataset
|
||||
|
||||
dataset = load_dataset("lbourdois/OCR-liboaccn-OPUS-MIT-5M-clean", "en", split = "train")
|
||||
# To select the first 2000 examples
|
||||
|
|
@ -66,12 +62,6 @@ train_dataset = [format_data(sample) for sample in train_dataset]
|
|||
eval_dataset = [format_data(sample) for sample in eval_dataset]
|
||||
|
||||
## Setup OCR main evaluation function and helpers
|
||||
import os
|
||||
import torch
|
||||
from tqdm import tqdm
|
||||
import pandas as pd
|
||||
from jiwer import wer, cer
|
||||
from qwen_vl_utils import process_vision_info
|
||||
|
||||
#
|
||||
ocr_evaluator = OCRModelEvaluator()
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
from unsloth import FastVisionModel
|
||||
|
||||
import torch
|
||||
from qwen_vl_utils import process_vision_info
|
||||
import os
|
||||
from datasets import load_dataset
|
||||
from trl import SFTTrainer, SFTConfig
|
||||
|
||||
|
|
@ -20,7 +17,6 @@ from tests.utils.ocr_eval import OCRModelEvaluator
|
|||
|
||||
|
||||
## Dataset Preparation
|
||||
from datasets import load_dataset
|
||||
|
||||
dataset = load_dataset("lbourdois/OCR-liboaccn-OPUS-MIT-5M-clean", "en", split = "train")
|
||||
# To select the first 2000 examples
|
||||
|
|
@ -66,12 +62,6 @@ train_dataset = [format_data(sample) for sample in train_dataset]
|
|||
eval_dataset = [format_data(sample) for sample in eval_dataset]
|
||||
|
||||
## Setup OCR main evaluation function and helpers
|
||||
import os
|
||||
import torch
|
||||
from tqdm import tqdm
|
||||
import pandas as pd
|
||||
from jiwer import wer, cer
|
||||
from qwen_vl_utils import process_vision_info
|
||||
|
||||
#
|
||||
ocr_evaluator = OCRModelEvaluator()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tarfile
|
||||
|
|
|
|||
|
|
@ -14,13 +14,11 @@ Run: pytest tests/studio/install/test_pr4562_bugfixes.py -v
|
|||
"""
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ Tests basic functionality without heavy dependencies.
|
|||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import importlib.util
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ def evaluate_model_aime(
|
|||
|
||||
print(f"\n{'='*70}")
|
||||
print(f"🧮 AIME EVALUATION - {model_type.upper()} MODEL")
|
||||
print(f"Combined Dataset: test2024 + test2025-I + test2025-II")
|
||||
print("Combined Dataset: test2024 + test2025-I + test2025-II")
|
||||
print(f"{'='*70}")
|
||||
|
||||
# Load combined AIME dataset
|
||||
|
|
@ -244,7 +244,7 @@ def evaluate_model_aime(
|
|||
seed = seed,
|
||||
)
|
||||
|
||||
print(f"\n🔧 Configuration:")
|
||||
print("\n🔧 Configuration:")
|
||||
print(f" Temperature: {temperature}")
|
||||
print(f" Samples per question: {n_sampling}")
|
||||
print(f" Max tokens: {max_tokens}")
|
||||
|
|
@ -421,28 +421,28 @@ def evaluate_model_aime(
|
|||
print(f"📊 AIME EVALUATION RESULTS - {model_type.upper()}")
|
||||
print(f"{'='*70}")
|
||||
|
||||
print(f"\n🎯 Overall Performance:")
|
||||
print("\n🎯 Overall Performance:")
|
||||
print(f" Total problems: {total_problems:>6}")
|
||||
print(
|
||||
f" Correct answers: {correct_answers:>6}/{total_problems} ({accuracy:>5.1f}%)"
|
||||
)
|
||||
print(f" Pass@{n_sampling}: {pass_at_k:>10.1f}%")
|
||||
|
||||
print(f"\n📈 Performance by Dataset:")
|
||||
print("\n📈 Performance by Dataset:")
|
||||
for source, stats in source_stats.items():
|
||||
source_acc = source_accuracies[source]
|
||||
print(
|
||||
f" {source:>12}: {stats['correct']:>3}/{stats['total']:>3} ({source_acc:>5.1f}%)"
|
||||
)
|
||||
|
||||
print(f"\n🔧 Configuration:")
|
||||
print("\n🔧 Configuration:")
|
||||
print(f" Temperature: {temperature}")
|
||||
print(f" Samples per problem: {n_sampling}")
|
||||
print(f" Max tokens: {max_tokens}")
|
||||
print(f" Top-p: {top_p}")
|
||||
print(f" Seed: {seed}")
|
||||
|
||||
print(f"\n📝 Token Statistics:")
|
||||
print("\n📝 Token Statistics:")
|
||||
print(f" Avg input tokens: {results['avg_input_tokens']:>10.1f}")
|
||||
print(f" Avg output tokens: {results['avg_output_tokens']:>10.1f}")
|
||||
print(f" Max input tokens: {results['max_input_tokens']:>10}")
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
from contextlib import contextmanager, nullcontext
|
||||
from typing import Callable, Optional
|
||||
from contextlib import nullcontext
|
||||
from typing import Callable
|
||||
|
||||
import bitsandbytes as bnb
|
||||
import torch
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ class OCRModelEvaluator:
|
|||
plt.savefig("ocr_model_comparison.png")
|
||||
plt.show()
|
||||
|
||||
print(f"\nVisualization saved to ocr_model_comparison.png")
|
||||
print("\nVisualization saved to ocr_model_comparison.png")
|
||||
|
||||
def get_comparison_results(self) -> Dict[str, Dict[str, float]]:
|
||||
"""Get the current comparison results."""
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ def require_package(package_name, executable_name = None):
|
|||
for pm_name, cmd in install_commands.items():
|
||||
print(f" {pm_name}: {cmd}")
|
||||
|
||||
print(f"\nAlternatively, install with conda:")
|
||||
print("\nAlternatively, install with conda:")
|
||||
print(f" conda install -c conda-forge {package_name}")
|
||||
|
||||
print(f"\nPlease install the required package and run the script again.")
|
||||
print("\nPlease install the required package and run the script again.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
@ -120,9 +120,9 @@ def require_python_package(package_name, import_name = None, pip_name = None):
|
|||
print(f"❌ Error: Python package '{package_name}' is not installed")
|
||||
print(f"\nPlease install {package_name} using pip:")
|
||||
print(f" pip install {pip_name}")
|
||||
print(f" # or with conda:")
|
||||
print(" # or with conda:")
|
||||
print(f" conda install {pip_name}")
|
||||
print(f"\nAfter installation, run this script again.")
|
||||
print("\nAfter installation, run this script again.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"✓ Python package '{package_name}' is installed")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#
|
||||
# Tests for Q-GaLore integration (unsloth/optimizers/).
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
import torch
|
||||
|
|
|
|||
|
|
@ -101,8 +101,6 @@ def run(args):
|
|||
return {"text": texts}
|
||||
|
||||
def load_dataset_smart(args):
|
||||
from transformers.utils import strtobool
|
||||
|
||||
if args.raw_text_file:
|
||||
# Use raw text loader
|
||||
loader = RawTextDataLoader(tokenizer, args.chunk_size, args.stride)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,15 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import warnings, importlib, sys
|
||||
import warnings
|
||||
import importlib
|
||||
import sys
|
||||
from packaging.version import Version
|
||||
import os, re, subprocess, inspect, functools
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import inspect
|
||||
import functools
|
||||
import numpy as np
|
||||
|
||||
# Log Unsloth is being used
|
||||
|
|
@ -105,7 +111,7 @@ try:
|
|||
import unsloth_zoo
|
||||
except PackageNotFoundError:
|
||||
raise ImportError(
|
||||
f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!"
|
||||
"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!"
|
||||
)
|
||||
except:
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -12,32 +12,60 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
try: import torch
|
||||
except: raise ImportError('Install torch via `pip install torch`')
|
||||
try:
|
||||
import torch
|
||||
except:
|
||||
raise ImportError("Install torch via `pip install torch`")
|
||||
from packaging.version import Version as V
|
||||
import re
|
||||
|
||||
v = V(re.match(r"[0-9\.]{3,}", torch.__version__).group(0))
|
||||
cuda = str(torch.version.cuda)
|
||||
is_ampere = torch.cuda.get_device_capability()[0] >= 8
|
||||
USE_ABI = torch._C._GLIBCXX_USE_CXX11_ABI
|
||||
if cuda not in ("11.8", "12.1", "12.4", "12.6", "12.8", "13.0"): raise RuntimeError(f"CUDA = {cuda} not supported!")
|
||||
if v <= V('2.1.0'): raise RuntimeError(f"Torch = {v} too old!")
|
||||
elif v <= V('2.1.1'): x = 'cu{}{}-torch211'
|
||||
elif v <= V('2.1.2'): x = 'cu{}{}-torch212'
|
||||
elif v < V('2.3.0'): x = 'cu{}{}-torch220'
|
||||
elif v < V('2.4.0'): x = 'cu{}{}-torch230'
|
||||
elif v < V('2.5.0'): x = 'cu{}{}-torch240'
|
||||
elif v < V('2.5.1'): x = 'cu{}{}-torch250'
|
||||
elif v <= V('2.5.1'): x = 'cu{}{}-torch251'
|
||||
elif v < V('2.7.0'): x = 'cu{}{}-torch260'
|
||||
elif v < V('2.7.9'): x = 'cu{}{}-torch270'
|
||||
elif v < V('2.8.0'): x = 'cu{}{}-torch271'
|
||||
elif v < V('2.8.9'): x = 'cu{}{}-torch280'
|
||||
elif v < V('2.9.1'): x = 'cu{}{}-torch290'
|
||||
elif v < V('2.9.2'): x = 'cu{}{}-torch291'
|
||||
elif v < V('2.10.1'): x = 'cu{}{}-torch2100'
|
||||
else: raise RuntimeError(f"Torch = {v} too new!")
|
||||
if v > V('2.6.9') and cuda not in ("11.8", "12.6", "12.8", "13.0"): raise RuntimeError(f"CUDA = {cuda} not supported!")
|
||||
if v >= V('2.10.0') and cuda not in ("12.6", "12.8", "13.0"): raise RuntimeError(f"Torch 2.10 requires CUDA 12.6, 12.8, or 13.0! Got CUDA = {cuda}")
|
||||
x = x.format(cuda.replace(".", ""), "-ampere" if False else "") # is_ampere is broken due to flash-attn
|
||||
print(f'pip install --upgrade pip && pip install --no-deps git+https://github.com/unslothai/unsloth-zoo.git && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git" --no-build-isolation')
|
||||
if cuda not in ("11.8", "12.1", "12.4", "12.6", "12.8", "13.0"):
|
||||
raise RuntimeError(f"CUDA = {cuda} not supported!")
|
||||
if v <= V("2.1.0"):
|
||||
raise RuntimeError(f"Torch = {v} too old!")
|
||||
elif v <= V("2.1.1"):
|
||||
x = "cu{}{}-torch211"
|
||||
elif v <= V("2.1.2"):
|
||||
x = "cu{}{}-torch212"
|
||||
elif v < V("2.3.0"):
|
||||
x = "cu{}{}-torch220"
|
||||
elif v < V("2.4.0"):
|
||||
x = "cu{}{}-torch230"
|
||||
elif v < V("2.5.0"):
|
||||
x = "cu{}{}-torch240"
|
||||
elif v < V("2.5.1"):
|
||||
x = "cu{}{}-torch250"
|
||||
elif v <= V("2.5.1"):
|
||||
x = "cu{}{}-torch251"
|
||||
elif v < V("2.7.0"):
|
||||
x = "cu{}{}-torch260"
|
||||
elif v < V("2.7.9"):
|
||||
x = "cu{}{}-torch270"
|
||||
elif v < V("2.8.0"):
|
||||
x = "cu{}{}-torch271"
|
||||
elif v < V("2.8.9"):
|
||||
x = "cu{}{}-torch280"
|
||||
elif v < V("2.9.1"):
|
||||
x = "cu{}{}-torch290"
|
||||
elif v < V("2.9.2"):
|
||||
x = "cu{}{}-torch291"
|
||||
elif v < V("2.10.1"):
|
||||
x = "cu{}{}-torch2100"
|
||||
else:
|
||||
raise RuntimeError(f"Torch = {v} too new!")
|
||||
if v > V("2.6.9") and cuda not in ("11.8", "12.6", "12.8", "13.0"):
|
||||
raise RuntimeError(f"CUDA = {cuda} not supported!")
|
||||
if v >= V("2.10.0") and cuda not in ("12.6", "12.8", "13.0"):
|
||||
raise RuntimeError(
|
||||
f"Torch 2.10 requires CUDA 12.6, 12.8, or 13.0! Got CUDA = {cuda}"
|
||||
)
|
||||
x = x.format(
|
||||
cuda.replace(".", ""), "-ampere" if False else ""
|
||||
) # is_ampere is broken due to flash-attn
|
||||
print(
|
||||
f'pip install --upgrade pip && pip install --no-deps git+https://github.com/unslothai/unsloth-zoo.git && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git" --no-build-isolation'
|
||||
)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,11 +12,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import csv
|
||||
from typing import List, Dict, Any, Union, Optional
|
||||
from datasets import Dataset
|
||||
from pathlib import Path
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
|||
import requests
|
||||
import torch
|
||||
import gc
|
||||
import time
|
||||
import re
|
||||
from unsloth_zoo.log import logger
|
||||
import numpy as np
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class HideLoggingMessage(logging.Filter):
|
|||
self.text = text
|
||||
|
||||
def filter(self, x):
|
||||
return not (self.text in x.getMessage())
|
||||
return self.text not in x.getMessage()
|
||||
|
||||
|
||||
class HidePrintMessage:
|
||||
|
|
@ -1310,7 +1310,7 @@ def disable_broken_wandb():
|
|||
return # wandb not installed, nothing to do
|
||||
|
||||
try:
|
||||
import wandb
|
||||
pass
|
||||
except Exception:
|
||||
# wandb is installed but broken - patch all checkers to skip it
|
||||
logger.info(
|
||||
|
|
|
|||
|
|
@ -23,12 +23,10 @@ from .utils import (
|
|||
torch_gpu_device,
|
||||
is_cdna,
|
||||
)
|
||||
from transformers.models.llama.modeling_llama import logger
|
||||
from unsloth_zoo.utils import Version
|
||||
|
||||
from unsloth_zoo.loss_utils import (
|
||||
patch_loss_functions as _patch_loss_functions,
|
||||
post_patch_loss_function,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from .utils import (
|
|||
fast_dequantize,
|
||||
QUANT_STATE,
|
||||
get_lora_parameters,
|
||||
get_lora_parameters_bias,
|
||||
matmul_lora,
|
||||
torch_amp_custom_fwd,
|
||||
torch_amp_custom_bwd,
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
import torch
|
||||
from functools import lru_cache
|
||||
from transformers.models.llama.modeling_llama import logger
|
||||
import os
|
||||
|
||||
torch_compile_options = {
|
||||
|
|
@ -80,7 +78,8 @@ else:
|
|||
# See https://github.com/pytorch-labs/attention-gym/blob/main/examples/flex_attn.ipynb
|
||||
# for more examples
|
||||
# BSD 3-Clause License Copyright (c) 2023, Driss Guessous, Horace He et al
|
||||
import functools, math
|
||||
import functools
|
||||
import math
|
||||
|
||||
def generate_tanh_softcap(t):
|
||||
def tanh_softcap(x, b, h, q_idx, kv_idx):
|
||||
|
|
|
|||
|
|
@ -13,11 +13,8 @@
|
|||
# limitations under the License.
|
||||
import os
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import triton
|
||||
import triton.language as tl
|
||||
from torch.nn import functional as F
|
||||
import math
|
||||
from unsloth_zoo.utils import Version
|
||||
from unsloth_zoo.log import logger
|
||||
from unsloth_zoo.temporary_patches.common import torch_compile
|
||||
|
|
@ -588,7 +585,7 @@ try:
|
|||
_has_fbgemm = test_has_fbgemm()
|
||||
if _has_fbgemm:
|
||||
os.environ["UNSLOTH_HAS_FBGEMM"] = "1"
|
||||
logger.info(f"Using fbgemm_gpu block quantized FP8 matmul")
|
||||
logger.info("Using fbgemm_gpu block quantized FP8 matmul")
|
||||
fp8_block_quant_linear = fp8_fbgemm_block_linear
|
||||
else:
|
||||
os.environ["UNSLOTH_HAS_FBGEMM"] = "0"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import triton
|
|||
import triton.language as tl
|
||||
import torch
|
||||
from .utils import (
|
||||
calculate_settings,
|
||||
triton_tanh,
|
||||
torch_gpu_device,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ import triton
|
|||
import triton.language as tl
|
||||
import torch
|
||||
from .utils import calculate_settings, torch_gpu_device
|
||||
from unsloth_zoo.patching_utils import (
|
||||
patch_layernorm,
|
||||
)
|
||||
|
||||
|
||||
@triton.jit
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import time
|
||||
from typing import Dict, List, Optional, Tuple, Any
|
||||
from typing import Dict, Optional, Tuple, Any
|
||||
import torch
|
||||
import triton
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ def save_autotune_results(autotune_cache, mode, ref_time, fused_time, results_di
|
|||
|
||||
for key, config in autotune_cache.items():
|
||||
key = [
|
||||
str(k) if not "torch" in str(k) else str(k.split("torch.")[-1]) for k in key
|
||||
str(k) if "torch" not in str(k) else str(k.split("torch.")[-1]) for k in key
|
||||
]
|
||||
filename = "_".join(key)
|
||||
save_path = f"{save_dir}/{filename}.json"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
import logging
|
||||
import warnings
|
||||
from dataclasses import asdict
|
||||
from unsloth import DEVICE_TYPE
|
||||
|
||||
import torch
|
||||
|
|
|
|||
|
|
@ -336,7 +336,6 @@ def exceeds_smem_capacity(
|
|||
|
||||
|
||||
def common_prune_criteria(config: triton.Config, kwargs: dict, dtype):
|
||||
from ..interface import supports_tma
|
||||
from .tuning import get_device_properties
|
||||
|
||||
smem_size = get_device_properties().SIZE_SMEM
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# SPDX-License-Identifier: GNU Affero General Public License v3.0
|
||||
# Copyright 2023-present the Unsloth team. All rights reserved.
|
||||
|
||||
import torch
|
||||
import triton
|
||||
import triton.language as tl
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# SPDX-License-Identifier: GNU Affero General Public License v3.0
|
||||
# Copyright 2023-present the Unsloth team. All rights reserved.
|
||||
|
||||
import torch
|
||||
import triton
|
||||
import triton.language as tl
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import pytest
|
|||
import torch
|
||||
|
||||
from grouped_gemm.interface import (
|
||||
grouped_gemm,
|
||||
grouped_gemm_dW,
|
||||
grouped_gemm_dX,
|
||||
grouped_gemm_forward,
|
||||
|
|
@ -582,7 +581,6 @@ def _test_grouped_gemm_backward_dX(
|
|||
kernel_config_bwd_dW = KernelConfigBackward_dW()
|
||||
else:
|
||||
from grouped_gemm.kernels.backward import (
|
||||
_autotuned_grouped_gemm_dW_kernel,
|
||||
_autotuned_grouped_gemm_dX_kernel,
|
||||
)
|
||||
from grouped_gemm.kernels.forward import (
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright 2023-present the Unsloth team. All rights reserved.
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from functools import partial
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
import triton
|
||||
import triton.language as tl
|
||||
import torch
|
||||
from .utils import calculate_settings, torch_gpu_device
|
||||
from .utils import torch_gpu_device
|
||||
|
||||
# signed int32 max is 2**31-1 so num_elements cannot exceed 2**31
|
||||
NUM_INT32_ELEMENTS = 2**31
|
||||
|
|
|
|||
|
|
@ -19,18 +19,13 @@ import ctypes
|
|||
MAX_FUSED_SIZE: int = 65536
|
||||
next_power_of_2 = triton.next_power_of_2
|
||||
import functools
|
||||
from typing import Optional
|
||||
|
||||
from ..device_type import (
|
||||
is_hip,
|
||||
get_device_type,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_TYPE_TORCH,
|
||||
DEVICE_COUNT,
|
||||
ALLOW_PREQUANTIZED_MODELS,
|
||||
)
|
||||
from .fp8 import weight_dequant, fp8_linear
|
||||
import functools
|
||||
|
||||
# torch.cuda.amp.custom_fwd is deprecated >= 2.4
|
||||
import torch
|
||||
|
|
|
|||
|
|
@ -86,35 +86,26 @@ from typing import Union, Optional, List, Any, Callable, Tuple, Iterator
|
|||
from platform import system as platform_system
|
||||
|
||||
platform_system = platform_system()
|
||||
import numpy as np
|
||||
import contextlib
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
import functools
|
||||
import textwrap
|
||||
import logging
|
||||
import warnings, subprocess, inspect, psutil, os, math
|
||||
import warnings
|
||||
import inspect
|
||||
import psutil
|
||||
import os
|
||||
from unsloth_zoo.utils import Version, get_quant_type
|
||||
from importlib.metadata import version as importlib_version
|
||||
from ..device_type import (
|
||||
is_hip,
|
||||
get_device_type,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_TYPE_TORCH,
|
||||
DEVICE_COUNT,
|
||||
ALLOW_PREQUANTIZED_MODELS,
|
||||
)
|
||||
from ..import_fixes import UNSLOTH_ENABLE_LOGGING
|
||||
from unsloth_zoo.log import logger
|
||||
from unsloth_zoo.tokenizer_utils import (
|
||||
patch_tokenizer as _patch_tokenizer,
|
||||
)
|
||||
from unsloth_zoo.rl_environments import (
|
||||
check_python_modules,
|
||||
create_locked_down_function,
|
||||
execute_with_time_limit,
|
||||
Benchmarker,
|
||||
)
|
||||
from unsloth_zoo.patching_utils import (
|
||||
patch_compiling_bitsandbytes,
|
||||
patch_layernorm,
|
||||
|
|
@ -127,8 +118,6 @@ from unsloth_zoo.gradient_checkpointing import (
|
|||
unsloth_offloaded_gradient_checkpoint,
|
||||
patch_unsloth_gradient_checkpointing,
|
||||
unpatch_unsloth_gradient_checkpointing,
|
||||
Unsloth_Gradient_Checkpointer,
|
||||
unsloth_gradient_checkpoint,
|
||||
patch_gradient_checkpointing,
|
||||
unpatch_gradient_checkpointing,
|
||||
patch_unsloth_smart_gradient_checkpointing,
|
||||
|
|
@ -313,7 +302,7 @@ class HideLoggingMessage(logging.Filter):
|
|||
self.text = text
|
||||
|
||||
def filter(self, x):
|
||||
return not (self.text in x.getMessage())
|
||||
return self.text not in x.getMessage()
|
||||
|
||||
|
||||
# Replace warning messages (analogous to HideLoggingMessage but for warnings.warn)
|
||||
|
|
@ -737,21 +726,21 @@ def patch_mistral_nemo_config(config):
|
|||
try:
|
||||
# Some Config files use layer_type_validation
|
||||
# for eg Gemma-2, so we must import it to stop errors.
|
||||
from transformers.configuration_utils import layer_type_validation
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
# Transformers 5.0+ uses RotaryEmbeddingConfigMixin as a base class for configs
|
||||
from transformers.modeling_rope_utils import RotaryEmbeddingConfigMixin
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
from transformers import __version__ as transformers_version
|
||||
|
||||
try:
|
||||
from transformers import PreTrainedConfig
|
||||
pass
|
||||
except:
|
||||
from transformers import PretrainedConfig
|
||||
pass
|
||||
|
||||
model_architectures = [
|
||||
"llama",
|
||||
|
|
@ -850,7 +839,7 @@ from transformers.utils import is_openai_available
|
|||
|
||||
if is_openai_available():
|
||||
try:
|
||||
from openai import OpenAI
|
||||
pass
|
||||
except:
|
||||
print("Unsloth: OpenAI failed to import - ignoring for now.")
|
||||
import transformers.utils
|
||||
|
|
@ -862,9 +851,7 @@ if is_openai_available():
|
|||
|
||||
# =============================================
|
||||
# Get Flash Attention v2 if Ampere (RTX 30xx, A100)
|
||||
import bitsandbytes as bnb
|
||||
|
||||
from transformers import AutoTokenizer
|
||||
from transformers.utils.import_utils import _is_package_available
|
||||
|
||||
SUPPORTS_BFLOAT16 = False
|
||||
|
|
@ -882,9 +869,9 @@ if DEVICE_TYPE == "cuda":
|
|||
try:
|
||||
try:
|
||||
# See https://github.com/unslothai/unsloth/issues/1437
|
||||
from flash_attn.flash_attn_interface import flash_attn_gpu
|
||||
pass
|
||||
except:
|
||||
from flash_attn.flash_attn_interface import flash_attn_cuda
|
||||
pass
|
||||
HAS_FLASH_ATTENTION = True
|
||||
|
||||
# Also check for softcapping
|
||||
|
|
@ -931,9 +918,9 @@ elif DEVICE_TYPE == "hip":
|
|||
try:
|
||||
try:
|
||||
# See https://github.com/unslothai/unsloth/issues/1437
|
||||
from flash_attn.flash_attn_interface import flash_attn_gpu
|
||||
pass
|
||||
except:
|
||||
from flash_attn.flash_attn_interface import flash_attn_cuda
|
||||
pass
|
||||
HAS_FLASH_ATTENTION = True
|
||||
|
||||
# Also check for softcapping
|
||||
|
|
@ -1286,7 +1273,7 @@ USE_MODELSCOPE = os.environ.get("UNSLOTH_USE_MODELSCOPE", "0") == "1"
|
|||
if USE_MODELSCOPE:
|
||||
if importlib.util.find_spec("modelscope") is None:
|
||||
raise ImportError(
|
||||
f"You are using the modelscope hub, please install modelscope by `pip install modelscope -U`"
|
||||
"You are using the modelscope hub, please install modelscope by `pip install modelscope -U`"
|
||||
)
|
||||
|
||||
import socket
|
||||
|
|
@ -1304,13 +1291,10 @@ def has_internet(host = "8.8.8.8", port = 53, timeout = 3):
|
|||
return True
|
||||
finally:
|
||||
sock.close()
|
||||
except socket.error as ex:
|
||||
except socket.error:
|
||||
return False
|
||||
|
||||
|
||||
import psutil
|
||||
|
||||
|
||||
def _get_statistics(statistics = None, force_download = True):
|
||||
# We log some basic stats about which environment is being used.
|
||||
# We simply download a README.md file from HF - all data is made public.
|
||||
|
|
@ -1477,7 +1461,6 @@ def get_statistics(local_files_only = False):
|
|||
# Fixes Bitsandbytes to remove missing warnings
|
||||
from transformers.utils.quantization_config import (
|
||||
BitsAndBytesConfig,
|
||||
QuantizationMethod,
|
||||
)
|
||||
|
||||
BitsAndBytesConfig__init__ = inspect.getsource(BitsAndBytesConfig.__init__)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from unsloth_zoo.utils import _get_dtype, Version
|
||||
from ..utils.packing import get_packed_info_from_kwargs
|
||||
|
|
@ -30,9 +29,6 @@ try:
|
|||
CohereDecoderLayer,
|
||||
CohereModel,
|
||||
CohereForCausalLM,
|
||||
CohereRotaryEmbedding,
|
||||
apply_rotary_pos_emb,
|
||||
repeat_kv,
|
||||
)
|
||||
except:
|
||||
transformers_version = Version(transformers_version)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import Version, _get_dtype
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from ..utils.packing import get_packed_info_from_kwargs
|
||||
|
|
@ -28,7 +26,6 @@ from ..utils.attention_dispatch import (
|
|||
from .llama import (
|
||||
LlamaRotaryEmbedding,
|
||||
LlamaLinearScalingRotaryEmbedding,
|
||||
_LlamaModel_fast_forward_inference,
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
@ -37,7 +34,6 @@ try:
|
|||
FalconH1DecoderLayer,
|
||||
FalconH1Model,
|
||||
FalconH1ForCausalLM,
|
||||
FalconHybridMambaAttentionDynamicCache,
|
||||
)
|
||||
except:
|
||||
from transformers import __version__ as transformers_version
|
||||
|
|
|
|||
|
|
@ -14,14 +14,8 @@
|
|||
|
||||
from .llama import *
|
||||
from .llama import _get_rope_theta
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import _get_dtype, Version
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from ..utils.packing import (
|
||||
build_sdpa_packed_attention_mask,
|
||||
build_xformers_block_causal_mask,
|
||||
get_packed_info_from_kwargs,
|
||||
)
|
||||
import math
|
||||
|
||||
try:
|
||||
|
|
@ -30,9 +24,6 @@ try:
|
|||
GemmaDecoderLayer,
|
||||
GemmaModel,
|
||||
GemmaForCausalLM,
|
||||
GemmaRotaryEmbedding,
|
||||
apply_rotary_pos_emb,
|
||||
repeat_kv,
|
||||
)
|
||||
except:
|
||||
transformers_version = Version(transformers_version)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import _get_dtype, Version
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from ..utils.packing import get_packed_info_from_kwargs
|
||||
|
|
@ -22,7 +21,6 @@ from ..utils.attention_dispatch import (
|
|||
AttentionContext,
|
||||
run_attention,
|
||||
select_attention_backend,
|
||||
SDPA,
|
||||
)
|
||||
from .gemma import (
|
||||
GemmaFixedRotaryEmbedding,
|
||||
|
|
@ -36,9 +34,6 @@ try:
|
|||
Gemma2DecoderLayer,
|
||||
Gemma2Model,
|
||||
Gemma2ForCausalLM,
|
||||
Gemma2RotaryEmbedding,
|
||||
apply_rotary_pos_emb,
|
||||
repeat_kv,
|
||||
)
|
||||
except:
|
||||
transformers_version = Version(transformers_version)
|
||||
|
|
@ -65,7 +60,7 @@ except:
|
|||
Gemma2FlashAttention2 = Gemma2Attention
|
||||
|
||||
if HAS_FLASH_ATTENTION_SOFTCAPPING:
|
||||
from flash_attn import flash_attn_func
|
||||
pass
|
||||
|
||||
|
||||
# Logit softcapping
|
||||
|
|
|
|||
|
|
@ -25,20 +25,11 @@ Key architecture differences from Qwen3 MoE:
|
|||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from .llama import (
|
||||
LlamaRotaryEmbedding,
|
||||
LlamaLinearScalingRotaryEmbedding,
|
||||
fix_prepare_inputs_for_generation,
|
||||
fast_rms_layernorm_inference,
|
||||
fast_swiglu_inference,
|
||||
LlamaModel_fast_forward,
|
||||
LlamaModel_fast_forward_inference,
|
||||
CausalLM_fast_forward,
|
||||
PeftModel_fast_forward,
|
||||
)
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from typing import Optional, Tuple
|
||||
from ..kernels import fast_rms_layernorm
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import _get_dtype, Version
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
|
|
@ -265,8 +264,6 @@ def GraniteDecoderLayer_fast_forward(
|
|||
return outputs
|
||||
|
||||
|
||||
from math import sqrt as math_sqrt
|
||||
|
||||
KV_CACHE_INCREMENT = 256 # KV Cache update size
|
||||
torch_nn_functional_softmax = torch.nn.functional.softmax
|
||||
torch_matmul = torch.matmul
|
||||
|
|
@ -285,7 +282,7 @@ def GraniteAttention_fast_forward_inference(
|
|||
):
|
||||
assert (
|
||||
position_embeddings is not None
|
||||
), f"Granite model requires position embeddings to be specified"
|
||||
), "Granite model requires position embeddings to be specified"
|
||||
|
||||
Xn = hidden_states
|
||||
bsz, _, hd = hidden_states.size()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ from ._utils import (
|
|||
_get_inference_mode_context_manager,
|
||||
_prepare_model_for_qat,
|
||||
is_bfloat16_supported,
|
||||
get_quant_type,
|
||||
)
|
||||
from .loader_utils import _get_fp8_mode_and_check_settings
|
||||
from ..utils.packing import (
|
||||
|
|
@ -50,12 +49,9 @@ from unsloth_zoo.hf_utils import (
|
|||
)
|
||||
from unsloth_zoo.peft_utils import SKIP_QUANTIZATION_MODULES
|
||||
from ..device_type import (
|
||||
is_hip,
|
||||
get_device_type,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_TYPE_TORCH,
|
||||
DEVICE_COUNT,
|
||||
ALLOW_PREQUANTIZED_MODELS,
|
||||
)
|
||||
|
||||
transformers_version = Version(transformers_version)
|
||||
|
|
@ -97,7 +93,6 @@ except:
|
|||
LlamaFlashAttention2 = LlamaAttention
|
||||
|
||||
from transformers import (
|
||||
AutoTokenizer,
|
||||
AutoModelForCausalLM,
|
||||
AutoModelForSequenceClassification,
|
||||
BitsAndBytesConfig,
|
||||
|
|
@ -108,14 +103,16 @@ from transformers import set_seed as transformers_set_seed
|
|||
from peft import LoraConfig, TaskType, get_peft_model as _get_peft_model
|
||||
from peft import PeftModelForCausalLM, PeftModelForSequenceClassification
|
||||
from ..save import patch_saving_functions
|
||||
import re, os, inspect, math, sys
|
||||
import re
|
||||
import os
|
||||
import inspect
|
||||
import types
|
||||
|
||||
try:
|
||||
from huggingface_hub.utils import get_token
|
||||
pass
|
||||
except:
|
||||
# Old HF Hub versions <= 0.0.25
|
||||
from huggingface_hub.utils._token import get_token
|
||||
pass
|
||||
from triton import __version__ as triton_version
|
||||
|
||||
HAS_XFORMERS = xformers is not None
|
||||
|
|
@ -2983,7 +2980,7 @@ class FastLlamaModel:
|
|||
try:
|
||||
assert module in accepted_modules
|
||||
final_modules.append(module)
|
||||
except AssertionError as e:
|
||||
except AssertionError:
|
||||
final_modules.append(module)
|
||||
print(
|
||||
"Unsloth: You added custom modules, but Unsloth hasn't optimized for this.\n"
|
||||
|
|
|
|||
|
|
@ -15,20 +15,17 @@
|
|||
from ._utils import (
|
||||
_prepare_model_for_qat,
|
||||
is_bfloat16_supported,
|
||||
is_vLLM_available,
|
||||
HAS_FLASH_ATTENTION,
|
||||
HAS_FLASH_ATTENTION_SOFTCAPPING,
|
||||
USE_MODELSCOPE,
|
||||
get_transformers_model_type,
|
||||
hf_login,
|
||||
)
|
||||
from .granite import FastGraniteModel
|
||||
from .llama import FastLlamaModel, logger
|
||||
from .mistral import FastMistralModel
|
||||
from .qwen2 import FastQwen2Model
|
||||
from .qwen3 import FastQwen3Model
|
||||
from .qwen3_moe import FastQwen3MoeModel
|
||||
from .cohere import FastCohereModel
|
||||
from transformers import AutoConfig
|
||||
from transformers import __version__ as transformers_version
|
||||
from peft import PeftConfig, PeftModel
|
||||
|
|
@ -39,22 +36,20 @@ from .loader_utils import (
|
|||
get_model_name,
|
||||
prepare_device_map,
|
||||
)
|
||||
import os, contextlib, sys
|
||||
import os
|
||||
import contextlib
|
||||
|
||||
try:
|
||||
from huggingface_hub import get_token
|
||||
pass
|
||||
except:
|
||||
try:
|
||||
from huggingface_hub.utils import get_token
|
||||
pass
|
||||
except:
|
||||
# For older versions of huggingface_hub
|
||||
from huggingface_hub.utils._token import get_token
|
||||
pass
|
||||
from huggingface_hub import HfFileSystem
|
||||
import importlib.util
|
||||
from ..device_type import (
|
||||
is_hip,
|
||||
get_device_type,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_TYPE_TORCH,
|
||||
DEVICE_COUNT,
|
||||
ALLOW_PREQUANTIZED_MODELS,
|
||||
|
|
@ -86,15 +81,12 @@ if SUPPORTS_GEMMA:
|
|||
if SUPPORTS_GEMMA2:
|
||||
from .gemma2 import FastGemma2Model
|
||||
if SUPPORTS_FALCON_H1:
|
||||
from .falcon_h1 import FastFalconH1Model
|
||||
pass
|
||||
import torch
|
||||
from ._utils import (
|
||||
patch_compiling_bitsandbytes,
|
||||
patch_model_and_tokenizer,
|
||||
prepare_model_for_kbit_training,
|
||||
apply_unsloth_gradient_checkpointing,
|
||||
patch_compiled_autograd,
|
||||
process_vision_info,
|
||||
unsloth_compile_transformers,
|
||||
fast_inference_setup,
|
||||
)
|
||||
|
|
@ -806,7 +798,6 @@ class FastLanguageModel(FastLlamaModel):
|
|||
|
||||
from ..kernels import (
|
||||
patch_loss_functions,
|
||||
post_patch_loss_function,
|
||||
)
|
||||
from .vision import FastBaseModel
|
||||
from transformers import (
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from ..device_type import DEVICE_TYPE_TORCH
|
|||
import importlib
|
||||
import os
|
||||
import torch
|
||||
import re
|
||||
import tempfile
|
||||
from typing import Union
|
||||
from .mapper import (
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import _get_dtype
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from ..utils.packing import (
|
||||
|
|
@ -48,7 +47,6 @@ try:
|
|||
except:
|
||||
MistralSdpaAttention = MistralAttention
|
||||
MistralFlashAttention2 = MistralAttention
|
||||
from unsloth_zoo.utils import Version, _get_dtype
|
||||
|
||||
|
||||
def MistralAttention_fast_forward(
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.utils import Version, _get_dtype
|
||||
from unsloth_zoo.utils import Version
|
||||
from ..utils.packing import get_packed_info_from_kwargs
|
||||
from ..utils.attention_dispatch import (
|
||||
AttentionConfig,
|
||||
|
|
@ -48,9 +46,6 @@ except:
|
|||
f'Try `pip install --upgrade "transformers>=4.50.3"`\n'
|
||||
f"to obtain the latest transformers build, then restart this session."
|
||||
)
|
||||
from transformers.modeling_attn_mask_utils import (
|
||||
_prepare_4d_causal_attention_mask_for_sdpa,
|
||||
)
|
||||
|
||||
# For Pytorch 2.1.1
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
import os
|
||||
from ._utils import __version__
|
||||
from .llama import (
|
||||
LlamaRotaryEmbedding,
|
||||
LlamaLinearScalingRotaryEmbedding,
|
||||
|
|
@ -43,7 +41,6 @@ from transformers.models.qwen3_moe.modeling_qwen3_moe import (
|
|||
# Qwen3SdpaAttention = Qwen3Attention
|
||||
# Qwen3FlashAttention2 = Qwen3Attention
|
||||
# pass
|
||||
from unsloth_zoo.utils import Version, _get_dtype
|
||||
|
||||
|
||||
torch_nn_functional_softmax = torch.nn.functional.softmax
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ __all__ = [
|
|||
]
|
||||
|
||||
import torch
|
||||
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
|
|
@ -539,8 +538,6 @@ def _wrap_grpo_generate_and_score(trainer_cls):
|
|||
|
||||
def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
|
||||
# Patch for vLLM and Unsloth PEFT
|
||||
import trl
|
||||
import trl.trainer
|
||||
|
||||
try:
|
||||
trainer = eval(f"trl.trainer.{trainer_file}")
|
||||
|
|
|
|||
|
|
@ -38,12 +38,7 @@ from unsloth_zoo.log import logger
|
|||
from unsloth_zoo.device_type import device_synchronize
|
||||
import importlib.util
|
||||
from ..device_type import (
|
||||
is_hip,
|
||||
get_device_type,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_TYPE_TORCH,
|
||||
DEVICE_COUNT,
|
||||
ALLOW_PREQUANTIZED_MODELS,
|
||||
)
|
||||
import textwrap
|
||||
from ._utils import _get_inference_mode_context_manager
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ def _push_to_hub_gguf(
|
|||
|
||||
# Save to temporary directory first
|
||||
with tempfile.TemporaryDirectory(prefix = "unsloth_st_gguf_") as temp_dir:
|
||||
print(f"Unsloth: Converting SentenceTransformer to GGUF format...")
|
||||
print("Unsloth: Converting SentenceTransformer to GGUF format...")
|
||||
|
||||
# Call save_pretrained_gguf to do the local conversion
|
||||
result = _save_pretrained_gguf(
|
||||
|
|
@ -577,9 +577,9 @@ class FastSentenceTransformer(FastModel):
|
|||
print(f"Pooling mode detected as {mode}, updating...")
|
||||
return mode
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print(
|
||||
f"Failed to detect pooling mode, not a sentence-transformers model. Using default pooling mode 'mean', this may or may not work."
|
||||
"Failed to detect pooling mode, not a sentence-transformers model. Using default pooling mode 'mean', this may or may not work."
|
||||
)
|
||||
return "mean"
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue