Yes, calling backward 6400 times is likely to be slow. I don’t know the best solution here as it is not a use case I am familiar with but it might be useful to check the amount of overhead that is due to Python.