When I do it:
>>> x = torch.rand(5, requires_grad=True)
>>> y = (x**2).sum()
>>> g1 = torch.autograd.grad(y,x,torch.ones(5), retain_graph=True)
>>> g2 = torch.autograd.grad(y,x,None, retain_graph=True)
>>> g1[0]==g2[0]
tensor([ 1,  1,  1,  1,  1], dtype=torch.uint8)

Can you show your code?
In autograd.grad, if you pass grad_output=None, it will change it into a tensor of ones of the same size than output with the line:
new_grads.append(torch.ones_like(out))

(that’s here : https://github.com/pytorch/pytorch/blob/master/torch/autograd/ 82__init__.py)