That’s not really possible, as in your code the loss is completely detached from any other operation, besides not being a torch.tensor.
I’m not sure, if that’s what you are looking for, but you could try to scale your loss to a specific value:
x = torch.randn(1, 1)
w = torch.randn(1, 1, requires_grad=True)
output = x * w
target = torch.randn(1, 1)
loss = (output - target)**2
factor = 6000. / loss.item()
loss = loss * factor
loss.backward()
print(w.grad)