nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 jinja2,
11 mlx,
12 numpy,
13 protobuf,
14 pyyaml,
15 transformers,
16
17 # tests
18 aiohttp,
19 lm-eval,
20 pytestCheckHook,
21 sentencepiece,
22 writableTmpDirAsHomeHook,
23}:
24
25buildPythonPackage (finalAttrs: {
26 pname = "mlx-lm";
27 version = "0.30.5";
28 pyproject = true;
29
30 src = fetchFromGitHub {
31 owner = "ml-explore";
32 repo = "mlx-lm";
33 tag = "v${finalAttrs.version}";
34 hash = "sha256-GXz9VtNJ0ldh8aDAyBvSR2DhZq/NctpPup58WLrIt6Y=";
35 };
36
37 build-system = [
38 setuptools
39 ];
40
41 pythonRelaxDeps = [
42 "transformers"
43 ];
44 dependencies = [
45 jinja2
46 mlx
47 numpy
48 protobuf
49 pyyaml
50 transformers
51 ];
52
53 nativeCheckInputs = [
54 aiohttp
55 lm-eval
56 pytestCheckHook
57 sentencepiece
58 writableTmpDirAsHomeHook
59 ];
60
61 pythonImportsCheck = [ "mlx_lm" ];
62
63 disabledTestPaths = [
64 # Requires network access to huggingface.co
65 "tests/test_datsets.py"
66 "tests/test_generate.py"
67 "tests/test_prompt_cache.py::TestPromptCache"
68 "tests/test_server.py"
69 "tests/test_tokenizers.py"
70 "tests/test_utils.py::TestUtils::test_convert"
71 "tests/test_utils.py::TestUtils::test_load"
72
73 # RuntimeError: [metal_kernel] No GPU back-end.
74 "tests/test_losses.py"
75 "tests/test_models.py::TestModels::test_bitnet"
76
77 # TypeError: 'NoneType' object is not callable
78 "tests/test_models.py::TestModels::test_gated_delta"
79 "tests/test_models.py::TestModels::test_gated_delta_masked"
80 ];
81
82 meta = {
83 description = "Run LLMs with MLX";
84 homepage = "https://github.com/ml-explore/mlx-lm";
85 changelog = "https://github.com/ml-explore/mlx-lm/releases/tag/${finalAttrs.src.tag}";
86 license = lib.licenses.mit;
87 };
88})