Hi @albanD and @Jean-Eric_Campagne  , i am facing the same problem here, but the  parameters are not being updated although i used requires grad = True.
    def minimize():
        xi = torch.tensor([1e-3, 1e-3, 1e-3, 1e-3, 1e-3, 1e-3], requires_grad=True)
        optimizer = torch.optim.Adam([xi], lr=0.1)
        for i in range(400):
            loss = self.f(xi)
            optimizer.zero_grad()
            loss.backward()
            optimizer.step()
        return xi

self.f(xi) is implemented in pytorch Tensors. Do you have any suggestions?