Skip to content

Commit

Permalink
Fix for weights-only load (pytorch#1228)
Browse files Browse the repository at this point in the history
stack-info: PR: pytorch#1228, branch: drisspg/stack/19
  • Loading branch information
drisspg authored and asahni04 committed Nov 7, 2024
1 parent 668a4ba commit 27b1d16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/prototype/test_low_bit_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ def test_optim_bf16_stochastic_round_correctness(self):
optim2.step()
optim2.zero_grad()

torch.testing.assert_close(loss1, loss2, msg=lambda msg: f"Iteration {idx}. {msg}")

torch.testing.assert_close(
loss1, loss2, msg=lambda msg: f"Iteration {idx}. {msg}"
)

@pytest.mark.skipif(not TORCH_VERSION_AT_LEAST_2_3, reason="requires PyTorch >= 2.3")
@parametrize("optim_name", ["Adam8bit", "AdamW8bit", "Adam4bit", "AdamW4bit", "AdamFp8", "AdamWFp8"])
Expand Down
12 changes: 11 additions & 1 deletion torchao/prototype/low_bit_optim/adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@

class _AdamBase(Optimizer):
def __init__(
self, params, lr, betas, eps, weight_decay, amsgrad, *, block_size, bf16_stochastic_round, is_adamw, exclude_low_bit_optim_params=None
self,
params,
lr,
betas,
eps,
weight_decay,
amsgrad,
*,
block_size,
bf16_stochastic_round,
is_adamw,
) -> None:
if not 0.0 <= lr:
raise ValueError("Invalid learning rate: {}".format(lr))
Expand Down

0 comments on commit 27b1d16

Please sign in to comment.