Unverified Commit 05d704a7 authored by Michael Daniels's avatar Michael Daniels Committed by GitHub
Browse files

python3Packages.compressed-tensors: fix build, adopt (#493778)

parents 739082da d845ec5e
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pythonAtLeast,

  # build-system
  setuptools,
  setuptools-scm,
  llvmPackages,

  # dependencies
  frozendict,
  loguru,
  pydantic,
  torch,
  transformers,
@@ -19,7 +23,7 @@
  pytestCheckHook,
}:

buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
  pname = "compressed-tensors";
  version = "0.13.0";
  pyproject = true;
@@ -28,10 +32,13 @@ buildPythonPackage rec {
  src = fetchFromGitHub {
    owner = "neuralmagic";
    repo = "compressed-tensors";
    tag = version;
    tag = finalAttrs.version;
    hash = "sha256-XsQRP186ISarMMES3P+ov4t/1KKJdl0tXBrfpjyM3XA=";
  };

  #  RuntimeError("torch.compile is not supported on Python 3.14+")
  disabled = pythonAtLeast "3.14";

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "setuptools_scm==8.2.0" "setuptools_scm"
@@ -42,8 +49,11 @@ buildPythonPackage rec {
    setuptools-scm
  ];

  buildInputs = lib.optional stdenv.cc.isClang llvmPackages.openmp;

  dependencies = [
    frozendict
    loguru
    pydantic
    torch
    transformers
@@ -72,18 +82,24 @@ buildPythonPackage rec {
    "test_model_forward_pass"
    "test_save_compressed_model"
    "test_target_prioritization"
    "test_expand_targets_with_llama_stories"
  ];

  disabledTestPaths = [
    # these try to download models from HF Hub
    "tests/test_quantization/lifecycle/test_apply.py"
    # RuntimeError: The weights trying to be saved contained shared tensors
    "tests/test_transform/factory/test_serialization.py::test_serialization[True-hadamard]"
    "tests/test_transform/factory/test_serialization.py::test_serialization[True-random-hadamard]"
    "tests/test_transform/factory/test_serialization.py::test_serialization[False-hadamard]"
    "tests/test_transform/factory/test_serialization.py::test_serialization[False-random-hadamard]"
  ];

  meta = {
    description = "Safetensors extension to efficiently store sparse quantized tensors on disk";
    homepage = "https://github.com/neuralmagic/compressed-tensors";
    changelog = "https://github.com/neuralmagic/compressed-tensors/releases/tag/${src.tag}";
    changelog = "https://github.com/neuralmagic/compressed-tensors/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.asl20;
    maintainers = [ ];
    maintainers = with lib.maintainers; [ sarahec ];
  };
}
})