summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/fairscale/default.nix
blob: eeccad5b3837d0e978dcc309a7037b4e897a87b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  # build inputs
  torch,
  numpy,
  ninja,
  # check inputs
  pytestCheckHook,
  parameterized,
  pytest-cov-stub,
  pytest-timeout,
  remote-pdb,
}:
let
  pname = "fairscale";
  version = "0.4.13";
in
buildPythonPackage {
  inherit pname version;
  pyproject = true;

  src = fetchFromGitHub {
    owner = "facebookresearch";
    repo = "fairscale";
    tag = "v${version}";
    hash = "sha256-L2Rl/qL6l0OLAofygzJBGQdp/2ZrgDFarwZRjyAR3dw=";
  };

  # setup.py depends on ninja python dependency, but we have the binary in nixpkgs
  postPatch = ''
    substituteInPlace setup.py \
      --replace 'setup_requires=["ninja"]' 'setup_requires=[]'
  '';

  nativeBuildInputs = [
    ninja
    setuptools
  ];

  propagatedBuildInputs = [
    torch
    numpy
  ];

  nativeCheckInputs = [
    pytestCheckHook
    parameterized
    pytest-cov-stub
    pytest-timeout
    remote-pdb
  ];

  # Some tests try to build distributed models, which doesn't work in the sandbox.
  doCheck = false;

  pythonImportsCheck = [ "fairscale" ];

  meta = {
    description = "PyTorch extensions for high performance and large scale training";
    mainProgram = "wgit";
    homepage = "https://github.com/facebookresearch/fairscale";
    changelog = "https://github.com/facebookresearch/fairscale/releases/tag/v${version}";
    license = with lib.licenses; [
      mit
      asl20
      bsd3
    ];
    maintainers = with lib.maintainers; [ happysalada ];
  };
}