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

gradient throws error #92

Open
alok opened this issue Nov 25, 2021 · 7 comments
Open

gradient throws error #92

alok opened this issue Nov 25, 2021 · 7 comments

Comments

@alok
Copy link

alok commented Nov 25, 2021

v1 is the standard basis vector

julia> Zygote.gradient(v->0v, v1)
ERROR: cannot convert from ⟨×××⟩ to ⟨+++---⟩*
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] (::SubManifold{⟨+++---⟩*, 6, 0x000000000000003f})(b::SubManifold{⟨×××⟩, 0, 0x0000000000000000})
    @ DirectSum ~/.julia/packages/DirectSum/XQ4T8/src/operations.jl:231
  [3] interop
    @ ~/.julia/packages/AbstractTensors/f9LPE/src/AbstractTensors.jl:151 [inlined]
  [4] *
    @ ~/.julia/packages/AbstractTensors/f9LPE/src/AbstractTensors.jl:186 [inlined]
  [5] (::ChainRules.var"#times_pullback#1182"{Int64, SubManifold{⟨×××⟩, 1, 0x0000000000000001}, ChainRulesCore.ProjectTo{Number, NamedTuple{(), Tuple{}}}, ChainRulesCore.ProjectTo{Float64, NamedTuple{(), Tuple{}}}})(Ω̇::SubManifold{⟨×××⟩, 0, 0x0000000000000000})
    @ ChainRules ~/.julia/packages/ChainRules/Tj6lu/src/rulesets/Base/fastmath_able.jl:243
  [6] ZBack
    @ ~/.julia/packages/Zygote/rv6db/src/compiler/chainrules.jl:179 [inlined]
  [7] Pullback
    @ ./REPL[18]:1 [inlined]
  [8] (::typeof(∂(#7)))(Δ::SubManifold{⟨×××⟩, 0, 0x0000000000000000})
    @ Zygote ~/.julia/packages/Zygote/rv6db/src/compiler/interface2.jl:0
  [9] (::Zygote.var"#52#53"{typeof(∂(#7))})(Δ::SubManifold{⟨×××⟩, 0, 0x0000000000000000})
    @ Zygote ~/.julia/packages/Zygote/rv6db/src/compiler/interface.jl:41
 [10] gradient(f::Function, args::SubManifold{⟨×××⟩, 1, 0x0000000000000001})
    @ Zygote ~/.julia/packages/Zygote/rv6db/src/compiler/interface.jl:76
 [11] top-level scope
    @ REPL[18]:1
@chakravala
Copy link
Owner

What's this? I have no idea what you're trying to discuss here.

@alok
Copy link
Author

alok commented Nov 29, 2021

The README mentions applications through automatic differentiation, but there seem to be some issues with it.

Some examples:

using Grassman, Zygote
basis"3" # this defines (⟨×××⟩, v, v₁, v₂, v₃, v₁₂, v₁₃, v₂₃, v₁₂₃)
Zygote.gradient(v->v^2 ,v₁) # this gives (2v₁,)
Zygote.gradient(v -> 1 * v^2, v₁) # similar error as above

The last two calls should be identical but are not. To be fair, the issue seems to be in DirectSum/AbstractTensors, so I can move the issue to there if you like, though iirc both of those are also your packages.

@chakravala
Copy link
Owner

Grassmann.jl has its own experimental automatic differentiation built-in to the tensor algebra. It is not intended to be used with a separate AD package, but is its own experimental AD design from scratch based on tensor algebra. I don't know about Zygote syntax.

@chakravala
Copy link
Owner

If you want to discuss my experimental AD design, we can do that in private. I no longer like to publicly discuss design details, these type of discussions with me are now a premium feature for private discussion.

@alok
Copy link
Author

alok commented Nov 29, 2021

interesting. are there any examples of its usage?

fwiw, adding zygote support would increase usability of the package a fair bit for several applications, and i'd be willing to chip in some money for it.

@chakravala
Copy link
Owner

Alright, I will email you to discuss this privately for now.

@chakravala
Copy link
Owner

By the way, you can make all your examples above work just by using a Signature instead of an Int

julia> @basis S"++"
(⟨++⟩, v, v₁, v₂, v₁₂)

julia> Zygote.gradient(v -> 1 * v^2, v₁) # similar error as above
(2v₁,)

julia> Zygote.gradient(v->0v, v1)
(0v,)

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

No branches or pull requests

2 participants