Autograd works only if you perform all operations to Variables, so it knows what has changed.
In your code, midvar.data[:,0] modifies the tensor wrapped inside a Variable directly. Instead of doing that,
modifying the Variable with the same operation lets autograd compute the gradients correct:
from torch.autograd import Variable

invar = Variable(torch.rand(5, 5), requires_grad=True)
midvar = invar + 1
midvar[:, 0] = 0
loss = midvar.sum()
loss.backward()
print(invar.grad.data)