You can just pass it in a list to the optimizer:
# Your parameter
w = torch.ones(1, requires_grad=True)
optimizer = torch.optim.SGD([w], lr=1.)

# Your forward and backward pass
(w * torch.ones(1)).backward()

# Update parameters
optimizer.step()