I’d probably stay away from messing with the internal functions.
A cleaner option may be to filter the parameters passed to the optimizer, prefix fixed params with fix_ and instantiate the optimizer like
SGD([p for n,p in m.named_parameters() if not n.startswith('fix_')], lr=my_lr).
Best regards
Thomas