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

Make BatchNorm twice-differentiable #2255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexrosen45
Copy link

Solves the 'BatchNorm not being twice-differentiable' problem first reported at https://discourse.julialang.org/t/compilation-error-in-zygote-flux-and-cuda-interaction/92571 and made into issue #2154. Relevant documentation update would be made at https://fluxml.ai/Flux.jl/stable/models/layers/#Flux.BatchNorm, however this is unnecessary.

PR Checklist

  • Tests are added
  • Entry in NEWS.md
  • Documentation, if applicable

Solves the BatchNorm not being twice-differentiable problem first reported at https://discourse.julialang.org/t/compilation-error-in-zygote-flux-and-cuda-interaction/92571 and made into issue FluxML#2154.
@CarloLucibello
Copy link
Member

Nice! Can you add a cuda test?

function batchnorm_pullback(Δ)
grad = ∇batchnorm(g, b, x, unthunk(Δ), running_mean, running_var, momentum; kw...)
(NoTangent(), grad..., NoTangent(), NoTangent(), NoTangent())
function batchnorm_pullback(Δ, σ²Δ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this second parameter coming from? You can see on the CI log that this raises a MethodError. The pullback should only take one argument (Δ) and destructure it from a tuple into its component parts if need be.

@ToucheSir
Copy link
Member

I think we'd also want a test for double-differentiability on GPU. Make sure you're looking at Buildkite and not GitHub actions because the latter doesn't run any of the GPU code :)

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.

3 participants