diff --git a/pkgs/development/python-modules/compressed-tensors/default.nix b/pkgs/development/python-modules/compressed-tensors/default.nix new file mode 100644 index 000000000000..450b87278c0c --- /dev/null +++ b/pkgs/development/python-modules/compressed-tensors/default.nix @@ -0,0 +1,66 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + pydantic, + torch, + transformers, + nbconvert, + nbformat, + pytestCheckHook, +}: + +buildPythonPackage rec { + pname = "compressed-tensors"; + version = "0.9.1"; + pyproject = true; + + # Release on PyPI is missing the `utils` directory, which `setup.py` wants to import + src = fetchFromGitHub { + owner = "neuralmagic"; + repo = pname; + tag = version; + hash = "sha256-AsbNFBvHxjiLl0T4JnQ5QrZdERUUYgS4iJvMRQytzN4="; + }; + + build-system = [ setuptools ]; + + dependencies = [ + pydantic + torch + transformers + ]; + + doCheck = true; + + pythonImportsCheck = [ "compressed_tensors" ]; + + nativeCheckInputs = [ + nbconvert + nbformat + pytestCheckHook + ]; + + disabledTests = [ + # these try to download models from HF Hub + "test_get_observer_token_count" + "test_kv_cache_quantization" + "test_target_prioritization" + "test_load_compressed_sharded" + "test_save_compressed_model" + "test_apply_tinyllama_dynamic_activations" + ]; + + disabledTestPaths = [ + # these try to download models from HF Hub + "tests/test_quantization/lifecycle/test_apply.py" + ]; + + meta = with lib; { + description = "A safetensors extension to efficiently store sparse quantized tensors on disk"; + homepage = "https://github.com/neuralmagic/compressed-tensors"; + license = licenses.asl20; + maintainers = [ ]; + }; +} diff --git a/pkgs/development/python-modules/mistral-common/default.nix b/pkgs/development/python-modules/mistral-common/default.nix new file mode 100644 index 000000000000..7c438e960d4d --- /dev/null +++ b/pkgs/development/python-modules/mistral-common/default.nix @@ -0,0 +1,57 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + poetry-core, + numpy, + pydantic, + jsonschema, + sentencepiece, + typing-extensions, + tiktoken, + pillow, + requests, +}: + +buildPythonPackage rec { + pname = "mistral-common"; + version = "1.5.2"; + pyproject = true; + + src = fetchPypi { + pname = "mistral_common"; + inherit version; + hash = "sha256-nRFXsTdsSdNav8dD2+AITyyjezpavQPnQSdqG8ZshS8="; + }; + + # relax dependencies + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail 'pillow = "^10.3.0"' 'pillow = ">=10.3.0"' \ + --replace-fail 'tiktoken = "^0.7.0"' 'tiktoken = ">=0.7.0"' \ + ''; + + build-system = [ poetry-core ]; + + dependencies = [ + numpy + pydantic + jsonschema + sentencepiece + typing-extensions + tiktoken + pillow + requests + ]; + + doCheck = true; + + pythonImportsCheck = [ "mistral_common" ]; + + meta = with lib; { + description = "mistral-common is a set of tools to help you work with Mistral models."; + homepage = "https://github.com/mistralai/mistral-common"; + license = licenses.asl20; + maintainers = with maintainers; [ bgamari ]; + }; +} diff --git a/pkgs/development/python-modules/partial-json-parser/default.nix b/pkgs/development/python-modules/partial-json-parser/default.nix new file mode 100644 index 000000000000..f356e6e0a312 --- /dev/null +++ b/pkgs/development/python-modules/partial-json-parser/default.nix @@ -0,0 +1,42 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + pdm-backend, + tqdm, + hypothesis, + pytest, +}: + +buildPythonPackage rec { + pname = "partial-json-parser"; + version = "0.2.1.1.post5"; + pyproject = true; + + src = fetchPypi { + pname = "partial_json_parser"; + inherit version; + hash = "sha256-mScQrGfpCzZ5IdUnJ2mJKAQPdxO6fsszuWNx6nrsgso="; + }; + + build-system = [ pdm-backend ]; + + dependencies = [ ]; + + doCheck = true; + + pythonImportsCheck = [ "partial_json_parser" ]; + + dev-dependencies = [ + hypothesis + tqdm + pytest + ]; + + meta = with lib; { + description = "Parse partial JSON generated by LLM"; + homepage = "https://github.com/promplate/partial-json-parser"; + license = licenses.mit; + maintainers = [ ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5c3dce22e736..c5515b993545 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2586,6 +2586,8 @@ self: super: with self; { compressed-rtf = callPackage ../development/python-modules/compressed-rtf { }; + compressed-tensors = callPackage ../development/python-modules/compressed-tensors { }; + concurrent-log-handler = callPackage ../development/python-modules/concurrent-log-handler { }; conda = callPackage ../development/python-modules/conda { }; @@ -8276,6 +8278,8 @@ self: super: with self; { mistletoe = callPackage ../development/python-modules/mistletoe { }; + mistral-common = callPackage ../development/python-modules/mistral-common { }; + mistune = callPackage ../development/python-modules/mistune { }; mitmproxy = callPackage ../development/python-modules/mitmproxy { }; @@ -10088,6 +10092,8 @@ self: super: with self; { partd = callPackage ../development/python-modules/partd { }; + partial-json-parser = callPackage ../development/python-modules/partial-json-parser { }; + parts = callPackage ../development/python-modules/parts { }; particle = callPackage ../development/python-modules/particle { };