Skip to content

LookSAM bugΒ #442

@riccstef

Description

@riccstef

I just want to report I bug I meet using LookSAM. It is at

sam.py", line 818, in second_step
grad, grad_norm * torch.sum(g_grad_norm * g_s_grad_norm) * g_grad_norm
~~~~~~~~~~~~^~~~~~~~~~~~~~~
RuntimeError: The size of tensor a (16) must match the size of tensor b (3) at non-singleton dimension 3

It happens when doing .second_step() on the optimizer.

Unfortunately I am not able to provide a code to reproduce the error since it came after custom modules and loss built inside a custom pytorch wrapper used to build network architectures with pytorch list. I just wanted to report this. The same code choosing SAM, FriendlySAM, WSAM and GSAM worked properly.

  • OS : Windows
  • PyTorch version : 2.8
  • Python version : 3.12
  • pytorch-optimizer version : the one present on github at the present moment (with pip I got an older one with less functions)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions