Jake_Eum:

but did you visit the github i provide?


I did not, but the error is in the code sample you shared 

I try to use the sam optimizer from what they provide

Note that these checks were buggy in old versions of PyTorch and fixed recently. So if this repo has not been updated in a while, that might be the reason why they share this code but it doesn’t work.
Your updated code should run fine no?