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

Test changes from https://github.com/FluxML/ZygoteRules.jl/pull/26 #1466

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ToucheSir
Copy link
Member

We have both Zygote's own CI and downstream tests here, so it'll be much easier to see what the impact is.

PR Checklist

  • Tests are added
  • Documentation, if applicable

@devmotion
Copy link
Collaborator

Seems the Zygote test failures only point to a few tests that have to be updated since they rely on the current non-collapsing behaviour.

@ToucheSir
Copy link
Member Author

Most if not all of those should be fixed by #1328, but it hasn't been merged yet. Do you have any insight into the DynamicPPL error? If it doesn't look related, the ZygoteRules PR should be good to go.

@devmotion
Copy link
Collaborator

devmotion commented Oct 25, 2023

DynamicPPL can be ignored - AbstractMCMC 4.5 contains a breaking change which was accidentally released in a non-breaking release (TuringLang/AbstractMCMC.jl#132 (comment)). Hopefully it will be yanked soon (JuliaRegistries/General#94031).

@devmotion
Copy link
Collaborator

I went through the CI logs once more and I think https://github.com/FluxML/Zygote.jl/actions/runs/6631670834/job/18015683033?pr=1466#step:6:818 might be problematic: There (nothing,) seems to be correct - at least I assumed the return value of gradient should always be a Tuple with one element for each of the function arguments. Otherwise splatting, indexing, etc. could lead to nasty surprises. I still think that the other two failing tests are actually improved by the ZygoteRules change because tuples of nothings that are returned by pullbacks are simplified.

@devmotion
Copy link
Collaborator

I guess my assumption about the return type of gradient was wrong (but this is not documented anywhere, is it?):

isnothing(grad) ? nothing : map(_project, args, grad)

@devmotion devmotion mentioned this pull request Oct 25, 2023
@ToucheSir
Copy link
Member Author

Yeah, so this goes all the way back to the early early days of Zygote and I don't think the behaviour nor the reasoning for it have ever been documented: https://github.com/FluxML/Zygote.jl/blame/087b55467afb4ee312ad1325de02bdf91e07e790/src/compiler/interface.jl#L60. We should make a more formal guarantee now, but of what? It would be good to know where other AD libraries fall on this, AbstractDifferentiation.jl and its backends come to mind. Also cc @mcabbott since I think he last had to deal with this part of the codebase.

@devmotion
Copy link
Collaborator

Yeah, I think such conventions should be documented more clearly and followed more consistently. IMO it would be reasonable to demand that gradient always returns a tuple with gradients for each input argument (as done e.g. in AbstractDifferentiation). Also for the pullback functions, I guess it would be helpful for developers to document that nothings should always be collapsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants