You could filter them out before, if you like. As long as the .grad attributes aren’t filled in the frozen parameters, the optimizer won’t update them, but your approach would be more explicit.
Were you able to reproduce the issue using my code snippet and the filtering or any other addition to the code?