I just run the snippet above in for loop as follows:
random_input = torch.randn(3,3)
random_target = torch.randn(3,3)
criterion = nn.MSELoss()

unit = Unit()
for i in range(5):
    loss = criterion(unit(random_input), random_target)
    print("linear weight", unit.linear.weight)
    loss.backward()
    print(unit.linear.weight.requires_grad)
    print(unit.linear.weight.grad)

And linear.weight.grad has value in each iteration.