'ValueError: optimizer got an empty parameter list' when it's clearly not empty

Here is the code I’m trying to run on Google Colab:

import torch


class Model(torch.nn.Module):

    def __init__(self):
        super(Model, self).__init__()

        self.U = torch.nn.Embedding(12, 8, sparse=True)
        self.V = torch.nn.Embedding(18, 8, sparse=True)

    def forward(self):
        # to be implemented
        pass

model = Model()
optimizer = torch.optim.SparseAdam(model.parameters(), lr=2e-3)

and I get a ValueError. However, printing list(model.parameters()) shows that the parameters clearly exist. What could be the issue here?

Hi,

I am not sure but it may be related to an issue in this thread:

I have no clue but apparently it works!

Bests

Thank you sir. It works (I also have no idea why).

This seems to be a newly introduces bug, so could you please create an issue on GitHub so that we can track and fix it?
I can reproduce it in 1.7.0, 1.8.0.dev20201110, but not 1.7.0.dev20200830.