about summary refs log tree commit diff
path: root/pkgs/development/python-modules/tensordict/default.nix
blob: 1ad591e13be6bc529bd18ef99f09921534e69220 (plain) (blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
  lib,
  buildPythonPackage,
  pythonOlder,
  fetchFromGitHub,

  # build-system
  setuptools,
  torch,
  which,

  # dependencies
  cloudpickle,
  numpy,
  orjson,

  # checks
  h5py,
  pytestCheckHook,

  stdenv,
}:

buildPythonPackage rec {
  pname = "tensordict";
  version = "0.5.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "pytorch";
    repo = "tensordict";
    rev = "refs/tags/v${version}";
    hash = "sha256-jnRlN9gefR77pioIXf0qM1CP6EtpeQkBvVIecGkb/pw=";
  };

  build-system = [
    setuptools
    torch
    which
  ];

  dependencies = [
    cloudpickle
    numpy
    orjson
    torch
  ];

  pythonImportsCheck = [ "tensordict" ];

  # We have to delete the source because otherwise it is used instead of the installed package.
  preCheck = ''
    rm -rf tensordict
  '';

  nativeCheckInputs = [
    h5py
    pytestCheckHook
  ];

  disabledTests =
    [
      # Hangs forever
      "test_copy_onto"

      # EOFError (MPI related)
      # AssertionError: assert tensor(False)
      # +  where tensor(False) = <built-in method all of Tensor object at 0x7ffe49bf87d0>()
      "test_mp"

      # torch._dynamo.exc.BackendCompilerFailed
      # Requires a more recent version of triton
      # Re-enable when https://github.com/NixOS/nixpkgs/pull/328247 is merged
      "test_functional"
      "test_linear"
      "test_seq"
      "test_seq_lmbda"
    ]
    ++ lib.optionals (stdenv.hostPlatform.system == "aarch64-linux") [
      # RuntimeError: internal error
      "test_add_scale_sequence"
      "test_modules"
      "test_setattr"

      # _queue.Empty errors in multiprocessing tests
      "test_isend"

      # hangs forever
      "test_map_iter_interrupt_early"
    ];

  disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
    # torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
    # OpenMP support not found.
    "test/test_compile.py"

    # ModuleNotFoundError: No module named 'torch._C._distributed_c10d'; 'torch._C' is not a package
    "test/test_distributed.py"
  ];

  meta = {
    description = "Pytorch dedicated tensor container";
    changelog = "https://github.com/pytorch/tensordict/releases/tag/v${version}";
    homepage = "https://github.com/pytorch/tensordict";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
}