diff --git a/pkgs/development/python-modules/mslk/default.nix b/pkgs/development/python-modules/mslk/default.nix new file mode 100644 index 000000000000..d5427badc34d --- /dev/null +++ b/pkgs/development/python-modules/mslk/default.nix @@ -0,0 +1,74 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + fetchpatch, + + # build-system + setuptools, + + # dependencies + numpy, + torch, +}: +buildPythonPackage (finalAttrs: { + pname = "mslk"; + version = "1.4.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "meta-pytorch"; + repo = "MSLK"; + tag = "v${finalAttrs.version}"; + hash = "sha256-/oC8FttZvJxrfNWR9LEzTeqiTtjBbuLNst/TMIsl4qU="; + }; + + patches = [ + # Fix the triton split-K attention kernel indexing + # https://github.com/meta-pytorch/MSLK/pull/630 + (fetchpatch { + name = "mslk-fix-splitk-dequantize-indexing.patch"; + url = "https://github.com/meta-pytorch/MSLK/commit/eda292adf77431c3f9a16893561e9903f9b19fca.patch"; + hash = "sha256-EUUAZBfSW6cEltejGn4neTZkft798LkJhaI/ygIionk="; + }) + # Fix triton >= 3.9 compatibility (block pointers have been removed) + # https://github.com/meta-pytorch/MSLK/pull/619 + (fetchpatch { + name = "mslk-splitk-remove-block-pointers.patch"; + url = "https://github.com/meta-pytorch/MSLK/commit/78ccdcee3c3af20820a74f8abccddb0a4d84e3f8.patch"; + hash = "sha256-cz5dCs8YlifhkXlvjKIWMATRf+gtP4ffFv+pto+c1wg="; + }) + ]; + + env = { + # Skip the C++/CUDA build (CMake + scikit-build) and only install the Python code. + # The native kernels are optional: the triton/flash-attention based ops work without them. + MSLK_PYTHON_ONLY = 1; + MSLK_VERSION_OVERRIDE = finalAttrs.version; + }; + + build-system = [ + setuptools + ]; + + dependencies = [ + numpy + torch + ]; + + pythonImportsCheck = [ + "mslk" + "mslk.attention.fmha" + ]; + + # Almost all tests require a GPU + doCheck = false; + + meta = { + description = "Collection of PyTorch GPU operator libraries for GenAI training and inference"; + homepage = "https://github.com/meta-pytorch/MSLK"; + changelog = "https://github.com/meta-pytorch/MSLK/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index eebcd4d905e5..d01497be5637 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -11475,6 +11475,8 @@ self: super: with self; { mslex = callPackage ../development/python-modules/mslex { }; + mslk = callPackage ../development/python-modules/mslk { }; + msmart-ng = callPackage ../development/python-modules/msmart-ng { }; msoffcrypto-tool = callPackage ../development/python-modules/msoffcrypto-tool { }; @@ -23112,9 +23114,7 @@ self: super: with self; { xen = toPythonModule (pkgs.xen.override { python3Packages = self; }); - xformers = callPackage ../development/python-modules/xformers { - inherit (pkgs.llvmPackages) openmp; - }; + xformers = callPackage ../development/python-modules/xformers { }; xgboost = callPackage ../development/python-modules/xgboost { inherit (pkgs) xgboost; };