This is intended behavior since binary comparisons are hard operations and you cannot derive them.
However if you do
import torch

w = torch.FloatTensor([1.0, 2.0])
w.requires_grad_(True)
out = w * 2

out[out>0] = 1
out[out<0] = -1

out.sum().backward()

the gradients will flow correctly.