Grassmann.jl
Grassmann.jl copied to clipboard
gradient throws error
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
What's this? I have no idea what you're trying to discuss here.
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.
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.
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.
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.
Alright, I will email you to discuss this privately for now.
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,)