Are you filtering the parameters based on their requires_grad attribute before passing them to the optimizer? Also, could you post an executable code snippet to reproduce this issue, as I’m currently unsure what might cause the error?