You could use broadcasting for the first operation and sum(1) for the second one as seen here:
# setup
mask_ref = torch.randn(125)
dots_ref = torch.randn(100, 125)

# loop approach
mask = mask_ref.clone()
dots = dots_ref.clone()

for i in range(125):
    for j in range(100):
        dots[j, i] = dots[j, i] * mask[i]
    

final_add = torch.zeros(100)

for i in range(125):
    for j in range(100):
        final_add[j] = final_add[j] + dots[j, i];
    
# broadcasting
mask = mask_ref.clone()
dots = dots_ref.clone()

dots = dots * mask.unsqueeze(0)
result = dots.sum(1)

print((result - final_add).abs().max())
> tensor(7.6294e-06)