1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 stdenv,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 accelerate,
12 huggingface-hub,
13 numpy,
14 packaging,
15 psutil,
16 pyyaml,
17 safetensors,
18 torch,
19 tqdm,
20 transformers,
21
22 # tests
23 datasets,
24 diffusers,
25 parameterized,
26 pytest-cov-stub,
27 pytest-xdist,
28 pytestCheckHook,
29 scipy,
30}:
31
32buildPythonPackage rec {
33 pname = "peft";
34 version = "0.17.1";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "huggingface";
39 repo = "peft";
40 tag = "v${version}";
41 hash = "sha256-xtpxwbKf7ZaUYblGdwtPZE09qrlBQTMm5oryUJwa6AA=";
42 };
43
44 build-system = [ setuptools ];
45
46 dependencies = [
47 accelerate
48 huggingface-hub
49 numpy
50 packaging
51 psutil
52 pyyaml
53 safetensors
54 torch
55 tqdm
56 transformers
57 ];
58
59 pythonImportsCheck = [ "peft" ];
60
61 nativeCheckInputs = [
62 datasets
63 diffusers
64 parameterized
65 pytest-cov-stub
66 pytest-xdist
67 pytestCheckHook
68 scipy
69 ];
70
71 enabledTestPaths = [ "tests" ];
72
73 # These tests fail when MPS devices are detected
74 disabledTests = lib.optional stdenv.hostPlatform.isDarwin [
75 "gpu"
76 ];
77
78 disabledTestPaths = [
79 # ValueError: Can't find 'adapter_config.json'
80 "tests/test_config.py"
81
82 # Require internet access to download a dataset
83 "tests/test_adaption_prompt.py"
84 "tests/test_auto.py"
85 "tests/test_boft.py"
86 "tests/test_cpt.py"
87 "tests/test_custom_models.py"
88 "tests/test_decoder_models.py"
89 "tests/test_encoder_decoder_models.py"
90 "tests/test_feature_extraction_models.py"
91 "tests/test_helpers.py"
92 "tests/test_hub_features.py"
93 "tests/test_incremental_pca.py"
94 "tests/test_initialization.py"
95 "tests/test_mixed.py"
96 "tests/test_multitask_prompt_tuning.py"
97 "tests/test_other.py"
98 "tests/test_other.py"
99 "tests/test_poly.py"
100 "tests/test_stablediffusion.py"
101 "tests/test_trainable_tokens.py"
102 "tests/test_tuners_utils.py"
103 "tests/test_vision_models.py"
104 "tests/test_xlora.py"
105 "tests/test_target_parameters.py"
106 "tests/test_seq_classifier.py"
107 "tests/test_low_level_api.py"
108 ];
109
110 meta = {
111 homepage = "https://github.com/huggingface/peft";
112 description = "State-of-the art parameter-efficient fine tuning";
113 changelog = "https://github.com/huggingface/peft/releases/tag/${src.tag}";
114 license = lib.licenses.asl20;
115 maintainers = with lib.maintainers; [ bcdarwin ];
116 };
117}