thank you for answering, but I don’t see it converging:
here is the updated code:
# Loss function
def loss(y_pred, y_val):
    return (y_pred - y_val).abs()

# Training loop
for epoch in range(1000):
    for x_val, y_val in zip(x_data, y_data):
        y_pred = forward(x_val) # 1) Forward pass
        l = loss(y_pred, y_val) # 2) Compute loss
        l.backward() # 3) Back propagation to update weights
        # print("\tgrad: ", x_val, y_val, w.grad.item())
        with torch.no_grad():
            w1 -= 0.01 * w1.grad.item()
            w1.grad.zero_()

            w2 -= 0.01 * w2.grad.item()
            w2.grad.zero_()

        print(l.item())

my last loss values too high and not converging:
27.027191162109375
319.6322021484375
58.488525390625
529.6104125976562
127.1507568359375
814.5077514648438
248.1339111328125
1190.4041748046875
Prediction (after training) 4 113.91207122802734

What am I doing wrong?