(max_unorm)
| 701 | # tight and a loose value produced identical updates. Runs on CPU, which implements |
| 702 | # the 32-bit LAMB kernel. |
| 703 | def one_step(max_unorm): |
| 704 | torch.manual_seed(0) |
| 705 | p = torch.nn.Parameter(torch.randn(128, 128)) |
| 706 | opt = bnb.optim.LAMB([p], lr=1e-1, max_unorm=max_unorm) |
| 707 | p.grad = torch.randn(128, 128) * 5.0 |
| 708 | opt.step() |
| 709 | return p.detach().clone() |
| 710 | |
| 711 | tight = one_step(1e-4) # aggressive clipping |
| 712 | loose = one_step(10.0) # effectively no clipping |
no test coverage detected