split venv_t5 into venv_t5_530 and venv_t5_550 for tiered transformers 5.x support
This commit is contained in:
parent
8f3554e574
commit
d0017ddba2
5 changed files with 123 additions and 5 deletions
|
|
@ -181,11 +181,8 @@ def _setup_log_capture(resp_queue: Any) -> None:
|
|||
|
||||
def _activate_transformers_version(model_name: str) -> None:
|
||||
"""Activate the correct transformers version BEFORE any ML imports."""
|
||||
# Ensure backend is on path for utils imports
|
||||
backend_path = str(Path(__file__).resolve().parent.parent.parent)
|
||||
if backend_path not in sys.path:
|
||||
sys.path.insert(0, backend_path)
|
||||
|
||||
from utils.transformers_version import activate_transformers_for_subprocess
|
||||
|
||||
activate_transformers_for_subprocess(model_name)
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ from utils.hardware import apply_gpu_ids
|
|||
|
||||
def _activate_transformers_version(model_name: str) -> None:
|
||||
"""Activate the correct transformers version BEFORE any ML imports."""
|
||||
# Ensure backend is on path for utils imports
|
||||
backend_path = str(Path(__file__).resolve().parent.parent.parent)
|
||||
if backend_path not in sys.path:
|
||||
sys.path.insert(0, backend_path)
|
||||
|
||||
|
|
|
|||
|
|
@ -1930,6 +1930,7 @@ def run_training_process(
|
|||
)
|
||||
return
|
||||
|
||||
<<<<<<< HEAD
|
||||
# ── 1a. Auto-enable trust_remote_code for NemotronH/Nano models ──
|
||||
# NemotronH has config parsing bugs in transformers that require
|
||||
# trust_remote_code=True as a workaround. Other transformers 5.x models
|
||||
|
|
@ -1941,6 +1942,22 @@ def run_training_process(
|
|||
if (
|
||||
any(sub in _lowered for sub in _NEMOTRON_TRUST_SUBSTRINGS)
|
||||
and (_lowered.startswith("unsloth/") or _lowered.startswith("nvidia/"))
|
||||
=======
|
||||
# ── 1a. Auto-enable trust_remote_code for unsloth/* transformers 5.x models ──
|
||||
# Some newer architectures (e.g. NemotronH) have config parsing bugs in
|
||||
# transformers that require trust_remote_code=True as a workaround.
|
||||
# Only auto-enable for unsloth/* prefixed models (trusted source).
|
||||
# Exclude Gemma 4 since it is a native transformers 5.5 model and
|
||||
# trust_remote_code=True would bypass the compiler (disabling fused CE).
|
||||
from utils.transformers_version import get_transformers_tier
|
||||
|
||||
_lowered = model_name.lower()
|
||||
_tier = get_transformers_tier(model_name)
|
||||
if (
|
||||
_tier != "default"
|
||||
and _lowered.startswith("unsloth/")
|
||||
and _tier != "550" # Gemma 4 is native t5.5 — trust_remote_code bypasses compiler
|
||||
>>>>>>> 970219a3 (split venv_t5 into venv_t5_530 and venv_t5_550 for tiered transformers 5.x support)
|
||||
and not config.get("trust_remote_code", False)
|
||||
):
|
||||
config["trust_remote_code"] = True
|
||||
|
|
|
|||
|
|
@ -2207,6 +2207,89 @@ if ($stackExit -ne 0) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
# ── Pre-install transformers 5.x into .venv_t5_530/ and .venv_t5_550/ ──
|
||||
# Models like GLM-4.7-Flash, Qwen3 MoE need transformers>=5.3.0.
|
||||
# Gemma 4 models need transformers>=5.5.0.
|
||||
# Pre-install into separate directories to avoid runtime pip overhead.
|
||||
# The training subprocess prepends the appropriate dir to sys.path.
|
||||
Write-Host ""
|
||||
|
||||
# Clean up legacy single .venv_t5 directory
|
||||
$VenvT5Legacy = Join-Path $env:USERPROFILE ".unsloth\studio\.venv_t5"
|
||||
if (Test-Path $VenvT5Legacy) { Remove-Item -Recurse -Force $VenvT5Legacy }
|
||||
|
||||
$prevEAP_t5 = $ErrorActionPreference
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
# --- .venv_t5_530 (transformers 5.3.0) ---
|
||||
substep "pre-installing transformers 5.3.0 for newer model support..."
|
||||
$VenvT5_530Dir = Join-Path $env:USERPROFILE ".unsloth\studio\.venv_t5_530"
|
||||
if (Test-Path $VenvT5_530Dir) { Remove-Item -Recurse -Force $VenvT5_530Dir }
|
||||
New-Item -ItemType Directory -Path $VenvT5_530Dir -Force | Out-Null
|
||||
foreach ($pkg in @("transformers==5.3.0", "huggingface_hub==1.8.0", "hf_xet==1.4.2")) {
|
||||
if ($script:UnslothVerbose) {
|
||||
Fast-Install --target $VenvT5_530Dir --no-deps $pkg
|
||||
$t5PkgExit = $LASTEXITCODE
|
||||
$output = ""
|
||||
} else {
|
||||
$output = Fast-Install --target $VenvT5_530Dir --no-deps $pkg | Out-String
|
||||
$t5PkgExit = $LASTEXITCODE
|
||||
}
|
||||
if ($t5PkgExit -ne 0) {
|
||||
Write-Host "[FAIL] Could not install $pkg into .venv_t5_530/" -ForegroundColor Red
|
||||
Write-Host $output -ForegroundColor Red
|
||||
$ErrorActionPreference = $prevEAP_t5
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
if ($script:UnslothVerbose) {
|
||||
Fast-Install --target $VenvT5_530Dir tiktoken
|
||||
$tiktokenInstallExit = $LASTEXITCODE
|
||||
$output = ""
|
||||
} else {
|
||||
$output = Fast-Install --target $VenvT5_530Dir tiktoken | Out-String
|
||||
$tiktokenInstallExit = $LASTEXITCODE
|
||||
}
|
||||
if ($tiktokenInstallExit -ne 0) {
|
||||
substep "Could not install tiktoken into .venv_t5_530/ -- Qwen tokenizers may fail" "Yellow"
|
||||
}
|
||||
step "transformers" "5.3.0 pre-installed"
|
||||
|
||||
# --- .venv_t5_550 (transformers 5.5.0) ---
|
||||
substep "pre-installing transformers 5.5.0 for Gemma 4 support..."
|
||||
$VenvT5_550Dir = Join-Path $env:USERPROFILE ".unsloth\studio\.venv_t5_550"
|
||||
if (Test-Path $VenvT5_550Dir) { Remove-Item -Recurse -Force $VenvT5_550Dir }
|
||||
New-Item -ItemType Directory -Path $VenvT5_550Dir -Force | Out-Null
|
||||
foreach ($pkg in @("transformers==5.5.0", "huggingface_hub==1.8.0", "hf_xet==1.4.2")) {
|
||||
if ($script:UnslothVerbose) {
|
||||
Fast-Install --target $VenvT5_550Dir --no-deps $pkg
|
||||
$t5PkgExit = $LASTEXITCODE
|
||||
$output = ""
|
||||
} else {
|
||||
$output = Fast-Install --target $VenvT5_550Dir --no-deps $pkg | Out-String
|
||||
$t5PkgExit = $LASTEXITCODE
|
||||
}
|
||||
if ($t5PkgExit -ne 0) {
|
||||
Write-Host "[FAIL] Could not install $pkg into .venv_t5_550/" -ForegroundColor Red
|
||||
Write-Host $output -ForegroundColor Red
|
||||
$ErrorActionPreference = $prevEAP_t5
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
if ($script:UnslothVerbose) {
|
||||
Fast-Install --target $VenvT5_550Dir tiktoken
|
||||
$tiktokenInstallExit = $LASTEXITCODE
|
||||
$output = ""
|
||||
} else {
|
||||
$output = Fast-Install --target $VenvT5_550Dir tiktoken | Out-String
|
||||
$tiktokenInstallExit = $LASTEXITCODE
|
||||
}
|
||||
if ($tiktokenInstallExit -ne 0) {
|
||||
substep "Could not install tiktoken into .venv_t5_550/ -- Qwen tokenizers may fail" "Yellow"
|
||||
}
|
||||
$ErrorActionPreference = $prevEAP_t5
|
||||
step "transformers" "5.5.0 pre-installed"
|
||||
|
||||
} else {
|
||||
step "python" "dependencies up to date"
|
||||
# Restore ErrorActionPreference (was lowered for pip/python section)
|
||||
|
|
|
|||
|
|
@ -599,6 +599,29 @@ fi
|
|||
|
||||
if [ "$_SKIP_PYTHON_DEPS" = false ]; then
|
||||
install_python_stack
|
||||
|
||||
# ── 6b. Pre-install transformers 5.x into .venv_t5_530/ and .venv_t5_550/ ──
|
||||
# Models like GLM-4.7-Flash, Qwen3 MoE need transformers>=5.3.0.
|
||||
# Gemma 4 models need transformers>=5.5.0.
|
||||
# Pre-install into separate directories to avoid runtime pip overhead.
|
||||
# The training subprocess prepends the appropriate dir to sys.path.
|
||||
|
||||
# Clean up legacy single .venv_t5 directory
|
||||
[ -d "$STUDIO_HOME/.venv_t5" ] && rm -rf "$STUDIO_HOME/.venv_t5"
|
||||
|
||||
mkdir -p "$VENV_T5_530_DIR"
|
||||
run_quiet "install transformers 5.3.0" fast_install --target "$VENV_T5_530_DIR" --no-deps "transformers==5.3.0"
|
||||
run_quiet "install huggingface_hub for t5_530" fast_install --target "$VENV_T5_530_DIR" --no-deps "huggingface_hub==1.8.0"
|
||||
run_quiet "install hf_xet for t5_530" fast_install --target "$VENV_T5_530_DIR" --no-deps "hf_xet==1.4.2"
|
||||
run_quiet "install tiktoken for t5_530" fast_install --target "$VENV_T5_530_DIR" "tiktoken"
|
||||
step "transformers" "5.3.0 pre-installed"
|
||||
|
||||
mkdir -p "$VENV_T5_550_DIR"
|
||||
run_quiet "install transformers 5.5.0" fast_install --target "$VENV_T5_550_DIR" --no-deps "transformers==5.5.0"
|
||||
run_quiet "install huggingface_hub for t5_550" fast_install --target "$VENV_T5_550_DIR" --no-deps "huggingface_hub==1.8.0"
|
||||
run_quiet "install hf_xet for t5_550" fast_install --target "$VENV_T5_550_DIR" --no-deps "hf_xet==1.4.2"
|
||||
run_quiet "install tiktoken for t5_550" fast_install --target "$VENV_T5_550_DIR" "tiktoken"
|
||||
step "transformers" "5.5.0 pre-installed"
|
||||
else
|
||||
step "python" "dependencies up to date"
|
||||
verbose_substep "python deps check: installed=$_PKG_NAME@${INSTALLED_VER:-unknown} latest=${LATEST_VER:-unknown}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue