From 39f2b9de2ac7fb14e4aaf61863e98d01a53bc875 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Sun, 12 Sep 2021 10:52:28 -0700 Subject: [PATCH] Pin scipy to 1.6.3 on Windows and Mac (#64844) Summary: It's already pinned by via docker install on Linux As `scipy.stats.`[`poission`|`geom`|`binom`] returns quite different results in 1.7+ versions of SciPy Pull Request resolved: https://github.com/pytorch/pytorch/pull/64844 Reviewed By: driazati Differential Revision: D30876591 Pulled By: malfet fbshipit-source-id: 4946e0922063e9ac320c218a0b089f73486466f7 --- .jenkins/pytorch/macos-test.sh | 2 +- .jenkins/pytorch/win-test-helpers/setup_pytorch_env.bat | 2 +- test/distributions/test_distributions.py | 13 +++++-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.jenkins/pytorch/macos-test.sh b/.jenkins/pytorch/macos-test.sh index 71d6773..d7e223f 100755 --- a/.jenkins/pytorch/macos-test.sh +++ b/.jenkins/pytorch/macos-test.sh @@ -7,7 +7,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/macos-common.sh" export PYTORCH_TEST_SKIP_NOARCH=1 conda install -y six -pip install -q hypothesis "expecttest==0.1.3" "librosa>=0.6.2" "numba<=0.49.1" psutil +pip install -q hypothesis "expecttest==0.1.3" "librosa>=0.6.2" "numba<=0.49.1" psutil "scipy==1.6.3" # TODO move this to docker pip install unittest-xml-reporting pytest diff --git a/.jenkins/pytorch/win-test-helpers/setup_pytorch_env.bat b/.jenkins/pytorch/win-test-helpers/setup_pytorch_env.bat index 2813433..692bdf8 100644 --- a/.jenkins/pytorch/win-test-helpers/setup_pytorch_env.bat +++ b/.jenkins/pytorch/win-test-helpers/setup_pytorch_env.bat @@ -20,7 +20,7 @@ if NOT "%BUILD_ENVIRONMENT%"=="" ( ) call %CONDA_PARENT_DIR%\Miniconda3\Scripts\activate.bat %CONDA_PARENT_DIR%\Miniconda3 if NOT "%BUILD_ENVIRONMENT%"=="" ( - call conda install -y -q python=3.8 numpy mkl cffi pyyaml boto3 protobuf numba scipy typing_extensions dataclasses libuv + call conda install -y -q python=3.8 numpy mkl cffi pyyaml boto3 protobuf numba scipy=1.6.3 typing_extensions dataclasses libuv if %errorlevel% neq 0 ( exit /b %errorlevel% ) call conda install -y -q -c conda-forge cmake if %errorlevel% neq 0 ( exit /b %errorlevel% ) diff --git a/test/distributions/test_distributions.py b/test/distributions/test_distributions.py index 268deb5..ee69b3c 100644 --- a/test/distributions/test_distributions.py +++ b/test/distributions/test_distributions.py @@ -20,6 +20,10 @@ change. This file contains two types of randomized tests: it's fine to increment the seed of the failing test (but you shouldn't need to increment it more than once; otherwise something is probably actually wrong). + +3. `test_geometric_sample`, `test_binomial_sample` and `test_poisson_sample` + are validated against `scipy.stats.` which are not guaranteed to be identical + across different versions of scipy (namely, they yield invalid results in 1.7+) """ import math @@ -38,7 +42,7 @@ torch.set_default_dtype(torch.double) from torch._six import inf from torch.testing._internal.common_utils import \ (TestCase, run_tests, set_rng_seed, TEST_WITH_UBSAN, load_tests, - gradcheck, IS_MACOS, IS_WINDOWS) + gradcheck) from torch.testing._internal.common_cuda import TEST_CUDA from torch.autograd import grad from torch.autograd.functional import jacobian @@ -1034,8 +1038,6 @@ class TestDistributions(TestCase): self.assertEqual(Geometric(p).entropy(), scipy.stats.geom(p.detach().numpy(), loc=-1).entropy(), atol=1e-3, rtol=0) self.assertEqual(float(Geometric(s).entropy()), scipy.stats.geom(s, loc=-1).entropy().item(), atol=1e-3, rtol=0) - @unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595") - @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347") @unittest.skipIf(not TEST_NUMPY, "NumPy not found") def test_geometric_sample(self): set_rng_seed(0) # see Note [Randomized statistical tests] @@ -1052,8 +1054,6 @@ class TestDistributions(TestCase): self.assertRaises(NotImplementedError, Binomial(10, p).rsample) self.assertRaises(NotImplementedError, Binomial(10, p).entropy) - @unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595") - @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347") @unittest.skipIf(not TEST_NUMPY, "NumPy not found") def test_binomial_sample(self): set_rng_seed(0) # see Note [Randomized statistical tests] @@ -1346,8 +1346,6 @@ class TestDistributions(TestCase): dist.log_prob(torch.ones_like(rate_zero)).backward() torch.testing.assert_allclose(rate_zero.grad, torch.inf) - @unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595") - @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") def test_poisson_sample(self): set_rng_seed(1) # see Note [Randomized statistical tests] @@ -1357,7 +1355,6 @@ class TestDistributions(TestCase): 'Poisson(lambda={})'.format(rate), failure_rate=1e-3) - @unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595") @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") def test_poisson_gpu_sample(self): -- 2.7.4