When you create an instance of the optimizer, you pass the parameters to it:
optimizer = torch.optim.SGD(model.parameters(), lr=1e-3)

The optimizer holds references to these parameters and updates them when calling optimizer.step() using the .grad attribute.