Zygote.jl icon indicating copy to clipboard operation
Zygote.jl copied to clipboard

Fix for #717 - grads for dictionaries in closures/struct fields

Open femtomc opened this issue 3 years ago • 12 comments

Commented out === check in lib @adjoint for literal_getproperty.

This is breaking grads for dicts in closures (and thus, also structs with dictionary fields).

There are a number of small MWEs for this issue:

https://github.com/FluxML/Zygote.jl/issues/717

I have no idea if this breaks other things, because master already has broken tests.

femtomc avatar Aug 15 '20 02:08 femtomc

@femtomc could you add a regression test please? Would like to prevent this bug from creeping back in.

willtebbutt avatar Aug 18 '20 09:08 willtebbutt

Absolutely.

I don’t fully understand this code - but I can transform the MWEs into a small set of tests.

femtomc avatar Aug 18 '20 11:08 femtomc

Not sure this is the right thing to do here, we want to shortcut out if something doesn't have a gradient

DhairyaLGandhi avatar Aug 18 '20 12:08 DhairyaLGandhi

Well it’s catching things which do have gradients - so the intention is not working as expected.

Is there an example of when the shortcut is applied? That would help me change my fix.

femtomc avatar Aug 18 '20 13:08 femtomc

Transformed the MWEs into a test suite.

femtomc avatar Aug 18 '20 15:08 femtomc

Bump. @willtebbutt @DhairyaLGandhi

Any pointers for fixing this PR now?

femtomc avatar Aug 22 '20 23:08 femtomc

We do need to return the nothing there, so the "fix" would be to let it fall back to the nt_nothing function and accumulate there.

DhairyaLGandhi avatar Jul 21 '21 09:07 DhairyaLGandhi

We do need to return the nothing there, so the "fix" would be to let it fall back to the nt_nothing function and accumulate there.

can you post a scratch of the approach?

CarloLucibello avatar Jul 21 '21 09:07 CarloLucibello

I'll try to post a write-up soon

DhairyaLGandhi avatar Jul 21 '21 10:07 DhairyaLGandhi

bumpity bump

CarloLucibello avatar Sep 02 '21 12:09 CarloLucibello

Yeah, I had written something similar for this and another project here (~https://github.com/Chemellia/ChemistryFeaturization.jl/pull/111~ edit: wrong link), I have to convert that into a cleaned up PR to Zygote since its not complete in its current state. ref https://github.com/FluxML/Zygote.jl/pull/688, #452

DhairyaLGandhi avatar Sep 02 '21 14:09 DhairyaLGandhi

Ref. https://github.com/FluxML/Zygote.jl/issues/717#issuecomment-1208927447 for visibility.

ToucheSir avatar Aug 09 '22 05:08 ToucheSir

closing as outdated. Also, #717 has been closed

CarloLucibello avatar Nov 30 '22 15:11 CarloLucibello