1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5
6 # build-system
7 setuptools,
8 setuptools-scm,
9
10 # dependencies
11 bitsandbytes,
12 numpy,
13 packaging,
14 torch,
15 unsloth-zoo,
16 xformers,
17 tyro,
18 transformers,
19 datasets,
20 sentencepiece,
21 tqdm,
22 accelerate,
23 trl,
24 peft,
25 protobuf,
26 huggingface-hub,
27 hf-transfer,
28 diffusers,
29 torchvision,
30}:
31
32buildPythonPackage rec {
33 pname = "unsloth";
34 version = "2025.9.4";
35 pyproject = true;
36
37 # Tags on the GitHub repo don't match
38 src = fetchPypi {
39 pname = "unsloth";
40 inherit version;
41 hash = "sha256-aT/RS48hBMZT1ab1Rx1lpSMi6yyEzJCASzDAP0d6ixA=";
42 };
43
44 build-system = [
45 setuptools
46 setuptools-scm
47 ];
48
49 dependencies = [
50 bitsandbytes
51 numpy
52 packaging
53 torch
54 unsloth-zoo
55 xformers
56 tyro
57 transformers
58 datasets
59 sentencepiece
60 tqdm
61 accelerate
62 trl
63 peft
64 protobuf
65 huggingface-hub
66 hf-transfer
67 diffusers
68 torchvision
69 ];
70
71 # pyproject.toml requires an obsolete version of protobuf,
72 # but it is not used.
73 # Upstream issue: https://github.com/unslothai/unsloth-zoo/pull/68
74 pythonRelaxDeps = [
75 "datasets"
76 "protobuf"
77 "transformers"
78 "torch"
79 ];
80
81 # The source repository contains no test
82 doCheck = false;
83
84 # Importing requires a GPU, else the following error is raised:
85 # NotImplementedError: Unsloth: No NVIDIA GPU found? Unsloth currently only supports GPUs!
86 dontUsePythonImportsCheck = true;
87
88 meta = {
89 description = "Finetune Llama 3.3, DeepSeek-R1 & Reasoning LLMs 2x faster with 70% less memory";
90 homepage = "https://github.com/unslothai/unsloth";
91 changelog = "https://github.com/unslothai/unsloth/releases/tag/${version}";
92 license = lib.licenses.asl20;
93 maintainers = with lib.maintainers; [ hoh ];
94 };
95}