Hi, no it’s same size. I used other optiimizers and all works, except LBFGS, since it needs a sort of closure.
X   = m0.clone()
gr  = lambda x: f.gradient(x)
opt = optim.Adam([X], lr=1e-2)
for _ in range(5000):
opt.zero_grad()
X.grad = -gr(X)
opt.step()
This Adam, and all other optimizers work