I nominate Adam for king of speed replies, wow!
So I tried two variations on repackage_hidden in the forward() method, both of which solve this issue:

Keep W and M as regular old tensors (not variables) then have:


W[M]] = w
out = F.conv2d(x,Variable(W))


Repackage W a la the example you linked:


W = V(self.W.data)
W[M] = w

#1 is ~15% faster than #2, and the original thing I was doing with W*M is ~7.5% faster than #2. This also makes it possible to save with torch.save.
The exact error I was getting when not properly Variable-ing around was:
RuntimeError: Trying to backward through the graph second time, but the buffers have already been freed. Please specify retain_variables=True when calling backward for the first time.
I was only calling backward() a single time, hence my initial confusion; I mostly found this interesting because it only occurred when switching to masked_copy_ from a direct indexing call.
I’ll put together a benchmark script to compare and validate different dilation implementations–I did some experimentation on that front for theano/lasagne 3 a few months back, so I’ll be really curious to see how things roll with PyTorch.
Thanks,
Andy