torch-dct icon indicating copy to clipboard operation
torch-dct copied to clipboard

Pytorch 1.8 and 1.9 compatibility

Open jbojar opened this issue 3 years ago • 13 comments

This version should be compatible with multiple PyTorch versions (it works at least on 1.6.0, 1.7.1, 1.8.1, 1.9.0).

This fix is based on suggestions from this comment https://github.com/zh217/torch-dct/issues/15#issuecomment-851439294 by @SunnerLi and on existing but not fully working PR https://github.com/zh217/torch-dct/pull/21 by @underdogliu.

My version does not use version checking during execution of dct calculation. Instead it tries to import new torch.fft module and conditionally defines three functions using either new or old implementation of FFT. This is done only once, when module is imported.

jbojar avatar Aug 11 '21 12:08 jbojar

Thanks a lot! Will have a check this week on some testing on numerical compatibility and version compatibility.

And actually, as a contributor I am thinking about dropping support before 1.7. @zh217 your thoughts?

underdogliu avatar Aug 12 '21 08:08 underdogliu

This implementation may encounter an error: "copy_" not implemented for 'ComplexHalf'.

lryta avatar Sep 10 '21 18:09 lryta

Sorry @jbojar I have been so busy to get back to this. Finally can have a look.

Yes I think your solution works ok, although I still recommend two things:

  1. Tweak on numerical accuacy (for example, using float, using numpy floating numbers....) to reduce errors. I tested your code with torch==1.9.1 with the case in README and got the error at level of 1e-5. I think it is a bit high, although my solution from #21 returns same.
  2. adding version checking or complete dropping torch<=1.7.1 off because state-of-the-art solutions should provide support on torch>=1.8.0 and python>=3.7.

@lryta I copied his code to my repo and did not encounter such error. I used torch==1.9.1.

I have not heard any news about @zh217.

underdogliu avatar Oct 14 '21 10:10 underdogliu

any news on this to be merged?

pythonmobile avatar Dec 19 '21 04:12 pythonmobile

Can this be merged? Currently things do not work at all with Pytorch 1.10

jonnor avatar Dec 26 '21 23:12 jonnor

Any plans on merging?

MrPeterJin avatar Dec 28 '21 03:12 MrPeterJin

@jonnor I think it is ready to merge. But obviously I do not have the permission. Maybe you can clone the repo from this PR and compile it locally in your conda/VM environment.

underdogliu avatar Dec 28 '21 08:12 underdogliu

@underdogliu I tried again @1.10.1 and I still encountered the same issue. I may look into it during the new year break.

lryta avatar Dec 28 '21 08:12 lryta

@zh217 Can you please merge this?

pythonmobile avatar Jan 03 '22 22:01 pythonmobile

Any plans on this being merged?

jackhwalters avatar Apr 04 '22 17:04 jackhwalters

Checked with python 3.10 Cuda 11.6 and pytorch 1.11.0. GPU: 3090 FE image

johnnynunez avatar Apr 18 '22 18:04 johnnynunez

tested on pytorch 1.12dev and cuda 11.6 and works fine!

johnnynunez avatar Apr 24 '22 18:04 johnnynunez

Could we please have this merged in?

nviable avatar Sep 01 '22 19:09 nviable

Thank you for merging @zh217 ! Can you also make a new release on PyPi? Then it would be easy to use the package again

jonnor avatar Nov 06 '22 15:11 jonnor

Now it's available on PyPi as version 0.1.6.

zh217 avatar Nov 06 '22 16:11 zh217

Thank you @zh217 ! I have installed it via pip, seems to work fine

jonnor avatar Nov 07 '22 21:11 jonnor