Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The latest pytorch nightly has removed torch.testing.assert_allclose #1981

Closed
xuzhao9 opened this issue Nov 3, 2022 · 6 comments · Fixed by #1982
Closed

The latest pytorch nightly has removed torch.testing.assert_allclose #1981

xuzhao9 opened this issue Nov 3, 2022 · 6 comments · Fixed by #1982
Labels
code heatlh 💊 Improvement the package code health enhancement 🚀 Improvement over an existing functionality help wanted Extra attention is needed

Comments

@xuzhao9
Copy link

xuzhao9 commented Nov 3, 2022

Describe the bug

The latest PyTorch nightly has removed torch.testing.assert_allclose:
pytorch/pytorch#87974

Kornia needs to update this code: https://github.com/kornia/kornia/blob/master/kornia/testing/__init__.py#L271

Reproduction steps

`import kornia`
on the latest PyTorch nightly

error:
Traceback (most recent call last):
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/kornia/testing/__init__.py", line 235, in <module>
    from torch.testing._core import _get_default_tolerance  # type: ignore
ModuleNotFoundError: No module named 'torch.testing._core'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "install.py", line 20, in <module>
    patch_dalle2()
  File "install.py", line 7, in patch_dalle2
    import dalle2_pytorch
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/dalle2_pytorch/__init__.py", line 2, in <module>
    from dalle2_pytorch.dalle2_pytorch import DALLE2, DiffusionPriorNetwork, DiffusionPrior, Unet, Decoder
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/dalle2_pytorch/dalle2_pytorch.py", line 20, in <module>
    from kornia.filters import gaussian_blur2d
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/kornia/__init__.py", line 3, in <module>
    from . import filters
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/kornia/filters/__init__.py", line 2, in <module>
    from .blur_pool import BlurPool2D, MaxBlurPool2D, blur_pool2d, edge_aware_blur_pool2d, max_blur_pool2d
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/kornia/filters/blur_pool.py", line 7, in <module>
    from kornia.testing import KORNIA_CHECK, KORNIA_CHECK_SHAPE
  File "/home/circleci/miniconda3/lib/python3.8/site-packages/kornia/testing/__init__.py", line 254, in <module>
    from torch.testing import assert_allclose as _assert_close
ImportError: cannot import name 'assert_allclose' from 'torch.testing' (/home/circleci/miniconda3/lib/python3.8/site-packages/torch/testing/__init__.py)

Expected behavior

successful return

Environment

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:


### Additional context

_No response_
@xuzhao9 xuzhao9 added the help wanted Extra attention is needed label Nov 3, 2022
@edgarriba
Copy link
Member

@xuzhao9 thanks to report! we are aware of it. was recently pointed out in a conversation @johnnv1

@pmeier
Copy link
Contributor

pmeier commented Nov 3, 2022

I actually authored the mitigation code in the kornia test suite. See #1031. The offending line here is

from torch.testing._core import _get_default_tolerance # type: ignore

Change this to

from torch.testing._comparison import default_tolerances

and you should be good again.

@edgarriba edgarriba added enhancement 🚀 Improvement over an existing functionality code heatlh 💊 Improvement the package code health labels Nov 3, 2022
@edgarriba
Copy link
Member

@pmeier do you think is safe to remove the try/catch block ? apparently this gives us also some headaches with mypy

@pmeier
Copy link
Contributor

pmeier commented Nov 3, 2022

It will be after you bump the minimum dependency to torch>=1.9, but it seems that has not happened yet:

kornia/setup.cfg

Lines 38 to 40 in b9f26e0

install_requires =
packaging
torch>=1.8.1

@edgarriba
Copy link
Member

@ducha-aiki @shijianjian opinions here?

@pmeier
Copy link
Contributor

pmeier commented Nov 3, 2022

Plus, my patch from #1031 only broke, because I needed to import from a private namespace. See #1134 for details. When that is fixed as well you can use torch.testing.assert_close without any workarounds I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code heatlh 💊 Improvement the package code health enhancement 🚀 Improvement over an existing functionality help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants