kymatio icon indicating copy to clipboard operation
kymatio copied to clipboard

MAINT Speed up `test_gradients`

Open MuawizChaudhary opened this issue 3 years ago • 2 comments

This pull request speeds up test_gradients by enabling fast_mode. Previously it took 109 seconds to run, now it takes 17 seconds.

fast_mode (bool, optional) – Fast mode for gradcheck and gradgradcheck is currently only implemented for R to R functions. If none of the inputs and outputs are complex a faster implementation of gradcheck that no longer computes the entire jacobian is run; otherwise, we fall back to the slow implementation.

Note that since our scattering takes in as input a real valued signal, and outputs a real valued signal, torch allows us to enable fast_mode to avoid computing additional entries of a jacobian.

See more here.

This PR resolves issue #872

MuawizChaudhary avatar Jun 12 '22 02:06 MuawizChaudhary

lol fast_mode is implemented in pytorch 1.9 but not before. Maybe this is an un-needed change?

I do believe that OLGD seemed to mention something about the tests taking a long time to finish running. perhaps this grad check business was slowing him down? Perhaps we should move this gradcheck to a seperate script+folder?

MuawizChaudhary avatar Jun 12 '22 02:06 MuawizChaudhary

lol fast_mode is implemented in pytorch 1.9 but not before. Maybe this is an un-needed change?

Ok and since we want to be testing 1.8 we'll have to run the slow check anyhow… One option is to just run the gradcheck on more recent torch versions. Another is to stop supporting old torch versions, but that's a separate question.

janden avatar Jun 13 '22 21:06 janden

@janden in the wake of https://github.com/kymatio/kymatio/pull/892, we no longer test torch 1.8 so i believe we could reopen this and merge it for v0.4

lostanlen avatar Feb 16 '23 21:02 lostanlen

Codecov Report

Patch and project coverage have no change.

Comparison is base (05ae680) 96.00% compared to head (62d542f) 96.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #873   +/-   ##
=======================================
  Coverage   96.00%   96.00%           
=======================================
  Files          73       73           
  Lines        2575     2575           
=======================================
  Hits         2472     2472           
  Misses        103      103           
Flag Coverage Δ
jenkins_main 96.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 3 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jun 29 '23 12:06 codecov[bot]