Solved by albanD in post #2 
              
              
                That would depend what your optimizer is. 
It might be clearer to have a custom optimizer that does the scaling by A * f? 
out = g + f
out.backward() # Compute \nable [ g + f]
optimizer.step(A * f)

But both should do the same step in the end (if your optimizer above is like SGD and has a lr of 1).