Yes, this should be possible (besides the minor typo in q.gard  ).
I’m not sure, what the second assignment should do, as the first one would already assign the gradients from model2 to model1.
The optimizer will just use the .grad attributes of all parameters without any knowledge how these gradients were created (at least in the default use cases).