1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 numpy,
12 packaging,
13 torch,
14 typing-extensions,
15
16 # tests
17 onnx,
18 pytestCheckHook,
19 torchvision,
20 pythonAtLeast,
21}:
22
23buildPythonPackage rec {
24 pname = "pytorch-pfn-extras";
25 version = "0.8.4";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "pfnet";
30 repo = "pytorch-pfn-extras";
31 tag = "v${version}";
32 hash = "sha256-OrUYO0V5fWqkIjHiYkhvjeFy0YX8CxeRqzrw3NfGK2A=";
33 };
34
35 build-system = [ setuptools ];
36
37 dependencies = [
38 numpy
39 packaging
40 torch
41 typing-extensions
42 ];
43
44 nativeCheckInputs = [
45 onnx
46 pytestCheckHook
47 torchvision
48 ];
49
50 pytestFlags = [
51 "-Wignore::DeprecationWarning"
52 ];
53
54 pythonImportsCheck = [ "pytorch_pfn_extras" ];
55
56 disabledTestMarks = [
57 # Requires CUDA access which is not possible in the nix environment.
58 "gpu"
59 "mpi"
60 ];
61
62 disabledTests = [
63 # AssertionError: assert 4 == 0
64 # where 4 = <MagicMock id='140733587469184'>.call_count
65 "test_lr_scheduler_wait_for_first_optimizer_step"
66 ]
67 ++ lib.optionals (pythonAtLeast "3.13") [
68 # RuntimeError: Dynamo is not supported on Python 3.13+
69 "test_register"
70 ]
71 ++ lib.optionals stdenv.hostPlatform.isDarwin [
72 # torch.distributed was not available on darwin at one point; revisit
73 "test_create_distributed_evaluator"
74 "test_distributed_evaluation"
75 "test_distributed_evaluator_progress_bar"
76 ];
77
78 disabledTestPaths = [
79 # Requires optuna which is currently (2022-02-16) marked as broken.
80 "tests/pytorch_pfn_extras_tests/test_config_types.py"
81
82 # requires onnxruntime which was removed because of poor maintainability
83 # See https://github.com/NixOS/nixpkgs/pull/105951 https://github.com/NixOS/nixpkgs/pull/155058
84 "tests/pytorch_pfn_extras_tests/onnx_tests/test_annotate.py"
85 "tests/pytorch_pfn_extras_tests/onnx_tests/test_as_output.py"
86 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export.py"
87 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export_testcase.py"
88 "tests/pytorch_pfn_extras_tests/onnx_tests/test_lax.py"
89 "tests/pytorch_pfn_extras_tests/onnx_tests/test_load_model.py"
90 "tests/pytorch_pfn_extras_tests/onnx_tests/test_torchvision.py"
91 "tests/pytorch_pfn_extras_tests/onnx_tests/utils.py"
92
93 # RuntimeError: No Op registered for Gradient with domain_version of 9
94 "tests/pytorch_pfn_extras_tests/onnx_tests/test_grad.py"
95
96 # torch._dynamo.exc.BackendCompilerFailed: backend='compiler_fn' raised:
97 # AttributeError: module 'torch.fx.experimental.proxy_tensor' has no attribute 'maybe_disable_fake_tensor_mode'
98 "tests/pytorch_pfn_extras_tests/dynamo_tests/test_compile.py"
99 ]
100 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
101 # torch.distributed was not available on darwin at one point; revisit
102 "tests/pytorch_pfn_extras_tests/distributed_tests/test_distributed_validation_sampler.py"
103 "tests/pytorch_pfn_extras_tests/nn_tests/parallel_tests/test_distributed.py"
104 "tests/pytorch_pfn_extras_tests/profiler_tests/test_record.py"
105 "tests/pytorch_pfn_extras_tests/profiler_tests/test_time_summary.py"
106 "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_accumulate.py"
107 "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_sharded_snapshot.py"
108 ]
109 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
110 # RuntimeError: internal error
111 # convolution (e.g. F.conv3d) causes runtime error
112 "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_conv.py"
113 ];
114
115 meta = {
116 description = "Supplementary components to accelerate research and development in PyTorch";
117 homepage = "https://github.com/pfnet/pytorch-pfn-extras";
118 changelog = "https://github.com/pfnet/pytorch-pfn-extras/releases/tag/${src.tag}";
119 license = lib.licenses.mit;
120 maintainers = with lib.maintainers; [ samuela ];
121 badPlatforms = [
122 # test_profile_report is broken on darwin
123 lib.systems.inspect.patterns.isDarwin
124 ];
125 };
126}