You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, this is a case I just tested to benchmark where the gradient calculation goes nicely with Reactant+Enzyme but not with CUDA+Enzyme, not sured where to post this, I hope it's ok to put this here,
using Lux,Random
using Reactant
using CUDA,LuxCUDA
using Enzyme
Reactant.set_default_backend("gpu")
const dev = xla_device()
const dev_test = gpu_device()
const rng = MersenneTwister(1234)
model = Lux.Chain(
Conv((3,3),1=>3,tanh,pad = SamePad()),
MaxPool((2,2)), # (14,14,3,N)
MaxPool((2,2)), # (7,7,3,N)
MaxPool((2,2)), # (3,3,3,N)
Lux.FlattenLayer(),
Dense(3*3*3=>10,tanh),
Dense(10=>10)
)
psn,stn = Lux.setup(rng,model);
pst,stt = (psn,stn) |> dev_test;
ps,st = (psn,stn) |> dev;
function loss(model,ps,st,x,y)
m,_ = model(x,ps,st)
return Lux.MSELoss()(m,y)
end
xn = rand(Float32,28,28,1,1000) ;
yn = rand(Float32,10,1000);
xt = xn |> dev_test;
yt = yn |> dev_test;
x = xn |> dev;
y = yn |> dev;
L = Reactant.@compile loss(model,ps,st,x,y);
L(model,ps,st,x,y) # works
loss(model,pst,stt,xt,yt) # works
function get_grad(model,ps,st,x,y)
dps = Enzyme.make_zero(ps)
Enzyme.autodiff(
Enzyme.Reverse,
loss,
Const(model),
Duplicated(ps,dps),
Const(st),
Const(x),
Const(y)
)
return dps
end;
G = Reactant.@compile get_grad(model,ps,st,x,y);
G(model,ps,st,x,y) # works
get_grad(model,pst,stt,xt,yt); # does not work
Hello, this is a case I just tested to benchmark where the gradient calculation goes nicely with Reactant+Enzyme but not with CUDA+Enzyme, not sured where to post this, I hope it's ok to put this here,
and here is the error,
and my versions
julia :
CUDA :
pkg :
The text was updated successfully, but these errors were encountered: