2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, absl-py
|
2022-03-05 16:20:37 +00:00
|
|
|
, blas
|
2021-12-06 16:07:01 +00:00
|
|
|
, buildPythonPackage
|
2022-09-09 14:08:57 +00:00
|
|
|
, etils
|
2021-12-06 16:07:01 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, jaxlib
|
2022-03-05 16:20:37 +00:00
|
|
|
, lapack
|
2022-09-09 14:08:57 +00:00
|
|
|
, matplotlib
|
2021-12-06 16:07:01 +00:00
|
|
|
, numpy
|
|
|
|
, opt-einsum
|
|
|
|
, pytestCheckHook
|
2022-02-20 05:27:41 +00:00
|
|
|
, pytest-xdist
|
2021-12-06 16:07:01 +00:00
|
|
|
, pythonOlder
|
|
|
|
, scipy
|
|
|
|
, typing-extensions
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
let
|
|
|
|
usingMKL = blas.implementation == "mkl" || lapack.implementation == "mkl";
|
|
|
|
in
|
2021-09-18 10:52:07 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "jax";
|
2022-10-30 15:09:59 +00:00
|
|
|
version = "0.3.23";
|
2021-12-06 16:07:01 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "google";
|
|
|
|
repo = pname;
|
2022-03-30 09:31:56 +00:00
|
|
|
rev = "jax-v${version}";
|
2022-10-30 15:09:59 +00:00
|
|
|
hash = "sha256-ruXOwpBwpi1G8jgH9nhbWbs14JupwWkjh+Wzrj8HVU4=";
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# jaxlib is _not_ included in propagatedBuildInputs because there are
|
|
|
|
# different versions of jaxlib depending on the desired target hardware. The
|
|
|
|
# JAX project ships separate wheels for CPU, GPU, and TPU. Currently only the
|
|
|
|
# CPU wheel is packaged.
|
2021-12-06 16:07:01 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
absl-py
|
2022-09-09 14:08:57 +00:00
|
|
|
etils
|
2021-12-06 16:07:01 +00:00
|
|
|
numpy
|
|
|
|
opt-einsum
|
|
|
|
scipy
|
|
|
|
typing-extensions
|
2022-09-09 14:08:57 +00:00
|
|
|
] ++ etils.optional-dependencies.epath;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
jaxlib
|
2022-09-09 14:08:57 +00:00
|
|
|
matplotlib
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestCheckHook
|
2022-02-20 05:27:41 +00:00
|
|
|
pytest-xdist
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
# high parallelism will result in the tests getting stuck
|
|
|
|
dontUsePytestXdist = true;
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
# NOTE: Don't run the tests in the expiremental directory as they require flax
|
|
|
|
# which creates a circular dependency. See https://discourse.nixos.org/t/how-to-nix-ify-python-packages-with-circular-dependencies/14648/2.
|
|
|
|
# Not a big deal, this is how the JAX docs suggest running the test suite
|
|
|
|
# anyhow.
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestFlagsArray = [
|
2022-04-27 09:35:20 +00:00
|
|
|
"--numprocesses=4"
|
2021-12-06 16:07:01 +00:00
|
|
|
"-W ignore::DeprecationWarning"
|
|
|
|
"tests/"
|
|
|
|
];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
disabledTests = [
|
|
|
|
# Exceeds tolerance when the machine is busy
|
|
|
|
"test_custom_linear_solve_aux"
|
|
|
|
] ++ lib.optionals usingMKL [
|
|
|
|
# See
|
|
|
|
# * https://github.com/google/jax/issues/9705
|
|
|
|
# * https://discourse.nixos.org/t/getting-different-results-for-the-same-build-on-two-equally-configured-machines/17921
|
|
|
|
# * https://github.com/NixOS/nixpkgs/issues/161960
|
2022-03-05 16:20:37 +00:00
|
|
|
"test_custom_linear_solve_cholesky"
|
|
|
|
"test_custom_root_with_aux"
|
|
|
|
"testEigvalsGrad_shape"
|
|
|
|
];
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# See https://github.com/google/jax/issues/11722. This is a temporary fix in
|
|
|
|
# order to unblock etils, and upgrading jax/jaxlib to the latest version. See
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/183173#issuecomment-1204074993.
|
|
|
|
disabledTestPaths = [
|
|
|
|
"tests/api_test.py"
|
|
|
|
"tests/core_test.py"
|
|
|
|
"tests/lax_numpy_indexing_test.py"
|
|
|
|
"tests/lax_numpy_test.py"
|
|
|
|
"tests/nn_test.py"
|
|
|
|
"tests/random_test.py"
|
|
|
|
"tests/sparse_test.py"
|
|
|
|
];
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
# As of 0.3.22, `import jax` does not work without jaxlib being installed.
|
|
|
|
pythonImportsCheck = [ ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Differentiate, compile, and transform Numpy code";
|
2021-12-06 16:07:01 +00:00
|
|
|
homepage = "https://github.com/google/jax";
|
|
|
|
license = licenses.asl20;
|
2021-09-18 10:52:07 +00:00
|
|
|
maintainers = with maintainers; [ samuela ];
|
|
|
|
};
|
|
|
|
}
|