Solved by JuanFMontesinos in post #2 
              
              
                Because in python when you use x-= you are using in-place operations 
I don’t know how do the rules work in these case but basically when you do x-=lr*grad you are still pointing to the original tensor whose data has been in-place modified. 
In the 2nd case you are overwritting a local variable x1 s…