I would try to write the code as explicit as possible and filter the unneeded parameters out as described also e.g. here. This would make sure that the optimizer does not have any references to these frozen parameters and will thus never update them.
The first approach could also work, but be aware that the optimizer could still update frozen parameters if it has running stats (e.g. as is the case for Adam) for these parameters from previous iterations.