This code snippet would create a prim::Constant on the GPU:
@torch.jit.script
def fun(x):
    y = x + torch.tensor(1, device='cuda')
    return y

print(fun.graph)
> graph(%x.1 : Tensor):
  %7 : bool = prim::Constant[value=0]()
  %21 : Device = prim::Constant[value="cuda"]()
  %5 : None = prim::Constant()
  %2 : int = prim::Constant[value=1]() # <ipython-input-36-11fdcf9e4060>:9:25
  %8 : Tensor = aten::tensor(%2, %5, %21, %7) # <ipython-input-36-11fdcf9e4060>:9:12
  %y.1 : Tensor = aten::add(%x.1, %8, %2) # <ipython-input-36-11fdcf9e4060>:9:8
  return (%y.1)