Giter Club home page Giter Club logo

Comments (7)

mBarreau avatar mBarreau commented on June 12, 2024 3

@ToucheSir any news on this issue?

from zygote.jl.

ToucheSir avatar ToucheSir commented on June 12, 2024 1

It's possible that either TaylorDiff.jl or Julia Base changed some implementation details between 1.9 and 1.10, so that code used to take a path that was differentiable but now is not.

Can confirm it goes even deeper than this to the compiler. To demonstrate:

1.9:

julia> @code_warntype TaylorScalar((1,))
MethodInstance for TaylorScalar(::Tuple{Int64})
  from TaylorScalar(value::Tuple{Vararg{T, N}}) where {T, N} @ TaylorDiff ~/.julia/packages/TaylorDiff/SMDgC/src/scalar.jl:17
Static Parameters
  T = Int64
  N = 1
Arguments
  #self#::Type{TaylorScalar}
  value::Tuple{Int64}
Body::TaylorScalar{Int64, 1}
1 ─ %1 = Core.apply_type(TaylorDiff.TaylorScalar, $(Expr(:static_parameter, 1)), $(Expr(:static_parameter, 2)))::Core.Const(TaylorScalar{Int64, 1})
│   %2 = (%1)(value)::TaylorScalar{Int64, 1}
└──      return %2

1.10:

julia> @code_warntype TaylorScalar((1,))
MethodInstance for TaylorScalar(::Tuple{Int64})
  from TaylorScalar(value::Tuple{Vararg{T, N}}) where {T, N} @ TaylorDiff ~/.julia/packages/TaylorDiff/SMDgC/src/scalar.jl:17
Static Parameters
  T = Int64
  N = 1
Arguments
  #self#::Type{TaylorScalar}
  value::Tuple{Int64}
Body::TaylorScalar{Int64, 1}
1 ─ %1 = Core.apply_type(TaylorDiff.TaylorScalar, $(Expr(:static_parameter, 1)), $(Expr(:static_parameter, 2)))::Core.Const(TaylorScalar{Int64, 1})
│   %2 = %new(%1, value)::TaylorScalar{Int64, 1}
└──      return %2

Essentially, the compiler can skip the intermediate step of calling the Type constructor when constructing new values. This means that rules like https://github.com/JuliaDiff/TaylorDiff.jl/blob/4f7b477b188ef15f6a4368285bb2c40319089a48/src/chainrules.jl#L9-L12 may not be picked up because Zygote has a fallback path for Expr(:new) it uses unconditionally. Evidently something needs to change to workaround this change in internals, but it's not clear who should make that change yet.

from zygote.jl.

ToucheSir avatar ToucheSir commented on June 12, 2024

Are you using TaylorDiff v0.2.1 (the latest released version) but looking at the code of the TaylorDiff.jl main branch? Note that there seem to have been a lot of changes between the two.

As for the behaviour being different between versions, I would not suspect rules not being picked up first. It's possible that either TaylorDiff.jl or Julia Base changed some implementation details between 1.9 and 1.10, so that code used to take a path that was differentiable but now is not. Again though, we need to know what versions of Zygote and TaylorDiff you're using, as well as if they're the same versions across 1.9 and 1.10.

from zygote.jl.

mrazomej avatar mrazomej commented on June 12, 2024

Thank you so much for your quick response. I was going to add the versions of the packages, and I completely forgot.

For both, 1.9.4 and 1.10+ I am using the latest versions of the packages.

[e88e6eb3] Zygote v0.6.69
[b36ab563] TaylorDiff v0.2.1

from zygote.jl.

ToucheSir avatar ToucheSir commented on June 12, 2024

Can you try adding TaylorDiff#main and seeing if that changes things?

from zygote.jl.

mrazomej avatar mrazomej commented on June 12, 2024

Just did it.

pkg> add TaylorDiff#main
Cloning git-repo `https://github.com/JuliaDiff/TaylorDiff.jl.git`
Updating git-repo `https://github.com/JuliaDiff/TaylorDiff.jl.git`

same error

from zygote.jl.

ToucheSir avatar ToucheSir commented on June 12, 2024

Unfortunately, no. I've not heard anything from the Base Julia side about possible solutions and I wouldn't know how to tackle this on the Zygote side. If somebody has news on the former or a concrete proposal for the latter, please chime in.

from zygote.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.