So there aren’t efficient ways to integrate similar to autodiff, so basically, you need (more refined) formulas like yours.
I haven’t seen implementations of the advanced quadrature rules in PyTorch.
It’s not quite what you want, but the Neural ODE code has ODE solvers which would give you some adaptivity even if they try to solve a much harder problem and are not as efficient for the integration problem:

  
      
      GitHub
  
  
    

rtqichen/torchdiffeq 59

Differentiable ODE solvers with full GPU support and O(1)-memory backpropagation. - rtqichen/torchdiffeq


  
  
    
    
  
  


Best regards
Thomas