The optimizers track the weights as Tensors directly.
So as long as you modify that Tensor inplace, they will work just fine.
But if you do model.weight = foo then the new model.weight will not correspond to the one that is in the optimizer and so no learning will happen.