Skip to content
Prev Previous commit
Next Next commit
Iterate the non-tied test's module pairs with zip
Pair each delayed Linear with its regular counterpart directly instead of
indexing both Sequentials, as suggested in review.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
  • Loading branch information
0z5a authored and denera committed Oct 30, 2026
commit 6a4839a6e41bc39e24e52fa62ab821506d97c20e
6 changes: 3 additions & 3 deletions tests/pytorch/test_tied_delayed_wgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ def test_non_tied_linear_gradients():
x = torch.randn(2, 16, device="cuda", dtype=torch.bfloat16)
for model in (delayed, regular):
model(x.detach().clone().requires_grad_(True)).float().sum().backward()
for index in (0, 1):
delayed[index].backward_dw()
for delayed_linear, regular_linear in zip(delayed, regular):
delayed_linear.backward_dw()
torch.testing.assert_close(
delayed[index].weight.grad, regular[index].weight.grad, rtol=0, atol=0
delayed_linear.weight.grad, regular_linear.weight.grad, rtol=0, atol=0
)


Expand Down