diff --git a/install.ps1 b/install.ps1 index 215c8f6040..f1f16d818d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -681,13 +681,13 @@ shell.Run cmd, 0, False if ($SkipTorch) { # No-torch: install unsloth + unsloth-zoo with --no-deps, then # runtime deps (typer, safetensors, transformers, etc.) with --no-deps. - uv pip install --python $VenvPython --no-deps --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo + uv pip install --python $VenvPython --no-deps --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.16" unsloth-zoo $NoTorchReq = Find-NoTorchRuntimeFile if ($NoTorchReq) { uv pip install --python $VenvPython --no-deps -r $NoTorchReq } } else { - uv pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo + uv pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.16" unsloth-zoo } if ($StudioLocalInstall) { Write-Host "==> Overlaying local repo (editable)..." @@ -709,7 +709,7 @@ shell.Run cmd, 0, False if ($SkipTorch) { # No-torch: install unsloth + unsloth-zoo with --no-deps, then # runtime deps (typer, safetensors, transformers, etc.) with --no-deps. - uv pip install --python $VenvPython --no-deps --upgrade-package unsloth --upgrade-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo + uv pip install --python $VenvPython --no-deps --upgrade-package unsloth --upgrade-package unsloth-zoo "unsloth>=2026.3.16" unsloth-zoo $NoTorchReq = Find-NoTorchRuntimeFile if ($NoTorchReq) { uv pip install --python $VenvPython --no-deps -r $NoTorchReq @@ -719,7 +719,7 @@ shell.Run cmd, 0, False uv pip install --python $VenvPython -e $RepoRoot --no-deps } } elseif ($StudioLocalInstall) { - uv pip install --python $VenvPython --upgrade-package unsloth "unsloth>=2026.3.14" unsloth-zoo + uv pip install --python $VenvPython --upgrade-package unsloth "unsloth>=2026.3.16" unsloth-zoo Write-Host "==> Overlaying local repo (editable)..." uv pip install --python $VenvPython -e $RepoRoot --no-deps } else { @@ -729,7 +729,7 @@ shell.Run cmd, 0, False # Fallback: GPU detection failed to produce a URL -- let uv resolve torch Write-Host "==> Installing unsloth (this may take a few minutes)..." if ($StudioLocalInstall) { - uv pip install --python $VenvPython unsloth-zoo "unsloth>=2026.3.14" --torch-backend=auto + uv pip install --python $VenvPython unsloth-zoo "unsloth>=2026.3.16" --torch-backend=auto Write-Host "==> Overlaying local repo (editable)..." uv pip install --python $VenvPython -e $RepoRoot --no-deps } else { diff --git a/install.sh b/install.sh index 4c960a129e..b50256ea5a 100755 --- a/install.sh +++ b/install.sh @@ -968,7 +968,7 @@ if [ "$_MIGRATED" = true ]; then # to prevent transitive torch resolution. uv pip install --python "$_VENV_PY" --no-deps \ --reinstall-package unsloth --reinstall-package unsloth-zoo \ - "unsloth>=2026.3.14" unsloth-zoo + "unsloth>=2026.3.16" unsloth-zoo _NO_TORCH_RT="$(_find_no_torch_runtime)" if [ -n "$_NO_TORCH_RT" ]; then uv pip install --python "$_VENV_PY" --no-deps -r "$_NO_TORCH_RT" @@ -976,7 +976,7 @@ if [ "$_MIGRATED" = true ]; then else uv pip install --python "$_VENV_PY" \ --reinstall-package unsloth --reinstall-package unsloth-zoo \ - "unsloth>=2026.3.14" unsloth-zoo + "unsloth>=2026.3.16" unsloth-zoo fi if [ "$STUDIO_LOCAL_INSTALL" = true ]; then echo "==> Overlaying local repo (editable)..." @@ -998,7 +998,7 @@ elif [ -n "$TORCH_INDEX_URL" ]; then # runtime deps (typer, safetensors, transformers, etc.) with --no-deps. uv pip install --python "$_VENV_PY" --no-deps \ --upgrade-package unsloth --upgrade-package unsloth-zoo \ - "unsloth>=2026.3.14" unsloth-zoo + "unsloth>=2026.3.16" unsloth-zoo _NO_TORCH_RT="$(_find_no_torch_runtime)" if [ -n "$_NO_TORCH_RT" ]; then uv pip install --python "$_VENV_PY" --no-deps -r "$_NO_TORCH_RT" @@ -1009,7 +1009,7 @@ elif [ -n "$TORCH_INDEX_URL" ]; then fi elif [ "$STUDIO_LOCAL_INSTALL" = true ]; then uv pip install --python "$_VENV_PY" \ - --upgrade-package unsloth "unsloth>=2026.3.14" unsloth-zoo + --upgrade-package unsloth "unsloth>=2026.3.16" unsloth-zoo echo "==> Overlaying local repo (editable)..." uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps else @@ -1020,7 +1020,7 @@ else # Fallback: GPU detection failed to produce a URL -- let uv resolve torch echo "==> Installing unsloth (this may take a few minutes)..." if [ "$STUDIO_LOCAL_INSTALL" = true ]; then - uv pip install --python "$_VENV_PY" unsloth-zoo "unsloth>=2026.3.14" --torch-backend=auto + uv pip install --python "$_VENV_PY" unsloth-zoo "unsloth>=2026.3.16" --torch-backend=auto echo "==> Overlaying local repo (editable)..." uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps else diff --git a/pyproject.toml b/pyproject.toml index e2173d6811..97096dc9e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,29 @@ classifiers = [ "Topic :: Scientific/Engineering :: Artificial Intelligence", ] dependencies = [ + "unsloth_zoo>=2026.3.6", + "wheel>=0.42.0", + "packaging", + "torch>=2.4.0,<2.11.0", + "torchvision", + "numpy", + "tqdm", + "psutil", + "tyro", + "protobuf", + "xformers>=0.0.27.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "triton>=3.0.0 ; ('linux' in sys_platform)", + "triton-windows ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", + "sentencepiece>=0.2.0", + "datasets>=3.4.1,!=4.0.*,!=4.1.0,<4.4.0", + "accelerate>=0.34.1", + "peft>=0.18.0,!=0.11.0", + "huggingface_hub>=0.34.0", + "hf_transfer", + "diffusers", + "transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,!=4.57.4,!=4.57.5,!=5.0.0,!=5.1.0,<=5.3.0", + "trl>=0.18.2,!=0.19.0,<=0.24.0", "typer", "pydantic", "pyyaml", @@ -61,14 +84,11 @@ studio = [ exclude = ["images*", "tests*", "kernels/moe*"] [project.optional-dependencies] -triton = [ - "triton>=3.0.0 ; ('linux' in sys_platform)", - "triton-windows ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] - -huggingfacenotorch = [ +huggingface = [ + "unsloth_zoo>=2026.3.6", "wheel>=0.42.0", "packaging", + "torchvision", "numpy", "tqdm", "psutil", @@ -83,257 +103,132 @@ huggingfacenotorch = [ "diffusers", "transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,!=4.57.4,!=4.57.5,!=5.0.0,!=5.1.0,<=5.3.0", "trl>=0.18.2,!=0.19.0,<=0.24.0", - "sentence-transformers", -] -huggingface = [ - "unsloth[huggingfacenotorch]", - "unsloth_zoo>=2026.3.6", - "torchvision", - "unsloth[triton]", -] -windows = [ - "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0 ; (sys_platform == 'win32')", - "xformers>=0.0.22.post7 ; (sys_platform == 'win32')", + "typer", + "pydantic", + "pyyaml", + "nest-asyncio", ] base = [ "unsloth[huggingface]", ] cu118only = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.22.post7%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.22.post7%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.22.post7%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.22.post7 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121only = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.22.post7 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch211 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.23 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch211 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.23 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch212 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23.post1%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23.post1%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.23.post1%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.23.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch212 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23.post1-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23.post1-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.23.post1-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.23.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch220 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.24%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.24%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.24%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.24 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch220 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.24-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.24-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.24-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", + "xformers==0.0.24 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch230 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27%2Bcu118-cp312-cp312-manylinux2014_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.27 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch230 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.27-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.27-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.27-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.27-cp312-cp312-manylinux2014_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.27 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch240 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27.post2%2Bcu118-cp39-cp39-manylinux2014_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27.post2%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27.post2%2Bcu118-cp311-cp311-manylinux2014_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.27.post2%2Bcu118-cp312-cp312-manylinux2014_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.27.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch240 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post1-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post1-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post1-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post1-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", -] -cu124onlytorch240 = [ - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post1-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.27.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch250 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.28.post2-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.28.post2-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.28.post2-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.28.post2-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.28.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch250 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post2-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post2-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post2-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.28.post2-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.28.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu124onlytorch250 = [ - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.28.post2-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.28.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch251 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post1-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post1-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post1-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post1-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.29.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu121onlytorch251 = [ - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.29.post1-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.29.post1-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.29.post1-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu121/xformers-0.0.29.post1-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.29.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu124onlytorch251 = [ - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post1-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.29.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch260 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post3-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post3-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.29.post3-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", + "xformers==0.0.29.post3 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu124onlytorch260 = [ - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu124/xformers-0.0.29.post3-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.29.post3 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch260 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.29.post3-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.29.post3 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch270 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.30-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.30 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch270 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.30-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.30 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch270 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp39-cp39-manylinux_2_28_x86_64.whl ; python_version=='3.9' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp310-cp310-manylinux_2_28_x86_64.whl ; python_version=='3.10' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp311-cp311-manylinux_2_28_x86_64.whl ; python_version=='3.11' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp312-cp312-manylinux_2_28_x86_64.whl ; python_version=='3.12' and ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp39-cp39-win_amd64.whl ; python_version=='3.9' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp310-cp310-win_amd64.whl ; python_version=='3.10' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp311-cp311-win_amd64.whl ; python_version=='3.11' and (sys_platform == 'win32')", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.30-cp312-cp312-win_amd64.whl ; python_version=='3.12' and (sys_platform == 'win32')", + "xformers==0.0.30 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch271 = [ - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.31.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu118/xformers-0.0.31.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.31.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch271 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.31.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.31.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.31.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch271 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.31.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.31.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.31.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118onlytorch280 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.32.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.32.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.32.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch280 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.32.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.32.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.32.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch280 = [ - "xformers @ https://download.pytorch.org/whl/cu129/xformers-0.0.32.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu129/xformers-0.0.32.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.32.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu130onlytorch280 = [ ] cu126onlytorch290 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.33.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.33.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch290 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.33.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.33.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu130onlytorch290 = [ - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.33.post1-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.33.post1-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post1 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch291 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.33.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.33.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch291 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.33.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.33.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu130onlytorch291 = [ - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.33.post2-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.33.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.33.post2 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu126onlytorch2100 = [ - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.34 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu128onlytorch2100 = [ - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.34 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu130onlytorch2100 = [ - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform)", - "xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')", + "xformers==0.0.34 ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", ] cu118 = [ "unsloth[huggingface]", @@ -347,22 +242,22 @@ cu121 = [ ] cu118-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu118onlytorch211]", ] cu121-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch211]", ] cu118-torch212 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu118onlytorch212]", ] cu121-torch212 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch212]", ] cu118-torch220 = [ @@ -432,17 +327,17 @@ cu124-torch251 = [ ] cu118-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu118onlytorch260]", ] cu124-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu124onlytorch260]", ] cu126-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu126onlytorch260]", ] cu118-torch270 = [ @@ -552,16 +447,19 @@ conda = [ ] colab-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch211]", ] +flashattention = [ + "packaging ; ('linux' in sys_platform)", + "ninja ; ('linux' in sys_platform)", + "flash-attn>=2.6.3 ; ('linux' in sys_platform)", +] colab-ampere-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch211]", - "packaging", - "ninja", - "flash-attn>=2.6.3 ; ('linux' in sys_platform)", + "unsloth[flashattention]", ] colab-torch220 = [ "unsloth[huggingface]", @@ -572,9 +470,7 @@ colab-ampere-torch220 = [ "unsloth[huggingface]", "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch220]", - "packaging", - "ninja", - "flash-attn>=2.6.3 ; ('linux' in sys_platform)", + "unsloth[flashattention]", ] colab-new = [ "unsloth_zoo>=2026.3.6", @@ -592,24 +488,22 @@ colab-new = [ "hf_transfer", "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[triton]", - "sentence-transformers", + "typer", + "pydantic", + "pyyaml", + "nest-asyncio", ] colab-no-deps = [ "accelerate>=0.34.1", "trl>=0.18.2,!=0.19.0,<=0.24.0", "peft>=0.18.0", - "xformers ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", + "xformers<0.0.27", "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "protobuf", ] colab = [ "unsloth[cu121]", ] -flashattention = [ - "packaging ; ('linux' in sys_platform)", - "ninja ; ('linux' in sys_platform)", - "flash-attn>=2.6.3 ; ('linux' in sys_platform)", -] colab-ampere = [ "unsloth[colab-ampere-torch220]", "unsloth[flashattention]", @@ -628,13 +522,13 @@ cu121-ampere = [ ] cu118-ampere-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu118onlytorch211]", "unsloth[flashattention]", ] cu121-ampere-torch211 = [ "unsloth[huggingface]", - "bitsandbytes==0.45.5", + "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu121onlytorch211]", "unsloth[flashattention]", ] @@ -718,19 +612,19 @@ cu124-ampere-torch251 = [ ] cu118-ampere-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu118onlytorch260]", "unsloth[flashattention]", ] cu124-ampere-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu124onlytorch260]", "unsloth[flashattention]", ] cu126-ampere-torch260 = [ "unsloth[huggingface]", - "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", + "bitsandbytes>=0.45.1", "unsloth[cu126onlytorch260]", "unsloth[flashattention]", ] @@ -792,7 +686,6 @@ cu130-ampere-torch280 = [ "unsloth[huggingface]", "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu130onlytorch280]", - "unsloth[flashattention]", ] cu126-ampere-torch290 = [ "unsloth[huggingface]", @@ -839,347 +732,8 @@ cu130-ampere-torch2100 = [ "bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0", "unsloth[cu130onlytorch2100]", ] -flashattentiontorch260abiFALSEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -flashattentiontorch260abiTRUEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -flashattentiontorch250abiFALSEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -flashattentiontorch250abiTRUEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiTRUE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiTRUE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiTRUE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiTRUE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiTRUE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -flashattentiontorch240abiFALSEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -flashattentiontorch240abiTRUEcu12x = [ - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiTRUE-cp39-cp39-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.9'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiTRUE-cp310-cp310-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.10'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiTRUE-cp311-cp311-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.11'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiTRUE-cp312-cp312-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.12'", - "flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiTRUE-cp313-cp313-linux_x86_64.whl ; ('linux' in sys_platform) and python_version == '3.13'", -] -intelgputorch260 = [ - "unsloth_zoo[intelgpu]", - "unsloth[huggingfacenotorch]", - - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.2.0-cp39-cp39-linux_x86_64.whl#sha256=147607f190a7d7aa24ba454def5977fbbfec792fdae18e4ed278cfec29b69271 ; ('linux' in sys_platform) and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.2.0-cp310-cp310-linux_x86_64.whl#sha256=23aa423fa1542afc34f67eb3ba8ef20060f6d1b3a4697eaeab22b11c92b30f2b ; ('linux' in sys_platform) and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.2.0-cp311-cp311-linux_x86_64.whl#sha256=bcfa995229bbfd9ffd8d6c8d9f6428d393e876fa6e23ee3c20e3c0d73ca75ca5 ; ('linux' in sys_platform) and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.2.0-cp312-cp312-linux_x86_64.whl#sha256=bd340903d03470708df3442438acb8b7e08087ab9e61fbe349b2872bf9257ab0 ; ('linux' in sys_platform) and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.2.0-cp313-cp313-linux_x86_64.whl#sha256=814dccc8a07159e6eca74bed70091bc8fea2d9dd87b0d91845f9f38cde62f01c ; ('linux' in sys_platform) and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torch @ https://download.pytorch.org/whl/xpu/torch-2.6.0%2Bxpu-cp39-cp39-linux_x86_64.whl#sha256=6a8adf6dc4c089406e8b3a7e58ab57a463bddf9b07130d2576e76eced43e92af ; ('linux' in sys_platform) and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.6.0%2Bxpu-cp310-cp310-linux_x86_64.whl#sha256=ff4561cbf07c83bbccaa0f6e9bb0e6dcf721bacd53c9c43c4eb0e7331b4792f9 ; ('linux' in sys_platform) and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.6.0%2Bxpu-cp311-cp311-linux_x86_64.whl#sha256=12005f66b810ddd3ab93f86c4522bcfdd412cbd27fc9d189b661ff7509bc5e8a ; ('linux' in sys_platform) and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.6.0%2Bxpu-cp312-cp312-linux_x86_64.whl#sha256=c4c5c67625cdacf35765c2b94e61fe166e3c3f4a14521b1212a59ad1b3eb0f2e ; ('linux' in sys_platform) and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.6.0%2Bxpu-cp313-cp313-linux_x86_64.whl#sha256=e6864f7a60a5ecc43d5d38f59a16e5dd132384f73dfd3a697f74944026038f7b ; ('linux' in sys_platform) and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -intel-gpu-torch260 = [ - "unsloth[intelgputorch260]" -] -intelgputorch270 = [ - "unsloth_zoo[intelgpu]", - "unsloth[huggingfacenotorch]", - - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=749a7098492c6a27b356c97149a4a62973b953eae60bc1b6259260974f344913 ; ('linux' in sys_platform) and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=44362e80abd752471a08341093321955b066daa2cfb4810e73b8e3b240850f93 ; ('linux' in sys_platform) and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=faa6b8c945a837a080f641bc8ccc77a98fa66980dcd7e62e715fd853737343fd ; ('linux' in sys_platform) and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=40f6fb65b345dc9a61813abe7ac9a585f2c9808f414d140cc2a5f11f53ee063c ; ('linux' in sys_platform) and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=b22b4c02ec71b4bfc862ae3cdfd2871dc0b05d2b1802f5db2196e0f897d581e9 ; ('linux' in sys_platform) and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp39-cp39-win_amd64.whl#sha256=d4b738d7fa5100c1bd766f91614962828a4810eb57b4df92cd5214a83505a752 ; sys_platform == 'win32' and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp310-cp310-win_amd64.whl#sha256=143fe8a64d807bcdb7d81bbc062816add325570aa160448454ab6ded4a0a17a1 ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp311-cp311-win_amd64.whl#sha256=a8025459ff325d6e3532eb5cf72519db1b178155e7d60aff6c56beb5968fc758 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp312-cp312-win_amd64.whl#sha256=0dd07e6d5b872e42e48f5ee140e609d4554ca3cc509d5bf509ac232267cf358e ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.3.0-cp313-cp313-win_amd64.whl#sha256=a936a18182d8e065a9933afc9a3ebbffadd38604969f87c493831214539fc027 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp39-cp39-linux_x86_64.whl#sha256=f8ee75e50fcbb37ed5b498299ca2264da99ab278a93fae2358e921e4a6e28273 ; ('linux' in sys_platform) and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp310-cp310-linux_x86_64.whl#sha256=d6fdc342961d98fdcd9d03dfd491a3208bb5f7fbb435841f8f72ce9fdcd2d026 ; ('linux' in sys_platform) and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp311-cp311-linux_x86_64.whl#sha256=74d07f9357df5cf2bf223ad3c84de16346bfaa0504f988fdd5590d3e177e5e86 ; ('linux' in sys_platform) and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp312-cp312-linux_x86_64.whl#sha256=c806d44aa2ca5d225629f6fbc6c994d5deaac2d2cde449195bc8e3522ddd219a ; ('linux' in sys_platform) and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp313-cp313-linux_x86_64.whl#sha256=25d8277b7f01d42e2e014ccbab57a2692b6ec4eff8dcf894eda1b297407cf97a ; ('linux' in sys_platform) and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp39-cp39-win_amd64.whl#sha256=046e85125266ae69c1a0d083e6c092f947ab4b6b41532c16bafe40dbced845df ; sys_platform == 'win32' and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=9ebaeffb82b0b3e39b6030927d3ebe0eb62a0e9045a3b2d7b0a9e7b15222c0db ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=356ba66cee127e7e2c942880bd50e03768306a4ea08d358a0f29c6eebfc4bc81 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=94739e665d9b4d5cd7af5f517cb6103f6f9fb421c095184609653a24524040f5 ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.7.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=31df3cb674918e89bc8c532baa331dc84f4430e1f9c0ec379232db44cba78355 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -intel-gpu-torch270 = [ - "unsloth[intelgputorch270]" -] -intelgputorch280 = [ - "unsloth_zoo[intelgpu]", - "unsloth[huggingfacenotorch]", - - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=ac4d8e33986b1c3c5e48151640539272b2187e83016985853111b46fb82c3c94 ; 'linux' in sys_platform and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=999fef4c1f711092b9d3086525920545df490de476ecebe899ffc777019ae17f ; 'linux' in sys_platform and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=57b09c8c492985ff6a27cd3a22b08e8f7b96b407bd8030967b6efbb9f63b80cf ; 'linux' in sys_platform and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=df4bb3282bac9a3b90231700077110d8680b338416de03c2b7c6133c9b602649 ; 'linux' in sys_platform and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=60da63c99ca827bdcb0df28e0298bf7d066dc607454c6d6176783cb4e79d838b ; 'linux' in sys_platform and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp39-cp39-win_amd64.whl#sha256=64aea8de349f3e2e0ebf4c24b011a8122531fdffda5776edaef45829cc241cf8 ; sys_platform == 'win32' and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp310-cp310-win_amd64.whl#sha256=ae573d255b257fdbed319a3440dc9d0a721e31160ab7f6eba1b2226e6a409a1d ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp311-cp311-win_amd64.whl#sha256=8e0ea4558e5776d8ddab0264310be9b26aee5641bcac0da023537556d4317b86 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp312-cp312-win_amd64.whl#sha256=4090dde07a4fffc34aaf855701a9db28e9fccb57b368ade520f1a0f8e811c878 ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.4.0-cp313-cp313-win_amd64.whl#sha256=a33d0888f3c8df028a2d028842715837d0049524d6c06b9bb11869890a13601a ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp39-cp39-linux_x86_64.whl ; 'linux' in sys_platform and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp310-cp310-linux_x86_64.whl ; 'linux' in sys_platform and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp311-cp311-linux_x86_64.whl ; 'linux' in sys_platform and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp312-cp312-linux_x86_64.whl ; 'linux' in sys_platform and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp313-cp313-linux_x86_64.whl ; 'linux' in sys_platform and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp39-cp39-win_amd64.whl#sha256=f2f401276892428e4875cf1d8717c5cbab704b16fc594ccf23795e7b16549a99 ; sys_platform == 'win32' and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=125c60cd59d51b39581a7e9afcd4679bc3a6b8c1f9440b1bb502a23fdd60571e ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=47f1a57258cd460e80b38b2ed6744e31587ab77a96b4215bf59546cb4bab5cc0 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=0937d8943c145a83d9bafc6f80ef28971167817f9eda26066d33f72caf8a6646 ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.8.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=e034aab1d71760dc80a731531be43673ffe15e99033b82d24e40d2e6d41bd8bf ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp39-cp39-manylinux_2_28_x86_64.whl#sha256=6e981c192045fc249c008441179ff237bb00174d818b875b0475730b63f0eaca ; 'linux' in sys_platform and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp310-cp310-manylinux_2_28_x86_64.whl#sha256=e5ba4805969277175ebfd59cc717093528cc6e3ada89ac2725fc7a3c1fee6169 ; 'linux' in sys_platform and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=74c39c144104416bc4c5ad8c26ab0c169dc5cc6be58059e01bc3665dd0ef676f ; 'linux' in sys_platform and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp312-cp312-manylinux_2_28_x86_64.whl#sha256=0acec355b80c3899841184084f365df336c508602812e34a44007b8b60d53af4 ; 'linux' in sys_platform and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp313-cp313-manylinux_2_28_x86_64.whl#sha256=e2109ae773dad27b98ca17681044b4f876563c37f2382b75de3a371399edcff8 ; 'linux' in sys_platform and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp39-cp39-win_amd64.whl#sha256=5f7904e7048d414379bc8c1167260f1e84204f105db2d0a2f9c89e87ce1cf205 ; sys_platform == 'win32' and python_version == '3.9' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=005fca5e658ca8e37adb63c1a021c84f5e56dfa6cf0d601d89cfe40b9473f79f ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=c6d030f5361461550c0ff1339b5bca8585fc1e84fda2e64b6184e65a581e4f98 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=91aafd61864cdce27461cbec13ddbf28c1bc6494265a1e4b80131c64a3b7d18f ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.23.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=71dc4a6421742ed1e7f585b04a100ad53615c341fbccfbc255aefb38ea9091da ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -intel-gpu-torch280 = [ - "unsloth[intelgputorch280]" -] -intelgputorch290 = [ - "unsloth_zoo[intelgpu]", - "unsloth[huggingfacenotorch]", - - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=c169a1de14c19673b17c751290d467fa282fc90fa5da4314b2e5cdab1f553146 ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=013d9dd5d6479bd22983161f462e61c8dbe1d82e6730624a7a8d5945507eaa61 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=afc8cabfbf7ed51fd278d1e0f88d6afc157b0201bad4b99d681e4d542f9e66d4 ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=0d24c1716088f2764d0d24c64227732195b6a42706c3c5fc89eeb4904bfa0818 ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp310-cp310-win_amd64.whl#sha256=c83ab007311d9cfb6e809ee5a4587d99a9eef4be720b90da4f1aaa68b45139a0 ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp311-cp311-win_amd64.whl#sha256=debf75348da8e8c7166b4d4a9b91d1508bb8d6581e339f79f7604b2e6746bacd ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp312-cp312-win_amd64.whl#sha256=97337a47425f1963a723475bd61037460e84ba01db4f87a1d662c3718ff6c47e ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp313-cp313-win_amd64.whl#sha256=2caf8138695f6abb023ecd02031a2611ba1bf8fff2f19802567cb2fadefe9e87 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp310-cp310-linux_x86_64.whl#sha256=5afbe860ce991825a36b75706a523601087e414b77598ef0d9d3d565741c277d ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp311-cp311-linux_x86_64.whl#sha256=607fe419c32d6e8e0556f745742e7cff1d0babce51f54be890e0c1422359c442 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp312-cp312-linux_x86_64.whl#sha256=376bae584d89980b8e59934d248c38d5fa3b7d4687a4df1a19f4bc1d23dcc8c1 ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp313-cp313-linux_x86_64.whl#sha256=98d6a06dd7fb185874367b18bd609f05f16fdce4142a5980ca94461949965cd2 ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=47cc68f631f65bd9c84924d052cd04dec7531023caa85e80345e9c94611c887d ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=d56c44ab4818aba57e5c7b628f422d014e0d507427170a771c5be85e308b0bc6 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=18cad93aaff76a01ce73aef6935ece7cfc03344b905592ec731446c44d44592b ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.9.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=579929cdc10a76800ead41289cac191ea36d1b16f5f501d3fc25607d4375cd83 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp310-cp310-manylinux_2_28_x86_64.whl#sha256=cbfae2b79b7549fd368c2462fc8e94f8f26cc450782ee72138e908077c09a519 ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=044fa36ef4b6b43edcd490b75c853fa4b3eb033c2bded29f8fbcf27734713c67 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp312-cp312-manylinux_2_28_x86_64.whl#sha256=4b91e4bec1d740a6211f02578a79888550b73f3a4e1383035f8f6d72f587212c ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp313-cp313-manylinux_2_28_x86_64.whl#sha256=88239e73ca37254bec84f29cd5887e10ff712de7edbbda3fbb3609cd6190d99e ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=19c7da8ca767d593e13a88a12bb08d06e34a673f6f26c2f9c191d60e81c02953 ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=9bb0d1421c544ac8e2eca5b47daacaf54706dc9139c003aa5e77ee5f355c5931 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=6a5194bc736089606342d48a3f6822829b167617e9495d91d753dd1bd46fda18 ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.24.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=da47a3ce2bb7f0301a31124668b5908f9b9e92d6241443de15a310ef9632fd83 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -intel-gpu-torch290 = [ - "unsloth[intelgputorch290]" -] -intelgputorch210 = [ - "unsloth_zoo[intelgpu]", - "unsloth[huggingfacenotorch]", - - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=c169a1de14c19673b17c751290d467fa282fc90fa5da4314b2e5cdab1f553146 ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=013d9dd5d6479bd22983161f462e61c8dbe1d82e6730624a7a8d5945507eaa61 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=afc8cabfbf7ed51fd278d1e0f88d6afc157b0201bad4b99d681e4d542f9e66d4 ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl#sha256=0d24c1716088f2764d0d24c64227732195b6a42706c3c5fc89eeb4904bfa0818 ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp310-cp310-win_amd64.whl#sha256=c83ab007311d9cfb6e809ee5a4587d99a9eef4be720b90da4f1aaa68b45139a0 ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp311-cp311-win_amd64.whl#sha256=debf75348da8e8c7166b4d4a9b91d1508bb8d6581e339f79f7604b2e6746bacd ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp312-cp312-win_amd64.whl#sha256=97337a47425f1963a723475bd61037460e84ba01db4f87a1d662c3718ff6c47e ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "pytorch_triton_xpu @ https://download.pytorch.org/whl/pytorch_triton_xpu-3.5.0-cp313-cp313-win_amd64.whl#sha256=2caf8138695f6abb023ecd02031a2611ba1bf8fff2f19802567cb2fadefe9e87 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp310-cp310-linux_x86_64.whl#sha256=abb1d1ec1ac672bac0ff35420c965f2df0c636ef9d94e2a830e34578489d0a57 ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp311-cp311-linux_x86_64.whl#sha256=71ad2f82da0f41eaec159f39fc85854e27c2391efa91b373e550648a6f4aaad3 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp312-cp312-linux_x86_64.whl#sha256=b473571d478912f92881cc13f15fa18f8463fb0fb8a068c96ed47a7d45a4da0a ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp313-cp313-linux_x86_64.whl#sha256=3bc64a746ff25a93de140902c60c9e819d7413f5cea1e88d80999c27a5901e9c ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=ce50691ab3fb6301d9b7bb8b3834cf5fa7152a2b5f91fd24c5efdc601a25b780 ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=cb9d37f21cb9fb7df67d62863f021c3144e8d8832b9ea8e8523ac308bc620ea1 ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=3ad605be4728b6d3a28a44d07dd794b1a9e45551b0057815bf25eb2a6d6a56a7 ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torch @ https://download.pytorch.org/whl/xpu/torch-2.10.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=2b4b56dd6c792aef82006904fa888692e3782e4ae5da27526801bad4898f05a5 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "bitsandbytes @ https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp310-cp310-manylinux_2_28_x86_64.whl#sha256=7e1e7b170fcf7161c8499b67156c5a05462243626dc0974010791a0bab4378d3 ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=bd6add201bd7628af70437292e1447abb368e0b5f4ff9abd334ae435efd44792 ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp312-cp312-manylinux_2_28_x86_64.whl#sha256=6ad2543496bc29e59d3dd614a94d09aa9870318aedb66045344fffddfedd2cf8 ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp313-cp313-manylinux_2_28_x86_64.whl#sha256=80269f37865fcd8b57f20e4786efae2200bfa2b2727926c3c7acc82f0e7d3548 ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp310-cp310-win_amd64.whl#sha256=6b9485ba85dcba4d196d6134d9c3332fb228fb2556416bf0450a64e8a472fcba ; sys_platform == 'win32' and python_version == '3.10' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp311-cp311-win_amd64.whl#sha256=36cbaedf10f6412af5c89afd9aeea474e6a56a0050348ada8fabe1ecaf6b879e ; sys_platform == 'win32' and python_version == '3.11' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp312-cp312-win_amd64.whl#sha256=738357d97468d75fe3d510ac37e65130f2787f81d9bbc1518898f7396dc3403f ; sys_platform == 'win32' and python_version == '3.12' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", - "torchvision @ https://download.pytorch.org/whl/xpu/torchvision-0.25.0%2Bxpu-cp313-cp313-win_amd64.whl#sha256=1c4b44b36a557f7381e3076fb8843366742238648441d607c8d049c6da0f8886 ; sys_platform == 'win32' and python_version == '3.13' and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -intel-gpu-torch210 = [ - "unsloth[intelgputorch210]" -] -intel = [ - "unsloth[intelgputorch280]", -] -amd = [ - "unsloth[huggingfacenotorch]", - "bitsandbytes>=0.49.1 ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64' or platform_machine == 'aarch64')", - "bitsandbytes>=0.49.1 ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')", -] -rocm702-torch280 = [ - "unsloth[amd]", - - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/triton-3.4.0%2Brocm7.0.2.gitf9e5bf54-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/triton-3.4.0%2Brocm7.0.2.gitf9e5bf54-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/triton-3.4.0%2Brocm7.0.2.gitf9e5bf54-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torch-2.8.0%2Brocm7.0.2.lw.git245bf6ed-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torch-2.8.0%2Brocm7.0.2.lw.git245bf6ed-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torch-2.8.0%2Brocm7.0.2.lw.git245bf6ed-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchvision-0.23.0%2Brocm7.0.2.git824e8c87-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchvision-0.23.0%2Brocm7.0.2.git824e8c87-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchvision-0.23.0%2Brocm7.0.2.git824e8c87-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", -] -rocm72-torch291 = [ - "unsloth[amd]", - - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torch-2.9.1%2Brocmsdk20260116-cp312-cp312-win_amd64.whl ; sys_platform == 'win32' and python_version == '3.12'", - - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torchvision-0.24.1%2Brocmsdk20260116-cp312-cp312-win_amd64.whl ; sys_platform == 'win32' and python_version == '3.12'", -] -rocm711-torch291 = [ - "unsloth[amd]", - - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.5.1%2Brocm7.1.1.gita272dfa8-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.5.1%2Brocm7.1.1.gita272dfa8-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.5.1%2Brocm7.1.1.gita272dfa8-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.5.1%2Brocm7.1.1.gita272dfa8-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.9.1%2Brocm7.1.1.lw.git351ff442-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.9.1%2Brocm7.1.1.lw.git351ff442-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.9.1%2Brocm7.1.1.lw.git351ff442-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.9.1%2Brocm7.1.1.lw.git351ff442-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.24.0%2Brocm7.1.1.gitb919bd0c-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.24.0%2Brocm7.1.1.gitb919bd0c-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.24.0%2Brocm7.1.1.gitb919bd0c-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.24.0%2Brocm7.1.1.gitb919bd0c-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", -] -rocm72-torch2100 = [ - "unsloth[amd]", - - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.6.0%2Brocm7.2.0.gitba5c1517-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.6.0%2Brocm7.2.0.gitba5c1517-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.6.0%2Brocm7.2.0.gitba5c1517-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.6.0%2Brocm7.2.0.gitba5c1517-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.10.0%2Brocm7.2.0.lw.gitb6ee5fde-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.10.0%2Brocm7.2.0.lw.gitb6ee5fde-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.10.0%2Brocm7.2.0.lw.gitb6ee5fde-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.10.0%2Brocm7.2.0.lw.gitb6ee5fde-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.25.0%2Brocm7.2.0.git82df5f59-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.25.0%2Brocm7.2.0.git82df5f59-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.25.0%2Brocm7.2.0.git82df5f59-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.25.0%2Brocm7.2.0.git82df5f59-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", -] -rocm711-torch2100 = [ - "unsloth[amd]", - - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.6.0%2Brocm7.1.1.gitba5c1517-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.6.0%2Brocm7.1.1.gitba5c1517-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.6.0%2Brocm7.1.1.gitba5c1517-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/triton-3.6.0%2Brocm7.1.1.gitba5c1517-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.10.0%2Brocm7.1.1.lw.gitd9556b05-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.10.0%2Brocm7.1.1.lw.gitd9556b05-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.10.0%2Brocm7.1.1.lw.gitd9556b05-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torch-2.10.0%2Brocm7.1.1.lw.gitd9556b05-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", - - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.25.0%2Brocm7.1.1.git82df5f59-cp310-cp310-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.10' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.25.0%2Brocm7.1.1.git82df5f59-cp311-cp311-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.11' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.25.0%2Brocm7.1.1.git82df5f59-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.12' and platform_machine == 'x86_64'", - "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.1.1/torchvision-0.25.0%2Brocm7.1.1.git82df5f59-cp313-cp313-linux_x86_64.whl ; platform_system == 'Linux' and python_version == '3.13' and platform_machine == 'x86_64'", -] [project.urls] homepage = "https://unsloth.ai" documentation = "https://unsloth.ai/docs" repository = "https://github.com/unslothai/unsloth" - -[tool.ruff] -target-version = "py311" -force-exclude = true -extend-exclude = [ - "*chat_templates.py", - "*ollama_template_mappers.py", - "*_auto_install.py", - "*mapper.py", -] - -[tool.ruff.lint] -select = ["E9", "F63", "F7", "F82"] -ignore = [ - "E402", - "E722", - "F403", - "F405", - "F811", - "F821", - "F841", - "F401", - "E731", - "E741", - "F601", - "E712", -] - -[tool.ruff.format] diff --git a/studio/backend/colab.py b/studio/backend/colab.py index efd0e10bdb..ab2b656627 100644 --- a/studio/backend/colab.py +++ b/studio/backend/colab.py @@ -82,7 +82,6 @@ def start(port: int = 8888): from colab import start start() """ - import sys logger.info("🦥 Starting Unsloth Studio...") diff --git a/studio/backend/core/data_recipe/jobs/worker.py b/studio/backend/core/data_recipe/jobs/worker.py index 63e38bd18d..47af7be3ea 100644 --- a/studio/backend/core/data_recipe/jobs/worker.py +++ b/studio/backend/core/data_recipe/jobs/worker.py @@ -4,8 +4,6 @@ from __future__ import annotations import json -import structlog -import loggers import logging import re import shutil diff --git a/studio/backend/core/data_recipe/local_callable_validators.py b/studio/backend/core/data_recipe/local_callable_validators.py index c32b2fccaf..53eee3b584 100644 --- a/studio/backend/core/data_recipe/local_callable_validators.py +++ b/studio/backend/core/data_recipe/local_callable_validators.py @@ -5,7 +5,6 @@ from __future__ import annotations import json import os -import structlog import subprocess from copy import deepcopy from dataclasses import dataclass diff --git a/studio/backend/core/export/export.py b/studio/backend/core/export/export.py index 966e045b13..f439556d80 100644 --- a/studio/backend/core/export/export.py +++ b/studio/backend/core/export/export.py @@ -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__) diff --git a/studio/backend/core/export/orchestrator.py b/studio/backend/core/export/orchestrator.py index a9fbe659b3..eb6be0ca97 100644 --- a/studio/backend/core/export/orchestrator.py +++ b/studio/backend/core/export/orchestrator.py @@ -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 diff --git a/studio/backend/core/export/worker.py b/studio/backend/core/export/worker.py index 6af6ff1193..af621b0c66 100644 --- a/studio/backend/core/export/worker.py +++ b/studio/backend/core/export/worker.py @@ -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 diff --git a/studio/backend/core/inference/audio_codecs.py b/studio/backend/core/inference/audio_codecs.py index bcf3ec2937..613cdb1d44 100644 --- a/studio/backend/core/inference/audio_codecs.py +++ b/studio/backend/core/inference/audio_codecs.py @@ -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 diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.py index 1a265690ff..6051090df3 100644 --- a/studio/backend/core/inference/inference.py +++ b/studio/backend/core/inference/inference.py @@ -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}") diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 05e038dbb7..fb5de094d5 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -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 diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.py index 6ff7fd2cbf..96f09aefdc 100644 --- a/studio/backend/core/inference/orchestrator.py +++ b/studio/backend/core/inference/orchestrator.py @@ -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__) diff --git a/studio/backend/core/inference/worker.py b/studio/backend/core/inference/worker.py index afe0ecc458..edcf809d84 100644 --- a/studio/backend/core/inference/worker.py +++ b/studio/backend/core/inference/worker.py @@ -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 diff --git a/studio/backend/core/training/trainer.py b/studio/backend/core/training/trainer.py index 2324916236..490ffbf316 100644 --- a/studio/backend/core/training/trainer.py +++ b/studio/backend/core/training/trainer.py @@ -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") diff --git a/studio/backend/core/training/training.py b/studio/backend/core/training/training.py index 4439e4e173..22250df850 100644 --- a/studio/backend/core/training/training.py +++ b/studio/backend/core/training/training.py @@ -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 diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.py index 891dfca8f7..b10b2f0380 100644 --- a/studio/backend/core/training/worker.py +++ b/studio/backend/core/training/worker.py @@ -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 diff --git a/studio/backend/main.py b/studio/backend/main.py index 65f5e7fe90..09ea1b271a 100644 --- a/studio/backend/main.py +++ b/studio/backend/main.py @@ -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 diff --git a/studio/backend/models/export.py b/studio/backend/models/export.py index a86596f199..d53ab7d0a0 100644 --- a/studio/backend/models/export.py +++ b/studio/backend/models/export.py @@ -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): diff --git a/studio/backend/routes/auth.py b/studio/backend/routes/auth.py index db37ed837d..0197f9b717 100644 --- a/studio/backend/routes/auth.py +++ b/studio/backend/routes/auth.py @@ -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, ) diff --git a/studio/backend/routes/datasets.py b/studio/backend/routes/datasets.py index 8333009626..ce99e9d3e0 100644 --- a/studio/backend/routes/datasets.py +++ b/studio/backend/routes/datasets.py @@ -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 diff --git a/studio/backend/routes/export.py b/studio/backend/routes/export.py index 3e60eaaf20..55f82f6076 100644 --- a/studio/backend/routes/export.py +++ b/studio/backend/routes/export.py @@ -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 diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index 6f44a3c69f..2c17ce21a5 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -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 diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py index 348ffbf6ea..5b81970042 100644 --- a/studio/backend/routes/models.py +++ b/studio/backend/routes/models.py @@ -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 diff --git a/studio/backend/routes/training.py b/studio/backend/routes/training.py index 4cfb060dee..a072bf3ff4 100644 --- a/studio/backend/routes/training.py +++ b/studio/backend/routes/training.py @@ -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 diff --git a/studio/backend/tests/test_transformers_version.py b/studio/backend/tests/test_transformers_version.py index f3dae537c7..31f89a24db 100644 --- a/studio/backend/tests/test_transformers_version.py +++ b/studio/backend/tests/test_transformers_version.py @@ -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 diff --git a/studio/backend/tests/test_utils.py b/studio/backend/tests/test_utils.py index 3c33b33cb3..20ff79d46a 100644 --- a/studio/backend/tests/test_utils.py +++ b/studio/backend/tests/test_utils.py @@ -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( diff --git a/studio/backend/utils/cache_cleanup.py b/studio/backend/utils/cache_cleanup.py index 4c8e6239a0..50bd599400 100644 --- a/studio/backend/utils/cache_cleanup.py +++ b/studio/backend/utils/cache_cleanup.py @@ -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 diff --git a/studio/backend/utils/datasets/chat_templates.py b/studio/backend/utils/datasets/chat_templates.py index 35fbaba8f0..f7ea2374f2 100644 --- a/studio/backend/utils/datasets/chat_templates.py +++ b/studio/backend/utils/datasets/chat_templates.py @@ -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('') + text = text.removeprefix("") 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, } diff --git a/studio/backend/utils/datasets/data_collators.py b/studio/backend/utils/datasets/data_collators.py index 687da74c21..66081e47e3 100644 --- a/studio/backend/utils/datasets/data_collators.py +++ b/studio/backend/utils/datasets/data_collators.py @@ -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 = [] diff --git a/studio/backend/utils/datasets/dataset_utils.py b/studio/backend/utils/datasets/dataset_utils.py index fac8c3d295..b5473cdc3a 100644 --- a/studio/backend/utils/datasets/dataset_utils.py +++ b/studio/backend/utils/datasets/dataset_utils.py @@ -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: diff --git a/studio/backend/utils/datasets/format_conversion.py b/studio/backend/utils/datasets/format_conversion.py index 39f0113fe0..83f0baef96 100644 --- a/studio/backend/utils/datasets/format_conversion.py +++ b/studio/backend/utils/datasets/format_conversion.py @@ -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 diff --git a/studio/backend/utils/datasets/format_detection.py b/studio/backend/utils/datasets/format_detection.py index 7b70ff3a76..0f686561f6 100644 --- a/studio/backend/utils/datasets/format_detection.py +++ b/studio/backend/utils/datasets/format_detection.py @@ -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 diff --git a/studio/backend/utils/datasets/llm_assist.py b/studio/backend/utils/datasets/llm_assist.py index fdc4f374ab..5b03073987 100644 --- a/studio/backend/utils/datasets/llm_assist.py +++ b/studio/backend/utils/datasets/llm_assist.py @@ -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 diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.py index 61ee8a0967..6f5cb607bb 100644 --- a/studio/backend/utils/hardware/hardware.py +++ b/studio/backend/utils/hardware/hardware.py @@ -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 diff --git a/studio/backend/utils/inference/inference_config.py b/studio/backend/utils/inference/inference_config.py index a0377f9869..d2408a3655 100644 --- a/studio/backend/utils/inference/inference_config.py +++ b/studio/backend/utils/inference/inference_config.py @@ -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 diff --git a/studio/backend/utils/models/checkpoints.py b/studio/backend/utils/models/checkpoints.py index b6b2e11c2e..81ffcd8eb7 100644 --- a/studio/backend/utils/models/checkpoints.py +++ b/studio/backend/utils/models/checkpoints.py @@ -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 diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py index 5de3fd2cf9..efe7eb1f99 100644 --- a/studio/backend/utils/models/model_config.py +++ b/studio/backend/utils/models/model_config.py @@ -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 diff --git a/studio/backend/utils/paths/path_utils.py b/studio/backend/utils/paths/path_utils.py index 1d6a952399..c5758ba306 100644 --- a/studio/backend/utils/paths/path_utils.py +++ b/studio/backend/utils/paths/path_utils.py @@ -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__) diff --git a/studio/backend/utils/transformers_version.py b/studio/backend/utils/transformers_version.py index d8724de723..6fb0e557c2 100644 --- a/studio/backend/utils/transformers_version.py +++ b/studio/backend/utils/transformers_version.py @@ -23,7 +23,6 @@ Strategy: import importlib import json -import structlog from loggers import get_logger import os import shutil diff --git a/studio/backend/utils/utils.py b/studio/backend/utils/utils.py index 4e61a5b969..9bdc7f4517 100644 --- a/studio/backend/utils/utils.py +++ b/studio/backend/utils/utils.py @@ -6,7 +6,6 @@ Shared backend utilities """ import os -import structlog from loggers import get_logger from contextlib import contextmanager from pathlib import Path diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py index e8ae22f470..a064e9f401 100644 --- a/studio/install_python_stack.py +++ b/studio/install_python_stack.py @@ -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")) diff --git a/tests/python/test_cross_platform_parity.py b/tests/python/test_cross_platform_parity.py index 6dd41be9fa..94098b7320 100644 --- a/tests/python/test_cross_platform_parity.py +++ b/tests/python/test_cross_platform_parity.py @@ -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" diff --git a/tests/python/test_e2e_no_torch_sandbox.py b/tests/python/test_e2e_no_torch_sandbox.py index f36f69201d..de8f84f977 100644 --- a/tests/python/test_e2e_no_torch_sandbox.py +++ b/tests/python/test_e2e_no_torch_sandbox.py @@ -21,7 +21,6 @@ from __future__ import annotations import os import shutil -import signal import subprocess import sys import textwrap diff --git a/tests/python/test_install_python_stack.py b/tests/python/test_install_python_stack.py index 16538ae42b..028cfc0ea0 100644 --- a/tests/python/test_install_python_stack.py +++ b/tests/python/test_install_python_stack.py @@ -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" diff --git a/tests/python/test_no_torch_filtering.py b/tests/python/test_no_torch_filtering.py index 5c2926a1f1..138914691b 100644 --- a/tests/python/test_no_torch_filtering.py +++ b/tests/python/test_no_torch_filtering.py @@ -10,7 +10,6 @@ Covers: from __future__ import annotations -import importlib import os import re import subprocess diff --git a/tests/python/test_studio_import_no_torch.py b/tests/python/test_studio_import_no_torch.py index 5592a282ff..248bacf231 100644 --- a/tests/python/test_studio_import_no_torch.py +++ b/tests/python/test_studio_import_no_torch.py @@ -15,7 +15,6 @@ import ast import os import shutil import subprocess -import sys import tempfile import textwrap from pathlib import Path diff --git a/tests/saving/language_models/test_merge_4bit_validation.py b/tests/saving/language_models/test_merge_4bit_validation.py index 343e737710..9669b92a3b 100644 --- a/tests/saving/language_models/test_merge_4bit_validation.py +++ b/tests/saving/language_models/test_merge_4bit_validation.py @@ -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 diff --git a/tests/saving/language_models/test_save_merged_grpo_model.py b/tests/saving/language_models/test_save_merged_grpo_model.py index 67b649305a..9625bbaec6 100644 --- a/tests/saving/language_models/test_save_merged_grpo_model.py +++ b/tests/saving/language_models/test_save_merged_grpo_model.py @@ -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)) diff --git a/tests/saving/non_peft/test_mistral_non_peft.py b/tests/saving/non_peft/test_mistral_non_peft.py index e03813367d..7f28334f5d 100644 --- a/tests/saving/non_peft/test_mistral_non_peft.py +++ b/tests/saving/non_peft/test_mistral_non_peft.py @@ -1,6 +1,4 @@ from unsloth import FastLanguageModel -from transformers import AutoModelForCausalLM -from peft import PeftModel from pathlib import Path import sys import warnings diff --git a/tests/saving/non_peft/test_whisper_non_peft.py b/tests/saving/non_peft/test_whisper_non_peft.py index 303d596c85..98af05f176 100644 --- a/tests/saving/non_peft/test_whisper_non_peft.py +++ b/tests/saving/non_peft/test_whisper_non_peft.py @@ -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 diff --git a/tests/saving/vision_models/test_index_file_sharded_model.py b/tests/saving/vision_models/test_index_file_sharded_model.py index f737169841..420125c441 100644 --- a/tests/saving/vision_models/test_index_file_sharded_model.py +++ b/tests/saving/vision_models/test_index_file_sharded_model.py @@ -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}") diff --git a/tests/saving/vision_models/test_push_to_hub_merged.py b/tests/saving/vision_models/test_push_to_hub_merged.py index 74fa058988..1e2b53d8ff 100644 --- a/tests/saving/vision_models/test_push_to_hub_merged.py +++ b/tests/saving/vision_models/test_push_to_hub_merged.py @@ -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}") diff --git a/tests/saving/vision_models/test_save_merge_qwen2.5vl32B_model_ocr_benchmark.py b/tests/saving/vision_models/test_save_merge_qwen2.5vl32B_model_ocr_benchmark.py index ebe078c73b..33f76c55c3 100644 --- a/tests/saving/vision_models/test_save_merge_qwen2.5vl32B_model_ocr_benchmark.py +++ b/tests/saving/vision_models/test_save_merge_qwen2.5vl32B_model_ocr_benchmark.py @@ -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() diff --git a/tests/saving/vision_models/test_save_merge_vision_model_ocr_benchmark.py b/tests/saving/vision_models/test_save_merge_vision_model_ocr_benchmark.py index b99785bcb1..5722b7697a 100644 --- a/tests/saving/vision_models/test_save_merge_vision_model_ocr_benchmark.py +++ b/tests/saving/vision_models/test_save_merge_vision_model_ocr_benchmark.py @@ -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() diff --git a/tests/studio/install/test_install_llama_prebuilt_logic.py b/tests/studio/install/test_install_llama_prebuilt_logic.py index eb30ac2745..56d30095f1 100644 --- a/tests/studio/install/test_install_llama_prebuilt_logic.py +++ b/tests/studio/install/test_install_llama_prebuilt_logic.py @@ -1,6 +1,5 @@ import importlib.util import io -import json import os import sys import tarfile diff --git a/tests/studio/install/test_pr4562_bugfixes.py b/tests/studio/install/test_pr4562_bugfixes.py index 9b8c6219de..61b1c1571e 100644 --- a/tests/studio/install/test_pr4562_bugfixes.py +++ b/tests/studio/install/test_pr4562_bugfixes.py @@ -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 diff --git a/tests/test_raw_text.py b/tests/test_raw_text.py index 9f2e8cda4e..e580e97b69 100644 --- a/tests/test_raw_text.py +++ b/tests/test_raw_text.py @@ -7,7 +7,6 @@ Tests basic functionality without heavy dependencies. import sys import os import tempfile -from pathlib import Path import importlib.util diff --git a/tests/utils/aime_eval.py b/tests/utils/aime_eval.py index 131da3e50b..6a80b16ce8 100644 --- a/tests/utils/aime_eval.py +++ b/tests/utils/aime_eval.py @@ -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}") diff --git a/tests/utils/hf_utils.py b/tests/utils/hf_utils.py index 8ad6d5ad08..02b0192748 100644 --- a/tests/utils/hf_utils.py +++ b/tests/utils/hf_utils.py @@ -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 diff --git a/tests/utils/ocr_eval.py b/tests/utils/ocr_eval.py index 3c5cd74a22..eff316a094 100644 --- a/tests/utils/ocr_eval.py +++ b/tests/utils/ocr_eval.py @@ -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.""" diff --git a/tests/utils/os_utils.py b/tests/utils/os_utils.py index 448f13b8a0..a76627946f 100644 --- a/tests/utils/os_utils.py +++ b/tests/utils/os_utils.py @@ -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") diff --git a/tests/utils/test_q_galore.py b/tests/utils/test_q_galore.py index 6dea5014a0..afd4e8c869 100644 --- a/tests/utils/test_q_galore.py +++ b/tests/utils/test_q_galore.py @@ -14,7 +14,6 @@ # # Tests for Q-GaLore integration (unsloth/optimizers/). -import pytest import sys import os import torch diff --git a/unsloth-cli.py b/unsloth-cli.py index 612da11eb2..3675d2ed02 100644 --- a/unsloth-cli.py +++ b/unsloth-cli.py @@ -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) diff --git a/unsloth/__init__.py b/unsloth/__init__.py index f922a9fa44..9ec20ca8d4 100644 --- a/unsloth/__init__.py +++ b/unsloth/__init__.py @@ -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 diff --git a/unsloth/_auto_install.py b/unsloth/_auto_install.py index f6deefeb33..73440595cd 100644 --- a/unsloth/_auto_install.py +++ b/unsloth/_auto_install.py @@ -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') \ No newline at end of file +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' +) diff --git a/unsloth/chat_templates.py b/unsloth/chat_templates.py index 35eb871529..0ea25cbcc8 100644 --- a/unsloth/chat_templates.py +++ b/unsloth/chat_templates.py @@ -17,13 +17,11 @@ __all__ = [ "test_chat_templates", "test_hf_gguf_equivalence", "remove_special_tokens", - "to_sharegpt", "standardize_sharegpt", "standardize_data_formats", "apply_chat_template", "train_on_responses_only", - "test_construct_chat_template", ] @@ -32,7 +30,6 @@ from torch import LongTensor, FloatTensor from transformers.models.llama.modeling_llama import logger from .save import patch_saving_functions import os -import shutil from .tokenizer_utils import * from .models._utils import patch_tokenizer import re @@ -41,272 +38,336 @@ from unsloth_zoo.dataset_utils import ( train_on_responses_only, standardize_data_formats, ) + standardize_sharegpt = standardize_data_formats CHAT_TEMPLATES = {} DEFAULT_SYSTEM_MESSAGE = {} + + def _ollama_template(name: str): return OLLAMA_TEMPLATES[name] + # =========================================== Unsloth # Unsloth efficient template leverages from Zephyr -unsloth_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{{ messages[0]['content'] + '\n' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% else %}"\ - "{{ '{system_message}' + '\n' }}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '>>> User: ' + message['content'] + '\n' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ '>>> Assistant: ' + message['content'] + eos_token + '\n' }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '>>> Assistant: ' }}"\ +unsloth_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{{ messages[0]['content'] + '\n' }}" + "{% set loop_messages = messages[1:] %}" + "{% else %}" + "{{ '{system_message}' + '\n' }}" + "{% set loop_messages = messages %}" "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ '>>> User: ' + message['content'] + '\n' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ '>>> Assistant: ' + message['content'] + eos_token + '\n' }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '>>> Assistant: ' }}" + "{% endif %}" +) unsloth_ollama = _ollama_template("unsloth") unsloth_eos_token = "eos_token" -CHAT_TEMPLATES["unsloth"] = (unsloth_template, unsloth_eos_token, False, unsloth_ollama,) +CHAT_TEMPLATES["unsloth"] = ( + unsloth_template, + unsloth_eos_token, + False, + unsloth_ollama, +) DEFAULT_SYSTEM_MESSAGE["unsloth"] = "You are a helpful assistant to the user" # =========================================== Zephyr # Zephyr has no BOS! -zephyr_template = \ - "{% for message in messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '<|user|>\n' + message['content'] + eos_token + '\n' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ '<|assistant|>\n' + message['content'] + eos_token + '\n' }}"\ - "{% else %}"\ - "{{ '<|system|>\n' + message['content'] + eos_token + '\n' }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '<|assistant|>\n' }}"\ +zephyr_template = ( + "{% for message in messages %}" + "{% if message['role'] == 'user' %}" + "{{ '<|user|>\n' + message['content'] + eos_token + '\n' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ '<|assistant|>\n' + message['content'] + eos_token + '\n' }}" + "{% else %}" + "{{ '<|system|>\n' + message['content'] + eos_token + '\n' }}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '<|assistant|>\n' }}" + "{% endif %}" +) zephyr_ollama = _ollama_template("zephyr") zephyr_eos_token = "eos_token" -CHAT_TEMPLATES["zephyr"] = (zephyr_template, zephyr_eos_token, False, zephyr_ollama,) -DEFAULT_SYSTEM_MESSAGE["zephyr"] = None # No system message in Zephyr +CHAT_TEMPLATES["zephyr"] = ( + zephyr_template, + zephyr_eos_token, + False, + zephyr_ollama, +) +DEFAULT_SYSTEM_MESSAGE["zephyr"] = None # No system message in Zephyr # =========================================== ChatML # ChatML has no BOS and not EOS! Rather <|im_start|> and <|im_end|> acts as BOS / EOS. -chatml_template = \ - "{% for message in messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{'<|im_start|>user\n' + message['content'] + '<|im_end|>\n'}}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' }}"\ - "{% else %}"\ - "{{ '<|im_start|>system\n' + message['content'] + '<|im_end|>\n' }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '<|im_start|>assistant\n' }}"\ +chatml_template = ( + "{% for message in messages %}" + "{% if message['role'] == 'user' %}" + "{{'<|im_start|>user\n' + message['content'] + '<|im_end|>\n'}}" + "{% elif message['role'] == 'assistant' %}" + "{{'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' }}" + "{% else %}" + "{{ '<|im_start|>system\n' + message['content'] + '<|im_end|>\n' }}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '<|im_start|>assistant\n' }}" + "{% endif %}" +) chatml_ollama = _ollama_template("chatml") chatml_eos_token = "<|im_end|>" -CHAT_TEMPLATES["chatml"] = (chatml_template, chatml_eos_token, True, chatml_ollama,) -DEFAULT_SYSTEM_MESSAGE["chatml"] = None # No system message in ChatML +CHAT_TEMPLATES["chatml"] = ( + chatml_template, + chatml_eos_token, + True, + chatml_ollama, +) +DEFAULT_SYSTEM_MESSAGE["chatml"] = None # No system message in ChatML # =========================================== Mistral-1 # Mistral Instruct doesn't allow system prompts, so we append it to the user message. -mistral_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{% if messages[1]['role'] == 'user' %}"\ - "{{ '[INST] ' + messages[0]['content'] + ' ' + messages[1]['content'] + ' [/INST]' }}"\ - "{% set loop_messages = messages[2:] %}"\ - "{% else %}"\ - "{{ '[INST] ' + messages[0]['content'] + ' [/INST]' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% endif %}"\ - "{% else %}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '[INST] ' + message['content'] + ' [/INST]' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ message['content'] + eos_token }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ +mistral_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{% if messages[1]['role'] == 'user' %}" + "{{ '[INST] ' + messages[0]['content'] + ' ' + messages[1]['content'] + ' [/INST]' }}" + "{% set loop_messages = messages[2:] %}" + "{% else %}" + "{{ '[INST] ' + messages[0]['content'] + ' [/INST]' }}" + "{% set loop_messages = messages[1:] %}" + "{% endif %}" + "{% else %}" + "{% set loop_messages = messages %}" + "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ '[INST] ' + message['content'] + ' [/INST]' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ message['content'] + eos_token }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" "{% endfor %}" +) # Ollama from https://www.ollama.com/library/mistral mistral_ollama = _ollama_template("mistral") mistral_eos_token = "eos_token" -CHAT_TEMPLATES["mistral"] = (mistral_template, mistral_eos_token, False, mistral_ollama,) -DEFAULT_SYSTEM_MESSAGE["mistral"] = None # No system message in Mistral +CHAT_TEMPLATES["mistral"] = ( + mistral_template, + mistral_eos_token, + False, + mistral_ollama, +) +DEFAULT_SYSTEM_MESSAGE["mistral"] = None # No system message in Mistral # =========================================== Llama-2 # Adds BOS to every convo! And weird <> system messages. -llama_template = \ - "{% if messages[0]['role'] == 'system' %}"\ - "{% if messages[1]['role'] == 'user' %}"\ - "{{ bos_token + '[INST] <>\n' + messages[0]['content'] + '\n<>\n\n' + messages[1]['content'] + ' [/INST]' }}"\ - "{% set loop_messages = messages[2:] %}"\ - "{% else %}"\ - "{{ bos_token + '[INST] ' + messages[0]['content'] + ' [/INST]' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% endif %}"\ - "{% else %}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ bos_token + '[INST] ' + message['content'].strip() + ' [/INST]' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ ' ' + message['content'].strip() + ' ' + eos_token }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ +llama_template = ( + "{% if messages[0]['role'] == 'system' %}" + "{% if messages[1]['role'] == 'user' %}" + "{{ bos_token + '[INST] <>\n' + messages[0]['content'] + '\n<>\n\n' + messages[1]['content'] + ' [/INST]' }}" + "{% set loop_messages = messages[2:] %}" + "{% else %}" + "{{ bos_token + '[INST] ' + messages[0]['content'] + ' [/INST]' }}" + "{% set loop_messages = messages[1:] %}" + "{% endif %}" + "{% else %}" + "{% set loop_messages = messages %}" + "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ bos_token + '[INST] ' + message['content'].strip() + ' [/INST]' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ ' ' + message['content'].strip() + ' ' + eos_token }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" "{% endfor %}" +) # Ollama from https://www.ollama.com/library/llama3 llama_ollama = _ollama_template("llama") llama_eos_token = "eos_token" -CHAT_TEMPLATES["llama"] = (llama_template, llama_eos_token, False, llama_ollama,) -DEFAULT_SYSTEM_MESSAGE["llama"] = None # No system message in Llama +CHAT_TEMPLATES["llama"] = ( + llama_template, + llama_eos_token, + False, + llama_ollama, +) +DEFAULT_SYSTEM_MESSAGE["llama"] = None # No system message in Llama # =========================================== Vicuna # https://github.com/lm-sys/FastChat/blob/main/docs/vicuna_weights_version.md#prompt-template -vicuna_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{{ messages[0]['content'] + ' ' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% else %}"\ - "{{ '{system_message}' + ' ' }}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ 'USER: ' + message['content'] + ' ' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ 'ASSISTANT: ' + message['content'] + eos_token }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ 'ASSISTANT:' }}"\ +vicuna_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{{ messages[0]['content'] + ' ' }}" + "{% set loop_messages = messages[1:] %}" + "{% else %}" + "{{ '{system_message}' + ' ' }}" + "{% set loop_messages = messages %}" "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ 'USER: ' + message['content'] + ' ' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ 'ASSISTANT: ' + message['content'] + eos_token }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ 'ASSISTANT:' }}" + "{% endif %}" +) # Ollama from https://www.ollama.com/library/vicuna vicuna_ollama = _ollama_template("vicuna") vicuna_eos_token = "eos_token" -CHAT_TEMPLATES["vicuna"] = (vicuna_template, vicuna_eos_token, False, vicuna_ollama,) -DEFAULT_SYSTEM_MESSAGE["vicuna"] = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions." +CHAT_TEMPLATES["vicuna"] = ( + vicuna_template, + vicuna_eos_token, + False, + vicuna_ollama, +) +DEFAULT_SYSTEM_MESSAGE["vicuna"] = ( + "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions." +) # =========================================== Vicuna Old # https://github.com/lm-sys/FastChat/blob/main/docs/vicuna_weights_version.md#prompt-template -vicuna_old_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{{ messages[0]['content'] + '\n' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% else %}"\ - "{{ '{system_message}' + '\n' }}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '### Human: ' + message['content'] + '\n' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ '### Assistant: ' + message['content'] + eos_token + '\n' }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '### Assistant:' }}"\ +vicuna_old_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{{ messages[0]['content'] + '\n' }}" + "{% set loop_messages = messages[1:] %}" + "{% else %}" + "{{ '{system_message}' + '\n' }}" + "{% set loop_messages = messages %}" "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ '### Human: ' + message['content'] + '\n' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ '### Assistant: ' + message['content'] + eos_token + '\n' }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '### Assistant:' }}" + "{% endif %}" +) vicuna_old_ollama = _ollama_template("vicuna_old") vicuna_old_eos_token = "eos_token" -CHAT_TEMPLATES["vicuna_old"] = (vicuna_old_template, vicuna_old_eos_token, False, vicuna_old_ollama,) -DEFAULT_SYSTEM_MESSAGE["vicuna_old"] = "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human\\'s questions." +CHAT_TEMPLATES["vicuna_old"] = ( + vicuna_old_template, + vicuna_old_eos_token, + False, + vicuna_old_ollama, +) +DEFAULT_SYSTEM_MESSAGE["vicuna_old"] = ( + "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human\\'s questions." +) CHAT_TEMPLATES["vicuna old"] = CHAT_TEMPLATES["vicuna_old"] DEFAULT_SYSTEM_MESSAGE["vicuna old"] = DEFAULT_SYSTEM_MESSAGE["vicuna_old"] # =========================================== Alpaca multi turn # https://github.com/tatsu-lab/stanford_alpaca Changed for multi-turn convos -alpaca_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{{ messages[0]['content'] + '\n\n' }}"\ - "{% set loop_messages = messages[1:] %}"\ - "{% else %}"\ - "{{ '{system_message}' + '\n\n' }}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}"\ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '### Instruction:\n' + message['content'] + '\n\n' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ '### Response:\n' + message['content'] + eos_token + '\n\n' }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '### Response:\n' }}"\ +alpaca_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{{ messages[0]['content'] + '\n\n' }}" + "{% set loop_messages = messages[1:] %}" + "{% else %}" + "{{ '{system_message}' + '\n\n' }}" + "{% set loop_messages = messages %}" "{% endif %}" + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ '### Instruction:\n' + message['content'] + '\n\n' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ '### Response:\n' + message['content'] + eos_token + '\n\n' }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '### Response:\n' }}" + "{% endif %}" +) alpaca_ollama = _ollama_template("alpaca") alpaca_eos_token = "eos_token" -CHAT_TEMPLATES["alpaca"] = (alpaca_template, alpaca_eos_token, False, alpaca_ollama,) -DEFAULT_SYSTEM_MESSAGE["alpaca"] = "Below are some instructions that describe some tasks. Write responses that appropriately complete each request." +CHAT_TEMPLATES["alpaca"] = ( + alpaca_template, + alpaca_eos_token, + False, + alpaca_ollama, +) +DEFAULT_SYSTEM_MESSAGE["alpaca"] = ( + "Below are some instructions that describe some tasks. Write responses that appropriately complete each request." +) # =========================================== Gemma # https://huggingface.co/google/gemma-7b-it # Notice we must use |trim for lstrip and rstrip. maps to 106. # maps to 107. user and model are normal 1 word tokens. -gemma_template = \ - "{{ bos_token }}"\ - "{% if messages[0]['role'] == 'system' %}"\ - "{{'user\n' + messages[0]['content'] | trim + ' ' + messages[1]['content'] | trim + '\n'}}"\ - "{% set messages = messages[2:] %}"\ - "{% endif %}"\ - "{% for message in messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{'user\n' + message['content'] | trim + '\n'}}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{'model\n' + message['content'] | trim + '\n' }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ 'model\n' }}"\ +gemma_template = ( + "{{ bos_token }}" + "{% if messages[0]['role'] == 'system' %}" + "{{'user\n' + messages[0]['content'] | trim + ' ' + messages[1]['content'] | trim + '\n'}}" + "{% set messages = messages[2:] %}" "{% endif %}" + "{% for message in messages %}" + "{% if message['role'] == 'user' %}" + "{{'user\n' + message['content'] | trim + '\n'}}" + "{% elif message['role'] == 'assistant' %}" + "{{'model\n' + message['content'] | trim + '\n' }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" + "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ 'model\n' }}" + "{% endif %}" +) # Ollama from https://www.ollama.com/library/gemma gemma_ollama = _ollama_template("gemma") gemma_eos_token = "" -CHAT_TEMPLATES["gemma"] = (gemma_template, gemma_eos_token, True, gemma_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma"] = None # No system message in Gemma +CHAT_TEMPLATES["gemma"] = ( + gemma_template, + gemma_eos_token, + True, + gemma_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma"] = None # No system message in Gemma # =========================================== Gemma with ChatML instead # We find using is still more appropriate! @@ -315,11 +376,16 @@ gemma_chatml_template = "{{ bos_token }}" + chatml_template gemma_chatml_ollama = _ollama_template("gemma_chatml") gemma_chatml_eos_token = ( - {"" : "<|im_start|>", "" : "<|im_end|>"}, + {"": "<|im_start|>", "": "<|im_end|>"}, "<|im_end|>", ) -CHAT_TEMPLATES["gemma_chatml"] = (gemma_chatml_template, gemma_chatml_eos_token, True, gemma_chatml_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma_chatml"] = None # No system message in Gemma +CHAT_TEMPLATES["gemma_chatml"] = ( + gemma_chatml_template, + gemma_chatml_eos_token, + True, + gemma_chatml_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma_chatml"] = None # No system message in Gemma # =========================================== Gemma 2 # Same as Gemma 1, but with sliding window attention! @@ -327,73 +393,100 @@ DEFAULT_SYSTEM_MESSAGE["gemma_chatml"] = None # No system message in Gemma gemma2_template = gemma_template gemma2_ollama = _ollama_template("gemma2") gemma2_eos_token = "" -CHAT_TEMPLATES["gemma2"] = (gemma2_template, gemma2_eos_token, True, gemma2_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma2"] = None # No system message in Gemma 2 +CHAT_TEMPLATES["gemma2"] = ( + gemma2_template, + gemma2_eos_token, + True, + gemma2_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma2"] = None # No system message in Gemma 2 # =========================================== Gemma 2 with ChatML instead gemma2_chatml_template = gemma_chatml_template gemma2_chatml_ollama = _ollama_template("gemma2_chatml") gemma2_chatml_eos_token = gemma_chatml_eos_token -CHAT_TEMPLATES["gemma2_chatml"] = (gemma2_chatml_template, gemma2_chatml_eos_token, True, gemma2_chatml_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma2_chatml"] = None # No system message in Gemma 2 +CHAT_TEMPLATES["gemma2_chatml"] = ( + gemma2_chatml_template, + gemma2_chatml_eos_token, + True, + gemma2_chatml_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma2_chatml"] = None # No system message in Gemma 2 # =========================================== Llama-3 # Weirdly \n\n is needed? -llama3_template = \ - "{{ bos_token }}"\ - "{% for message in messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ '<|start_header_id|>user<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}"\ - "{% else %}"\ - "{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}"\ +llama3_template = ( + "{{ bos_token }}" + "{% for message in messages %}" + "{% if message['role'] == 'user' %}" + "{{ '<|start_header_id|>user<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}" + "{% elif message['role'] == 'assistant' %}" + "{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}" + "{% else %}" + "{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}" + "{% endif %}" +) # Ollama from https://www.ollama.com/library/llama3 llama3_ollama = _ollama_template("llama-3") llama3_template_eos_token = "eos_token" -CHAT_TEMPLATES["llama-3"] = (llama3_template, llama3_template_eos_token, False, llama3_ollama,) -DEFAULT_SYSTEM_MESSAGE["llama-3"] = None # No system message in Llama-3 +CHAT_TEMPLATES["llama-3"] = ( + llama3_template, + llama3_template_eos_token, + False, + llama3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["llama-3"] = None # No system message in Llama-3 -CHAT_TEMPLATES["llama3"] = (llama3_template, llama3_template_eos_token, False, llama3_ollama,) -DEFAULT_SYSTEM_MESSAGE["llama3"] = None # No system message in Llama-3 +CHAT_TEMPLATES["llama3"] = ( + llama3_template, + llama3_template_eos_token, + False, + llama3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["llama3"] = None # No system message in Llama-3 # =========================================== Phi-3 # "{{ bos_token }}"\ # Phi-3.5 removes BOS? -phi3_template = \ - "{% for message in messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{'<|user|>\n' + message['content'] + '<|end|>\n'}}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}"\ - "{% else %}"\ - "{{'<|' + message['role'] + '|>\n' + message['content'] + '<|end|>\n'}}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '<|assistant|>\n' }}"\ +phi3_template = ( + "{% for message in messages %}" + "{% if message['role'] == 'user' %}" + "{{'<|user|>\n' + message['content'] + '<|end|>\n'}}" + "{% elif message['role'] == 'assistant' %}" + "{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}" + "{% else %}" + "{{'<|' + message['role'] + '|>\n' + message['content'] + '<|end|>\n'}}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '<|assistant|>\n' }}" + "{% endif %}" +) # Ollama from https://www.ollama.com/library/phi3 phi3_ollama = _ollama_template("phi-3") phi3_template_eos_token = "<|end|>" -CHAT_TEMPLATES["phi-3"] = (phi3_template, phi3_template_eos_token, False, phi3_ollama,) -DEFAULT_SYSTEM_MESSAGE["phi-3"] = None # No system message in Phi-3 +CHAT_TEMPLATES["phi-3"] = ( + phi3_template, + phi3_template_eos_token, + False, + phi3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["phi-3"] = None # No system message in Phi-3 -CHAT_TEMPLATES["phi-35"] = CHAT_TEMPLATES["phi-3"] -DEFAULT_SYSTEM_MESSAGE["phi-35"] = None # No system message in Phi-3.5 +CHAT_TEMPLATES["phi-35"] = CHAT_TEMPLATES["phi-3"] +DEFAULT_SYSTEM_MESSAGE["phi-35"] = None # No system message in Phi-3.5 CHAT_TEMPLATES["phi-3.5"] = CHAT_TEMPLATES["phi-3"] -DEFAULT_SYSTEM_MESSAGE["phi-3.5"] = None # No system message in Phi-3.5 +DEFAULT_SYSTEM_MESSAGE["phi-3.5"] = None # No system message in Phi-3.5 # =========================================== Llama-3.1 """ @@ -412,8 +505,7 @@ tokenizer.apply_chat_template( ) """ -llama31_template = \ -"""{{- bos_token }} +llama31_template = """{{- bos_token }} {%- if custom_tools is defined %} {%- set tools = custom_tools %} {%- endif %} @@ -528,11 +620,25 @@ llama31_template = \ llama31_ollama = _ollama_template("llama-3.1") llama31_template_eos_token = "eos_token" -CHAT_TEMPLATES["llama-3.1"] = (llama31_template, llama31_template_eos_token, False, llama31_ollama,) -DEFAULT_SYSTEM_MESSAGE["llama-3.1"] = "" # Llama3.1 default system message is empty + the dates +CHAT_TEMPLATES["llama-3.1"] = ( + llama31_template, + llama31_template_eos_token, + False, + llama31_ollama, +) +DEFAULT_SYSTEM_MESSAGE["llama-3.1"] = ( + "" # Llama3.1 default system message is empty + the dates +) -CHAT_TEMPLATES["llama-31"] = (llama31_template, llama31_template_eos_token, False, llama31_ollama,) -DEFAULT_SYSTEM_MESSAGE["llama-31"] = "" # Llama3.1 default system message is empty + the dates +CHAT_TEMPLATES["llama-31"] = ( + llama31_template, + llama31_template_eos_token, + False, + llama31_ollama, +) +DEFAULT_SYSTEM_MESSAGE["llama-31"] = ( + "" # Llama3.1 default system message is empty + the dates +) for version in ("llama-3.2", "llama-3.3", "llama-32", "llama-33"): CHAT_TEMPLATES[version] = CHAT_TEMPLATES["llama-3.1"] @@ -540,8 +646,7 @@ for version in ("llama-3.2", "llama-3.3", "llama-32", "llama-33"): # =========================================== Qwen 2.5 -qwen25_template = \ -"""{%- if tools %} +qwen25_template = """{%- if tools %} {{- \'<|im_start|>system\\n\' }} {%- if messages[0][\'role\'] == \'system\' %} {{- messages[0][\'content\'] }} @@ -596,53 +701,89 @@ qwen25_template = \ qwen25_ollama = _ollama_template("qwen-2.5") qwen25_template_eos_token = "eos_token" -qwen25_default_system_message = "You are Qwen, created by Alibaba Cloud. You are a helpful assistant." -CHAT_TEMPLATES["qwen-2.5"] = (qwen25_template, qwen25_template_eos_token, False, qwen25_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen-2.5"] = qwen25_default_system_message # No system message in Qwen 2.5 +qwen25_default_system_message = ( + "You are Qwen, created by Alibaba Cloud. You are a helpful assistant." +) +CHAT_TEMPLATES["qwen-2.5"] = ( + qwen25_template, + qwen25_template_eos_token, + False, + qwen25_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen-2.5"] = ( + qwen25_default_system_message # No system message in Qwen 2.5 +) -CHAT_TEMPLATES["qwen-25"] = (qwen25_template, qwen25_template_eos_token, False, qwen25_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen-25"] = qwen25_default_system_message # No system message in Qwen 2.5 +CHAT_TEMPLATES["qwen-25"] = ( + qwen25_template, + qwen25_template_eos_token, + False, + qwen25_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen-25"] = ( + qwen25_default_system_message # No system message in Qwen 2.5 +) -CHAT_TEMPLATES["qwen25"] = (qwen25_template, qwen25_template_eos_token, False, qwen25_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen25"] = qwen25_default_system_message # No system message in Qwen 2.5 +CHAT_TEMPLATES["qwen25"] = ( + qwen25_template, + qwen25_template_eos_token, + False, + qwen25_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen25"] = ( + qwen25_default_system_message # No system message in Qwen 2.5 +) -CHAT_TEMPLATES["qwen2.5"] = (qwen25_template, qwen25_template_eos_token, False, qwen25_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen2.5"] = qwen25_default_system_message # No system message in Qwen 2.5 +CHAT_TEMPLATES["qwen2.5"] = ( + qwen25_template, + qwen25_template_eos_token, + False, + qwen25_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen2.5"] = ( + qwen25_default_system_message # No system message in Qwen 2.5 +) # =========================================== Phi-4 # "{{ bos_token }}"\ # Phi-4 removes BOS? -phi4_template = \ - "{% for message in messages %}"\ - "{% if (message['role'] == 'system') %}"\ - "{{'<|im_start|>system<|im_sep|>' + message['content'] + '<|im_end|>'}}"\ - "{% elif (message['role'] == 'user') %}"\ - "{{'<|im_start|>user<|im_sep|>' + message['content'] + '<|im_end|>'}}"\ - "{% elif (message['role'] == 'assistant') %}"\ - "{{'<|im_start|>assistant<|im_sep|>' + message['content'] + '<|im_end|>'}}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '<|im_start|>assistant<|im_sep|>' }}"\ +phi4_template = ( + "{% for message in messages %}" + "{% if (message['role'] == 'system') %}" + "{{'<|im_start|>system<|im_sep|>' + message['content'] + '<|im_end|>'}}" + "{% elif (message['role'] == 'user') %}" + "{{'<|im_start|>user<|im_sep|>' + message['content'] + '<|im_end|>'}}" + "{% elif (message['role'] == 'assistant') %}" + "{{'<|im_start|>assistant<|im_sep|>' + message['content'] + '<|im_end|>'}}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '<|im_start|>assistant<|im_sep|>' }}" + "{% endif %}" +) -_phi4_ollama_template = \ - "{{ if .System }}<|im_start|><|system|><|im_sep|>{{ .System }}<|im_end|>{{ end }}"\ - "{{ if .Prompt }}<|im_start|><|user|><|im_sep|>{{ .Prompt }}<|im_end|>{{ end }}"\ +_phi4_ollama_template = ( + "{{ if .System }}<|im_start|><|system|><|im_sep|>{{ .System }}<|im_end|>{{ end }}" + "{{ if .Prompt }}<|im_start|><|user|><|im_sep|>{{ .Prompt }}<|im_end|>{{ end }}" "<|im_start|><|assistant|><|im_sep|>{{ .Response }}<|im_end|>" +) # Ollama from https://www.ollama.com/library/phi4 is different phi4_ollama = _ollama_template("phi-4") phi4_template_eos_token = "<|im_end|>" -CHAT_TEMPLATES["phi-4"] = (phi4_template, phi4_template_eos_token, False, phi4_ollama,) -DEFAULT_SYSTEM_MESSAGE["phi-4"] = None # No system message in Phi-4 +CHAT_TEMPLATES["phi-4"] = ( + phi4_template, + phi4_template_eos_token, + False, + phi4_ollama, +) +DEFAULT_SYSTEM_MESSAGE["phi-4"] = None # No system message in Phi-4 # =========================================== Gemma-3 # Obtained via # print(tokenizer.chat_template.replace("}\n", "####").replace("\n", "\\n").replace("####", "}\n")) -gemma3_template = \ -"""{{ bos_token }} +gemma3_template = """{{ bos_token }} {%- if messages[0]['role'] == 'system' -%} {%- if messages[0]['content'] is string -%} {%- set first_user_prefix = messages[0]['content'] + '\n\n' -%} @@ -688,16 +829,25 @@ gemma3_template = \ gemma3_ollama = _ollama_template("gemma-3") gemma3_template_eos_token = "" -CHAT_TEMPLATES["gemma-3"] = (gemma3_template, gemma3_template_eos_token, False, gemma3_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma-3"] = None # No system message in Gemma-3 +CHAT_TEMPLATES["gemma-3"] = ( + gemma3_template, + gemma3_template_eos_token, + False, + gemma3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma-3"] = None # No system message in Gemma-3 -CHAT_TEMPLATES["gemma3"] = (gemma3_template, gemma3_template_eos_token, False, gemma3_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma3"] = None # No system message in Gemma-3 +CHAT_TEMPLATES["gemma3"] = ( + gemma3_template, + gemma3_template_eos_token, + False, + gemma3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma3"] = None # No system message in Gemma-3 # =========================================== Qwen-3 # Official Qwen-3 chat template (see https://ollama.com/library/qwen3/blobs/eb4402837c78) -qwen3_template = \ -""" +qwen3_template = """ {%- if tools %} {{- '<|im_start|>system\n' }} {%- if messages[0].role == 'system' %} @@ -800,17 +950,26 @@ qwen3_template = \ qwen3_ollama = _ollama_template("qwen-3") qwen3_template_eos_token = "<|im_end|>" -CHAT_TEMPLATES["qwen-3"] = (qwen3_template, qwen3_template_eos_token, False, qwen3_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen-3"] = None # No default system message for Qwen-3 +CHAT_TEMPLATES["qwen-3"] = ( + qwen3_template, + qwen3_template_eos_token, + False, + qwen3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen-3"] = None # No default system message for Qwen-3 -CHAT_TEMPLATES["qwen3"] = (qwen3_template, qwen3_template_eos_token, False, qwen3_ollama,) -DEFAULT_SYSTEM_MESSAGE["qwen3"] = None # No default system message for Qwen-3 +CHAT_TEMPLATES["qwen3"] = ( + qwen3_template, + qwen3_template_eos_token, + False, + qwen3_ollama, +) +DEFAULT_SYSTEM_MESSAGE["qwen3"] = None # No default system message for Qwen-3 # =========================================== Gemma-3n # Obtained via # print(tokenizer.chat_template.replace("}\n", "####").replace("\n", "\\n").replace("####", "}\n")) -gemma3n_template = \ -"""{{ bos_token }} +gemma3n_template = """{{ bos_token }} {%- if messages[0]['role'] == 'system' -%} {%- if messages[0]['content'] is string -%} {%- set first_user_prefix = messages[0]['content'] + '\n\n' -%} @@ -857,17 +1016,26 @@ gemma3n_template = \ # Ollama from https://ollama.com/library/gemma3n/blobs/e0a42594d802 gemma3n_ollama = _ollama_template("gemma-3n") gemma3n_template_eos_token = "" -CHAT_TEMPLATES["gemma-3n"] = (gemma3n_template, gemma3n_template_eos_token, False, gemma3n_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma-3n"] = None # No system message in Gemma-3n +CHAT_TEMPLATES["gemma-3n"] = ( + gemma3n_template, + gemma3n_template_eos_token, + False, + gemma3n_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma-3n"] = None # No system message in Gemma-3n -CHAT_TEMPLATES["gemma3n"] = (gemma3n_template, gemma3n_template_eos_token, False, gemma3n_ollama,) -DEFAULT_SYSTEM_MESSAGE["gemma3n"] = None # No system message in Gemma-3n +CHAT_TEMPLATES["gemma3n"] = ( + gemma3n_template, + gemma3n_template_eos_token, + False, + gemma3n_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gemma3n"] = None # No system message in Gemma-3n # =========================================== GPT-OSS # Obtained via # print(tokenizer.chat_template.replace("}\n", "####").replace("\n", "\\n").replace("####", "}\n")) -gptoss_template = \ -"""{#- +gptoss_template = """{#- In addition to the normal inputs of `messages` and `tools`, this template also accepts the following kwargs: - "builtin_tools": A list, can contain "browser" and/or "python". @@ -1217,8 +1385,7 @@ gptoss_template = \ {%- endif -%}""" # Ollama from https://ollama.com/library/gpt-oss -gptoss_ollama = \ -''' +gptoss_ollama = ''' FROM {__FILE_LOCATION__} TEMPLATE """<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI. Knowledge cutoff: 2024-06 @@ -1399,15 +1566,24 @@ PARAMETER top_p 1.0 ''' gptoss_template_template_eos_token = "<|return|>" -CHAT_TEMPLATES["gpt-oss"] = (gptoss_template, gptoss_template_template_eos_token, False, gptoss_ollama,) -DEFAULT_SYSTEM_MESSAGE["gpt-oss"] = None # No system message in GPT-oss +CHAT_TEMPLATES["gpt-oss"] = ( + gptoss_template, + gptoss_template_template_eos_token, + False, + gptoss_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gpt-oss"] = None # No system message in GPT-oss -CHAT_TEMPLATES["gptoss"] = (gptoss_template, gptoss_template_template_eos_token, False, gptoss_ollama,) -DEFAULT_SYSTEM_MESSAGE["gptoss"] = None # No system message in GPT-oss +CHAT_TEMPLATES["gptoss"] = ( + gptoss_template, + gptoss_template_template_eos_token, + False, + gptoss_ollama, +) +DEFAULT_SYSTEM_MESSAGE["gptoss"] = None # No system message in GPT-oss # =========================================== Qwen3-Instruct -qwen3_instruct_template = \ -'''{%- if tools %} +qwen3_instruct_template = """{%- if tools %} {{- '<|im_start|>system\\n' }} {%- if messages[0].role == 'system' %} {{- messages[0].content + '\\n\\n' }} @@ -1492,16 +1668,20 @@ qwen3_instruct_template = \ {%- endfor %} {%- if add_generation_prompt %} {{- '<|im_start|>assistant\\n' }} -{%- endif %}''' +{%- endif %}""" qwen3_template_eos_token = "<|im_end|>" -CHAT_TEMPLATES["qwen3-instruct"] = (qwen3_instruct_template, qwen3_template_eos_token, False, _ollama_template("qwen3-instruct"),) -DEFAULT_SYSTEM_MESSAGE["qwen3-instruct"] = None # No system message in Qwen3 +CHAT_TEMPLATES["qwen3-instruct"] = ( + qwen3_instruct_template, + qwen3_template_eos_token, + False, + _ollama_template("qwen3-instruct"), +) +DEFAULT_SYSTEM_MESSAGE["qwen3-instruct"] = None # No system message in Qwen3 # =========================================== Qwen3-Thinking -qwen3_thinking_template = \ -'''{%- if tools %} +qwen3_thinking_template = """{%- if tools %} {{- '<|im_start|>system\\n' }} {%- if messages[0].role == 'system' %} {{- messages[0].content + '\\n\\n' }} @@ -1586,7 +1766,7 @@ qwen3_thinking_template = \ {%- endfor %} {%- if add_generation_prompt %} {{- '<|im_start|>assistant\n\n' }} -{%- endif %}''' +{%- endif %}""" CHAT_TEMPLATES["qwen3-thinking"] = ( qwen3_thinking_template, @@ -1594,26 +1774,29 @@ CHAT_TEMPLATES["qwen3-thinking"] = ( False, _ollama_template("qwen3-thinking"), ) -DEFAULT_SYSTEM_MESSAGE["qwen3-thinking"] = None # No system message in Qwen3 +DEFAULT_SYSTEM_MESSAGE["qwen3-thinking"] = None # No system message in Qwen3 # =========================================== Liquid-LFM2 -liquid_lfm2_template = \ -''' +liquid_lfm2_template = """ {{bos_token}}{% for message in messages %}{{'<|im_start|>' + message['role'] + ' ' + message['content'] + '<|im_end|>' + ' '}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant -' }}{% endif %}''' +' }}{% endif %}""" liquid_lfm2_template_eos_token = "<|im_end|>" -CHAT_TEMPLATES["lfm-2"] = (liquid_lfm2_template, liquid_lfm2_template_eos_token, False, None) -DEFAULT_SYSTEM_MESSAGE["lfm-2"] = None # No system message in Phi-3 +CHAT_TEMPLATES["lfm-2"] = ( + liquid_lfm2_template, + liquid_lfm2_template_eos_token, + False, + None, +) +DEFAULT_SYSTEM_MESSAGE["lfm-2"] = None # No system message in Phi-3 # =========================================== Starling-LM -starling_template = \ -"""{{ bos_token }} +starling_template = """{{ bos_token }} {%- for message in messages %} {{ 'GPT4 Correct ' + message['role'].title() + ': ' + message['content'] + '<|end_of_turn|>' }} {%- endfor %} @@ -1625,14 +1808,18 @@ starling_template = \ starling_ollama = _ollama_template("starling") starling_template_eos_token = "<|end_of_turn|>" -CHAT_TEMPLATES["starling"] = (starling_template, starling_template_eos_token, False, starling_ollama) +CHAT_TEMPLATES["starling"] = ( + starling_template, + starling_template_eos_token, + False, + starling_ollama, +) DEFAULT_SYSTEM_MESSAGE["starling"] = None # =========================================== Yi-chat -yi_chat_template = \ -""" +yi_chat_template = """ {% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{{'<|im_start|>' + message['role'] + ' ' + message['content'] + '<|im_end|>' + ' '}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant @@ -1643,10 +1830,18 @@ yi_chat_template = \ yi_chat_ollama = _ollama_template("yi-chat") yi_chat_template_eos_token = "<|endoftext|>" -CHAT_TEMPLATES["yi-chat"] = (yi_chat_template, yi_chat_template_eos_token, False, yi_chat_ollama) +CHAT_TEMPLATES["yi-chat"] = ( + yi_chat_template, + yi_chat_template_eos_token, + False, + yi_chat_ollama, +) DEFAULT_SYSTEM_MESSAGE["yi-chat"] = None -def _change_system_message(template: str, type_chat_template: str, system_message: str = None): + +def _change_system_message( + template: str, type_chat_template: str, system_message: str = None +): system_message_pattern = r"\{system_message\}" # For predefined templates, check if default system message exists @@ -1666,14 +1861,18 @@ def _change_system_message(template: str, type_chat_template: str, system_messag if has_placeholder: if system_message is None: - raise ValueError("Unsloth: You need to provide a system message for custom templates.") + raise ValueError( + "Unsloth: You need to provide a system message for custom templates." + ) new_template = re.sub(system_message_pattern, system_message, template) return new_template, system_message return template, system_message # For predefined templates with default system message - message_to_use = system_message if system_message is not None else default_system_message + message_to_use = ( + system_message if system_message is not None else default_system_message + ) new_template = re.sub(system_message_pattern, message_to_use, template) return new_template, message_to_use @@ -1682,16 +1881,22 @@ def _change_system_message(template: str, type_chat_template: str, system_messag def get_chat_template( tokenizer, chat_template = "chatml", - mapping = {"role" : "role", "content" : "content", "user" : "user", "assistant" : "assistant"}, + mapping = { + "role": "role", + "content": "content", + "user": "user", + "assistant": "assistant", + }, map_eos_token = True, system_message = None, ): - assert(type(map_eos_token) is bool) + assert type(map_eos_token) is bool old_tokenizer = tokenizer IS_GEMMA = False if tokenizer.__class__.__name__.startswith("Gemma"): - if chat_template == "chatml": chat_template = "gemma_chatml" + if chat_template == "chatml": + chat_template = "gemma_chatml" IS_GEMMA = True # We add a check for Llama-3 @@ -1712,32 +1917,42 @@ def get_chat_template( same_padding_token = False type_chat_template = None - if type(chat_template) in (list, tuple,): + if type(chat_template) in ( + list, + tuple, + ): # For changing system message later # Since it's not supported yet, we will raise an error first! type_chat_template = chat_template[0].lower() chat_template, stop_word = chat_template - assert(type(chat_template) is str) - assert(type(stop_word) is str) + assert type(chat_template) is str + assert type(stop_word) is str ollama_modelfile = None elif type(chat_template) is str: # For changing system message later type_chat_template = chat_template.lower() - chat_template, stop_word, yes_map_eos_token, ollama_modelfile = CHAT_TEMPLATES[chat_template] + chat_template, stop_word, yes_map_eos_token, ollama_modelfile = CHAT_TEMPLATES[ + chat_template + ] # Check mapping to eos_token - if not map_eos_token and yes_map_eos_token: map_eos_token = True - if not yes_map_eos_token and map_eos_token: map_eos_token = False + if not map_eos_token and yes_map_eos_token: + map_eos_token = True + if not yes_map_eos_token and map_eos_token: + map_eos_token = False - if type(stop_word) in (list, tuple,): + if type(stop_word) in ( + list, + tuple, + ): token_mapping, stop_word = stop_word - assert(type(token_mapping) is dict) + assert type(token_mapping) is dict else: token_mapping = None - assert(type(stop_word) is str) + assert type(stop_word) is str # Check fast tokenizer if not is_fast_tokenizer: @@ -1764,13 +1979,17 @@ def get_chat_template( elif old_count == 0: raise RuntimeError(f"{old_token} was not part of the tokenizer!") else: - string_vocab = string_vocab.replace(f'"{old_token}"', f'"{new_token}"') + string_vocab = string_vocab.replace( + f'"{old_token}"', f'"{new_token}"' + ) pass pass - if map_eos_token and (not stop_word in token_mapping.values()): + if map_eos_token and (stop_word not in token_mapping.values()): # Do not map 107 = <|im_end|> and 1 = <|im_end|>. This will reduce the vocab size by 1 - logger.warning_once(f"Unsloth: Will map {stop_word} to EOS = {tokenizer.eos_token}.") + logger.warning_once( + f"Unsloth: Will map {stop_word} to EOS = {tokenizer.eos_token}." + ) string_vocab = string_vocab.replace(tokenizer.eos_token, stop_word) pass @@ -1798,12 +2017,18 @@ def get_chat_template( pass # Must fix the sentence piece tokenizer since there's no tokenizer.model file! - tokenizer = fix_sentencepiece_tokenizer(tokenizer, new_tokenizer, token_mapping,) + tokenizer = fix_sentencepiece_tokenizer( + tokenizer, + new_tokenizer, + token_mapping, + ) else: pass elif map_eos_token and (stop_word != "eos_token"): - logger.warning_once(f"Unsloth: Will map {stop_word} to EOS = {tokenizer.eos_token}.") + logger.warning_once( + f"Unsloth: Will map {stop_word} to EOS = {tokenizer.eos_token}." + ) # Replaces the old EOS token with a new one. # Useful for ChatML <|im_end|> for example. @@ -1845,43 +2070,60 @@ def get_chat_template( ) # Must fix the sentence piece tokenizer since there's no tokenizer.model file! - token_mapping = { old_eos_token : stop_word, } - tokenizer = fix_sentencepiece_tokenizer(tokenizer, new_tokenizer, token_mapping,) + token_mapping = { + old_eos_token: stop_word, + } + tokenizer = fix_sentencepiece_tokenizer( + tokenizer, + new_tokenizer, + token_mapping, + ) pass else: raise TypeError( - f"Unsloth: `chat_template` must be a tuple of (your_template, eos_token,) or one of\n"\ + f"Unsloth: `chat_template` must be a tuple of (your_template, eos_token,) or one of\n" f"{CHAT_TEMPLATES.keys()}" ) # Careful on Gemma # bos_token is a must or else losses become too high - if IS_GEMMA and not chat_template.startswith(("{{ bos_token }}", "{{- bos_token }}")): + if IS_GEMMA and not chat_template.startswith( + ("{{ bos_token }}", "{{- bos_token }}") + ): chat_template = "{{ bos_token }}" + chat_template # For ShareGPT role -> from and content -> value - new_chat_template = chat_template\ - .replace("'role'", "'" + mapping["role"] + "'")\ - .replace("'content'", "'" + mapping["content"] + "'")\ - .replace("'user'", "'" + mapping["user"] + "'")\ + new_chat_template = ( + chat_template.replace("'role'", "'" + mapping["role"] + "'") + .replace("'content'", "'" + mapping["content"] + "'") + .replace("'user'", "'" + mapping["user"] + "'") .replace("'assistant'", "'" + mapping["assistant"] + "'") + ) _, tokenizer = patch_tokenizer(model = None, tokenizer = tokenizer) tokenizer.padding_side = old_padding_side # If not normal HF, we add a check to make old templates work - if mapping != {"role" : "role", "content" : "content", "user" : "user", "assistant" : "assistant"}: - chat_template = \ - "{% if 'role' in messages[0] %}" + \ - chat_template + \ - "{% else %}" + \ - new_chat_template + \ - "{% endif %}" + if mapping != { + "role": "role", + "content": "content", + "user": "user", + "assistant": "assistant", + }: + chat_template = ( + "{% if 'role' in messages[0] %}" + + chat_template + + "{% else %}" + + new_chat_template + + "{% endif %}" + ) else: chat_template = new_chat_template - chat_template, system_message = _change_system_message(chat_template, type_chat_template, system_message) + chat_template, system_message = _change_system_message( + chat_template, type_chat_template, system_message + ) tokenizer.chat_template = chat_template @@ -1889,13 +2131,16 @@ def get_chat_template( old_pad_token = getattr(old_tokenizer, "pad_token", None) old_bos_token = getattr(old_tokenizer, "bos_token", None) old_unk_token = getattr(old_tokenizer, "unk_token", None) - new_pad_token = getattr(tokenizer, "pad_token", None) - new_bos_token = getattr(tokenizer, "bos_token", None) - new_unk_token = getattr(tokenizer, "unk_token", None) - if old_bos_token != new_bos_token: tokenizer.bos_token = old_bos_token - if old_unk_token != new_unk_token: tokenizer.unk_token = old_unk_token + new_pad_token = getattr(tokenizer, "pad_token", None) + new_bos_token = getattr(tokenizer, "bos_token", None) + new_unk_token = getattr(tokenizer, "unk_token", None) + if old_bos_token != new_bos_token: + tokenizer.bos_token = old_bos_token + if old_unk_token != new_unk_token: + tokenizer.unk_token = old_unk_token if not same_padding_token: - if old_pad_token != new_pad_token: tokenizer.pad_token = old_pad_token + if old_pad_token != new_pad_token: + tokenizer.pad_token = old_pad_token # stopping_criteria = create_stopping_criteria(tokenizer, stop_word) @@ -1904,14 +2149,14 @@ def get_chat_template( # Add Ollama tokenizer._ollama_modelfile = ollama_modelfile - tokenizer._system_message = system_message - return tokenizer#, stopping_criteria + tokenizer._system_message = system_message + return tokenizer # , stopping_criteria def remove_special_tokens(tokenizer, prompt): # Removes double BOS token if prompt.startswith(tokenizer.bos_token): - prompt = prompt[len(tokenizer.bos_token):] + prompt = prompt[len(tokenizer.bos_token) :] return prompt @@ -1922,12 +2167,14 @@ def _parse_combined_prompt(combined_prompt, dataset): for column in possible_columns: if column not in dataset_columns: raise KeyError( - f"Unsloth: Your prompt includes '{column}' but this does not exist in the dataset. "\ + f"Unsloth: Your prompt includes '{column}' but this does not exist in the dataset. " f"Only allowed columns are {list(dataset_columns)}" ) # Find [[...]] - optional_prompts = list(re.finditer(r"\[\[.+?\]\]", combined_prompt, flags = re.DOTALL | re.MULTILINE)) + optional_prompts = list( + re.finditer(r"\[\[.+?\]\]", combined_prompt, flags = re.DOTALL | re.MULTILINE) + ) optional_prompts = [(x.span(), x.group(0)) for x in optional_prompts] final_optional_prompts = [] @@ -1935,25 +2182,30 @@ def _parse_combined_prompt(combined_prompt, dataset): # Add left left = optional_prompts[0] l = left[0][0] - if l != 0: final_optional_prompts.append(combined_prompt[:l]) + if l != 0: + final_optional_prompts.append(combined_prompt[:l]) # Add in between for left, right in zip(optional_prompts[:-1], optional_prompts[1:]): l, r = left[0][-1], right[0][0] final_optional_prompts.append(left) - if l != r: final_optional_prompts.append(combined_prompt[l : r]) + if l != r: + final_optional_prompts.append(combined_prompt[l:r]) final_optional_prompts.append(optional_prompts[-1]) # Add right right = optional_prompts[-1] r = right[0][1] - if r != len(combined_prompt): final_optional_prompts.append(combined_prompt[r:]) + if r != len(combined_prompt): + final_optional_prompts.append(combined_prompt[r:]) else: # Just add in the entire string final_optional_prompts.append(combined_prompt) - check_combined = "".join(x if type(x) is str else x[1] for x in final_optional_prompts) - assert(combined_prompt == check_combined) + check_combined = "".join( + x if type(x) is str else x[1] for x in final_optional_prompts + ) + assert combined_prompt == check_combined return possible_columns, final_optional_prompts @@ -1974,7 +2226,9 @@ def _create_formatter(possible_columns, final_optional_prompts, user_column_name prompt = prompt[2:-2] needed_columns = re.findall(r"\{(.+?)\}", prompt) if len(needed_columns) == 0: - raise IndexError("Unsloth: Optional [[...]] blocks must contain at least 1 {column}.") + raise IndexError( + "Unsloth: Optional [[...]] blocks must contain at least 1 {column}." + ) optional_name = f"__optional_{j}__" formatter_templates.append(("optional", optional_name, prompt, needed_columns)) merged_prompt_parts.append("{" + optional_name + "}") @@ -2004,7 +2258,9 @@ def _create_formatter(possible_columns, final_optional_prompts, user_column_name _, optional_name, prompt, needed_columns = formatter_template if row_values[needed_columns[0]] not in (None, ""): - prompt_values = {column: row_values[column] for column in needed_columns} + prompt_values = { + column: row_values[column] for column in needed_columns + } formatter_values[optional_name] = prompt.format(**prompt_values) else: formatter_values[optional_name] = "" @@ -2042,14 +2298,20 @@ def to_sharegpt( if "conversations" in dataset.column_names: convo = dataset[0]["conversations"] if type(convo) is list: - raise TypeError("Unsloth: Your dataset is probably already in ShareGPT format!") + raise TypeError( + "Unsloth: Your dataset is probably already in ShareGPT format!" + ) - possible_columns, final_optional_prompts = _parse_combined_prompt(merged_prompt, dataset) - formatter = _create_formatter(possible_columns, final_optional_prompts, merged_column_name) + possible_columns, final_optional_prompts = _parse_combined_prompt( + merged_prompt, dataset + ) + formatter = _create_formatter( + possible_columns, final_optional_prompts, merged_column_name + ) dataset = dataset.map(formatter, batched = True, desc = "Merging columns") def __convert_to_sharegpt__(examples): - users = examples[merged_column_name] + users = examples[merged_column_name] assistants = examples[output_column_name] if len(users) != len(assistants): raise ValueError( @@ -2058,12 +2320,14 @@ def to_sharegpt( ) texts = [ [ - {"from" : "human", "value" : str(user) }, - {"from" : "gpt", "value" : str(assistant)}, - ] \ + {"from": "human", "value": str(user)}, + {"from": "gpt", "value": str(assistant)}, + ] for user, assistant in zip(users, assistants) ] - return { "conversations" : texts, } + return { + "conversations": texts, + } dataset = dataset.map( __convert_to_sharegpt__, @@ -2075,19 +2339,24 @@ def to_sharegpt( # Randomnly concat conversations to create a long stream! from datasets import concatenate_datasets - n_extensions = max(conversation_extension-1, 0) - if n_extensions == 0: return dataset - dataset = dataset.rename_columns({"conversations" : "conversations0"}) + n_extensions = max(conversation_extension - 1, 0) + if n_extensions == 0: + return dataset + + dataset = dataset.rename_columns({"conversations": "conversations0"}) all_shuffled = [dataset] - for j in range(1, n_extensions+1): - shuffled = dataset.shuffle(seed = random_state+j).rename_columns({"conversations0" : f"conversations{j}"}) + for j in range(1, n_extensions + 1): + shuffled = dataset.shuffle(seed = random_state + j).rename_columns( + {"conversations0": f"conversations{j}"} + ) all_shuffled.append(shuffled) dataset = concatenate_datasets(all_shuffled, axis = 1) # Combine them into 1 n_extensions += 1 conversation_columns = [f"conversations{j}" for j in range(n_extensions)] + def __combine_conversations__(examples): columns = [examples[column] for column in conversation_columns] convos = [] @@ -2096,7 +2365,7 @@ def to_sharegpt( for conversation in conversations: merged_conversation.extend(conversation) convos.append(merged_conversation) - return {"conversations" : convos} + return {"conversations": convos} dataset = dataset.map( __combine_conversations__, @@ -2117,18 +2386,20 @@ def get_ollama_eos_tokens(tokenizer, extra_eos_tokens = []): # Remove BOS if getattr(tokenizer, "bos_token", None) is not None: - added_tokens_decoder = [x for x in added_tokens_decoder if x != tokenizer.bos_token] + added_tokens_decoder = [ + x for x in added_tokens_decoder if x != tokenizer.bos_token + ] repeatted_tokens = [] # Join all vocab joined_text = "\x01\x00".join(added_tokens_decoder) for token in added_tokens_decoder: n = len(token) - repeatted_counts = joined_text.count(token[:n//2]) + repeatted_counts = joined_text.count(token[: n // 2]) # Try finding longer than 1/2 of the token in the rest # For eg <|reserved_special_token_0|>, <|reserved_special_token_1|> if repeatted_counts > 2: - for j in range(n//2+1, n): + for j in range(n // 2 + 1, n): if joined_text.count(token[:j]) < repeatted_counts: j -= 1 # Remove repeatted tokens to reduce search space @@ -2138,26 +2409,30 @@ def get_ollama_eos_tokens(tokenizer, extra_eos_tokens = []): # Remove duplicates splitted = joined_text.split("\x01\x00") - final_eos_tokens = [old for old, new in zip(added_tokens_decoder, splitted) if old == new] + final_eos_tokens = [ + old for old, new in zip(added_tokens_decoder, splitted) if old == new + ] final_eos_tokens += extra_eos_tokens final_eos_tokens += repeatted_tokens # Remove new lines, spaces and HTML tags filtered_eos_tokens = [] for token in final_eos_tokens: - if token.count("\n") == len(token): continue - elif token.count("▁") == len(token): continue - elif token.startswith("<") and len(token) <= 2: continue - elif token.startswith("<|start_header_id|>system<|end_header_id|> +def construct_chat_template( + tokenizer = None, + chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> {SYSTEM}<|eot_id|><|start_header_id|>user<|end_header_id|> @@ -2168,11 +2443,8 @@ chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> {INPUT}<|eot_id|><|start_header_id|>assistant<|end_header_id|> {OUTPUT}<|eot_id|>""", - -default_system_message = \ - "Below are some instructions that describe some tasks. Write responses that appropriately complete each request.", - -extra_eos_tokens = None, + default_system_message = "Below are some instructions that describe some tasks. Write responses that appropriately complete each request.", + extra_eos_tokens = None, ): """ Creates an Ollama modelfile and a HF Jinja template from a custom @@ -2184,25 +2456,32 @@ extra_eos_tokens = None, # Strip only the left chat_template = chat_template.lstrip() - assert(tokenizer is not None) + assert tokenizer is not None - if extra_eos_tokens is None: extra_eos_tokens = [] - elif type(extra_eos_tokens) is str: extra_eos_tokens = [extra_eos_tokens,] + if extra_eos_tokens is None: + extra_eos_tokens = [] + elif type(extra_eos_tokens) is str: + extra_eos_tokens = [ + extra_eos_tokens, + ] vocab = tokenizer.get_vocab() for extra_eos in extra_eos_tokens: - assert(type(extra_eos) is str) + assert type(extra_eos) is str if extra_eos not in vocab: - raise ValueError(f"Unsloth: `{extra_eos}` is not a singular token in the tokenizer.") + raise ValueError( + f"Unsloth: `{extra_eos}` is not a singular token in the tokenizer." + ) - error_msg = \ - "Unsloth: Your prompt template must have 2 examples showing the user input {INPUT} "\ - "and the assistant output {OUTPUT}\n\n"\ - "For example what is not allowed is just:\n"\ - "### Input:\\n{INPUT}\\n\\n### Response:\\n{OUTPUT}\\n\n\n"\ - "What is required is 2x of this:\n"\ - "### Input:\\n{INPUT}\\n\\n### Response:\\n{OUTPUT}\\n"\ + error_msg = ( + "Unsloth: Your prompt template must have 2 examples showing the user input {INPUT} " + "and the assistant output {OUTPUT}\n\n" + "For example what is not allowed is just:\n" + "### Input:\\n{INPUT}\\n\\n### Response:\\n{OUTPUT}\\n\n\n" + "What is required is 2x of this:\n" "### Input:\\n{INPUT}\\n\\n### Response:\\n{OUTPUT}\\n" + "### Input:\\n{INPUT}\\n\\n### Response:\\n{OUTPUT}\\n" + ) # Check for EOS after {OUTPUT} if tokenizer.eos_token is not None: @@ -2214,14 +2493,17 @@ extra_eos_tokens = None, # Check tokenizer types tokenizer_name = tokenizer.name_or_path.lower() - if tokenizer_name.startswith(("unsloth/llama-3-8b-instruct", "unsloth/llama-3-70b-instruct")): + if tokenizer_name.startswith( + ("unsloth/llama-3-8b-instruct", "unsloth/llama-3-70b-instruct") + ): # Add <|eot_id|> extra_eos_tokens.append("<|eot_id|>") - elif ("<|eot_id|>" in extra_eos_tokens or "<|eot_id|>" in chat_template) and \ - tokenizer_name.startswith(("unsloth/llama-3-8b", "unsloth/llama-3-70b")): + elif ( + "<|eot_id|>" in extra_eos_tokens or "<|eot_id|>" in chat_template + ) and tokenizer_name.startswith(("unsloth/llama-3-8b", "unsloth/llama-3-70b")): # Warn logger.warning( - "Unsloth: Base llama-3 models did not train <|eot_id|>.\n"\ + "Unsloth: Base llama-3 models did not train <|eot_id|>.\n" "Please use the instruct version or use <|end_of_text|>" ) extra_eos_tokens = list(set(extra_eos_tokens)) @@ -2235,42 +2517,51 @@ extra_eos_tokens = None, try: # O(N^2) search finding 2 repeatted pieces of text - j = len(chat_template)-1 + j = len(chat_template) - 1 at_least_one = False while j > 0: found = chat_template.rfind(chat_template[j:], 0, j) - if found == -1: break + if found == -1: + break j -= 1 at_least_one = True - if j > 0: j += 1 - else: raise RuntimeError(error_msg) + if j > 0: + j += 1 + else: + raise RuntimeError(error_msg) - if not at_least_one: raise RuntimeError(error_msg) + if not at_least_one: + raise RuntimeError(error_msg) # Must be equivalent to left final_combined_check = True # Repeatted text instruction_response = chat_template[j:] - if instruction_response.count("{INPUT}") != 1 or instruction_response.count("{OUTPUT}") != 1: + if ( + instruction_response.count("{INPUT}") != 1 + or instruction_response.count("{OUTPUT}") != 1 + ): raise RuntimeError(error_msg) # 1st System, Instruction, Output pair - left = chat_template[:j] + left = chat_template[:j] # 2nd Instruction, Output pair right = chat_template[j:] final_combined_check = left if final_combined_check else chat_template # Isolate input - extra_eos_tokens_regex = "|".join(f"(?:{re.escape(x)})" for x in extra_eos_tokens) + extra_eos_tokens_regex = "|".join( + f"(?:{re.escape(x)})" for x in extra_eos_tokens + ) if len(extra_eos_tokens_regex) != 0: find_end = f"(?:{extra_eos_tokens_regex})?" else: find_end = "" find_end = r"\{INPUT\}[\s\n]{0,}" + find_end input_end = list(re.finditer(find_end, right)) - assert(len(input_end) == 1) + assert len(input_end) == 1 input_end = input_end[0] input_end = input_end.span(0)[1] input_part = right[:input_end] @@ -2280,46 +2571,63 @@ extra_eos_tokens = None, # Isolate system where_system = left.find(input_part) - system_part = left[:where_system if where_system != -1 else len(left)] + system_part = left[: where_system if where_system != -1 else len(left)] # Check if the user provided a correct prompt combined = system_part + input_part + output_part if combined != final_combined_check: - combined_changed = combined .replace('\n', '\\n') - left_changed = final_combined_check.replace('\n', '\\n') + combined_changed = combined.replace("\n", "\\n") + left_changed = final_combined_check.replace("\n", "\\n") raise RuntimeError( - "Unsloth: The prompt template you provided isn't correct. You gave:\n"\ - f"{combined_changed}\n\n"\ - "But we require the following:\n"\ + "Unsloth: The prompt template you provided isn't correct. You gave:\n" + f"{combined_changed}\n\n" + "But we require the following:\n" f"{left_changed}" ) except: - ending = chat_template[chat_template.find("{OUTPUT}") + len("{OUTPUT}"):] + ending = chat_template[chat_template.find("{OUTPUT}") + len("{OUTPUT}") :] ending = re.escape(ending) find_text = "{INPUT}" + ending + "(.+?{OUTPUT}" + ending + ")" - response_part = re.findall(find_text, chat_template, flags = re.DOTALL | re.MULTILINE) + response_part = re.findall( + find_text, chat_template, flags = re.DOTALL | re.MULTILINE + ) response_part = response_part[0] for j in range(1, len(response_part)): try_find = re.escape(response_part[:j]) - try: found = next(re.finditer("(" + try_find + ").+?\\{INPUT\\}", chat_template, flags = re.DOTALL | re.MULTILINE)) - except: break + try: + found = next( + re.finditer( + "(" + try_find + ").+?\\{INPUT\\}", + chat_template, + flags = re.DOTALL | re.MULTILINE, + ) + ) + except: + break separator = found.group(1) response_start = chat_template.find(response_part) start_instruction = chat_template[:response_start].rfind(separator) - if start_instruction == -1: start_instruction = 0 + if start_instruction == -1: + start_instruction = 0 instruction_part = chat_template[start_instruction:response_start] combined = instruction_part + response_part where = chat_template.find(combined) system_part = chat_template[:where] - system_part, input_part, output_part = system_part, instruction_part, response_part + system_part, input_part, output_part = ( + system_part, + instruction_part, + response_part, + ) if count_eos == 0: - logger.warning("Unsloth: We automatically added an EOS token to stop endless generations.") + logger.warning( + "Unsloth: We automatically added an EOS token to stop endless generations." + ) eos = extra_eos_tokens[0] output_part = output_part + eos @@ -2333,54 +2641,73 @@ extra_eos_tokens = None, always_bos_token = True if ollama_system.startswith(tokenizer.bos_token): has_bos_token = True - ollama_system = ollama_system[len(tokenizer.bos_token):] + ollama_system = ollama_system[len(tokenizer.bos_token) :] # Check system if "{SYSTEM}" in ollama_system: - system_modelfile = "{{ if .System }}" + ollama_system.replace("{SYSTEM}", "{{ .System }}") + "{{ end }}" + system_modelfile = ( + "{{ if .System }}" + + ollama_system.replace("{SYSTEM}", "{{ .System }}") + + "{{ end }}" + ) else: system_modelfile = ollama_system - input_modelfile = "{{ if .Prompt }}" + input_part .replace("{INPUT}", "{{ .Prompt }}") + "{{ end }}" + input_modelfile = ( + "{{ if .Prompt }}" + + input_part.replace("{INPUT}", "{{ .Prompt }}") + + "{{ end }}" + ) output_modelfile = output_part.replace("{OUTPUT}", "{{ .Response }}") # Ollama EOS ollama_eos = get_ollama_eos_tokens(tokenizer, extra_eos_tokens) - ollama_eos = '\n'.join(f'PARAMETER stop "{eos}"' for eos in ollama_eos) + ollama_eos = "\n".join(f'PARAMETER stop "{eos}"' for eos in ollama_eos) # Add temperature and min_p to counteract gibberish ollama_eos += "\nPARAMETER temperature 1.5\nPARAMETER min_p 0.1" # Ollama modelfile part = '"""' - modelfile = 'FROM {__FILE_LOCATION__}\n\n'\ - 'TEMPLATE ' + part + system_modelfile + input_modelfile + output_modelfile + \ - part + '\n\n' + ollama_eos + modelfile = ( + "FROM {__FILE_LOCATION__}\n\n" + "TEMPLATE " + + part + + system_modelfile + + input_modelfile + + output_modelfile + + part + + "\n\n" + + ollama_eos + ) # HF Jinja Chat template def process(part, which, content = "message['content']"): if part.endswith(which): - part = "'" + part[:part.find(which)] + f"' + {content}" + part = "'" + part[: part.find(which)] + f"' + {content}" elif part.startswith(which): - part = f"{content} + '" + part[part.find(which):] + "'" + part = f"{content} + '" + part[part.find(which) :] + "'" else: part = "'" + part.replace(which, f"' + {content} + '") + "'" - if part.startswith("'' + "): part = part[5:] + if part.startswith("'' + "): + part = part[5:] return part - input_jinja = process(input_part, "{INPUT}") + + input_jinja = process(input_part, "{INPUT}") output_jinja = process(output_part, "{OUTPUT}") - jinja_template = \ - "{% for message in loop_messages %}"\ - "{% if message['role'] == 'user' %}"\ - "{{ " + input_jinja + " }}"\ - "{% elif message['role'] == 'assistant' %}"\ - "{{ " + output_jinja + " }}"\ - "{% else %}"\ - "{{ raise_exception('Only user and assistant roles are supported!') }}"\ - "{% endif %}"\ - "{% endfor %}"\ - "{% if add_generation_prompt %}"\ - "{{ '" + output_part[:output_part.find("{OUTPUT}")] + "' }}"\ + jinja_template = ( + "{% for message in loop_messages %}" + "{% if message['role'] == 'user' %}" + "{{ " + input_jinja + " }}" + "{% elif message['role'] == 'assistant' %}" + "{{ " + output_jinja + " }}" + "{% else %}" + "{{ raise_exception('Only user and assistant roles are supported!') }}" "{% endif %}" + "{% endfor %}" + "{% if add_generation_prompt %}" + "{{ '" + output_part[: output_part.find("{OUTPUT}")] + "' }}" + "{% endif %}" + ) # Now add system prompt to jinja if len(system_part) != 0: @@ -2394,20 +2721,23 @@ extra_eos_tokens = None, # Separate the BOS if has_bos_token: partial_system = partial_system.replace(tokenizer.bos_token, "", 1) - system_part = system_part .replace(tokenizer.bos_token, "", 1) + system_part = system_part.replace(tokenizer.bos_token, "", 1) - partial_system = \ - "{% if messages[0]['role'] == 'system' %}"\ - "{{ " + partial_system + " }}"\ - "{% set loop_messages = messages[1:] %}" + partial_system = ( + "{% if messages[0]['role'] == 'system' %}" + "{{ " + partial_system + " }}" + "{% set loop_messages = messages[1:] %}" + ) if default_system_message is not None: full_system = system_part.replace("{SYSTEM}", default_system_message) if "{SYSTEM}" in system_part: modelfile += '\nSYSTEM "' + default_system_message + '"' - partial_system += "{% else %}"\ - "{{ '" + full_system + "' }}"\ - "{% set loop_messages = messages %}"\ - "{% endif %}" + partial_system += ( + "{% else %}" + "{{ '" + full_system + "' }}" + "{% set loop_messages = messages %}" + "{% endif %}" + ) else: partial_system += "{% endif %}" @@ -2421,17 +2751,18 @@ extra_eos_tokens = None, jinja_template = jinja_template.replace( "{% for message in loop_messages %}", "{% for message in messages %}", - 1, # Only replace the first one + 1, # Only replace the first one ) # Check if system part is the same! jinja_template = re.sub( - r"\{\% if messages\[0\]\['role'\] \=\= 'system' \%\}\{\{ '(.+?)' \}\}"\ - r"\{\% set loop\_messages \= messages\[1\:\] \%\}"\ - r"\{\% else \%\}\{\{ '\1' \}\}\{\% set loop\_messages \= messages \%\}\{\% endif \%\}"\ + r"\{\% if messages\[0\]\['role'\] \=\= 'system' \%\}\{\{ '(.+?)' \}\}" + r"\{\% set loop\_messages \= messages\[1\:\] \%\}" + r"\{\% else \%\}\{\{ '\1' \}\}\{\% set loop\_messages \= messages \%\}\{\% endif \%\}" r"\{\% for message in loop\_messages \%\}", r"{{ '\1' }}{% for message in messages %}", - jinja_template, flags = re.MULTILINE | re.DOTALL, + jinja_template, + flags = re.MULTILINE | re.DOTALL, ) # Check jinja template for bos @@ -2440,15 +2771,18 @@ extra_eos_tokens = None, jinja_template = "{{ bos_token }}" + jinja_template # Get instruction and output parts for train_on_inputs = False - input_part = input_part [:input_part .find("{INPUT}")] - output_part = output_part[:output_part.find("{OUTPUT}")] + input_part = input_part[: input_part.find("{INPUT}")] + output_part = output_part[: output_part.find("{OUTPUT}")] return modelfile, jinja_template, input_part, output_part def test_construct_chat_template(): token = "hf_" from transformers import AutoTokenizer - tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", token = token) + + tokenizer = AutoTokenizer.from_pretrained( + "meta-llama/Meta-Llama-3-8B-Instruct", token = token + ) chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> @@ -2462,8 +2796,7 @@ def test_construct_chat_template(): {OUTPUT}<|eot_id|>""" - default_system_message = \ - "Below are some instructions that describe some tasks. Write responses that appropriately complete each request." + default_system_message = "Below are some instructions that describe some tasks. Write responses that appropriately complete each request." extra_eos_tokens = None @@ -2481,19 +2814,21 @@ def test_construct_chat_template(): {"role": "assistant", "content": "Anything else?"}, {"role": "user", "content": "What's 2x2?"}, ] - correct_output = tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + correct_output = tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) tokenizer.chat_template = jinja_template - new_output = tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) - assert(correct_output == new_output) + new_output = tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) + assert correct_output == new_output -def apply_chat_template( \ - -dataset, -tokenizer = None, - -chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> +def apply_chat_template( + dataset, + tokenizer = None, + chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> {SYSTEM}<|eot_id|><|start_header_id|>user<|end_header_id|> @@ -2504,12 +2839,8 @@ chat_template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> {INPUT}<|eot_id|><|start_header_id|>assistant<|end_header_id|> {OUTPUT}<|eot_id|>""", - -default_system_message = \ - "Below are some instructions that describe some tasks. Write responses that appropriately complete each request.", - -extra_eos_tokens = None, - + default_system_message = "Below are some instructions that describe some tasks. Write responses that appropriately complete each request.", + extra_eos_tokens = None, ): """ Creates an Ollama modelfile and a HF Jinja template from a custom @@ -2524,27 +2855,42 @@ extra_eos_tokens = None, default_system_message = default_system_message, extra_eos_tokens = extra_eos_tokens, ) + def formatting_prompts_func(examples): convos = examples["conversations"] - texts = [tokenizer.apply_chat_template(convo, tokenize = False, add_generation_prompt = False) for convo in convos] - return { "text" : texts, } + texts = [ + tokenizer.apply_chat_template( + convo, tokenize = False, add_generation_prompt = False + ) + for convo in convos + ] + return { + "text": texts, + } tokenizer.chat_template = jinja_template tokenizer._ollama_modelfile = modelfile - tokenizer._unsloth_input_part = input_part + tokenizer._unsloth_input_part = input_part tokenizer._unsloth_output_part = output_part if hasattr(tokenizer, "tokenizer"): tokenizer.tokenizer.chat_template = jinja_template tokenizer.tokenizer._ollama_modelfile = modelfile - tokenizer.tokenizer._unsloth_input_part = input_part + tokenizer.tokenizer._unsloth_input_part = input_part tokenizer.tokenizer._unsloth_output_part = output_part - return dataset.map(formatting_prompts_func, batched = True,) + return dataset.map( + formatting_prompts_func, + batched = True, + ) def create_stopping_criteria(tokenizer, stop_word = "eos_token"): class StoppingCriteriaSub(StoppingCriteria): - __slots__ = "stop_token", "single_match", "length", + __slots__ = ( + "stop_token", + "single_match", + "length", + ) def __init__(self, stops = "eos_token", device = "cuda", encounters = 1): super().__init__() @@ -2552,7 +2898,9 @@ def create_stopping_criteria(tokenizer, stop_word = "eos_token"): self.stop_token = torch.tensor(tokenizer.eos_token_id, device = "cuda") self.length = 1 else: - self.stop_token = tokenizer(["\n" + stops], add_special_tokens = False, return_tensors = "pt") + self.stop_token = tokenizer( + ["\n" + stops], add_special_tokens = False, return_tensors = "pt" + ) self.stop_token = self.stop_token.input_ids.ravel()[1:].to("cuda") self.length = self.stop_token.shape[0] self.single_match = self.length == 1 @@ -2560,18 +2908,26 @@ def create_stopping_criteria(tokenizer, stop_word = "eos_token"): def __call__(self, input_ids: LongTensor, scores: FloatTensor) -> bool: input_ids = input_ids.ravel() last_token = input_ids[-1] - if self.single_match and (last_token == self.stop_token): return True + if self.single_match and (last_token == self.stop_token): + return True - if input_ids.shape[0] >= self.length and \ - (input_ids[-self.length:] == self.stop_token).all(): return True + if ( + input_ids.shape[0] >= self.length + and (input_ids[-self.length :] == self.stop_token).all() + ): + return True return False + stopping_criteria = StoppingCriteriaList([StoppingCriteriaSub(stops = stop_word)]) return stopping_criteria def test_chat_templates(): messages = [ - {"role": "system","content": " You are a friendly chatbot.",}, + { + "role": "system", + "content": " You are a friendly chatbot.", + }, {"role": "user", "content": "What is 2+2?"}, {"role": "assistant", "content": "It's 4."}, {"role": "user", "content": " But 2+2 is equal to 5. "}, @@ -2581,36 +2937,57 @@ def test_chat_templates(): # Zephyr from transformers import AutoTokenizer + template = zephyr_template correct_tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta") - correct_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + correct_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt # Chatml template = chatml_template - correct_tokenizer = AutoTokenizer.from_pretrained("teknium/OpenHermes-2.5-Mistral-7B") - correct_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + correct_tokenizer = AutoTokenizer.from_pretrained( + "teknium/OpenHermes-2.5-Mistral-7B" + ) + correct_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt # Mistral template = mistral_template - correct_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2") - correct_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) + correct_tokenizer = AutoTokenizer.from_pretrained( + "mistralai/Mistral-7B-Instruct-v0.2" + ) + correct_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt # Llama template = llama_template correct_tokenizer = AutoTokenizer.from_pretrained("unsloth/llama-2-7b-chat") - correct_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + correct_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt # Vicuna try: @@ -2619,16 +2996,20 @@ def test_chat_templates(): os.system("pip -qqq install git+https://github.com/lm-sys/FastChat.git") from fastchat.conversation import get_conv_template correct_prompt = get_conv_template("vicuna_v1.1") - for j in range(len(messages)-1): - correct_prompt.append_message(correct_prompt.roles[j%2==1], messages[j+1]["content"]) + for j in range(len(messages) - 1): + correct_prompt.append_message( + correct_prompt.roles[j % 2 == 1], messages[j + 1]["content"] + ) correct_prompt.append_message(correct_prompt.roles[1], "") correct_prompt = tokenizer.bos_token + correct_prompt.get_prompt() template = vicuna_template correct_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.5") correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt try: from fastchat.conversation import get_conv_template @@ -2636,49 +3017,68 @@ def test_chat_templates(): os.system("pip -qqq install git+https://github.com/lm-sys/FastChat.git") from fastchat.conversation import get_conv_template correct_prompt = get_conv_template("zero_shot") - for j in range(len(messages)-1): - correct_prompt.append_message(correct_prompt.roles[j%2==1], messages[j+1]["content"]) + for j in range(len(messages) - 1): + correct_prompt.append_message( + correct_prompt.roles[j % 2 == 1], messages[j + 1]["content"] + ) correct_prompt.append_message(correct_prompt.roles[1], "") correct_prompt = tokenizer.bos_token + correct_prompt.get_prompt() template = vicuna_old_template correct_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.5") correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) + our_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) # We add ourselves - assert(correct_prompt == our_prompt.replace("", "")) + assert correct_prompt == our_prompt.replace("", "") # Gemma correct_tokenizer = AutoTokenizer.from_pretrained("unsloth/gemma-7b-it") - correct_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) + correct_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = gemma_template - our_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) - assert(our_prompt == correct_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) + assert our_prompt == correct_prompt # Llama-3 template = llama3_template correct_tokenizer = AutoTokenizer.from_pretrained("unsloth/llama-3-8b-Instruct") - correct_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + correct_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt # Phi-3 template = phi3_template - correct_tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct") - correct_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) + correct_tokenizer = AutoTokenizer.from_pretrained( + "microsoft/Phi-3-mini-4k-instruct" + ) + correct_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) correct_tokenizer.chat_template = template - our_prompt = correct_tokenizer.apply_chat_template(messages[1:], tokenize = False, add_generation_prompt = True) - assert(correct_prompt == our_prompt) + our_prompt = correct_tokenizer.apply_chat_template( + messages[1:], tokenize = False, add_generation_prompt = True + ) + assert correct_prompt == our_prompt def test_hf_gguf_equivalence(tokenizer, gguf_model = "./model-unsloth.F16.gguf"): """ - Carefully checks the output of GGUF's tokenization and HF. - Can catch all tokenization bugs. + Carefully checks the output of GGUF's tokenization and HF. + Can catch all tokenization bugs. """ import subprocess import re + messages = [ {"role": "user", "content": "What is 2+2?"}, {"role": "assistant", "content": "It's 4."}, @@ -2697,14 +3097,18 @@ def test_hf_gguf_equivalence(tokenizer, gguf_model = "./model-unsloth.F16.gguf") ### Response: {}""".format( - "Describe the city given eloquently.", # instruction - "The lost city of Atlantis.", # input - "", # output - leave this blank for generation! + "Describe the city given eloquently.", # instruction + "The lost city of Atlantis.", # input + "", # output - leave this blank for generation! ) - prompts = [ prompt, ] + prompts = [ + prompt, + ] if tokenizer.chat_template is not None: - prompt = tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) + prompt = tokenizer.apply_chat_template( + messages, tokenize = False, add_generation_prompt = True + ) prompt = remove_special_tokens(tokenizer, prompt) prompts.append(prompt) @@ -2712,23 +3116,41 @@ def test_hf_gguf_equivalence(tokenizer, gguf_model = "./model-unsloth.F16.gguf") # Use a list of args with shell=False so prompt content is passed literally. command = [ "./llama.cpp/llama-cli", - "-m", gguf_model, - "-n", "0", - "--temp", "0.0", + "-m", + gguf_model, + "-n", + "0", + "--temp", + "0.0", "--verbose-prompt", "--check-tensors", - "-p", prompt, + "-p", + prompt, ] datas = [] - with subprocess.Popen(command, shell = False, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, bufsize = 1) as sp: + with subprocess.Popen( + command, + shell = False, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT, + bufsize = 1, + ) as sp: for line in sp.stdout: datas.append(line.decode("utf-8", errors = "replace")) gguf_tokens = "".join(datas) # Now extract GGUF tokenization attempt - gguf_tokenized = re.findall(r"([\d]{1,}) \-\> \'([^\']{1,})\'", gguf_tokens, flags = re.MULTILINE) - gguf_tokenized = [(int(x[0]), x[1],) for x in gguf_tokenized] + gguf_tokenized = re.findall( + r"([\d]{1,}) \-\> \'([^\']{1,})\'", gguf_tokens, flags = re.MULTILINE + ) + gguf_tokenized = [ + ( + int(x[0]), + x[1], + ) + for x in gguf_tokenized + ] input_ids = tokenizer(prompt).input_ids tokens = tokenizer.batch_decode(input_ids) @@ -2736,7 +3158,7 @@ def test_hf_gguf_equivalence(tokenizer, gguf_model = "./model-unsloth.F16.gguf") # Compare to Huggingface for j, (hf_token, gguf_token) in enumerate(zip(hf_tokenized, gguf_tokenized)): - if (hf_token[0] != gguf_token[0]): + if hf_token[0] != gguf_token[0]: print("Failed GGUF != HF at", j) print("HF =", hf_token) print("GGUF =", gguf_token) diff --git a/unsloth/dataprep/raw_text.py b/unsloth/dataprep/raw_text.py index ba010edabb..a643340d44 100644 --- a/unsloth/dataprep/raw_text.py +++ b/unsloth/dataprep/raw_text.py @@ -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 diff --git a/unsloth/dataprep/synthetic.py b/unsloth/dataprep/synthetic.py index 612c531f47..6e06cb49ba 100644 --- a/unsloth/dataprep/synthetic.py +++ b/unsloth/dataprep/synthetic.py @@ -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 diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py index ca44a0ce7e..6792d7a995 100644 --- a/unsloth/import_fixes.py +++ b/unsloth/import_fixes.py @@ -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( diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py index d92229314f..3e40b4da69 100644 --- a/unsloth/kernels/cross_entropy_loss.py +++ b/unsloth/kernels/cross_entropy_loss.py @@ -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, ) diff --git a/unsloth/kernels/fast_lora.py b/unsloth/kernels/fast_lora.py index f1c0e298d9..0a5eb62223 100644 --- a/unsloth/kernels/fast_lora.py +++ b/unsloth/kernels/fast_lora.py @@ -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, diff --git a/unsloth/kernels/flex_attention.py b/unsloth/kernels/flex_attention.py index b94ff56dec..e65dc7b7b0 100644 --- a/unsloth/kernels/flex_attention.py +++ b/unsloth/kernels/flex_attention.py @@ -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): diff --git a/unsloth/kernels/fp8.py b/unsloth/kernels/fp8.py index a57f4ffb64..3f9fc51b5f 100644 --- a/unsloth/kernels/fp8.py +++ b/unsloth/kernels/fp8.py @@ -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" diff --git a/unsloth/kernels/geglu.py b/unsloth/kernels/geglu.py index 50b4e521d3..e3d51715a7 100644 --- a/unsloth/kernels/geglu.py +++ b/unsloth/kernels/geglu.py @@ -16,7 +16,6 @@ import triton import triton.language as tl import torch from .utils import ( - calculate_settings, triton_tanh, torch_gpu_device, ) diff --git a/unsloth/kernels/layernorm.py b/unsloth/kernels/layernorm.py index 9e64c3d341..faf0f87f9f 100644 --- a/unsloth/kernels/layernorm.py +++ b/unsloth/kernels/layernorm.py @@ -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 diff --git a/unsloth/kernels/moe/autotune_cache.py b/unsloth/kernels/moe/autotune_cache.py index f23d9688ea..9b5d1d7d40 100644 --- a/unsloth/kernels/moe/autotune_cache.py +++ b/unsloth/kernels/moe/autotune_cache.py @@ -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__) diff --git a/unsloth/kernels/moe/benchmark/utils.py b/unsloth/kernels/moe/benchmark/utils.py index 21905d8df1..0e2ab317d9 100644 --- a/unsloth/kernels/moe/benchmark/utils.py +++ b/unsloth/kernels/moe/benchmark/utils.py @@ -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" diff --git a/unsloth/kernels/moe/grouped_gemm/interface.py b/unsloth/kernels/moe/grouped_gemm/interface.py index 5588458973..bb48ba96ce 100644 --- a/unsloth/kernels/moe/grouped_gemm/interface.py +++ b/unsloth/kernels/moe/grouped_gemm/interface.py @@ -3,7 +3,6 @@ import logging import warnings -from dataclasses import asdict from unsloth import DEVICE_TYPE import torch diff --git a/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py b/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py index d25913975e..38d06ebec0 100644 --- a/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py +++ b/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py @@ -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 diff --git a/unsloth/kernels/moe/grouped_gemm/kernels/backward.py b/unsloth/kernels/moe/grouped_gemm/kernels/backward.py index 5e07056b52..0ea1be8294 100644 --- a/unsloth/kernels/moe/grouped_gemm/kernels/backward.py +++ b/unsloth/kernels/moe/grouped_gemm/kernels/backward.py @@ -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 diff --git a/unsloth/kernels/moe/grouped_gemm/kernels/forward.py b/unsloth/kernels/moe/grouped_gemm/kernels/forward.py index a42ec5ffe9..cb8264ea9d 100644 --- a/unsloth/kernels/moe/grouped_gemm/kernels/forward.py +++ b/unsloth/kernels/moe/grouped_gemm/kernels/forward.py @@ -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 diff --git a/unsloth/kernels/moe/tests/test_grouped_gemm.py b/unsloth/kernels/moe/tests/test_grouped_gemm.py index bd98b6a276..23e1910e38 100644 --- a/unsloth/kernels/moe/tests/test_grouped_gemm.py +++ b/unsloth/kernels/moe/tests/test_grouped_gemm.py @@ -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 ( diff --git a/unsloth/kernels/moe/tests/test_llama4_moe.py b/unsloth/kernels/moe/tests/test_llama4_moe.py index 13ad552bf4..0b22b94dbd 100644 --- a/unsloth/kernels/moe/tests/test_llama4_moe.py +++ b/unsloth/kernels/moe/tests/test_llama4_moe.py @@ -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 diff --git a/unsloth/kernels/swiglu.py b/unsloth/kernels/swiglu.py index b3ae9d40e6..6ed686839e 100644 --- a/unsloth/kernels/swiglu.py +++ b/unsloth/kernels/swiglu.py @@ -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 diff --git a/unsloth/kernels/utils.py b/unsloth/kernels/utils.py index 90f2d5d238..7526ae1730 100644 --- a/unsloth/kernels/utils.py +++ b/unsloth/kernels/utils.py @@ -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 diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index abdd19c615..1137d23c40 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -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__) diff --git a/unsloth/models/cohere.py b/unsloth/models/cohere.py index 4251f3acd9..2716f3fd23 100644 --- a/unsloth/models/cohere.py +++ b/unsloth/models/cohere.py @@ -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) diff --git a/unsloth/models/falcon_h1.py b/unsloth/models/falcon_h1.py index 6e3b16b21b..2fca99c088 100644 --- a/unsloth/models/falcon_h1.py +++ b/unsloth/models/falcon_h1.py @@ -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 diff --git a/unsloth/models/gemma.py b/unsloth/models/gemma.py index cf543ae094..c00596746f 100644 --- a/unsloth/models/gemma.py +++ b/unsloth/models/gemma.py @@ -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) diff --git a/unsloth/models/gemma2.py b/unsloth/models/gemma2.py index e59b8d5ebd..2aea84f751 100644 --- a/unsloth/models/gemma2.py +++ b/unsloth/models/gemma2.py @@ -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 diff --git a/unsloth/models/glm4_moe.py b/unsloth/models/glm4_moe.py index 5d04b2f1d0..05a7d77e79 100644 --- a/unsloth/models/glm4_moe.py +++ b/unsloth/models/glm4_moe.py @@ -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 diff --git a/unsloth/models/granite.py b/unsloth/models/granite.py index 79ac41c43f..d522129900 100644 --- a/unsloth/models/granite.py +++ b/unsloth/models/granite.py @@ -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() diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 93d93e26d6..be5d42f627 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -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" diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index b54ceaf842..146f4a6b6d 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -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 ( diff --git a/unsloth/models/loader_utils.py b/unsloth/models/loader_utils.py index cf5af983a6..9f571a2ae6 100644 --- a/unsloth/models/loader_utils.py +++ b/unsloth/models/loader_utils.py @@ -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 ( diff --git a/unsloth/models/mapper.py b/unsloth/models/mapper.py index f0f430eb7e..38a289f551 100644 --- a/unsloth/models/mapper.py +++ b/unsloth/models/mapper.py @@ -20,1333 +20,1310 @@ __all__ = [ "FLOAT_TO_FP8_ROW_MAPPER", ] -__INT_TO_FLOAT_MAPPER = \ -{ - "unsloth/mistral-7b-bnb-4bit" : ( +__INT_TO_FLOAT_MAPPER = { + "unsloth/mistral-7b-bnb-4bit": ( "unsloth/mistral-7b", "mistralai/Mistral-7B-v0.1", ), - "unsloth/llama-2-7b-bnb-4bit" : ( + "unsloth/llama-2-7b-bnb-4bit": ( "unsloth/llama-2-7b", "meta-llama/Llama-2-7b-hf", ), - "unsloth/llama-2-13b-bnb-4bit" : ( + "unsloth/llama-2-13b-bnb-4bit": ( "unsloth/llama-2-13b", "meta-llama/Llama-2-13b-hf", ), - "unsloth/codellama-34b-bnb-4bit" : ( - "codellama/CodeLlama-34b-hf", - ), - "unsloth/zephyr-sft-bnb-4bit" : ( + "unsloth/codellama-34b-bnb-4bit": ("codellama/CodeLlama-34b-hf",), + "unsloth/zephyr-sft-bnb-4bit": ( "unsloth/zephyr-sft", "HuggingFaceH4/mistral-7b-sft-beta", ), - "unsloth/tinyllama-bnb-4bit" : ( + "unsloth/tinyllama-bnb-4bit": ( "unsloth/tinyllama", "TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T", ), - "unsloth/tinyllama-chat-bnb-4bit" : ( + "unsloth/tinyllama-chat-bnb-4bit": ( "unsloth/tinyllama-chat", "TinyLlama/TinyLlama-1.1B-Chat-v1.0", ), - "unsloth/mistral-7b-instruct-v0.1-bnb-4bit" : ( + "unsloth/mistral-7b-instruct-v0.1-bnb-4bit": ( "unsloth/mistral-7b-instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.1", ), - "unsloth/mistral-7b-instruct-v0.2-bnb-4bit" : ( + "unsloth/mistral-7b-instruct-v0.2-bnb-4bit": ( "unsloth/mistral-7b-instruct-v0.2", "mistralai/Mistral-7B-Instruct-v0.2", ), - "unsloth/llama-2-7b-chat-bnb-4bit" : ( + "unsloth/llama-2-7b-chat-bnb-4bit": ( "unsloth/llama-2-7b-chat", "meta-llama/Llama-2-7b-chat-hf", ), - "unsloth/llama-2-7b-chat-bnb-4bit" : ( + "unsloth/llama-2-7b-chat-bnb-4bit": ( "unsloth/llama-2-7b-chat", "meta-llama/Llama-2-7b-chat-hf", ), - "unsloth/Mixtral-8x7B-v0.1-unsloth-bnb-4bit" : ( + "unsloth/Mixtral-8x7B-v0.1-unsloth-bnb-4bit": ( "unsloth/Mixtral-8x7B-v0.1", "mistralai/Mixtral-8x7B-v0.1", "unsloth/Mixtral-8x7B-v0.1-bnb-4bit", ), - "unsloth/Mixtral-8x7B-Instruct-v0.1-unsloth-bnb-4bit" : ( + "unsloth/Mixtral-8x7B-Instruct-v0.1-unsloth-bnb-4bit": ( "unsloth/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x7B-Instruct-v0.1", "unsloth/Mixtral-8x7B-Instruct-v0.1-bnb-4bit", ), - "unsloth/codellama-7b-bnb-4bit" : ( + "unsloth/codellama-7b-bnb-4bit": ( "unsloth/codellama-7b", "codellama/CodeLlama-7b-hf", ), - "unsloth/codellama-13b-bnb-4bit" : ( - "codellama/CodeLlama-13b-hf", - ), - "unsloth/yi-6b-bnb-4bit" : ( + "unsloth/codellama-13b-bnb-4bit": ("codellama/CodeLlama-13b-hf",), + "unsloth/yi-6b-bnb-4bit": ( "unsloth/yi-6b", "01-ai/Yi-6B", ), - "unsloth/solar-10.7b-bnb-4bit" : ( - "upstage/SOLAR-10.7B-v1.0", - ), - "unsloth/gemma-7b-bnb-4bit" : ( + "unsloth/solar-10.7b-bnb-4bit": ("upstage/SOLAR-10.7B-v1.0",), + "unsloth/gemma-7b-bnb-4bit": ( "unsloth/gemma-7b", "google/gemma-7b", ), - "unsloth/gemma-2b-bnb-4bit" : ( + "unsloth/gemma-2b-bnb-4bit": ( "unsloth/gemma-2b", "google/gemma-2b", ), - "unsloth/gemma-7b-it-bnb-4bit" : ( + "unsloth/gemma-7b-it-bnb-4bit": ( "unsloth/gemma-7b-it", "google/gemma-7b-it", ), - "unsloth/gemma-2b-bnb-4bit" : ( + "unsloth/gemma-2b-bnb-4bit": ( "unsloth/gemma-2b-it", "google/gemma-2b-it", ), - "unsloth/mistral-7b-v0.2-bnb-4bit" : ( + "unsloth/mistral-7b-v0.2-bnb-4bit": ( "unsloth/mistral-7b-v0.2", "alpindale/Mistral-7B-v0.2-hf", ), - "unsloth/gemma-1.1-2b-it-bnb-4bit" : ( + "unsloth/gemma-1.1-2b-it-bnb-4bit": ( "unsloth/gemma-1.1-2b-it", "google/gemma-1.1-2b-it", ), - "unsloth/gemma-1.1-7b-it-bnb-4bit" : ( + "unsloth/gemma-1.1-7b-it-bnb-4bit": ( "unsloth/gemma-1.1-7b-it", "google/gemma-1.1-7b-it", ), - "unsloth/Starling-LM-7B-beta" : ( + "unsloth/Starling-LM-7B-beta": ( "unsloth/Starling-LM-7B-beta", "Nexusflow/Starling-LM-7B-beta", ), - "unsloth/Hermes-2-Pro-Mistral-7B-bnb-4bit" : ( + "unsloth/Hermes-2-Pro-Mistral-7B-bnb-4bit": ( "unsloth/Hermes-2-Pro-Mistral-7B", "NousResearch/Hermes-2-Pro-Mistral-7B", ), - "unsloth/OpenHermes-2.5-Mistral-7B-bnb-4bit" : ( + "unsloth/OpenHermes-2.5-Mistral-7B-bnb-4bit": ( "unsloth/OpenHermes-2.5-Mistral-7B", "teknium/OpenHermes-2.5-Mistral-7B", ), - "unsloth/codegemma-2b-bnb-4bit" : ( + "unsloth/codegemma-2b-bnb-4bit": ( "unsloth/codegemma-2b", "google/codegemma-2b", ), - "unsloth/codegemma-7b-bnb-4bit" : ( + "unsloth/codegemma-7b-bnb-4bit": ( "unsloth/codegemma-7b", "google/codegemma-7b", ), - "unsloth/codegemma-7b-it-bnb-4bit" : ( + "unsloth/codegemma-7b-it-bnb-4bit": ( "unsloth/codegemma-7b-it", "google/codegemma-7b-it", ), - "unsloth/llama-3-8b-bnb-4bit" : ( + "unsloth/llama-3-8b-bnb-4bit": ( "unsloth/llama-3-8b", "meta-llama/Meta-Llama-3-8B", ), - "unsloth/llama-3-8b-Instruct-bnb-4bit" : ( + "unsloth/llama-3-8b-Instruct-bnb-4bit": ( "unsloth/llama-3-8b-Instruct", "meta-llama/Meta-Llama-3-8B-Instruct", ), - "unsloth/llama-3-70b-bnb-4bit" : ( - "meta-llama/Meta-Llama-3-70B", - ), - "unsloth/llama-3-70b-Instruct-bnb-4bit" : ( - "meta-llama/Meta-Llama-3-70B-Instruct", - ), - "unsloth/Phi-3-mini-4k-instruct-bnb-4bit" : ( + "unsloth/llama-3-70b-bnb-4bit": ("meta-llama/Meta-Llama-3-70B",), + "unsloth/llama-3-70b-Instruct-bnb-4bit": ("meta-llama/Meta-Llama-3-70B-Instruct",), + "unsloth/Phi-3-mini-4k-instruct-bnb-4bit": ( "unsloth/Phi-3-mini-4k-instruct", "microsoft/Phi-3-mini-4k-instruct", ), - "unsloth/mistral-7b-v0.3-bnb-4bit" : ( + "unsloth/mistral-7b-v0.3-bnb-4bit": ( "unsloth/mistral-7b-v0.3", "mistralai/Mistral-7B-v0.3", ), - "unsloth/mistral-7b-instruct-v0.3-bnb-4bit" : ( + "unsloth/mistral-7b-instruct-v0.3-bnb-4bit": ( "unsloth/mistral-7b-instruct-v0.3", "mistralai/Mistral-7B-Instruct-v0.3", ), - "unsloth/Phi-3-medium-4k-instruct-bnb-4bit" : ( + "unsloth/Phi-3-medium-4k-instruct-bnb-4bit": ( "unsloth/Phi-3-medium-4k-instruct", "microsoft/Phi-3-medium-4k-instruct", ), - "unsloth/Qwen2-0.5B-bnb-4bit" : ( + "unsloth/Qwen2-0.5B-bnb-4bit": ( "unsloth/Qwen2-0.5B", "Qwen/Qwen2-0.5B", ), - "unsloth/Qwen2-0.5B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2-0.5B-Instruct-bnb-4bit": ( "unsloth/Qwen2-0.5B-Instruct", "Qwen/Qwen2-0.5B-Instruct", ), - "unsloth/Qwen2-1.5B-bnb-4bit" : ( + "unsloth/Qwen2-1.5B-bnb-4bit": ( "unsloth/Qwen2-1.5B", "Qwen/Qwen2-1.5B", ), - "unsloth/Qwen2-1.5B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2-1.5B-Instruct-bnb-4bit": ( "unsloth/Qwen2-1.5B-Instruct", "Qwen/Qwen2-1.5B-Instruct", ), - "unsloth/Qwen2-7B-bnb-4bit" : ( + "unsloth/Qwen2-7B-bnb-4bit": ( "unsloth/Qwen2-7B", "Qwen/Qwen2-7B", ), - "unsloth/Qwen2-7B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2-7B-Instruct-bnb-4bit": ( "unsloth/Qwen2-7B-Instruct", "Qwen/Qwen2-7B-Instruct", ), - "unsloth/Qwen2-70B-bnb-4bit" : ( - "Qwen/Qwen2-70B", - ), - "unsloth/Qwen2-70B-Instruct-bnb-4bit" : ( - "Qwen/Qwen2-70B-Instruct", - ), - "mistralai/Codestral-22B-v0.1" : ( - "mistral-community/Codestral-22B-v0.1", - ), - "unsloth/gemma-2-9b-bnb-4bit" : ( + "unsloth/Qwen2-70B-bnb-4bit": ("Qwen/Qwen2-70B",), + "unsloth/Qwen2-70B-Instruct-bnb-4bit": ("Qwen/Qwen2-70B-Instruct",), + "mistralai/Codestral-22B-v0.1": ("mistral-community/Codestral-22B-v0.1",), + "unsloth/gemma-2-9b-bnb-4bit": ( "unsloth/gemma-2-9b", "google/gemma-2-9b", ), - "unsloth/gemma-2-27b-bnb-4bit" : ( + "unsloth/gemma-2-27b-bnb-4bit": ( "unsloth/gemma-2-27b", "google/gemma-2-27b", ), - "unsloth/gemma-2-9b-it-bnb-4bit" : ( + "unsloth/gemma-2-9b-it-bnb-4bit": ( "unsloth/gemma-2-9b-it", "google/gemma-2-9b-it", ), - "unsloth/gemma-2-27b-it-bnb-4bit" : ( + "unsloth/gemma-2-27b-it-bnb-4bit": ( "unsloth/gemma-2-27b-it", "google/gemma-2-27b-it", ), - "unsloth/Phi-3-mini-4k-instruct-v0-bnb-4bit" : ( # Old Phi pre July + "unsloth/Phi-3-mini-4k-instruct-v0-bnb-4bit": ( # Old Phi pre July "unsloth/Phi-3-mini-4k-instruct-v0", ), - "unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit" : ( # New 12b Mistral models + "unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit": ( # New 12b Mistral models "unsloth/Mistral-Nemo-Instruct-2407", "mistralai/Mistral-Nemo-Instruct-2407", ), - "unsloth/Mistral-Nemo-Base-2407-bnb-4bit" : ( # New 12b Mistral models + "unsloth/Mistral-Nemo-Base-2407-bnb-4bit": ( # New 12b Mistral models "unsloth/Mistral-Nemo-Base-2407", "mistralai/Mistral-Nemo-Base-2407", ), - "unsloth/Meta-Llama-3.1-8B-unsloth-bnb-4bit" : ( + "unsloth/Meta-Llama-3.1-8B-unsloth-bnb-4bit": ( "unsloth/Meta-Llama-3.1-8B", "meta-llama/Meta-Llama-3.1-8B", "unsloth/Meta-Llama-3.1-8B-bnb-4bit", ), - "unsloth/Meta-Llama-3.1-8B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Meta-Llama-3.1-8B-Instruct-unsloth-bnb-4bit": { + "8": ( "RedHatAI/Llama-3.1-8B-Instruct-FP8", "unsloth/Llama-3.1-8B-Instruct-FP8-Block", "unsloth/Llama-3.1-8B-Instruct-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Meta-Llama-3.1-8B-Instruct", "meta-llama/Meta-Llama-3.1-8B-Instruct", "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit", ), }, - "unsloth/Llama-3.1-8B-unsloth-bnb-4bit" : ( + "unsloth/Llama-3.1-8B-unsloth-bnb-4bit": ( "unsloth/Llama-3.1-8B", "meta-llama/Llama-3.1-8B", "unsloth/Llama-3.1-8B-bnb-4bit", ), - "unsloth/Llama-3.1-8B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Llama-3.1-8B-Instruct-unsloth-bnb-4bit": { + "8": ( "RedHatAI/Llama-3.1-8B-Instruct-FP8", "unsloth/Llama-3.1-8B-Instruct-FP8-Block", "unsloth/Llama-3.1-8B-Instruct-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Llama-3.1-8B-Instruct", "meta-llama/Llama-3.1-8B-Instruct", "unsloth/Llama-3.1-8B-Instruct-bnb-4bit", ), }, - "unsloth/Meta-Llama-3.1-70B-bnb-4bit" : ( + "unsloth/Meta-Llama-3.1-70B-bnb-4bit": ( "unsloth/Meta-Llama-3.1-70B", "meta-llama/Meta-Llama-3.1-70B", ), - "unsloth/Meta-Llama-3.1-405B-bnb-4bit" : ( - "meta-llama/Meta-Llama-3.1-405B", - ), - "unsloth/Meta-Llama-3.1-405B-Instruct-bnb-4bit" : ( + "unsloth/Meta-Llama-3.1-405B-bnb-4bit": ("meta-llama/Meta-Llama-3.1-405B",), + "unsloth/Meta-Llama-3.1-405B-Instruct-bnb-4bit": ( "meta-llama/Meta-Llama-3.1-405B-Instruct", ), - "unsloth/Meta-Llama-3.1-70B-Instruct-bnb-4bit" : ( + "unsloth/Meta-Llama-3.1-70B-Instruct-bnb-4bit": ( "unsloth/Meta-Llama-3.1-70B-Instruct", "meta-llama/Meta-Llama-3.1-70B-Instruct", ), - "unsloth/Mistral-Large-Instruct-2407-bnb-4bit" : ( + "unsloth/Mistral-Large-Instruct-2407-bnb-4bit": ( "mistralai/Mistral-Large-Instruct-2407", ), - "unsloth/gemma-2-2b-bnb-4bit" : ( + "unsloth/gemma-2-2b-bnb-4bit": ( "unsloth/gemma-2-2b", "google/gemma-2-2b", ), - "unsloth/gemma-2-2b-it-bnb-4bit" : ( + "unsloth/gemma-2-2b-it-bnb-4bit": ( "unsloth/gemma-2-2b-it", "google/gemma-2-2b-it", ), - "unsloth/Phi-3.5-mini-instruct-bnb-4bit" : ( + "unsloth/Phi-3.5-mini-instruct-bnb-4bit": ( "unsloth/Phi-3.5-mini-instruct", "microsoft/Phi-3.5-mini-instruct", ), - "unsloth/c4ai-command-r-08-2024-bnb-4bit" : ( - "CohereForAI/c4ai-command-r-08-2024", - ), - "unsloth/c4ai-command-r-plus-08-2024-bnb-4bit" : ( + "unsloth/c4ai-command-r-08-2024-bnb-4bit": ("CohereForAI/c4ai-command-r-08-2024",), + "unsloth/c4ai-command-r-plus-08-2024-bnb-4bit": ( "CohereForAI/c4ai-command-r-plus-08-2024", ), - "unsloth/Llama-3.1-Storm-8B-bnb-4bit" : ( + "unsloth/Llama-3.1-Storm-8B-bnb-4bit": ( "unsloth/Llama-3.1-Storm-8B", "akjindal53244/Llama-3.1-Storm-8B", ), - "unsloth/Hermes-3-Llama-3.1-8B-bnb-4bit" : ( + "unsloth/Hermes-3-Llama-3.1-8B-bnb-4bit": ( "unsloth/Hermes-3-Llama-3.1-8B", "NousResearch/Hermes-3-Llama-3.1-8B", ), - "unsloth/Hermes-3-Llama-3.1-70B-bnb-4bit" : ( + "unsloth/Hermes-3-Llama-3.1-70B-bnb-4bit": ( "unsloth/Hermes-3-Llama-3.1-70B", "NousResearch/Hermes-3-Llama-3.1-70B", ), - "unsloth/Hermes-3-Llama-3.1-405B-bnb-4bit" : ( + "unsloth/Hermes-3-Llama-3.1-405B-bnb-4bit": ( "NousResearch/Hermes-3-Llama-3.1-405B", ), - "unsloth/SmolLM-135M-bnb-4bit" : ( + "unsloth/SmolLM-135M-bnb-4bit": ( "unsloth/SmolLM-135M", "HuggingFaceTB/SmolLM-135M", ), - "unsloth/SmolLM-360M-bnb-4bit" : ( + "unsloth/SmolLM-360M-bnb-4bit": ( "unsloth/SmolLM-360M", "HuggingFaceTB/SmolLM-360M", ), - "unsloth/SmolLM-1.7B-bnb-4bit" : ( + "unsloth/SmolLM-1.7B-bnb-4bit": ( "unsloth/SmolLM-1.7B", "HuggingFaceTB/SmolLM-1.7B", ), - "unsloth/SmolLM-135M-Instruct-bnb-4bit" : ( + "unsloth/SmolLM-135M-Instruct-bnb-4bit": ( "unsloth/SmolLM-135M-Instruct", "HuggingFaceTB/SmolLM-135M-Instruct", ), - "unsloth/SmolLM-360M-Instruct-bnb-4bit" : ( + "unsloth/SmolLM-360M-Instruct-bnb-4bit": ( "unsloth/SmolLM-360M-Instruct", "HuggingFaceTB/SmolLM-360M-Instruct", ), - "unsloth/SmolLM-1.7B-Instruct-bnb-4bit" : ( + "unsloth/SmolLM-1.7B-Instruct-bnb-4bit": ( "unsloth/SmolLM-1.7B-Instruct", "HuggingFaceTB/SmolLM-1.7B-Instruct", ), - "unsloth/Mistral-Small-Instruct-2409-bnb-4bit" : ( + "unsloth/Mistral-Small-Instruct-2409-bnb-4bit": ( "unsloth/Mistral-Small-Instruct-2409", "mistralai/Mistral-Small-Instruct-2409", ), - "unsloth/Qwen2.5-0.5B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-0.5B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-0.5B-Instruct", "Qwen/Qwen2.5-0.5B-Instruct", "unsloth/Qwen2.5-0.5B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-1.5B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-1.5B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-1.5B-Instruct", "Qwen/Qwen2.5-1.5B-Instruct", "unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-3B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-3B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-3B-Instruct", "Qwen/Qwen2.5-3B-Instruct", "unsloth/Qwen2.5-3B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-7B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-7B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-7B-Instruct", "Qwen/Qwen2.5-7B-Instruct", "unsloth/Qwen2.5-7B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-14B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-14B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-14B-Instruct", "Qwen/Qwen2.5-14B-Instruct", "unsloth/Qwen2.5-14B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-32B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-32B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-32B-Instruct", "Qwen/Qwen2.5-32B-Instruct", ), - "unsloth/Qwen2.5-72B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-72B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-72B-Instruct", "Qwen/Qwen2.5-72B-Instruct", ), - "unsloth/Qwen2.5-0.5B-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-0.5B-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-0.5B", "Qwen/Qwen2.5-0.5B", "unsloth/Qwen2.5-0.5B-bnb-4bit", ), - "unsloth/Qwen2.5-1.5B-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-1.5B-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-1.5B", "Qwen/Qwen2.5-1.5B", "unsloth/Qwen2.5-1.5B-bnb-4bit", ), - "unsloth/Qwen2.5-3B-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-3B-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-3B", "Qwen/Qwen2.5-3B", "unsloth/Qwen2.5-3B-bnb-4bit", ), - "unsloth/Qwen2.5-7B-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-7B-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-7B", "Qwen/Qwen2.5-7B", "unsloth/Qwen2.5-7B-bnb-4bit", ), - "unsloth/Qwen2.5-14B-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-14B-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-14B", "Qwen/Qwen2.5-14B", "unsloth/Qwen2.5-14B-bnb-4bit", ), - "unsloth/Qwen2.5-32B-bnb-4bit" : ( + "unsloth/Qwen2.5-32B-bnb-4bit": ( "unsloth/Qwen2.5-32B", "Qwen/Qwen2.5-32B", ), - "unsloth/Qwen2.5-72B-bnb-4bit" : ( + "unsloth/Qwen2.5-72B-bnb-4bit": ( "unsloth/Qwen2.5-72B", "Qwen/Qwen2.5-72B", ), - "unsloth/Qwen2.5-Math-1.5B-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-1.5B-bnb-4bit": ( "unsloth/Qwen2.5-Math-1.5B", "Qwen/Qwen2.5-Math-1.5B", ), - "unsloth/Qwen2.5-Math-7B-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-7B-bnb-4bit": ( "unsloth/Qwen2.5-Math-7B", "Qwen/Qwen2.5-Math-7B", ), - "unsloth/Qwen2.5-Math-72B-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-72B-bnb-4bit": ( "unsloth/Qwen2.5-Math-72B", "Qwen/Qwen2.5-Math-72B", ), - "unsloth/Qwen2.5-Math-1.5B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-1.5B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Math-1.5B-Instruct", "Qwen/Qwen2.5-Math-1.5B-Instruct", ), - "unsloth/Qwen2.5-Math-7B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-7B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Math-7B-Instruct", "Qwen/Qwen2.5-Math-7B-Instruct", ), - "unsloth/Qwen2.5-Math-72B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Math-72B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Math-72B-Instruct", "Qwen/Qwen2.5-Math-72B-Instruct", ), - "unsloth/Qwen2.5-Coder-0.5B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-0.5B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-0.5B", "Qwen/Qwen2.5-Coder-0.5B", ), - "unsloth/Qwen2.5-Coder-1.5B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-1.5B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-1.5B", "Qwen/Qwen2.5-Coder-1.5B", ), - "unsloth/Qwen2.5-Coder-3B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-3B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-3B", "Qwen/Qwen2.5-Coder-3B", ), - "unsloth/Qwen2.5-Coder-7B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-7B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-7B", "Qwen/Qwen2.5-Coder-7B", ), - "unsloth/Qwen2.5-Coder-14B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-14B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-14B", "Qwen/Qwen2.5-Coder-14B", ), - "unsloth/Qwen2.5-Coder-32B-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-32B-bnb-4bit": ( "unsloth/Qwen2.5-Coder-32B", "Qwen/Qwen2.5-Coder-32B", ), - "unsloth/Qwen2.5-Coder-0.5B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-0.5B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-0.5B-Instruct", "Qwen/Qwen2.5-Coder-0.5B-Instruct", ), - "unsloth/Qwen2.5-Coder-1.5B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-1.5B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-1.5B-Instruct", "Qwen/Qwen2.5-Coder-1.5B-Instruct", ), - "unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-3B-Instruct", "Qwen/Qwen2.5-Coder-3B-Instruct", ), - "unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-7B-Instruct", "Qwen/Qwen2.5-Coder-7B-Instruct", ), - "unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-14B-Instruct", "Qwen/Qwen2.5-Coder-14B-Instruct", ), - "unsloth/Qwen2.5-Coder-32B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2.5-Coder-32B-Instruct-bnb-4bit": ( "unsloth/Qwen2.5-Coder-32B-Instruct", "Qwen/Qwen2.5-Coder-32B-Instruct", ), - "unsloth/Llama-3.2-1B-unsloth-bnb-4bit" : ( + "unsloth/Llama-3.2-1B-unsloth-bnb-4bit": ( "unsloth/Llama-3.2-1B", "meta-llama/Llama-3.2-1B", "unsloth/Llama-3.2-1B-bnb-4bit", ), - "unsloth/Llama-3.2-3B-unsloth-bnb-4bit" : ( + "unsloth/Llama-3.2-3B-unsloth-bnb-4bit": ( "unsloth/Llama-3.2-3B", "meta-llama/Llama-3.2-3B", "unsloth/Llama-3.2-3B-bnb-4bit", ), - "unsloth/Llama-3.2-1B-Instruct-unsloth-bnb-4bit" : { + "unsloth/Llama-3.2-1B-Instruct-unsloth-bnb-4bit": { "8": ( "RedHatAI/Llama-3.2-1B-Instruct-FP8", "unsloth/Llama-3.2-1B-Instruct-FP8-Block", "unsloth/Llama-3.2-1B-Instruct-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Llama-3.2-1B-Instruct", "meta-llama/Llama-3.2-1B-Instruct", "unsloth/Llama-3.2-1B-Instruct-bnb-4bit", ), }, - "unsloth/Llama-3.2-3B-Instruct-unsloth-bnb-4bit" : { + "unsloth/Llama-3.2-3B-Instruct-unsloth-bnb-4bit": { "8": ( "RedHatAI/Llama-3.2-3B-Instruct-FP8", "unsloth/Llama-3.2-3B-Instruct-FP8-Block", "unsloth/Llama-3.2-3B-Instruct-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Llama-3.2-3B-Instruct", "meta-llama/Llama-3.2-3B-Instruct", "unsloth/Llama-3.2-3B-Instruct-bnb-4bit", ), }, - "unsloth/Llama-3.1-Nemotron-70B-Instruct-bnb-4bit" : ( + "unsloth/Llama-3.1-Nemotron-70B-Instruct-bnb-4bit": ( "unsloth/Llama-3.1-Nemotron-70B-Instruct", "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF", ), - "unsloth/Qwen2-VL-2B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2-VL-2B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2-VL-2B-Instruct", "Qwen/Qwen2-VL-2B-Instruct", "unsloth/Qwen2-VL-2B-Instruct-bnb-4bit", ), - "unsloth/Qwen2-VL-7B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2-VL-7B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2-VL-7B-Instruct", "Qwen/Qwen2-VL-7B-Instruct", "unsloth/Qwen2-VL-7B-Instruct-bnb-4bit", ), - "unsloth/Qwen2-VL-72B-Instruct-bnb-4bit" : ( + "unsloth/Qwen2-VL-72B-Instruct-bnb-4bit": ( "unsloth/Qwen2-VL-72B-Instruct", "Qwen/Qwen2-VL-72B-Instruct", ), - "unsloth/Qwen2-VL-2B-bnb-4bit" : ( + "unsloth/Qwen2-VL-2B-bnb-4bit": ( "unsloth/Qwen2-VL-2B", "Qwen/Qwen2-VL-2B", ), - "unsloth/Qwen2-VL-7B-bnb-4bit" : ( + "unsloth/Qwen2-VL-7B-bnb-4bit": ( "unsloth/Qwen2-VL-7B", "Qwen/Qwen2-VL-7B", ), - "unsloth/Qwen2-VL-72B-bnb-4bit" : ( + "unsloth/Qwen2-VL-72B-bnb-4bit": ( "unsloth/Qwen2-VL-72B", "Qwen/Qwen2-VL-72B", ), - "unsloth/Llama-3.2-11B-Vision-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Llama-3.2-11B-Vision-Instruct-unsloth-bnb-4bit": ( "unsloth/Llama-3.2-11B-Vision-Instruct", "meta-llama/Llama-3.2-11B-Vision-Instruct", "unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit", ), - "unsloth/Llama-3.2-90B-Vision-Instruct-bnb-4bit" : ( + "unsloth/Llama-3.2-90B-Vision-Instruct-bnb-4bit": ( "unsloth/Llama-3.2-90B-Vision-Instruct", "meta-llama/Llama-3.2-90B-Vision-Instruct", ), - "unsloth/Llama-3.2-11B-Vision-unsloth-bnb-4bit" : ( + "unsloth/Llama-3.2-11B-Vision-unsloth-bnb-4bit": ( "unsloth/Llama-3.2-11B-Vision", "meta-llama/Llama-3.2-11B-Vision", "unsloth/Llama-3.2-11B-Vision-bnb-4bit", ), - "unsloth/Llama-3.2-90B-Vision-bnb-4bit" : ( + "unsloth/Llama-3.2-90B-Vision-bnb-4bit": ( "unsloth/Llama-3.2-90B-Vision", "meta-llama/Llama-3.2-90B-Vision", ), - "unsloth/Pixtral-12B-2409-unsloth-bnb-4bit" : ( + "unsloth/Pixtral-12B-2409-unsloth-bnb-4bit": ( "unsloth/Pixtral-12B-2409", "mistralai/Pixtral-12B-2409", "unsloth/Pixtral-12B-2409-bnb-4bit", ), - "unsloth/Pixtral-12B-2409-Base-bnb-4bit" : ( + "unsloth/Pixtral-12B-2409-Base-bnb-4bit": ( "unsloth/Pixtral-12B-Base-2409", "mistralai/Pixtral-12B-Base-2409", ), - "unsloth/llava-1.5-7b-hf-bnb-4bit" : ( + "unsloth/llava-1.5-7b-hf-bnb-4bit": ( "unsloth/llava-1.5-7b-hf", "llava-hf/llava-1.5-7b-hf", ), - "unsloth/llava-v1.6-mistral-7b-hf-bnb-4bit" : ( + "unsloth/llava-v1.6-mistral-7b-hf-bnb-4bit": ( "unsloth/llava-v1.6-mistral-7b-hf", "llava-hf/llava-v1.6-mistral-7b-hf", ), - "unsloth/Llama-3.1-Tulu-3-8B-bnb-4bit" : ( + "unsloth/Llama-3.1-Tulu-3-8B-bnb-4bit": ( "unsloth/Llama-3.1-Tulu-3-8B", "allenai/Llama-3.1-Tulu-3-8B", ), - "unsloth/Llama-3.1-Tulu-3-70B-bnb-4bit" : ( + "unsloth/Llama-3.1-Tulu-3-70B-bnb-4bit": ( "unsloth/Llama-3.1-Tulu-3-70B", "allenai/Llama-3.1-Tulu-3-70B", ), - "unsloth/QwQ-32B-Preview-bnb-4bit" : ( + "unsloth/QwQ-32B-Preview-bnb-4bit": ( "unsloth/QwQ-32B-Preview", "Qwen/QwQ-32B-Preview", ), - "unsloth/Llama-3.3-70B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Llama-3.3-70B-Instruct-unsloth-bnb-4bit": { + "8": ( "RedHatAI/Llama-3.3-70B-Instruct-FP8", "unsloth/Llama-3.3-70B-Instruct-FP8-Block", "unsloth/Llama-3.3-70B-Instruct-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Llama-3.3-70B-Instruct", "meta-llama/Llama-3.3-70B-Instruct", "unsloth/Llama-3.3-70B-Instruct-bnb-4bit", ), }, - "unsloth/phi-4-unsloth-bnb-4bit" : ( + "unsloth/phi-4-unsloth-bnb-4bit": ( "unsloth/phi-4", "microsoft/phi-4", "unsloth/phi-4-bnb-4bit", ), - "unsloth/DeepSeek-R1-Distill-Qwen-32B-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Qwen-32B-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Qwen-32B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", ), - "unsloth/DeepSeek-R1-Distill-Qwen-14B-unsloth-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Qwen-14B-unsloth-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Qwen-14B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", "unsloth/DeepSeek-R1-Distill-Qwen-14B-bnb-4bit", ), - "unsloth/DeepSeek-R1-Distill-Qwen-7B-unsloth-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Qwen-7B-unsloth-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Qwen-7B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", "unsloth/DeepSeek-R1-Distill-Qwen-7B-bnb-4bit", ), - "unsloth/DeepSeek-R1-Distill-Qwen-1.5B-unsloth-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Qwen-1.5B-unsloth-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Qwen-1.5B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", "unsloth/DeepSeek-R1-Distill-Qwen-1.5B-bnb-4bit", ), - "unsloth/DeepSeek-R1-Distill-Llama-8B-unsloth-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Llama-8B-unsloth-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Llama-8B", "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "unsloth/DeepSeek-R1-Distill-Llama-8B-bnb-4bit", ), - "unsloth/DeepSeek-R1-Distill-Llama-70B-bnb-4bit" : ( + "unsloth/DeepSeek-R1-Distill-Llama-70B-bnb-4bit": ( "unsloth/DeepSeek-R1-Distill-Llama-70B", "deepseek-ai/DeepSeek-R1-Distill-Llama-70B", ), - "unsloth/Mistral-Small-24B-Base-2501-unsloth-bnb-4bit" : ( + "unsloth/Mistral-Small-24B-Base-2501-unsloth-bnb-4bit": ( "unsloth/Mistral-Small-24B-Base-2501", "mistralai/Mistral-Small-24B-Base-2501", "unsloth/Mistral-Small-24B-Base-2501-bnb-4bit", ), - "unsloth/Mistral-Small-24B-Instruct-2501-unsloth-bnb-4bit" : ( + "unsloth/Mistral-Small-24B-Instruct-2501-unsloth-bnb-4bit": ( "unsloth/Mistral-Small-24B-Instruct-2501", "mistralai/Mistral-Small-24B-Instruct-2501", "unsloth/Mistral-Small-24B-Instruct-2501-bnb-4bit", ), - "unsloth/Qwen2.5-VL-3B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-VL-3B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-VL-3B-Instruct", "Qwen/Qwen2.5-VL-3B-Instruct", "unsloth/Qwen2.5-VL-3B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-VL-7B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-VL-7B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-VL-7B-Instruct", "Qwen/Qwen2.5-VL-7B-Instruct", "unsloth/Qwen2.5-VL-7B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-VL-32B-Instruct", "Qwen/Qwen2.5-VL-32B-Instruct", "unsloth/Qwen2.5-VL-32B-Instruct-bnb-4bit", ), - "unsloth/Qwen2.5-VL-72B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/Qwen2.5-VL-72B-Instruct-unsloth-bnb-4bit": ( "unsloth/Qwen2.5-VL-72B-Instruct", "Qwen/Qwen2.5-VL-72B-Instruct", "unsloth/Qwen2.5-VL-72B-Instruct-bnb-4bit", ), - "unsloth/DeepScaleR-1.5B-Preview-unsloth-bnb-4bit" : ( + "unsloth/DeepScaleR-1.5B-Preview-unsloth-bnb-4bit": ( "unsloth/DeepHermes-3-Llama-3-8B-Preview", "agentica-org/DeepScaleR-1.5B-Preview", "unsloth/DeepScaleR-1.5B-Preview-bnb-4bit", ), - "unsloth/OpenThinker-7B-unsloth-bnb-4bit" : ( + "unsloth/OpenThinker-7B-unsloth-bnb-4bit": ( "unsloth/OpenThinker-7B", "open-thoughts/OpenThinker-7B", "unsloth/OpenThinker-7B-bnb-4bit", ), - "unsloth/granite-3.2-2b-instruct-unsloth-bnb-4bit" : ( + "unsloth/granite-3.2-2b-instruct-unsloth-bnb-4bit": ( "unsloth/granite-3.2-2b-instruct", "ibm-granite/granite-3.2-2b-instruct", "unsloth/granite-3.2-2b-instruct-bnb-4bit", ), - "unsloth/granite-3.2-8b-instruct-unsloth-bnb-4bit" : ( + "unsloth/granite-3.2-8b-instruct-unsloth-bnb-4bit": ( "unsloth/granite-3.2-8b-instruct", "ibm-granite/granite-3.2-8b-instruct", "unsloth/granite-3.2-8b-instruct-bnb-4bit", ), - "unsloth/QwQ-32B-unsloth-bnb-4bit" : ( + "unsloth/QwQ-32B-unsloth-bnb-4bit": ( "unsloth/QwQ-32B", "Qwen/QwQ-32B", "unsloth/QwQ-32B-bnb-4bit", ), - "unsloth/gemma-3-1b-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-1b-it-unsloth-bnb-4bit": ( "unsloth/gemma-3-1b-it", "google/gemma-3-1b-it", "unsloth/gemma-3-1b-it-bnb-4bit", ), - "unsloth/gemma-3-4b-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-4b-it-unsloth-bnb-4bit": ( "unsloth/gemma-3-4b-it", "google/gemma-3-4b-it", "unsloth/gemma-3-4b-it-bnb-4bit", ), - "unsloth/gemma-3-12b-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-12b-it-unsloth-bnb-4bit": ( "unsloth/gemma-3-12b-it", "google/gemma-3-12b-it", "unsloth/gemma-3-12b-it-bnb-4bit", ), - "unsloth/gemma-3-27b-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-27b-it-unsloth-bnb-4bit": ( "unsloth/gemma-3-27b-it", "google/gemma-3-27b-it", "unsloth/gemma-3-27b-it-bnb-4bit", ), - "unsloth/gemma-3-1b-pt-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-1b-pt-unsloth-bnb-4bit": ( "unsloth/gemma-3-1b-pt", "google/gemma-3-1b-pt", "unsloth/gemma-3-1b-pt-bnb-4bit", ), - "unsloth/gemma-3-4b-pt-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-4b-pt-unsloth-bnb-4bit": ( "unsloth/gemma-3-4b-pt", "google/gemma-3-4b-pt", "unsloth/gemma-3-4b-pt-bnb-4bit", ), - "unsloth/gemma-3-12b-pt-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-12b-pt-unsloth-bnb-4bit": ( "unsloth/gemma-3-12b-pt", "google/gemma-3-12b-pt", "unsloth/gemma-3-12b-pt-bnb-4bit", ), - "unsloth/gemma-3-27b-pt-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-27b-pt-unsloth-bnb-4bit": ( "unsloth/gemma-3-27b-pt", "google/gemma-3-27b-pt", "unsloth/gemma-3-27b-pt-bnb-4bit", ), - "unsloth/reka-flash-3-unsloth-bnb-4bit" : ( + "unsloth/reka-flash-3-unsloth-bnb-4bit": ( "unsloth/reka-flash-3", "RekaAI/reka-flash-3", "unsloth/reka-flash-3-bnb-4bit", ), - "unsloth/c4ai-command-a-03-2025-unsloth-bnb-4bit" : ( + "unsloth/c4ai-command-a-03-2025-unsloth-bnb-4bit": ( "unsloth/c4ai-command-a-03-2025", "CohereForAI/c4ai-command-a-03-2025", "unsloth/c4ai-command-a-03-2025-bnb-4bit", ), - "unsloth/aya-vision-32b-unsloth-bnb-4bit" : ( + "unsloth/aya-vision-32b-unsloth-bnb-4bit": ( "unsloth/aya-vision-32b", "CohereForAI/aya-vision-32b", "unsloth/aya-vision-32b-bnb-4bit", ), - "unsloth/aya-vision-8b-unsloth-bnb-4bit" : ( + "unsloth/aya-vision-8b-unsloth-bnb-4bit": ( "unsloth/aya-vision-8b", "CohereForAI/aya-vision-8b", "unsloth/aya-vision-8b-bnb-4bit", ), - "unsloth/granite-vision-3.2-2b-unsloth-bnb-4bit" : ( + "unsloth/granite-vision-3.2-2b-unsloth-bnb-4bit": ( "unsloth/granite-vision-3.2-2b", "ibm-granite/granite-vision-3.2-2b", "unsloth/granite-vision-3.2-2b-bnb-4bit", ), - "unsloth/OLMo-2-0325-32B-Instruct-unsloth-bnb-4bit" : ( + "unsloth/OLMo-2-0325-32B-Instruct-unsloth-bnb-4bit": ( "unsloth/OLMo-2-0325-32B-Instruct", "allenai/OLMo-2-0325-32B-Instruct", "unsloth/OLMo-2-0325-32B-Instruct-bnb-4bit", ), - "unsloth/Mistral-Small-3.1-24B-Instruct-2503-unsloth-bnb-4bit" : ( + "unsloth/Mistral-Small-3.1-24B-Instruct-2503-unsloth-bnb-4bit": ( "unsloth/Mistral-Small-3.1-24B-Instruct-2503", "mistralai/Mistral-Small-3.1-24B-Instruct-2503", "unsloth/Mistral-Small-3.1-24B-Instruct-2503-bnb-4bit", ), - "unsloth/Mistral-Small-3.1-24B-Base-2503-unsloth-bnb-4bit" : ( + "unsloth/Mistral-Small-3.1-24B-Base-2503-unsloth-bnb-4bit": ( "unsloth/Mistral-Small-3.1-24B-Base-2503", "mistralai/Mistral-Small-3.1-24B-Base-2503", "unsloth/Mistral-Small-3.1-24B-Base-2503-bnb-4bit", ), - "unsloth/Qwen3-0.6B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-0.6B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-0.6B-FP8", "unsloth/Qwen3-0.6B-FP8", "unsloth/Qwen3-0.6B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-0.6B", "Qwen/Qwen3-0.6B", "unsloth/Qwen3-0.6B-bnb-4bit", ), }, - "unsloth/Qwen3-1.7B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-1.7B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-1.7B-FP8", "unsloth/Qwen3-1.7B-FP8", "unsloth/Qwen3-1.7B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-1.7B", "Qwen/Qwen3-1.7B", "unsloth/Qwen3-1.7B-bnb-4bit", ), }, - "unsloth/Qwen3-4B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-4B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-4B-FP8", "unsloth/Qwen3-4B-FP8", "unsloth/Qwen3-4B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-4B", "Qwen/Qwen3-4B", "unsloth/Qwen3-4B-bnb-4bit", ), }, - "unsloth/Qwen3-8B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-8B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-8B-FP8", "unsloth/Qwen3-8B-FP8", "unsloth/Qwen3-8B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-8B", "Qwen/Qwen3-8B", "unsloth/Qwen3-8B-bnb-4bit", ), }, - "unsloth/Qwen3-14B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-14B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-14B-FP8", "unsloth/Qwen3-14B-FP8", "unsloth/Qwen3-14B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-14B", "Qwen/Qwen3-14B", "unsloth/Qwen3-14B-bnb-4bit", ), }, - "unsloth/Qwen3-32B-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-32B-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-32B-FP8", "unsloth/Qwen3-32B-FP8", "unsloth/Qwen3-32B-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-32B", "Qwen/Qwen3-32B", "unsloth/Qwen3-32B-bnb-4bit", ), }, - "unsloth/Qwen3-30B-A3B-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-30B-A3B-unsloth-bnb-4bit": ( "unsloth/Qwen3-30B-A3B", "Qwen/Qwen3-30B-A3B", "unsloth/Qwen3-30B-A3B-bnb-4bit", ), - "unsloth/Qwen3-0.6B-Base-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-0.6B-Base-unsloth-bnb-4bit": ( "unsloth/Qwen3-0.6B-Base", "Qwen/Qwen3-0.6B-Base", "unsloth/Qwen3-0.6B-Base-bnb-4bit", ), - "unsloth/Qwen3-1.7B-Base-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-1.7B-Base-unsloth-bnb-4bit": ( "unsloth/Qwen3-1.7B-Base", "Qwen/Qwen3-1.7B-Base", "unsloth/Qwen3-1.7B-Base-bnb-4bit", ), - "unsloth/Qwen3-4B-Base-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-4B-Base-unsloth-bnb-4bit": ( "unsloth/Qwen3-4B-Base", "Qwen/Qwen3-4B-Base", "unsloth/Qwen3-4B-Base-bnb-4bit", ), - "unsloth/Qwen3-8B-Base-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-8B-Base-unsloth-bnb-4bit": ( "unsloth/Qwen3-8B-Base", "Qwen/Qwen3-8B-Base", "unsloth/Qwen3-8B-Base-bnb-4bit", ), - "unsloth/Qwen3-14B-Base-unsloth-bnb-4bit" : ( + "unsloth/Qwen3-14B-Base-unsloth-bnb-4bit": ( "unsloth/Qwen3-14B-Base", "Qwen/Qwen3-14B-Base", "unsloth/Qwen3-14B-Base-bnb-4bit", ), - "unsloth/Qwen3-30B-A3B-Base-bnb-4bit" : ( + "unsloth/Qwen3-30B-A3B-Base-bnb-4bit": ( "unsloth/Qwen3-30B-A3B-Base", "Qwen/Qwen3-30B-A3B-Base", ), - "unsloth/phi-4-reasoning-unsloth-bnb-4bit" : ( + "unsloth/phi-4-reasoning-unsloth-bnb-4bit": ( "unsloth/phi-4-reasoning", "microsoft/Phi-4-reasoning", "unsloth/phi-4-reasoning-bnb-4bit", ), - "unsloth/phi-4-reasoning-plus-unsloth-bnb-4bit" : ( + "unsloth/phi-4-reasoning-plus-unsloth-bnb-4bit": ( "unsloth/phi-4-reasoning-plus", "microsoft/Phi-4-reasoning-plus", "unsloth/phi-4-reasoning-plus-bnb-4bit", ), - "unsloth/phi-4-mini-reasoning-unsloth-bnb-4bit" : ( + "unsloth/phi-4-mini-reasoning-unsloth-bnb-4bit": ( "unsloth/phi-4-mini-reasoning", "microsoft/Phi-4-mini-reasoning", "unsloth/phi-4-mini-reasoning-bnb-4bit", ), - "unsloth/Phi-4-mini-instruct-unsloth-bnb-4bit" : ( + "unsloth/Phi-4-mini-instruct-unsloth-bnb-4bit": ( "unsloth/Phi-4-mini-instruct", "microsoft/Phi-4-mini-instruct", "unsloth/Phi-4-mini-instruct-bnb-4bit", ), - "unsloth/orpheus-3b-0.1-pretrained-unsloth-bnb-4bit" : ( + "unsloth/orpheus-3b-0.1-pretrained-unsloth-bnb-4bit": ( "unsloth/orpheus-3b-0.1-pretrained", "canopylabs/orpheus-3b-0.1-pretrained", "unsloth/orpheus-3b-0.1-pretrained-bnb-4bit", ), - "unsloth/orpheus-3b-0.1-ft-unsloth-bnb-4bit" : ( + "unsloth/orpheus-3b-0.1-ft-unsloth-bnb-4bit": ( "unsloth/orpheus-3b-0.1-ft", "canopylabs/orpheus-3b-0.1-ft", "unsloth/orpheus-3b-0.1-ft-bnb-4bit", ), - "unsloth/csm-1b" : ( + "unsloth/csm-1b": ( "unsloth/csm-1b", "sesame/csm-1b", ), - "unsloth/whisper-large-v3" : ( + "unsloth/whisper-large-v3": ( "unsloth/whisper-large-v3", "openai/whisper-large-v3", ), - "unsloth/whisper-large-v3-turbo" : ( + "unsloth/whisper-large-v3-turbo": ( "unsloth/whisper-large-v3-turbo", "openai/whisper-large-v3-turbo", ), - "unsloth/whisper-small" : ( + "unsloth/whisper-small": ( "unsloth/whisper-small", "openai/whisper-small", ), - "unsloth/CrisperWhisper" : ( + "unsloth/CrisperWhisper": ( "unsloth/CrisperWhisper", "nyrahealth/CrisperWhisper", ), - "unsloth/Llasa-1B" : ( + "unsloth/Llasa-1B": ( "unsloth/Llasa-1B", "HKUSTAudio/Llasa-1B", ), - "unsloth/Spark-TTS-0.5B" : ( + "unsloth/Spark-TTS-0.5B": ( "unsloth/Spark-TTS-0.5B", "SparkAudio/Spark-TTS-0.5B", ), - "unsloth/Llama-OuteTTS-1.0-1B" : ( + "unsloth/Llama-OuteTTS-1.0-1B": ( "unsloth/Llama-OuteTTS-1.0-1B", "OuteAI/Llama-OuteTTS-1.0-1B", ), - "unsloth/medgemma-4b-it-unsloth-bnb-4bit" : ( + "unsloth/medgemma-4b-it-unsloth-bnb-4bit": ( "unsloth/medgemma-4b-it", "google/medgemma-4b-it", "unsloth/medgemma-4b-it-bnb-4bit", ), - "unsloth/medgemma-27b-text-it-unsloth-bnb-4bit" : ( + "unsloth/medgemma-27b-text-it-unsloth-bnb-4bit": ( "unsloth/medgemma-27b-text-it", "google/medgemma-27b-text-it", "unsloth/medgemma-27b-text-it-bnb-4bit", ), - "unsloth/Devstral-Small-2505-unsloth-bnb-4bit" : ( + "unsloth/Devstral-Small-2505-unsloth-bnb-4bit": ( "unsloth/Devstral-Small-2505", "mistralai/Devstral-Small-2505", "unsloth/Devstral-Small-2505-bnb-4bit", ), - "unsloth/DeepSeek-R1-0528-Qwen3-8B-unsloth-bnb-4bit" : ( + "unsloth/DeepSeek-R1-0528-Qwen3-8B-unsloth-bnb-4bit": ( "unsloth/DeepSeek-R1-0528-Qwen3-8B", "deepseek-ai/DeepSeek-R1-0528-Qwen3-8B", "unsloth/DeepSeek-R1-0528-Qwen3-8B-bnb-4bit", ), - "unsloth/Magistral-Small-2506-unsloth-bnb-4bit" : ( + "unsloth/Magistral-Small-2506-unsloth-bnb-4bit": ( "unsloth/Magistral-Small-2506", "mistralai/Magistral-Small-2506", "unsloth/Magistral-Small-2506-bnb-4bit", ), - "unsloth/Mistral-Small-3.2-24B-Instruct-2506-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Mistral-Small-3.2-24B-Instruct-2506-unsloth-bnb-4bit": { + "8": ( "mistralai/Mistral-Small-3.2-24B-Instruct-2506", "unsloth/Mistral-Small-3.2-24B-Instruct-2506-FP8", "unsloth/Mistral-Small-3.2-24B-Instruct-2506-FP8", ), - "16" : ( + "16": ( "unsloth/Mistral-Small-3.2-24B-Instruct-2506", "mistralai/Mistral-Small-3.2-24B-Instruct-2506", "unsloth/Mistral-Small-3.2-24B-Instruct-2506-bnb-4bit", ), }, - "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit": ( "unsloth/gemma-3n-E4B-it", "google/gemma-3n-E4B-it", "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit", ), - "unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit": ( "unsloth/gemma-3n-E2B-it", "google/gemma-3n-E2B-it", "unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit", ), - "unsloth/gemma-3n-E4B-unsloth-bnb-4bit" : ( + "unsloth/gemma-3n-E4B-unsloth-bnb-4bit": ( "unsloth/gemma-3n-E4B", "google/gemma-3n-E4B", "unsloth/gemma-3n-E4B-unsloth-bnb-4bit", ), - "unsloth/gemma-3n-E2B-unsloth-bnb-4bit" : ( + "unsloth/gemma-3n-E2B-unsloth-bnb-4bit": ( "unsloth/gemma-3n-E2B", "google/gemma-3n-E2B", "unsloth/gemma-3n-E2B-unsloth-bnb-4bit", ), - "unsloth/Devstral-Small-2507-unsloth-bnb-4bit" : ( + "unsloth/Devstral-Small-2507-unsloth-bnb-4bit": ( "unsloth/Devstral-Small-2507", "mistralai/Devstral-Small-2507", "unsloth/Devstral-Small-2507-bnb-4bit", ), - "unsloth/Qwen3-30B-A3B-Thinking-2507" : ( + "unsloth/Qwen3-30B-A3B-Thinking-2507": ( "unsloth/Qwen3-30B-A3B-Thinking-2507", "Qwen/Qwen3-30B-A3B-Thinking-2507", ), - "unsloth/Qwen3-30B-A3B-Instruct-2507" : ( + "unsloth/Qwen3-30B-A3B-Instruct-2507": ( "unsloth/Qwen3-30B-A3B-Instruct-2507", "Qwen/Qwen3-30B-A3B-Instruct-2507", ), - "unsloth/Qwen3-Coder-30B-A3B-Instruct" : ( + "unsloth/Qwen3-Coder-30B-A3B-Instruct": ( "unsloth/Qwen3-Coder-30B-A3B-Instruct", "Qwen/Qwen3-Coder-30B-A3B-Instruct", ), - "unsloth/gpt-oss-20b-unsloth-bnb-4bit" : ( + "unsloth/gpt-oss-20b-unsloth-bnb-4bit": ( "unsloth/gpt-oss-20b", "openai/gpt-oss-20b", "unsloth/gpt-oss-20b-unsloth-bnb-4bit", ), - "unsloth/gpt-oss-120b-unsloth-bnb-4bit" : ( + "unsloth/gpt-oss-120b-unsloth-bnb-4bit": ( "unsloth/gpt-oss-120b", "openai/gpt-oss-120b", "unsloth/gpt-oss-120b-unsloth-bnb-4bit", ), - "unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-4B-Instruct-2507-FP8", "unsloth/Qwen3-4B-Instruct-2507-FP8", "unsloth/Qwen3-4B-Instruct-2507-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-4B-Instruct-2507", "Qwen/Qwen3-4B-Instruct-2507", "unsloth/Qwen3-4B-Instruct-2507-bnb-4bit", ), }, - "unsloth/Qwen3-4B-Thinking-2507-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-4B-Thinking-2507-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-4B-Thinking-2507-FP8", "unsloth/Qwen3-4B-Thinking-2507-FP8", "unsloth/Qwen3-4B-Thinking-2507-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-4B-Thinking-2507", "Qwen/Qwen3-4B-Thinking-2507", "unsloth/Qwen3-4B-Thinking-2507-bnb-4bit", ), }, - "unsloth/gemma-3-270m-it-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-270m-it-unsloth-bnb-4bit": ( "unsloth/gemma-3-270m-it", "google/gemma-3-270m-it", "unsloth/gemma-3-270m-it-bnb-4bit", ), - "unsloth/gemma-3-270m-unsloth-bnb-4bit" : ( + "unsloth/gemma-3-270m-unsloth-bnb-4bit": ( "unsloth/gemma-3-270m", "google/gemma-3-270m", "unsloth/gemma-3-270m-bnb-4bit", ), - "unsloth/Magistral-Small-2507-unsloth-bnb-4bit" : ( + "unsloth/Magistral-Small-2507-unsloth-bnb-4bit": ( "unsloth/Magistral-Small-2507", "mistralai/Magistral-Small-2507", "unsloth/Magistral-Small-2507-bnb-4bit", ), - "unsloth/Magistral-Small-2509-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Magistral-Small-2509-unsloth-bnb-4bit": { + "8": ( "mistralai/Magistral-Small-2509", "unsloth/Magistral-Small-2509-FP8-Dynamic", "unsloth/Magistral-Small-2509-FP8-Dynamic", ), - "16" : ( + "16": ( "unsloth/Magistral-Small-2509", "mistralai/Magistral-Small-2509", "unsloth/Magistral-Small-2509-bnb-4bit", ), }, - "unsloth/Apertus-70B-Instruct-2509-unsloth-bnb-4bit" : ( + "unsloth/Apertus-70B-Instruct-2509-unsloth-bnb-4bit": ( "unsloth/Apertus-70B-Instruct-2509", "swiss-ai/Apertus-70B-2509", "unsloth/Apertus-70B-Instruct-2509-unsloth-bnb-4bit", ), - "unsloth/Apertus-8B-Instruct-2509-unsloth-bnb-4bit" : ( + "unsloth/Apertus-8B-Instruct-2509-unsloth-bnb-4bit": ( "unsloth/Apertus-8B-Instruct-2509", "swiss-ai/Apertus-8B-2509", "unsloth/Apertus-8B-Instruct-2509-unsloth-bnb-4bit", ), - "unsloth/granite-4.0-micro-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-micro-unsloth-bnb-4bit": ( "unsloth/granite-4.0-micro", "ibm-granite/granite-4.0-micro", "unsloth/granite-4.0-micro-bnb-4bit", ), - "unsloth/granite-4.0-h-micro-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-micro-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-micro", "ibm-granite/granite-4.0-h-micro", "unsloth/granite-4.0-h-micro-bnb-4bit", ), - "unsloth/granite-4.0-micro-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-micro-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-micro-base", "ibm-granite/granite-4.0-micro-base", "unsloth/granite-4.0-micro-base-bnb-4bit", ), - "unsloth/granite-4.0-h-micro-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-micro-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-micro-base", "ibm-granite/granite-4.0-h-micro-base", "unsloth/granite-4.0-h-micro-base-bnb-4bit", ), - "unsloth/granite-4.0-h-tiny" : ( + "unsloth/granite-4.0-h-tiny": ( "unsloth/granite-4.0-h-tiny", "ibm-granite/granite-4.0-h-tiny", ), - "unsloth/granite-4.0-h-small" : ( + "unsloth/granite-4.0-h-small": ( "unsloth/granite-4.0-h-small", "ibm-granite/granite-4.0-h-small", ), - "unsloth/granite-4.0-h-tiny-base" : ( + "unsloth/granite-4.0-h-tiny-base": ( "unsloth/granite-4.0-h-tiny-base", "ibm-granite/granite-4.0-h-tiny-base", ), - "unsloth/granite-4.0-h-small-base" : ( + "unsloth/granite-4.0-h-small-base": ( "unsloth/granite-4.0-h-small-base", "ibm-granite/granite-4.0-h-small-base", ), - "unsloth/Qwen3-VL-4B-Thinking-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-4B-Thinking-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-4B-Thinking-FP8", "unsloth/Qwen3-VL-4B-Thinking-FP8", "unsloth/Qwen3-VL-4B-Thinking-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-4B-Thinking", "Qwen/Qwen3-VL-4B-Thinking", "unsloth/Qwen3-VL-4B-Thinking-bnb-4bit", ), }, - "unsloth/Qwen3-VL-8B-Thinking-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-8B-Thinking-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-8B-Thinking-FP8", "unsloth/Qwen3-VL-8B-Thinking-FP8", "unsloth/Qwen3-VL-8B-Thinking-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-8B-Thinking", "Qwen/Qwen3-VL-8B-Thinking", "unsloth/Qwen3-VL-8B-Thinking-bnb-4bit", ), }, - "unsloth/Qwen3-VL-4B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-4B-Instruct-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-4B-Instruct-FP8", "unsloth/Qwen3-VL-4B-Instruct-FP8", "unsloth/Qwen3-VL-4B-Instruct-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-4B-Instruct", "Qwen/Qwen3-VL-4B-Instruct", "unsloth/Qwen3-VL-4B-Instruct-bnb-4bit", ), }, - "unsloth/Qwen3-VL-8B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-8B-Instruct-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-8B-Instruct-FP8", "unsloth/Qwen3-VL-8B-Instruct-FP8", "unsloth/Qwen3-VL-8B-Instruct-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-8B-Instruct", "Qwen/Qwen3-VL-8B-Instruct", "unsloth/Qwen3-VL-8B-Instruct-bnb-4bit", ), }, - "unsloth/Qwen3-VL-2B-Thinking-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-2B-Thinking-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-2B-Thinking-FP8", "unsloth/Qwen3-VL-2B-Thinking-FP8", "unsloth/Qwen3-VL-2B-Thinking-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-2B-Thinking", "Qwen/Qwen3-VL-2B-Thinking", "unsloth/Qwen3-VL-2B-Thinking-bnb-4bit", ), }, - "unsloth/Qwen3-VL-32B-Thinking-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-32B-Thinking-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-32B-Thinking-FP8", "unsloth/Qwen3-VL-32B-Thinking-FP8", "unsloth/Qwen3-VL-32B-Thinking-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-32B-Thinking", "Qwen/Qwen3-VL-32B-Thinking", "unsloth/Qwen3-VL-32B-Thinking-bnb-4bit", ), }, - "unsloth/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-2B-Instruct-FP8", "unsloth/Qwen3-VL-2B-Instruct-FP8", "unsloth/Qwen3-VL-2B-Instruct-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-2B-Instruct", "Qwen/Qwen3-VL-2B-Instruct", "unsloth/Qwen3-VL-2B-Instruct-bnb-4bit", ), }, - "unsloth/Qwen3-VL-32B-Instruct-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Qwen3-VL-32B-Instruct-unsloth-bnb-4bit": { + "8": ( "Qwen/Qwen3-VL-32B-Instruct-FP8", "unsloth/Qwen3-VL-32B-Instruct-FP8", "unsloth/Qwen3-VL-32B-Instruct-FP8", ), - "16" : ( + "16": ( "unsloth/Qwen3-VL-32B-Instruct", "Qwen/Qwen3-VL-32B-Instruct", "unsloth/Qwen3-VL-32B-Instruct-bnb-4bit", ), }, - "unsloth/granite-4.0-350m-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-350m-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-350m-base", "ibm-granite/granite-4.0-350m-base", "unsloth/granite-4.0-350m-base-bnb-4bit", ), - "unsloth/granite-4.0-350m-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-350m-unsloth-bnb-4bit": ( "unsloth/granite-4.0-350m", "ibm-granite/granite-4.0-350m", "unsloth/granite-4.0-350m-bnb-4bit", ), - "unsloth/granite-4.0-h-350m-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-350m-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-350m-base", "ibm-granite/granite-4.0-h-350m-base", "unsloth/granite-4.0-h-350m-base-bnb-4bit", ), - "unsloth/granite-4.0-h-350m-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-350m-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-350m", "ibm-granite/granite-4.0-h-350m", "unsloth/granite-4.0-h-350m-bnb-4bit", ), - "unsloth/granite-4.0-1b-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-1b-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-1b-base", "ibm-granite/granite-4.0-1b-base", "unsloth/granite-4.0-1b-base-bnb-4bit", ), - "unsloth/granite-4.0-1b-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-1b-unsloth-bnb-4bit": ( "unsloth/granite-4.0-1b", "ibm-granite/granite-4.0-1b", "unsloth/granite-4.0-1b-bnb-4bit", ), - "unsloth/granite-4.0-h-1b-base-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-1b-base-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-1b-base", "ibm-granite/granite-4.0-h-1b-base", "unsloth/granite-4.0-h-1b-base-bnb-4bit", ), - "unsloth/granite-4.0-h-1b-unsloth-bnb-4bit" : ( + "unsloth/granite-4.0-h-1b-unsloth-bnb-4bit": ( "unsloth/granite-4.0-h-1b", "ibm-granite/granite-4.0-h-1b", "unsloth/granite-4.0-h-1b-bnb-4bit", ), - "unsloth/gpt-oss-safeguard-20b" : ( + "unsloth/gpt-oss-safeguard-20b": ( "unsloth/gpt-oss-safeguard-20b", "openai/gpt-oss-safeguard-20b", ), - "unsloth/gpt-oss-safeguard-120b" : ( + "unsloth/gpt-oss-safeguard-120b": ( "unsloth/gpt-oss-safeguard-120b", "openai/gpt-oss-safeguard-120b", ), - "unsloth/functiongemma-270m-it-unsloth-bnb-4bit" : ( + "unsloth/functiongemma-270m-it-unsloth-bnb-4bit": ( "unsloth/functiongemma-270m-it", "google/functiongemma-270m-it", "unsloth/functiongemma-270m-it-unsloth-bnb-4bit", ), # Ministral 3 models - "unsloth/Ministral-3-3B-Instruct-2512-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Ministral-3-3B-Instruct-2512-unsloth-bnb-4bit": { + "8": ( "mistralai/Ministral-3-3B-Instruct-2512", "unsloth/Ministral-3-3B-Instruct-2512-FP8", "unsloth/Ministral-3-3B-Instruct-2512-FP8", ), - "16" : ( + "16": ( "unsloth/Ministral-3-3B-Instruct-2512", "mistralai/Ministral-3-3B-Instruct-2512", "unsloth/Ministral-3-3B-Instruct-2512-bnb-4bit", ), }, - "unsloth/Ministral-3-3B-Base-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-3B-Base-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-3B-Base-2512", "mistralai/Ministral-3-3B-Base-2512", "unsloth/Ministral-3-3B-Base-2512-bnb-4bit", ), - "unsloth/Ministral-3-3B-Reasoning-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-3B-Reasoning-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-3B-Reasoning-2512", "mistralai/Ministral-3-3B-Reasoning-2512", "unsloth/Ministral-3-3B-Reasoning-2512-bnb-4bit", ), - "unsloth/Ministral-3-8B-Instruct-2512-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Ministral-3-8B-Instruct-2512-unsloth-bnb-4bit": { + "8": ( "mistralai/Ministral-3-8B-Instruct-2512", "unsloth/Ministral-3-8B-Instruct-2512-FP8", "unsloth/Ministral-3-8B-Instruct-2512-FP8", ), - "16" : ( + "16": ( "unsloth/Ministral-3-8B-Instruct-2512", "mistralai/Ministral-3-8B-Instruct-2512", "unsloth/Ministral-3-8B-Instruct-2512-bnb-4bit", ), }, - "unsloth/Ministral-3-8B-Base-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-8B-Base-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-8B-Base-2512", "mistralai/Ministral-3-8B-Base-2512", "unsloth/Ministral-3-8B-Base-2512-bnb-4bit", ), - "unsloth/Ministral-3-8B-Reasoning-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-8B-Reasoning-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-8B-Reasoning-2512", "mistralai/Ministral-3-8B-Reasoning-2512", "unsloth/Ministral-3-8B-Reasoning-2512-bnb-4bit", ), - "unsloth/Ministral-3-14B-Instruct-2512-unsloth-bnb-4bit" : { - "8" : ( + "unsloth/Ministral-3-14B-Instruct-2512-unsloth-bnb-4bit": { + "8": ( "mistralai/Ministral-3-14B-Instruct-2512", "unsloth/Ministral-3-14B-Instruct-2512-FP8", "unsloth/Ministral-3-14B-Instruct-2512-FP8", ), - "16" : ( + "16": ( "unsloth/Ministral-3-14B-Instruct-2512", "mistralai/Ministral-3-14B-Instruct-2512", "unsloth/Ministral-3-14B-Instruct-2512-bnb-4bit", ), }, - "unsloth/Ministral-3-14B-Base-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-14B-Base-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-14B-Base-2512", "mistralai/Ministral-3-14B-Base-2512", "unsloth/Ministral-3-14B-Base-2512-bnb-4bit", ), - "unsloth/Ministral-3-14B-Reasoning-2512-unsloth-bnb-4bit" : ( + "unsloth/Ministral-3-14B-Reasoning-2512-unsloth-bnb-4bit": ( "unsloth/Ministral-3-14B-Reasoning-2512", "mistralai/Ministral-3-14B-Reasoning-2512", "unsloth/Ministral-3-14B-Reasoning-2512-bnb-4bit", ), - "unsloth/Kimi-K2-Instruct-BF16" : ( - "unsloth/Kimi-K2-Instruct", - ), + "unsloth/Kimi-K2-Instruct-BF16": ("unsloth/Kimi-K2-Instruct",), } -INT_TO_FLOAT_MAPPER = {} -FLOAT_TO_INT_MAPPER = {} +INT_TO_FLOAT_MAPPER = {} +FLOAT_TO_INT_MAPPER = {} MAP_TO_UNSLOTH_16bit = {} FLOAT_TO_FP8_BLOCK_MAPPER = {} -FLOAT_TO_FP8_ROW_MAPPER = {} +FLOAT_TO_FP8_ROW_MAPPER = {} def _add_with_lower(mapper, key, value): @@ -1361,6 +1338,7 @@ def _add_lower_only(mapper, key, value): return mapper[key.lower()] = value + for key, values in __INT_TO_FLOAT_MAPPER.items(): block, row = None, None if type(values) is dict: diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py index 83e9ab9486..fd8dc57e41 100644 --- a/unsloth/models/mistral.py +++ b/unsloth/models/mistral.py @@ -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( diff --git a/unsloth/models/qwen3.py b/unsloth/models/qwen3.py index b93dddb186..1d008bd1a8 100644 --- a/unsloth/models/qwen3.py +++ b/unsloth/models/qwen3.py @@ -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: diff --git a/unsloth/models/qwen3_moe.py b/unsloth/models/qwen3_moe.py index e1f8c71b6b..efd58fc72e 100644 --- a/unsloth/models/qwen3_moe.py +++ b/unsloth/models/qwen3_moe.py @@ -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 diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index 5651a7da41..c5b167c50c 100755 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -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}") diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py index 9f555416d4..7def25cf94 100755 --- a/unsloth/models/rl_replacements.py +++ b/unsloth/models/rl_replacements.py @@ -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 diff --git a/unsloth/models/sentence_transformer.py b/unsloth/models/sentence_transformer.py index ad59165a50..45f49039ff 100644 --- a/unsloth/models/sentence_transformer.py +++ b/unsloth/models/sentence_transformer.py @@ -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" diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index f558aa3f00..be2214eb19 100644 --- a/unsloth/models/vision.py +++ b/unsloth/models/vision.py @@ -17,7 +17,6 @@ from transformers import ( BitsAndBytesConfig, AutoProcessor, AutoTokenizer, - AutoModelForCausalLM, ) try: @@ -62,29 +61,22 @@ from unsloth_zoo.patching_utils import patch_model_and_tokenizer from unsloth_zoo.training_utils import prepare_model_for_training from unsloth_zoo.utils import Version -from transformers import __version__ as transformers_version import types import functools import os import gc -import math -from typing import Optional, Tuple, List, Union -import re, inspect, sys -import contextlib +import inspect 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 ..device_type import ( - is_hip, - get_device_type, DEVICE_TYPE, DEVICE_TYPE_TORCH, DEVICE_COUNT, - ALLOW_PREQUANTIZED_MODELS, ) __all__ = [ @@ -108,7 +100,7 @@ PRE_COMPILE_INFERENCE = [ "gpt_oss", ] -from transformers import GenerationConfig, CompileConfig, AutoConfig +from transformers import CompileConfig, AutoConfig try: from transformers import PreTrainedConfig @@ -627,7 +619,7 @@ class FastBaseModel: default_attn_impl = "eager" else: default_attn_impl = "flex_attention" if flex_attn_impl else "sdpa" - if not ("attn_implementation" in kwargs): + if "attn_implementation" not in kwargs: kwargs["attn_implementation"] = default_attn_impl if not supports_sdpa and kwargs.get("attn_implementation") == "sdpa": if os.environ.get("UNSLOTH_ENABLE_FLEX_ATTENTION", "0") == "0": @@ -682,13 +674,13 @@ class FastBaseModel: if dtype == torch.bfloat16: if float32_mixed_precision != True: print( - f"Unsloth: Using bfloat16 full finetuning which cuts memory usage by 50%.\n" - f"To enable float32 training, use `float32_mixed_precision = True` during FastLanguageModel.from_pretrained" + "Unsloth: Using bfloat16 full finetuning which cuts memory usage by 50%.\n" + "To enable float32 training, use `float32_mixed_precision = True` during FastLanguageModel.from_pretrained" ) else: print( - f"Unsloth: Using full float32 full finetuning. " - f"To enable bfloat16 training to reduce VRAM usage by 50% albeit with a slightly higher loss, do:\n" + "Unsloth: Using full float32 full finetuning. " + "To enable bfloat16 training to reduce VRAM usage by 50% albeit with a slightly higher loss, do:\n" "use `float32_mixed_precision = False` during FastLanguageModel.from_pretrained" ) os.environ["UNSLOTH_BFLOAT16_MIXED_PRECISION"] = "1" diff --git a/unsloth/save.py b/unsloth/save.py index 1759d86fb1..47a675513b 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -38,19 +38,16 @@ from peft.tuners.lora import Linear4bit as Peft_Linear4bit from peft.tuners.lora import Linear as Peft_Linear from typing import Optional, Callable, Union, List import sys -import requests import torch import os import shutil import pickle import gc from transformers.models.llama.modeling_llama import logger -from .kernels import fast_dequantize, QUANT_STATE, get_lora_parameters_bias +from .kernels import fast_dequantize, get_lora_parameters_bias import subprocess import psutil import re -from transformers.models.llama.modeling_llama import logger -from .tokenizer_utils import fix_sentencepiece_gguf from .models.loader_utils import get_model_name from .models._utils import _convert_torchao_model from .ollama_template_mappers import OLLAMA_TEMPLATES, MODEL_TO_OLLAMA_TEMPLATE_MAPPER @@ -1239,7 +1236,7 @@ def save_to_gguf( print( f"Unsloth: [1] Converting model into {first_conversion_dtype} GGUF format." ) - print(f"This might take 3 minutes...") + print("This might take 3 minutes...") initial_files, is_vlm_update = convert_to_gguf( model_name = model_name, @@ -1362,7 +1359,7 @@ def save_to_gguf( else: want_full_precision = first_conversion in frozenset(quantization_method) - print(f"Unsloth: All GGUF conversions completed successfully!") + print("Unsloth: All GGUF conversions completed successfully!") print(f"Generated files: {all_saved_locations}") return all_saved_locations, want_full_precision, is_vlm @@ -2231,7 +2228,7 @@ def unsloth_push_to_hub_gguf( cleanup_temp = False # Step 2: Call save_pretrained_gguf to do the conversion - print(f"Unsloth: Converting model to GGUF format...") + print("Unsloth: Converting model to GGUF format...") try: # Call save_pretrained_gguf - it returns all the info we need @@ -2640,13 +2637,11 @@ def unsloth_convert_lora_to_ggml_and_save_locally( ) -from .models.loader_utils import get_model_name from unsloth_zoo.saving_utils import ( merge_and_overwrite_lora, prepare_saving, ) from unsloth_zoo.llama_cpp import ( - install_llama_cpp, convert_to_gguf as _convert_to_gguf, ) @@ -2974,7 +2969,6 @@ def _unsloth_save_torchao_with_given_config( AutoModelForImageTextToText, AutoProcessor, ) - from torchao import quantize_ if isinstance(torchao_config, TorchAoConfig): quantization_config = torchao_config @@ -3112,7 +3106,6 @@ def not_implemented_save(*args, **kwargs): def patch_saving_functions(model, vision = False): import inspect import types - from typing import Callable, Optional, Union, List # And now re add our saving methods! if model.push_to_hub.__name__ == "unsloth_push_to_hub": diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index 8be6bb5a5a..09ab936ed2 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -18,22 +18,11 @@ from transformers import PreTrainedTokenizerFast import re import os from transformers.models.llama.modeling_llama import logger -from peft import PeftModelForCausalLM import torch -import itertools -import collections import numpy as np -import gc -import subprocess -import psutil from unsloth_zoo.tokenizer_utils import ( - mean_of_trained_tokens, add_new_tokens, - fix_untrained_tokens, -) -from unsloth_zoo.training_utils import ( - fix_zero_training_loss, ) __all__ = [ @@ -357,7 +346,7 @@ def fix_sentencepiece_tokenizer( from transformers.convert_slow_tokenizer import import_protobuf sentencepiece_model_pb2 = import_protobuf() - except Exception as e: + except Exception: try: import google.protobuf from unsloth_zoo.utils import Version @@ -946,7 +935,6 @@ def get_tokenizer_info(tokenizer) -> dict: } -import inspect from inspect import getsource import trl import trl.trainer.sft_trainer @@ -991,7 +979,7 @@ def patch_sft_trainer_tokenizer(): Patches the trainer with changes """ try: - sft_trainer = eval(f"trl.trainer.sft_trainer.SFTTrainer") + sft_trainer = eval("trl.trainer.sft_trainer.SFTTrainer") except: return all_imports = dir(trl.trainer.sft_trainer) diff --git a/unsloth/trainer.py b/unsloth/trainer.py index eea985e958..b9b6d286e2 100644 --- a/unsloth/trainer.py +++ b/unsloth/trainer.py @@ -14,16 +14,13 @@ import logging import os -import psutil -import warnings -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Optional, List from functools import wraps import trl import inspect from trl import SFTTrainer -from . import is_bfloat16_supported from unsloth.utils import ( configure_padding_free, configure_sample_packing,