From a7a65d53a2e2a0825fb12477f6c4e82b065755fa Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Thu, 17 Apr 2025 12:52:37 +0200 Subject: [PATCH] python312Packages.unsloth: init at 2025.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GaƩtan Lepage <33058747+GaetanLepage@users.noreply.github.com> Co-authored-by: OTABI Tomoya --- .../python-modules/unsloth/default.nix | 92 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 94 insertions(+) create mode 100644 pkgs/development/python-modules/unsloth/default.nix diff --git a/pkgs/development/python-modules/unsloth/default.nix b/pkgs/development/python-modules/unsloth/default.nix new file mode 100644 index 000000000000..797dc6e51ac3 --- /dev/null +++ b/pkgs/development/python-modules/unsloth/default.nix @@ -0,0 +1,92 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + + # build-system + setuptools, + setuptools-scm, + + # dependencies + bitsandbytes, + numpy, + packaging, + torch, + unsloth-zoo, + xformers, + tyro, + transformers, + datasets, + sentencepiece, + tqdm, + accelerate, + trl, + peft, + protobuf, + huggingface-hub, + hf-transfer, + diffusers, + torchvision, +}: + +buildPythonPackage rec { + pname = "unsloth"; + version = "2025.4.1"; + pyproject = true; + + # Tags on the GitHub repo don't match + src = fetchPypi { + pname = "unsloth"; + inherit version; + hash = "sha256-9LtDGfdWH7R3U/xi+aK3V4zA+vs83S6Cp0F2NQKvSdY="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + bitsandbytes + numpy + packaging + torch + unsloth-zoo + xformers + tyro + transformers + datasets + sentencepiece + tqdm + accelerate + trl + peft + protobuf + huggingface-hub + hf-transfer + diffusers + torchvision + ]; + + # pyproject.toml requires an obsolete version of protobuf, + # but it is not used. + # Upstream issue: https://github.com/unslothai/unsloth-zoo/pull/68 + pythonRelaxDeps = [ + "protobuf" + ]; + + # The source repository contains no test + doCheck = false; + + # Importing requires a GPU, else the following error is raised: + # NotImplementedError: Unsloth: No NVIDIA GPU found? Unsloth currently only supports GPUs! + dontUsePythonImportsCheck = true; + + meta = { + description = "Finetune Llama 3.3, DeepSeek-R1 & Reasoning LLMs 2x faster with 70% less memory"; + homepage = "https://github.com/unslothai/unsloth"; + changelog = "https://github.com/unslothai/unsloth/releases/tag/${version}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ hoh ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 163f241b590f..1613dfd9e0b5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18433,6 +18433,8 @@ self: super: with self; { unrpa = callPackage ../development/python-modules/unrpa { }; + unsloth = callPackage ../development/python-modules/unsloth { }; + unsloth-zoo = callPackage ../development/python-modules/unsloth-zoo { }; unstructured = callPackage ../development/python-modules/unstructured { };