Ah I see – in my example above my torch.autograd.grad call was just relying on autodiff on the forward method and never calling into the backward method.
And thanks! Nesting the Function inside a Python function is a really clean and easy way of updating my older code and not something I considered before – I updated qpth to do this in a few minutes and I think it’ll work well for the mpc one too with some slight modifications 

  
      github.com/locuslab/qpth
  
  
      
    
  


  Update to the new Function interface and update some byte->bool indexing 5




  by bamos
  on 03:02PM - 09 Sep 19 UTC



  changed 4 files
  with 169 additions
  and 173 deletions.