1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, pythonRelaxDepsHook
6, which
7# runtime dependencies
8, numpy
9, torch
10, pyre-extensions
11# check dependencies
12, pytestCheckHook
13, pytest-cov
14# , pytest-mpi
15, pytest-timeout
16# , pytorch-image-models
17, hydra-core
18, fairscale
19, scipy
20, cmake
21, openai-triton
22, networkx
23#, apex
24, einops
25, transformers
26, timm
27#, flash-attn
28}:
29let
30 version = "0.03";
31in
32buildPythonPackage {
33 pname = "xformers";
34 inherit version;
35 format = "setuptools";
36
37 disabled = pythonOlder "3.7";
38
39 src = fetchFromGitHub {
40 owner = "facebookresearch";
41 repo = "xformers";
42 rev = "refs/tags/v${version}";
43 hash = "sha256-G8f7tny5B8SAQ6+2uOjhY7nD0uOT4sskIwtTdwivQXo=";
44 fetchSubmodules = true;
45 };
46
47 preBuild = ''
48 cat << EOF > ./xformers/version.py
49 # noqa: C801
50 __version__ = "${version}"
51 EOF
52 '';
53
54 nativeBuildInputs = [
55 pythonRelaxDepsHook
56 which
57 ];
58
59 pythonRelaxDeps = [
60 "pyre-extensions"
61 ];
62
63 propagatedBuildInputs = [
64 numpy
65 torch
66 pyre-extensions
67 ];
68
69 pythonImportsCheck = [ "xformers" ];
70
71 dontUseCmakeConfigure = true;
72
73 # see commented out missing packages
74 doCheck = false;
75
76 nativeCheckInputs = [
77 pytestCheckHook
78 pytest-cov
79 pytest-timeout
80 hydra-core
81 fairscale
82 scipy
83 cmake
84 networkx
85 openai-triton
86 # apex
87 einops
88 transformers
89 timm
90 # flash-attn
91 ];
92
93 meta = with lib; {
94 description = "XFormers: A collection of composable Transformer building blocks";
95 homepage = "https://github.com/facebookresearch/xformers";
96 changelog = "https://github.com/facebookresearch/xformers/blob/${version}/CHANGELOG.md";
97 license = licenses.bsd3;
98 maintainers = with maintainers; [ happysalada ];
99 };
100}