Solved by albanD in post #2 
              
              
                Hi, 
I don’t think there is any update. The for loop is simple and is the most efficient thing that can be done here. 
Especially with your special logic of things already not requiring gradients, that would be tricky. 
Note that you can add a method to your q_model module yourself to do that to mak…