Closed pagnani closed 6 months ago
Since I know tulio does odd things under the hood and has custom derivative rules defined for other AD tools, I think the correct solution here is to define custom enzyme rules within Tulio.jl.
Open an issue on Tulio.jl and cc me?
However @pagnani what is your julia/os/enzyme version.
On my system (julia 1.10, ubuntu, latest Enzyme), this succeeds:
julia> gradenzyme(provaloop,A,B)
([0.23380880969329965 0.5227475047630739; 0.48402478399611826 0.48401775694315896], [0.3002268423233645 0.9257902665611332; 0.6552753578836962 0.1012109582137013])
never mind, you already uploaded that. Can you upload the full stack trace?
never mind, you already uploaded that. Can you upload the full stack trace?
Hi @wsmoses thanks for the timely reply.
Here the complete (and scary) stacktrace.
However @pagnani what is your julia/os/enzyme version.
On my system (julia 1.10, ubuntu, latest Enzyme), this succeeds:
julia> gradenzyme(provaloop,A,B) ([0.23380880969329965 0.5227475047630739; 0.48402478399611826 0.48401775694315896], [0.3002268423233645 0.9257902665611332; 0.6552753578836962 0.1012109582137013])
Yes, the loopy version, as in my original issue, works for me too, is the Tullio version which is not working. The original problem is in a much more complicated loss function, but I found out that also this minimal case is not working.
Il will also open an issue on Tullio and cross-link it here later.
Also, unrelated to this issue, is this way of computing the gradient over two sets of variables ( i.e. by making two closures over A, and B) the correct thing to do?
Zygote allows to make lambdas over variable as
function gradzygote(f,A,B)
Zygote.gradient((x,y)->f(x,y), A,B)
end
but I did not manage to find an equivalent in Enzyme.
Thanks for your work!
Added this issue on Tullio's repo.
A
@pagnani this code succeeds for me on present Enzyme.
julia> gradenzyme(provaloop,A,B)
([0.5663164027331671 0.3256755318530826; 0.6901298018433815 0.2663614388591653], [0.5089800932986028 0.9230120823778869; 0.6783049935954609 0.13943622375552933])
julia> gradenzyme(provatullio,A,B)
┌ Warning: active variables passed by value to jl_new_task are not yet supported
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/kqxyC/src/utils.jl:59
┌ Warning: active variables passed by value to jl_new_task are not yet supported
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/kqxyC/src/utils.jl:59
┌ Warning: active variables passed by value to jl_new_task are not yet supported
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/kqxyC/src/utils.jl:59
┌ Warning: active variables passed by value to jl_new_task are not yet supported
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/kqxyC/src/utils.jl:59
([0.5663164027331671 0.3256755318530826; 0.6901298018433815 0.2663614388591653], [0.5089800932986028 0.9230120823778869; 0.6783049935954609 0.13943622375552933])
It is still likely desirable that Tullio add EnzymeRules, but in any case everything works otherwise.
Closing, please reopen if it persists.
Hi there,
I experience a problem with Enzyme interacting with Tullio. The MWE is the computation of the trace of the product with two matrices $tr(A*B)$. I wrote a method with loops and one using Tullio.
Then I constructed a wrapper to compute the gradient of the two methods
Test:
The tullio version does not work. Below the very long stacktrace that I had to cut because could not fit the limit size of issues. A t the end my versioninfo and my package status).
Package status:
Versioninfo