Solved by livenletdie_gvs in post #3 
              
              
                What if you did a clone to avoid the in-place operations? 
Something like this: 



a = torch.randn(8,16, requires_grad = True) 
b = a.clone() 
b[:, 3] = a[:,3].clamp(0,1) 
b[:, 0] = a[:,0].clamp(0,1) 
bFinal = b.sum() 
bFinal.backward() 



This does not throw error for me.